pycharm sqlite delete fields in the database: Could not delete --- near "DROP": syntax error [SQL: 'ALTER TABLE users DROP COLUMN avatar']

 

sqlite in ALTER TABLE statement does not support DROP COLUMN, ADD only RENAME and
solutions:

1. Create a temporary table, in addition to the field you want to delete a field plus

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

select * from _temp;

 

2. Delete the original table

drop table person;

 

3. The temporary table named as the original table

alter table  _temp rename to person;

 

To

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

Guess you like

Origin www.cnblogs.com/aidenzdly/p/12605154.html