mrong
asked on
How to re-import data in Oracle 11g on Oracle Linux 6.5
Greetings,
I need to re-import the data pump file(by Oracle Enterprise Manager) to an Oracle 11g database running on Oracle Linux 6.5.
Please provide detailed instructions.
Thanks.
Mark
I need to re-import the data pump file(by Oracle Enterprise Manager) to an Oracle 11g database running on Oracle Linux 6.5.
Please provide detailed instructions.
Thanks.
Mark
You can also take a look at:
http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_import.htm#SUTIL936
TABLE_EXISTS_ACTION=[SKIP | APPEND | TRUNCATE | REPLACE]
http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_import.htm#SUTIL936
TABLE_EXISTS_ACTION=[SKIP | APPEND | TRUNCATE | REPLACE]
REPLACE drops the existing table and then creates and loads it from the source. This is not a valid option if the CONTENT parameter is set to DATA_ONLY.
ASKER
slightwv,
I mean to import and replace all the data from previous imported dmp files.
Can I use the oracle em feature(Data Movement->Import from export file to do it?
Thanks.
Mark
I mean to import and replace all the data from previous imported dmp files.
Can I use the oracle em feature(Data Movement->Import from export file to do it?
Thanks.
Mark
>>I mean to import and replace all the data from previous imported dmp files.
I've never tried TABLE_EXISTS_ACTION=REPLAC E but from the docs, it should do it.
When I've needed to do something like this, I drop/recreate the user then import. This way I know I'm getting everything in the import file and not leaving any potential new stuff around.
>>Can I use the oracle em feature(Data Movement->Import from export file to do it?
Don't know. Don't use the GUI for much of anything. The GUI should have all the options available that the command line has but I cannot say for sure.
I've never tried TABLE_EXISTS_ACTION=REPLAC
When I've needed to do something like this, I drop/recreate the user then import. This way I know I'm getting everything in the import file and not leaving any potential new stuff around.
>>Can I use the oracle em feature(Data Movement->Import from export file to do it?
Don't know. Don't use the GUI for much of anything. The GUI should have all the options available that the command line has but I cannot say for sure.
ASKER
Can I use TABLE_EXISTS_ACTION to replace all the tables?
Thanks.
Thanks.
>>Can I use TABLE_EXISTS_ACTION to replace all the tables?
That is what the documentation says it does. I have to believe the docs since I've never personally done it.
That is what the documentation says it does. I have to believe the docs since I've never personally done it.
Also to add TABLE_EXISTS_ACTION=REPLAC E will very much do replace the table data, but the only exception to use this option is you must not have any referential integrity (constraints) on the your tables as it simply deletes and inserts the data again, in case of referential integrity constraints might prevent the deletion in case the child-parent order is not followed(and as far as i remember the import of table data will happen in alphabetical order)
>> on the your tables as it simply deletes and inserts the data again
Small correction: REPLACE drops the table. TRUNCATE deletes the data.
The comment on referential integrity constraints is correct and also in the docs:
Small correction: REPLACE drops the table. TRUNCATE deletes the data.
The comment on referential integrity constraints is correct and also in the docs:
When you use TRUNCATE or REPLACE, ensure that rows in the affected tables are not targets of any referential constraints.
ASKER
What sql stmt do I need to run to drop the schema?
The user is root. Do I have to drop the root user in order to drop the schema?
Thanks.
The user is root. Do I have to drop the root user in order to drop the schema?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I need to drop and then import ROOT schema.
Thanks.
Thanks.
Just to clarify: You have a database user named 'ROOT'?
If so, the steps are the same as posted above.
If so, the steps are the same as posted above.
ASKER
Yes, ROOT is a database user.
Please let me know if any mistakes from the steps below.
1. spool the output from get_ddl into rebuild_root.sql file
2. drop the users/schema by: drop user SOMEUSER cascade;
3. re-create the users by running rebuild_root.sql
4. reimport the ROOT Schema and import the data again.
Thanks.
Please let me know if any mistakes from the steps below.
1. spool the output from get_ddl into rebuild_root.sql file
2. drop the users/schema by: drop user SOMEUSER cascade;
3. re-create the users by running rebuild_root.sql
4. reimport the ROOT Schema and import the data again.
Thanks.
Step 3: not users plural since there is only the one user:
drop user root cascade;
Step 4 should be able to be done in one step as long as the export file only contains that user.
Other than that it looks good with the one exception I noted above:
drop user root cascade;
Step 4 should be able to be done in one step as long as the export file only contains that user.
Other than that it looks good with the one exception I noted above:
If the schemas have a lot of grants, the import might not get them all depending on who granted them.
If you drop a user, all grants are removed. Depending on the export, you might need to re-grant them. Again, depends on the export.
ASKER
I will try slightwv's suggestion and update this case soon. thanks.
ASKER
slightwv,
Below are what I did on the Oracle demo server. Please let me know if you see any problems. Thanks.
1. SELECT DBMS_METADATA.GET_DDL('USE R','ROOT') FROM dual;
DBMS_METADATA.GET_DDL('USE R','ROOT')
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
CREATE USER "ROOT" IDENTIFIED BY VALUES 'S:FA1C56EED0DDECDC3E3FD23 20F5351845 1
C10B980B9C63AC96AE35BC8AB0 ;34754AB43 4AE34CE'
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
2. drop user ROOT cascade
3. Use the dll in step1 to recreate ROOT user
4. Use oem datapump to create schema and data import. Below is the sql if I click 'show sql' from oem
declare
h1 NUMBER;
begin
h1 := dbms_datapump.open (operation => 'IMPORT', job_mode => 'SCHEMA', job_name => 'IMPORT ', version => 'COMPATIBLE');
dbms_datapump.set_parallel (handle => h1, degree => 1);
dbms_datapump.add_file(han dle => h1, filename => 'IMPORT.LOG', directory => 'DATA_PUMP_DIR', filetype => 3);
dbms_datapump.set_paramete r(handle => h1, name => 'KEEP_MASTER', value => 0);
dbms_datapump.add_file(han dle => h1, filename => 'expAiMfull.dmp', directory => 'DATA_PUMP_DIR', filetype => 1);
dbms_datapump.metadata_rem ap(handle => h1, name => 'REMAP_TABLESPACE', old_value => '/ORACLE/ORADATA/MAX/UD1/D ATAMAX_01. DBF', value => '+DATA/MAX/DATAFILE/MAX01. 266.860253 321.DBF');
dbms_datapump.metadata_fil ter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''ROOT'')');
dbms_datapump.set_paramete r(handle => h1, name => 'INCLUDE_METADATA', value => 1);
dbms_datapump.set_paramete r(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
dbms_datapump.set_paramete r(handle => h1, name => 'TABLE_EXISTS_ACTION', value => 'REPLACE');
dbms_datapump.set_paramete r(handle => h1, name => 'SKIP_UNUSABLE_INDEXES', value => 0);
dbms_datapump.start_job(ha ndle => h1, skip_current => 0, abort_step => 0);
dbms_datapump.detach(handl e => h1);
end;
/
5. Ran the following after the import completed.
Exec sys.utl_recomp.recomp_seri al(‘ROOT’)
Select object_name from dba_objects where status <> ‘VALID’ and owner = ‘ROOT’;
No row return.
Below are what I did on the Oracle demo server. Please let me know if you see any problems. Thanks.
1. SELECT DBMS_METADATA.GET_DDL('USE
DBMS_METADATA.GET_DDL('USE
--------------------------
CREATE USER "ROOT" IDENTIFIED BY VALUES 'S:FA1C56EED0DDECDC3E3FD23
C10B980B9C63AC96AE35BC8AB0
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP"
2. drop user ROOT cascade
3. Use the dll in step1 to recreate ROOT user
4. Use oem datapump to create schema and data import. Below is the sql if I click 'show sql' from oem
declare
h1 NUMBER;
begin
h1 := dbms_datapump.open (operation => 'IMPORT', job_mode => 'SCHEMA', job_name => 'IMPORT ', version => 'COMPATIBLE');
dbms_datapump.set_parallel
dbms_datapump.add_file(han
dbms_datapump.set_paramete
dbms_datapump.add_file(han
dbms_datapump.metadata_rem
dbms_datapump.metadata_fil
dbms_datapump.set_paramete
dbms_datapump.set_paramete
dbms_datapump.set_paramete
dbms_datapump.set_paramete
dbms_datapump.start_job(ha
dbms_datapump.detach(handl
end;
/
5. Ran the following after the import completed.
Exec sys.utl_recomp.recomp_seri
Select object_name from dba_objects where status <> ‘VALID’ and owner = ‘ROOT’;
No row return.
ASKER
the import job said failed, but the tables look fine. Below is the import.log file. It is just a warning caused user ROOT was already created in step 3 above ?
Processing object type DATABASE_EXPORT/SCHEMA/USE R
ORA-31684: Object type USER:"ROOT" already exists
Processing object type DATABASE_EXPORT/SCHEMA/GRA NT/SYSTEM_ GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROL E_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEF AULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/SEQ UENCE/SEQU ENCE
Processing object type DATABASE_EXPORT/SCHEMA/PRO CACT_SCHEM A
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/TABLE_D ATA
. . imported "ROOT"."AE_X" 287.8 MB 641774 rows
xxxxxxx imported all other tablesXXXXXXX
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/GRANT/O WNER_GRANT /OBJECT_GR ANT
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/INDEX/I NDEX
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/CONSTRA INT/CONSTR AINT
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/INDEX/S TATISTICS/ INDEX_STAT ISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/FUN CTION/FUNC TION
Processing object type DATABASE_EXPORT/SCHEMA/PRO CEDURE/PRO CEDURE
Processing object type DATABASE_EXPORT/SCHEMA/FUN CTION/ALTE R_FUNCTION
Processing object type DATABASE_EXPORT/SCHEMA/PRO CEDURE/ALT ER_PROCEDU RE
Processing object type DATABASE_EXPORT/SCHEMA/VIE W/VIEW
Processing object type DATABASE_EXPORT/SCHEMA/VIE W/GRANT/OW NER_GRANT/ OBJECT_GRA NT
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/STATIST ICS/TABLE_ STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/POST_TA BLE_ACTION
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/TRIGGER
Processing object type DATABASE_EXPORT/SCHEMA/MAT ERIALIZED_ VIEW
Processing object type DATABASE_EXPORT/SCHEMA/TAB LE/MATERIA LIZED_VIEW _LOG
Job "oracle"."11-16-2014 DATA IMPORT" completed with 1 error(s) at 08:36:10
Processing object type DATABASE_EXPORT/SCHEMA/USE
ORA-31684: Object type USER:"ROOT" already exists
Processing object type DATABASE_EXPORT/SCHEMA/GRA
Processing object type DATABASE_EXPORT/SCHEMA/ROL
Processing object type DATABASE_EXPORT/SCHEMA/DEF
Processing object type DATABASE_EXPORT/SCHEMA/SEQ
Processing object type DATABASE_EXPORT/SCHEMA/PRO
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/TAB
. . imported "ROOT"."AE_X" 287.8 MB 641774 rows
xxxxxxx imported all other tablesXXXXXXX
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/FUN
Processing object type DATABASE_EXPORT/SCHEMA/PRO
Processing object type DATABASE_EXPORT/SCHEMA/FUN
Processing object type DATABASE_EXPORT/SCHEMA/PRO
Processing object type DATABASE_EXPORT/SCHEMA/VIE
Processing object type DATABASE_EXPORT/SCHEMA/VIE
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Processing object type DATABASE_EXPORT/SCHEMA/MAT
Processing object type DATABASE_EXPORT/SCHEMA/TAB
Job "oracle"."11-16-2014 DATA IMPORT" completed with 1 error(s) at 08:36:10
Looks like the import tried to recreate the ROOT user. Looks like you could have skipped that step.
ASKER
Should I let the import to recreate the user instead of using dll to do it? Thanks.
>>Should I let the import to recreate the user instead of using dll to do it?
If you want no errors, then let the import do it.
The benefit to doing it manually is you have the opportunity to change things like the password.
If you are reloading something like a test database from a production export, you typically don't have the same passwords.
If you want no errors, then let the import do it.
The benefit to doing it manually is you have the opportunity to change things like the password.
If you are reloading something like a test database from a production export, you typically don't have the same passwords.
If you mean:
Get rid of everything currently in the database and do the import again:
Drop and recreate the schemas you want imported, then run the import for those schemas.