本人基本上算个小白。。
前一段时间做数据库,我一直以为varchar是自动增长的,就随手把一个字段设置为了varchar(5000)。
但是今天在网上忽然发现varchar不能超过指定长度,简直崩溃, 因为出问题就全都要重做了。
可是我去数据库里面没有发现数据被截断啊?
而且里面显示28741chars,不是明显超出5000了吗?
本人用的数据库是sqlite3.
求大神指点。感激不尽!
本人基本上算个小白。。
前一段时间做数据库,我一直以为varchar是自动增长的,就随手把一个字段设置为了varchar(5000)。
但是今天在网上忽然发现varchar不能超过指定长度,简直崩溃, 因为出问题就全都要重做了。
可是我去数据库里面没有发现数据被截断啊?
而且里面显示28741chars,不是明显超出5000了吗?
本人用的数据库是sqlite3.
求大神指点。感激不尽!
What is the maximum size of a VARCHAR in SQLite?
SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) and SQLite will be happy to store a 500-million character string there. And it will keep all 500-million characters intact. Your content is never truncated. SQLite understands the column type of "VARCHAR(N)" to be the same as "TEXT", regardless of the value of N.
意思是你定义了长度,哪怕超出了还是不会被截取!官方原话如上。有点考古吧,但网上没人考究,我正好查到就给后面的人开开路
https://www.sqlite.org/faq.html#q9