sqlite alter table改变某一列

sqlite不支持alter table的时候修改某列的定义,所以如果需要改变某一列,思路是:

1、先建一张临时表,把原来表中的数据复制进去

2、删除旧表

3、新增表

4、从临时表中把数据复制回新表

5、删除临时表

Nsstring *sql1 = @"create table tb_users_temp as select * from tb_users";
Nsstring *sql2 = @"drop table tb_users;";
Nsstring *sql3 = @"CREATE TABLE IF NOT EXISTS tb_users (...);";
Nsstring *sql4 = @"insert into tb_users select * from tb_users_temp;";
Nsstring *sql5 = @"drop table tb_users_temp";

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能