Reputation: 399
I`ve got a table 'Students' which has foreign key to tables 'School' and 'Teachers' and ... . I want to export a specific student (row) and a teacher and school and other rows connected with it. How to do it?
Upvotes: 1
Views: 523
Reputation: 1256
Using expdp
(Data Pump) you can limit the data to be exported with the QUERY
Parameter (Manual), which is basically a WHERE
-clause (so you have to use Sub-Selects to join the tables):
Contents of the Parameter(par)-file exp.par:
include=TABLE:"IN ('STUDENTS','TEACHERS', 'SCHOOLS')"
query=STUDENTS:"WHERE student_name=\'STUDENT ONE\'"
query=SCHOOLS:"WHERE school_pk in ( select school_fk from STUDENTS where student_name=\'STUDENT ONE\')"
...
and so on... Then you can start the export like this:
$ expdp YOURSCHEMA directory=TEMP dumpfile=data.dmp logfile=expdp.log parfile=exp.par
Upvotes: 1