You can do it, but you need to parse the existing table schema.

1. Get the existing schema for the table, along with associated triggers and 
indexes: select group_concat(SQL, x'0A' || ';' || x'0A') from SQLite_Master 
where tbl_name = 'My Table'.

2. Edit the create table schema to remove the column you no longer want.

3. Execute the following, with the edited schema inserted as shown:

begin immediate
;
pragma foreign_keys = NO
;
pragma triggers = NO
;
create temp table "Cache" as select * from "My Table"
;
drop table "My Table"
;
<insert edited schema>
;
insert into "My Table" (<list of new columns>) select <list of new columns> 
from temp.Cache
;
drop table temp.Cache
;
pragma foreign_keys = YES
;

4. If any of that generates an error, then issue a rollback. If it works fine, 
then execute commit.

Tom

Tom Brodhurst-Hill
BareFeetWare

--
iPhone/iPad/iPod and Mac software development, specialising in databases
develo...@barefeetware.com
--
Follow us on Twitter: http://twitter.com/barefeetware/
Like us on Facebook: http://www.facebook.com/BareFeetWare

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

Reply via email to