I cannot drop a column with ALTER TABLE
. I create a table within SQLite:
sqlite> create table example ( "field" text not null );
sqlite> .schema
CREATE TABLE example ( "field" text not null);
Then I add a column with ALTER TABLE
:
sqlite> alter table example add column onsale bool;
sqlite> .schema
CREATE TABLE example ( "field" text not null , onsale bool);
Then I try to delete it:
sqlite> alter table example drop column onsale;
Error: near "drop": syntax error
It's weird that the name onsale
is not between parenthesis. Is that the reason? Is this particular to SQLite3 or is it an SQL issue in general?
You can't drop a column in SQLite prior version 3.35.
You need to create a new table. Copy from your "example" table to the new table =)
That's at least how I always do it for small tables.