首先声明:如果你想直接alter,放弃吧。以下内容可以忽略了。
sqlite官方说明如下:
SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. It is not possible to rename a column, remove a column, or add or remove constraints from a table.
大概意思是sqlite的alter功能只是alter table的一个子集,只有部分功能,比如重命名表名,新增列到现有表中。
不支持现有列的重命名,删除和修改。
我们只能通过临时表来解决。
这样可以解决,但是如果有自增主键的话,那就要小心了。