此问题已在此处有答案:
Drop column from SQLite table(11个回答)
alter table drop column syntax error using sqlite(1个答案)
11天前关闭
我不能删除带有ALTER TABLE
的列。我在SQLite中创建一个表:
sqlite> create table example ( "field" text not null );
sqlite> .schema
CREATE TABLE example ( "field" text not null);
然后添加一列ALTER TABLE
:
sqlite> alter table example add column onsale bool;
sqlite> .schema
CREATE TABLE example ( "field" text not null , onsale bool);
我试着删除它:
sqlite> alter table example drop column onsale;
Error: near "drop": syntax error
奇怪的是,名称onsale
不在括号之间。是因为这个吗这是SQLite3特有的问题,还是一般的SQL问题?
1条答案
按热度按时间dphi5xsq1#
在SQLite 3.35之前的版本中,您不能删除列。
您需要创建一个新表。从“example”表复制到新表=)
至少我在小table上总是这么做的。