I just recreated the table. Thanks for your input Jan.
Steve

Jan Ekström wrote:

Try this
13) How do I add or delete columns from an existing table in SQLite.
SQLite does yes not support the "ALTER TABLE" SQL command. If you what to change the structure of a table, you have to recreate the table. You can save existing data to a temporary table, drop the old table, create the new table, then copy the data back in from the temporary table.


For example, suppose you have a table named "t1" with columns names "a", "b", and "c" and that you want to delete column "c" from this table. The following steps illustrate how this could be done:

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;
.............Jan----- Original Message ----- From: "Ulrik Petersen" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Wednesday, March 02, 2005 8:03 PM
Subject: Re: [sqlite] Adding a column to an sqlite database through the sqlite utility interface



Steve Frierdich wrote:

Does anyone know how to add a column to an sqlite database through the
sqlite utility interface. I tried the SQL statement , ALTER TABLE table
Name ADD column variable, and it did not work. Anyone know any other way?
Thanks
Steve



http://www.sqlite.org/faq.html#q13





Reply via email to