February 11th, 2004, 05:50 PM
Copying tables BUT not data
How can I create a copy of a table without copying the data from the origional table
February 12th, 2004, 03:54 AM
CREATE TABLE new_table
* FROM old_table
But this will only recreate the structure of the table. Primary keys, foreign keys or other table constraints will not be copied.
February 13th, 2004, 02:40 PM
Thanks for the help!
Originally Posted by shammat
Do you know if there is a way to copy the columns over but not their data or definitions?
February 13th, 2004, 07:11 PM
Do the following :
Create new_table as
Select * from old_table where
This will give you an empty new table with the identical structure of the old table.
February 14th, 2004, 09:42 AM
What do you mean with that? My statement (ninakot's which is essentially the same as mine) will create a table with the same columns as the old one. No data will be copied.
Originally Posted by gdjsmith
A column needs a definition, so what would you want to copy if you omit the definition?
February 16th, 2004, 02:08 PM
CREATE TABLE <table characteristics> AS SELECT <query> is generally known as CTAS.
When you create a table using the subquery, only the NOT NULL constraints associated with the columns are copied to the new table. Other constraints and column default definitions are not copied.