Summary of common SQLite database errors

Source: Internet
Author: User

Some time ago, I used the SQLite database as a Public Transit Query System. When I was using the SQLite database, I encountered some problems. I would like to summarize them and share them with you:

1. The primary key of the SQLite database must be of the integer type. Other types are definitely not supported. If no primary key is set in a table, an invisible default primary key automatically increases when data is inserted. If you declare that the primary key in the table is of the integer primary key type, every time you insert a null value in a row, null is automatically converted to an integer that is 1 greater than the maximum value in the row, if the table is empty, it will be 1. (If the maximum value is 9223372036854775807, the key value is a random unused number .)

2 SQLite allows you to insert a string into an integer field. Any data can be inserted into any column. You can insert a string of any length into an integer column, insert a floating point number to a Boolean column, or insert a date value to a numeric column.
The data type specified in create table does not limit the insertion of any data in this column. Any column can accept strings of any length (except in one case: columns marked as integer primary key can only store 64-bit integers, an error occurs when inserting data other than integers into such columns.

3
SQLite does not force the length of varchar. You can declare a varchar (10) In SQLite. SQLite is happy to allow 500 characters. And the 500 characters are unblocked and will never be truncated.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.