I have had success using:

create temp table my_temp as select * from my_table;

Of course, if you don't know the column names, it might be a challenge getting 
the data back into the new (altered) table.

If all you need is to add a column, ALTER TABLE does a good job in later 
releases.  I'm on 3.2.7, and it's been very useful.  

ALTER TABLE also supports renaming a table, so when I have a more significant 
change to make, I've found it more useful to rename the original table, create 
the new table, select data from old to new, and drop the old.  But that 
requires knowing both the old and new schemas.

 -Clark


----- Original Message ----
From: John Newby <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Monday, July 24, 2006 5:29:16 AM
Subject: [sqlite] Altering a table when field(column) names are unknown

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

Hi, the above link goes to an FAQ on the SQLite website stating that the
ALTER TABLE command has limited functionality and recommends creating a temp
table and copying everything there, dropping the original table, re-creating
it with the desired changes and copying everything back from the temp table
and then dropping that.

This is all good when the fields(columns) are known in advance, but how
would I attempt doing this without knowing the name of the fields?

Any ideas?

Many thanks

John



Reply via email to