sqlite 无法删除具有ALTER TABLE [重复]的列

izj3ouym  于 2023-06-23  发布在  SQLite
关注(0)|答案(1)|浏览(159)

此问题已在此处有答案

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问题?

dphi5xsq

dphi5xsq1#

在SQLite 3.35之前的版本中,您不能删除列。
您需要创建一个新表。从“example”表复制到新表=)
至少我在小table上总是这么做的。

相关问题