什么是长字符串的最佳 SQLite 数据类型 [英] Whats the best SQLite data type for a long string
问题描述
在 SQLite3 中,我将存储一个很长的字符串,看起来像这样:
In SQLite3 I am going to be storing a very long string that looks something like this:
string linkList = "www.blah.com,www.meh.com,www.hah.com";
肯定会超过 255 个字符,可能会超过 1000 个字符
will definitely exceed 255 chars, will probably be over 1000 chars
如果列 linkList
是 varchar
,TEXT
或其他用于存储可能超过 1000 个字符的字符串
Should the column linkList
be a varchar
, TEXT
or something else to store a string that will probably be longer than 1000 chars
CREATE TABLE(uId INT PRIMARY KEY, linkList varchar);
用于 linkList
列的最佳变量类型是什么?
What would be the best variable type to use for the column linkList
?
推荐答案
你应该使用TEXT
.
虽然,这和 VARCHAR
是一样的:
如果列的声明类型包含任何字符串CHAR"、CLOB"或TEXT",则该列具有 TEXT 亲和性.请注意,类型 VARCHAR 包含字符串CHAR",因此被分配了 TEXT 亲和性
If the declared type of the column contains any of the strings "CHAR", "CLOB", or "TEXT" then that column has TEXT affinity. Notice that the type VARCHAR contains the string "CHAR" and is thus assigned TEXT affinity
还有:
请注意,SQLite 会忽略类型名称后面括号中的数字参数(例如:VARCHAR(255)")——SQLite 不会对字符串的长度施加任何长度限制(除了大的全局 SQLITE_MAX_LENGTH 限制)、BLOB 或数值.
Note that numeric arguments in parentheses that following the type name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not impose any length restrictions (other than the large global SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values.
SQLite 不施加任何长度限制"
这篇关于什么是长字符串的最佳 SQLite 数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!