i trying import database using command
impdp system/password directory=dmpdir dumpfile=database.dmp content=data_only
this works @ importing parts of data, however, getting error:
ora-02291: integrity constraint (system.user_role_user_fk) violated - parent key not found
basically need import data user
first before can import data user_role
is there way specify order of operation or table data import first when using impdp?
edit: bad solution have found use same impdp
statement above twice. doing twice, can import both user
, user_role
, there has easier way this.
you disable constraints before importing, , re-enable them afterwards. can dynamic sql:
begin r in ( select 'alter table "'||c.table_name|| '" disable constraint "'||c.constraint_name||'"' cmd user_constraints c c.constraint_type = 'r' ) loop execute immediate r.cmd; end loop; end; /
after you've run that, e.g. via sql*plus using heredoc in shell script, can run impdp
command import of tables in 1 go; , run same pl/sql block enable
instead of disable
.
it's worth checking if have disabled constraints before start. if disable script skip them based on status, enable script wouldn't able tell whether should re-enabled or not; either create static enable script, or hard-code exceptions need.
Comments
Post a Comment