Ask the Expert

SQL commands to copy selected records from old system to new

If I have 100 records in one system and I want only 15 selected records from the old system in a new system, are there any commands in SQL to copy that data from one system to another system?

    Requires Free Membership to View

The first thing to do is to formulate the SQL to select only those 15 records. Let's assume the SQL statement looks like the following:
SELECT * FROM my_table WHERE deptno=15;
I can then create a database link to the other database and then insert data in to a table in the other database link as follows:
INSERT INTO remote_table@remote_db 
SELCT * FROM my_table WHERE deptno=15;
You can also use this with the export and import utilities. Create a dump file containing the records from the table:
exp userid=scott tables=emp file=emp.dmp where='deptno=15'
Then import the dump file into the other database.

This was first published in March 2007

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: