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.