Reputation: 589
I am using SQL Developer to access an oracle database. I want to export that table and keep the primary keys generation. Since I can´t use SQLloader I can only use "export to sql".
Here is an example:
Database1 is the database that contains the data I want to copy to another database (Database2). The next record on Database1 will get the primary key 200.
Database2 should get all the Data from Database1 (including primary keys, foreign key etc etc etc). When I drop the table there and recreate it using the sql that sql developer gave me and create a new record it will get the ID 92 (EXAMPLE !!).
This will certainly lead me into issues.
Is there any way to create the table and make sure it will get the same primary key that it would get if it would run run Database1 ?
Upvotes: 0
Views: 1133
Reputation: 46
May be in your situation you use sequence and you can find it in one of the triggers at the table. Next should alter sequence like below:
DROP SEQUENCE my_seq;
CREATE SEQUENCE my_seq
START WITH 200
MAXVALUE 9999999999999999999
MINVALUE 1
So that way let you to load data. But I think copy PK from one database to another isn't a good idea, because PK sensitive for storage level data, not business data
Upvotes: 1