Forums Register Login
Import data from database with sequence as primary key
HI all,

I want to import data from another database using JDBC. All the tables have sequence as the primary key and the sequences on the source and destination need not match. I want to enter data into 'N' related tables (having the sequence column as the foreign key) in a single transaction. What is the best approach to achieve this?

Thanks in advance

Well, let me make my question more clear.
I have a Java application (job) which receives data for multiple tables from another schema. These tables have DB sequence as the primary key. Now I want to replicate the data from this schema onto my schema using a Java program. How can i handle sequences and Foreign key references to these sequences while executing the java job?

Thanks in advance.
Welcome to JavaRanch

in which format your job receives the input data? is it Flat file or delimited file or Excel or some other?

whatever it may be, in the output schema why do you bother about the sequence of the input schema.
Just consider that as input field and persist in your resultant DB schema. If you want you can make that column as PK.

If you have FK columns, first in the referred table then referring table.

Thanks Krish for the response...

I get the input as a flat file.

Say, I have 3 related tables... Student -> Student_Address -> Location. Each of these tables have Sequence as primary key.
I have to import data for all the 3 tables in the same transaction. Is it possible?


I assume Student and Location are independent tables. And Student_Address is dependent on both these tables.
Also from your mail I understand you will get Student_id (PK of student table), Location_id (PK of Location table).
So, you first insert these two tables and then insert the Student_Address table.

This thread has been viewed 1414 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 11, 2018 01:57:03.