DROP Syntax error in SQLiteManager

Taj rajan picture Taj rajan · Jan 9, 2014 · Viewed 8.7k times · Source

I have downloaded sqlite manager app in Firefox browser and open sqlite manager app.

1) Created database named DBSQLTEST.

2) Created table named SQLTEST contain has threes fields are SLNO, NAME and AGE

3) Inserted new records

But i want remove a ‘AGE’ column in sqltest table

i using sql command like below

ALTER TABLE SQLTEST DROP COLUMN AGE

SQLiteManager message says

SQLiteManager: Likely SQL syntax error: ALTER TABLE SQLTEST DROP COLUMN AGE [ near "DROP": syntax error ] Exception Name: NS_ERROR_FAILURE Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement]

What is error that?

Answer

laalto picture laalto · Jan 9, 2014

sqlite does not support DROP COLUMN in ALTER TABLE. You can only rename tables and add columns.

Reference: http://www.sqlite.org/lang_altertable.html

If you need to remove columns, create a new table, copy the data there, drop the old table and rename the table to its intented name.