On 19 May 2010 08:31, Raoul <pazou...@gmail.com> wrote: > Hi all, > > I have read that it’s not possible to alter an existing table to add a > primary key, this is causing me some troubles. I have a table “My_main_tbl” > from where I want to take a subset of rows in order to create a new table > with the exact same columns. > > CREATE TABLE My_second_tbl AS SELECT * FROM My_main_tbl WHERE topic = > ‘aviation’ > > My problem is that is on my original table the column QID is a primary key > but on my new created table the column QID is not a primary key anymore, in > fact I have no primary key at all. > > Is there any way of doing this without explicitly specifying each column, > and without going into doing the copy table as explained in > http://www.sqlite.org/faq.html#q11 ? > > As far as I can read over the net SELECT INTO is not supported in sqlite, > right?
CREATE TABLE My_second_tbl( qid integer primary key, ... ); INSERT INTO My_second_tb SELECT * FROM My_main_tbl WHERE topic = ‘aviation’; > > Thanks for your help, > > Fabou Regards, Simon _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users