0

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?

user4157124
  • 2,809
  • 13
  • 27
  • 42
Something Something
  • 3,999
  • 1
  • 6
  • 21

1 Answers1

0

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.

Bobby Donchev
  • 335
  • 1
  • 5