开发者

If I change the type of a field in sqlite3 database, from string to text, will I lose the data in that field?

开发者 https://www.devze.com 2023-01-17 14:03 出处:网络
If I change the type of a field in my database via a Ruby 开发者_运维百科on Rails migration, from string to text, will I lose the data in the field?As far as I remember, SQLite uses the type only for

If I change the type of a field in my database via a Ruby 开发者_运维百科on Rails migration, from string to text, will I lose the data in the field?


As far as I remember, SQLite uses the type only for input/output. Internally, everything is stored as text (that's why you can also store text in an int-field if you want). So no, it shouldn't remove any data, because it's only a superficial change.

No guarantees though, it's been a while since since I last worked with SQLite ;-)

This page explains SQLite's typing system nicely.


You will not lose data. String and text in SQLite are the same. There are really only five types in SQLite (NULL, INTEGER, REAL, TEXT, BLOB). Even if your field originally contained binary data (BLOB) and the database type was changed to TEXT the data is unchanged unless you store new data.

0

精彩评论

暂无评论...
验证码 换一张
取 消