I guess experienced users have solved this one already.  How do I drop  
a column from a table if I don't already know what columns are in the  
table ?  The FAQ says

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;

which assumes I know that the other columns are a and b.  I can find  
this out programmatically by interrogating sqlite_master, but is there  
an easier way to do it ?  Also, I would like my new table to have all  
indices which don't include the field I deleted.  can I do this  
without interrogating sqlite_master ?

While thinking about that, you might want to deal with changing the  
column order instead of dropping a column.  This is actually simpler  
since you can preserve all the indices.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to