问题
I have several texts which are very long (tens of thousands of characters). Which is the best option to store such texts in SQLite: as TEXT or as BLOB ?
回答1:
In SQLite's database file format, TEXT and BLOB values are stored in exactly the same way. The only difference is that the bytes of a TEXT value are assumed to be valid UTF-8.
回答2:
Answer: TEXT
BLOB is good only for binary files and generally storing any binary data (images, songs, etc) in a database is not a good idea and is to be done only as a last resort.
Here is list of data types in SQLite and which data type from SQL are their corresponding ones:
- INTEGER – INT, INTEGER, TINYINT, SMALLINT, MEDIUMINT, BIGINT, UNSIGNED BIG INT, INT2, INT8
- TEXT – CHARACTER(20), VARCHAR(255), VARYING CHARACTER(255),NCHAR(55), NATIVE CHARACTER(70), VARCHAR(100), TEXT, CLOB
- BLOB (no datatype specified) – NONE
- REAL – REAL, DOUBLE, DOUBLE PRECISION, FLOAT
- NUMERIC – NUMERIC, DECIMAL(10,5), BOOLEAN, DATE, DATETIME
For a really good guide about SQLite refer to this guide.
来源:https://stackoverflow.com/questions/25547904/store-very-long-text-blob-or-text