Store very long text: BLOB or TEXT

白昼怎懂夜的黑 提交于 2019-12-04 04:58:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!