sqlite 的字段长度是假的吧

2020-07-01 13:50:14 +08:00
 pinkSlime

我指定了 char(10) 结果往里怼了几百个汉字

937 次点击
所在节点    问与答
1 条回复
ACTom
2020-07-01 15:38:06 +08:00
SQLite 只有 5 种数据类型:NULL 、INTEGER 、REAL 、TEXT 、BLOB,你所定义的其它类型都被转到这 5 种类型最终存储。
SQLite 中类型定义的括号中的数字是会被忽略的。( 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.)

详见: https://sqlite.org/datatype3.html#affinity_name_examples

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/686232

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX