pycharm中删除sqlite数据库中的字段:无法删除---near "DROP": syntax error [SQL: 'ALTER TABLE users DROP COLUMN avatar']

 

sqlite中ALTER TABLE语句不支持DROP COLUMN,只有RENAME 和ADD
解决办法:

1.创建一个临时表,把除了要删的字段以外的字段加上

create table _temp as select _id,name,age,balance from person;

select * from _temp;

 

2.删除原表

drop table person;

 

3.把临时表命名成原表

alter table  _temp rename to person;

 

即可

转自:http://www.mamicode.com/info-detail-161149.html

posted @ 2020-03-31 14:43  aidenzdly  阅读(799)  评论(0编辑  收藏  举报