|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Copying tables BUT not data
How can I create a copy of a table without copying the data from the origional table
|
|
#2
|
|||
|
|||
|
CREATE TABLE new_table
AS SELECT * FROM old_table WHERE 1=2; But this will only recreate the structure of the table. Primary keys, foreign keys or other table constraints will not be copied. |
|
#3
|
|||
|
|||
|
Quote:
Thanks for the help! Do you know if there is a way to copy the columns over but not their data or definitions? |
|
#4
|
|||
|
|||
|
Do the following :
Create new_table as Select * from old_table where rownum <1 This will give you an empty new table with the identical structure of the old table. |
|
#5
|
|||
|
|||
|
Quote:
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. A column needs a definition, so what would you want to copy if you omit the definition? |
|
#6
|
|||
|
|||
|
Good Day,
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. Regards, Dan |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Copying tables BUT not data |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|