I want to create a new table called table2
from another table called table1
without importing data and constraints. I used this query:
create table2 as select * from table1 where 1=2;
this code created table2
without any data, but imports constraints from table1
. Is there a way not to import constraints from table1
?
The answer can be found in the question create table with select union has no constraints.
If the select is a union, Oracle will not add any constraints, so simply use the same select twice, and be sure not to include any records in the second select:
create table2 as
select * from table1 where 1=2
union all
select * from table1 where 1=2;