Original address: http://blog.csdn.net/xingfeng0501/article/details/7817121
1, CHAR. Char is convenient to store the fixed-length data, the index on the Char field is more efficient, such as the definition of char (10), then regardless of whether you store data reached 10 bytes, take up 10 bytes of space, insufficient to automatically fill with spaces.
2, VARCHAR. Store variable-length data, but the storage efficiency is no higher than char. If the possible value of a field is not fixed length, we only know that it cannot exceed 10 characters, it is the most advantageous to define it as VARCHAR (10). the actual length of the varchar type is +1 of the actual length of its value. Why "+1"? This byte is used to hold the length that is actually used. from the space consideration, with the varchar suitable, from the efficiency consideration, uses the char to be suitable, the key is to find the tradeoff point according to the actual situation.
3, TEXT. Text stores non-Unicode data of variable length, with a maximum length of 2^31-1 (2,147,483,647) characters.
4, NCHAR, NVARCHAR, NTEXT. These three kinds of names from the first three more than the previous "N". It represents a character stored in a Unicode data type. We know that characters, the English character only need a byte storage is enough, but the number of Chinese characters, need two bytes of storage, English and Chinese characters at the same time prone to confusion, the Unicode character set is to solve the character set this incompatibility problem, all of its characters are expressed in two bytes, That is, the English character is also represented in two bytes. The length of the nchar and nvarchar is between 1 and 4000. Compared to char and varchar, nchar and nvarchar store up to 4,000 characters, whether in English or Chinese characters, while char and varchar can store up to 8,000 English and 4,000 Chinese characters. It can be seen that the use of nchar, nvarchar data types without worrying about the input characters are English or Chinese characters, more convenient, but in the storage of English number of some losses.
So generally, if it contains Chinese characters, use Nchar/nvarchar, if pure English and numbers, with Char/varchar.
The biggest feature of SQLite is that its data type is no data type (typelessness). This means that you can save any type of data to any column of any table that you want to save, regardless of what data type the column declares. While generating the table structure, you declare the data type of each domain, but SQLite does not do any checking . Developers rely on their own programs to control the type of input and readout data. One exception is that when a primary key is an integer value, an exception is generated if a non-integer value is inserted.
Although SQLite allows data types to be ignored, it is still recommended to specify the data type in the CREATE TABLE statement because the data type facilitates readability of the program. In addition, although the data is inserted or read the time is not differentiated type, but at the time of comparison, different data types are differentiated
The difference between the char,varchar,text,nchar,nvarchar,ntext of "reprint" SQLite database