Its about creating table in ORACLE. Surely how to create a table is not an issue here.
I was trying to create a table from another table with this query.
create table table_2 as (select * from table_1);
This will work fine. It will create a table and copy all data from table 1 to table 2. This may not be desired everywhere. Sometimes you may need and empty table with the same schema. That is also possible in this way. Just add a where clause which selects no values. Like the following
create table table_2 as (select * from table_1 where table_1.fiels_1 = ‘la bla bla’);
I was facing a different problem. The originating table has primary key and few foreign keys. These were not being incorporated to the new table. This is very much obvious because most of the keys have data dependency. So if oracle wants to put the constraints on the new table, it will take a lot of time to create the new table due to a brut force data analysis.
So during creating table keep this in mind that the constraints will not be incorporated in this way.
No comments:
Post a Comment