pinkSlime
V2EX  ›  问与答

sqlite 的字段长度是假的吧

By pinkSlime at 2020 年 7 月 1 日 · 2335 次点击

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

1 条回复  •  2020-07-01 15:38:06 +08:00
ACTom
   1
ACTom  
   2020 年 7 月 1 日
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
© 2026 V2EX · 24ms · 3.9.8.5