Professional Documents
Culture Documents
Page 1 of 13
Questions
Home > Question Details
Resources
Archives
Links
Popular
Hot
Files
Mohammed -- Thanks for the question regarding "Oracle Data pump (DBMS_DATAPUMP)", version 10.2.0
Submitted on 18-Oct-2007 15:57 Eastern US time Last updated 26-Nov-2007 11:11
You Asked
Dear Mr.Kyte greetings I wrote this pl/sql block to export schema using dbms_datapump package this is step one.(which will create the datapump job).
declare h1 number; begin h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'scott1', version => 'COMPATIBLE'); dbms_datapump.set_parallel(handle => h1, degree => 1); dbms_datapump.add_file(handle => h1, filename => 'EXPDAT.LOG', directory => 'DATA_PUMP_DIR', filetype => 3); dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0); dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''SCOTT'')'); dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS'); dbms_datapump.add_file(handle => h1, filename => 'EXPDAT%U' || to_char(sysdate, 'dd-mm-yyyy') || '.DMP', directory => 'DATA_PUMP_DIR', filetype => 1); dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1); dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC'); dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0); exception when others then raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR'||SQLERRM); end; /
end of step one the results of this step (step one) are as follow: 1) the dump file and the log file are created. 2) the job is created. (it's name scott1) 3) the status of the job is (DEFINING) after the completion of the job i wrote the following code to restart the job.(Step tow)
declare h1 number;
Page 2 of 13
the result of this code tell me that: The job does not exists.(scott1, that was created in step one) --end of step tow so i wrote the following code to create the job. because step tow tell me taht it does not exists.(Step Three)
declare h1 number; begin h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'scott1', version => 'COMPATIBLE'); dbms_datapump.start_job(h1) ; exception when others then raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR'||SQLERRM); end;
the result of this code tell me that: The job already exists.(scott1, that was created in step one) --end of step three I hope i give you more details and organize my question more. and if the question still not clear, I just want to do the following: 1) create data pump job using dbms_datapump packge (not using oem or the command line). 2) start, stop, kill and resume the data pump job using dbms_datapump pachage only. Thank you in advanced and thank you for giving me this chance
and we said...
It is just what I thought - and said previously. You create the job in the big block, it is attached to by that session, it starts running and its STATUS (query dba_datapump_jobs) is 1) EXECUTING and then 2) COMPLETING
When that session ends, that job goes away, you ran it, it was successful, it finished and when the last attached session to it exited, it goes away.
So, I don't see anything 'wrong' here, it did exactly what it was supposed to do - it just happened so fast that yo didn't really have time to stop it, kill it, resume it from another session unless you were to do this on a larger schema. file://C:\Documents and Settings\ashfaq.ahmed\Desktop\ashfaque1\Ask Tom Oracle Data pump(DBMS_DA... 3/31/2008
Ask Tom "Oracle Data pump(DBMS_DATAPUMP)" You would a) run the big block to create the job, log out b) attach to it from another session and start it c) do whatever while it is running d) not expect it to be there after a while - since when it completes, it goes away.
Page 3 of 13
ops$tkyte%ORA10GR2> connect / as sysdba Connected. sys%ORA10GR2> sys%ORA10GR2> grant select on dba_datapump_jobs to scott; Grant succeeded. sys%ORA10GR2> sys%ORA10GR2> connect / Connected. ops$tkyte%ORA10GR2> ops$tkyte%ORA10GR2> create or replace directory data_pump_dir as '/tmp' 2 / Directory created. ops$tkyte%ORA10GR2> grant all on directory data_pump_dir to scott 2 / Grant succeeded. ops$tkyte%ORA10GR2> ops$tkyte%ORA10GR2> connect scott/tiger Connected. scott%ORA10GR2> scott%ORA10GR2> declare 2 h1 number; 3 begin 4 h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'scott1', version => 'COMPATIBLE'); 5 dbms_datapump.set_parallel(handle => h1, degree => 1); 6 dbms_datapump.add_file(handle => h1, filename => 'EXPDAT.LOG', directory => 'DATA_PUMP_DIR', filetype => 3); 7 dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0); 8 dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''SCOTT'')'); 9 dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS'); 10 dbms_datapump.add_file(handle => h1, filename => 'EXPDAT%U' || to_char(sysdate, 'dd-mm-yyyyhh24miss') || '.DMP', directory => 'DATA_PUMP_DIR', filetype => 1); 11 dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1); 12 dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC'); 13 dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0); 14 end; 15 / PL/SQL procedure successfully completed. scott%ORA10GR2> scott%ORA10GR2> select * from dba_datapump_jobs; OWNER_NAME JOB_NAME ------------------------------ -----------------------------OPERATION JOB_MODE
Page 4 of 13
scott%ORA10GR2> begin 2 loop 3 for x in (select * from dba_datapump_jobs) 4 loop 5 dbms_output.put_line( to_char(sysdate,'hh24:mi:ss') || ' ' || x.job_name || ', ' || x.state ); 6 dbms_application_info.set_client_info( to_char(sysdate,'hh24:mi:ss') || ' ' || x.job_name || ', ' || x.state ); 7 if ( x.state <> 'EXECUTING' ) 8 then 9 return; 10 end if; 11 dbms_lock.sleep(1); 12 end loop; 13 end loop; 14 end; 15 / 08:07:56 scott1, EXECUTING 08:07:57 scott1, EXECUTING 08:07:58 scott1, EXECUTING 08:07:59 scott1, EXECUTING 08:08:00 scott1, EXECUTING 08:08:01 scott1, EXECUTING 08:08:02 scott1, EXECUTING 08:08:03 scott1, EXECUTING 08:08:04 scott1, EXECUTING 08:08:05 scott1, EXECUTING 08:08:06 scott1, EXECUTING 08:08:07 scott1, EXECUTING 08:08:08 scott1, EXECUTING 08:08:09 scott1, COMPLETING PL/SQL procedure successfully completed. scott%ORA10GR2> select * from dba_datapump_jobs; OWNER_NAME -----------------------------OPERATION -----------------------------STATE -----------------------------SCOTT EXPORT COMPLETING JOB_NAME -----------------------------JOB_MODE -----------------------------DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS ---------- ----------------- ----------------scott1 SCHEMA 1 1 2
scott%ORA10GR2> connect scott/tiger Connected. scott%ORA10GR2> select * from dba_datapump_jobs; OWNER_NAME -----------------------------OPERATION -----------------------------STATE -----------------------------SCOTT EXPORT NOT RUNNING JOB_NAME -----------------------------JOB_MODE -----------------------------DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS ---------- ----------------- ----------------scott1 SCHEMA 0 0 0
Page 5 of 13
another way to 'see this' would be to a) create the job b) then from another session attach and start it, eg:
scott%ORA10GR2> declare 2 h1 number; 3 begin 4 h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'scott1', version => 'COMPATIBLE'); 5 dbms_datapump.set_parallel(handle => h1, degree => 1); 6 dbms_datapump.add_file(handle => h1, filename => 'EXPDAT.LOG', directory => 'DATA_PUMP_DIR', filetype => 3); 7 dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0); 8 dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''SCOTT'')'); 9 dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS'); 10 dbms_datapump.add_file(handle => h1, filename => 'EXPDAT%U' || to_char(sysdate, 'dd-mm-yyyyhh24miss') || '.DMP', directory => 'DATA_PUMP_DIR', filetype => 1); 11 dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1); 12 dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC'); 13 end; 14 / PL/SQL procedure successfully completed. scott%ORA10GR2> select * from dba_datapump_jobs; OWNER_NAME -----------------------------OPERATION -----------------------------STATE -----------------------------SCOTT EXPORT DEFINING JOB_NAME -----------------------------JOB_MODE -----------------------------DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS ---------- ----------------- ----------------scott1 SCHEMA 1 1 2
scott%ORA10GR2> scott%ORA10GR2> scott%ORA10GR2> scott%ORA10GR2> connect scott/tiger Connected. scott%ORA10GR2> declare 2 h1 number; 3 begin 4 h1 := dbms_datapump.attach (job_name => 'scott1'); 5 dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0); 6 end; 7 / PL/SQL procedure successfully completed. scott%ORA10GR2> select * from dba_datapump_jobs;
Ask Tom "Oracle Data pump(DBMS_DATAPUMP)" Reviews DBMS_DATAPUMP October 29, 2007 - 6pm US/Eastern Reviewer: Eric Peterson from Seattle, WA
Page 6 of 13
Bookmark | Bottom |
My DBA exported (using Data Pump) 3 partitions of 4 tables from Production. I want to import into a test db th data. The test database is on a server I do not have unix access on, so I can't use impdp from the command l
The DBA did not tell me he was using Data Pump, so at first I tried imp but that failed. I attempted to do impdb from the unix box I have access, to load this data into the database, but the DIRECTORY object was not "findable" from the database. i.e prefered "/opt/t16/app/oracle/t16ah00/util/<db>" where I had the data in "/u01/test/export". Then I got the idea of trying to use the DATAPUMP package to have the database read the local directory directly, instead of me trying to load from a seperate machine. Using your example, I came up with: I created a directory and granted appropriate permissions.
SET SERVEROUTPUT ON DECLARE dph BEGIN dph := DBMS_DATAPUMP.OPEN ( operation job_mode remote_link job_name version DBMS_DATAPUMP.ADD_FILE ( handle filename directory filetype DBMS_DATAPUMP.ADD_FILE ( handle filename directory filetype => => => => => => => => => => => => => 'IMPORT', 'TABLE', NULL, 'Import2', 'COMPATIBLE' );
NUMBER;
-- job handle
-- Tried to load all 3 partitions together --value => '= P_2007_08, P_2007_09, P_2007_10', DBMS_DATAPUMP.DATA_FILTER ( handle name value table_name => => => => dph, 'PARTITION_LIST', '= P_2007_09', 'DSLOG' );
DBMS_DATAPUMP.SET_PARALLEL ( handle => dph, degree => 1 ); DBMS_DATAPUMP.SET_PARAMETER ( handle => dph, name => 'INCLUDE_METADATA', value => 0 ); DBMS_DATAPUMP.SET_PARAMETER ( handle => dph, name => 'TABLE_EXISTS_ACTION', value =>'APPEND' ); DBMS_DATAPUMP.START_JOB ( dph ); DBMS_DATAPUMP.DETACH ( dph ); END; /
Page 7 of 13
But then looking at the status of the job I get the following, eventually it stops and clears out of dba_datapump_jobs. But no data is imported into the table's partition.
> SELECT * FROM dba_datapump_jobs; OWNER_NAME JOB_NAME ------------------------------ -----------OPERATION ------------------------------------------JOB_MODE STATE ------------------------------------------- ----------------ATTACHED_SESSIONS DATAPUMP_SESSIONS ----------------- ----------------RPTMGR Import2 IMPORT TABLE COMPLETING 1 2
So I guess I'm confused on how to appropriately use this package. Am I on the right track? Or should I bother DBAs & SAs for a unix account on the box with the database? Thanks for any insight you can provide. Eric
impdb always runs in the database - even if you use the command line client, all that does is log into Oracle a run the plsql packages like you did in sqlplus. And they run on the server. impdb October 30, 2007 - 1pm US/Eastern Reviewer: Eric Peterson from Seattle, WA
Yes, the files are on the database server. The par file: I tried to load from the client.
Bookmark | Bottom |
Page 8 of 13
The directory is there and granted to this user. I get the following error. I went through the documentation and think I have all the parameters and values correct. I must still be missing something.
>impdp xxx/yyy@zzz tbl_imp.par Import: Release 10.2.0.1.0 - 64bit Production on Tuesday, 30 October, 2007 10:14:14 Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production With the Partitioning, OLAP and Data Mining options UDI-00014: invalid value for parameter, 'attach'
dbms_datapump script vs procedure November 12, 2007 - 1pm US/Eastern Bookmark | Bott | Top Reviewer: Jasbir from Toronto, Canada
Hi Tom, Database Version: 10.2 (Windows 32 bit) I ran the following script in SQLPLUS but when I made it into a procedure it stopped working and gave the error ORA-31626: job does not exist. SCRIPT: DECLARE l_schema VARCHAR2(30) := sys_context('USERENV', 'CURRENT_SCHEMA'); l_dp_handle NUMBER; BEGIN l_dp_handle := dbms_datapump.open(operation => 'EXPORT', job_mode => 'SCHEMA', remote_link => NULL, job_name => 'EMP_EXPORT', version => 'LATEST'); dbms_datapump.add_file(handle => l_dp_handle, filename => l_schema||'_'||to_char(sysdate,'yyyymmddhh24miss')||'.dmp', directory => 'DATA_PUMP_DIR'); dbms_datapump.metadata_filter(handle => l_dp_handle, name => 'SCHEMA_EXPR', value => '= '''||l_schema||'''');
Page 9 of 13
PROCEDURE: CREATE OR REPLACE PROCEDURE EXPORTDB IS l_schema VARCHAR2(30) := sys_context('USERENV', 'CURRENT_SCHEMA'); l_dp_handle NUMBER; BEGIN l_dp_handle := dbms_datapump.open(operation => 'EXPORT', job_mode => 'SCHEMA', remote_link => NULL, job_name => 'EMP_EXPORT', version => 'LATEST'); dbms_datapump.add_file(handle => l_dp_handle, filename => l_schema||'_'||to_char(sysdate,'yyyymmddhh24miss')||'.dmp', directory => 'DATA_PUMP_DIR'); dbms_datapump.metadata_filter(handle => l_dp_handle, name => 'SCHEMA_EXPR', value => '= '''||l_schema||''''); dbms_datapump.start_job(l_dp_handle); dbms_datapump.detach(l_dp_handle); END; Thanks.
no roles in that procedure. they would need CREATE TABLE directly granted, not via a role:
ops$tkyte%ORA10GR2> create user test identified by test; User created. ops$tkyte%ORA10GR2> grant resource, connect to test; Grant succeeded. ops$tkyte%ORA10GR2> grant EXP_FULL_DATABASE to test; Grant succeeded. ops$tkyte%ORA10GR2> grant IMP_FULL_DATABASE to test; Grant succeeded. ops$tkyte%ORA10GR2> grant all on directory data_pump_dir to test; Grant succeeded. ops$tkyte%ORA10GR2> ops$tkyte%ORA10GR2> connect test/test Connected. test%ORA10GR2> CREATE OR REPLACE PROCEDURE EXPORTDB 2 IS 3 l_schema VARCHAR2(30) := sys_context('USERENV', 'CURRENT_SCHEMA'); 4 l_dp_handle NUMBER; 5 BEGIN 6 l_dp_handle := dbms_datapump.open(operation => 'EXPORT', job_mode => 'SCHEMA', remote_link => NULL, job_name => 'EMP_EXPORT', version => 'LATEST'); 7 dbms_datapump.add_file(handle => l_dp_handle, filename => 'test2.dmp', directory => 'DATA_PUMP_DIR'); 8 dbms_datapump.metadata_filter(handle => l_dp_handle, name => 'SCHEMA_EXPR', value => '= '''||l_schema||''''); 9 dbms_datapump.start_job(l_dp_handle); 10 dbms_datapump.detach(l_dp_handle);
Page 10 of 13
Procedure created. test%ORA10GR2> test%ORA10GR2> exec exportdb BEGIN exportdb; END; * ERROR at line 1: ORA-31626: job does not exist ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79 ORA-06512: at "SYS.DBMS_DATAPUMP", line 911 ORA-06512: at "SYS.DBMS_DATAPUMP", line 4356 ORA-06512: at "TEST.EXPORTDB", line 6 ORA-06512: at line 1
test%ORA10GR2> test%ORA10GR2> connect / Connected. ops$tkyte%ORA10GR2> grant create table to test; Grant succeeded. ops$tkyte%ORA10GR2> connect test/test Connected. test%ORA10GR2> exec exportdb PL/SQL procedure successfully completed.
dbms_datapump script vs procedure November 12, 2007 - 6pm US/Eastern Bookmark | Bott | Top Reviewer: Jasbir from Toronto, Canada
To add to my previous post. grants: My user I was testing the script vs procedure with had the following
create user test identified by test; grant resource, connect to test; grant EXP_FULL_DATABASE to test; grant IMP_FULL_DATABASE to test; Thanks.
grant create table to test November 22, 2007 - 3pm US/Eastern Reviewer: Jasbir from Toronto, Canada
Hi Tom,
Bookmark | Bottom |
Thank you for your help it fixed my problem. My obvious question is why do you have to explicitly execute "grant create table to test" when this should be part of the resource role. Thanks, Jasbir.
Page 11 of 13
reiterated.... Export Error December 8, 2007 - 5am US/Eastern Reviewer: Nishith Pandey from India
Hi Tom I submit the Export Job via OEM. Our database is Oracle Database 10gR2. Sometimes the Job fails with the following log : Job EXPORT006981 has been reopened at Wednesday, 05 December, 2007 23:10 Restarting "SYSTEM"."EXPORT006981": Estimate in progress using BLOCKS method... Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA . estimated "AGR"."AD_AGOMAST" 256 MB . estimated "SAN"."FA_VCHDET" 216 MB . estimated "PATNA"."AD_DUMYDATA" 192 MB . estimated "COMMOBJ"."AD_OUTSTAND_16_10_07" 176 MB . estimated "NOIDA"."AD_CCPEDTN" 176 MB . estimated "NOIDA"."CR_DLYSUP" 168 MB . estimated "VNS"."VNS_AD_CCPEDTN" 161 MB . estimated "NOIDA"."FA_VCHDET" 152 MB . estimated "AGR"."NEW_DUMMYDATA" 144 MB . estimated "CENRO"."N_AD_CCPDET" 144 MB . estimated "VNS"."NEW_DUMMYDATA" 141 MB . estimated "LKO"."AD_CCPEDTN" 140 MB . estimated "ALLD"."ALD_AD_CCPEDTN" 136 MB . estimated "CENRO"."D_AD_CCPEDTN" 120 MB . estimated "CENRO"."L_AD_CCPDET" 120 MB . estimated "LKO"."LKO_AD_CCPDET" 120 MB . . . (Not shown for abbreviation) . . . . . estimated "VNS"."PAY_PRV_MONSTATUS" 0 KB . estimated "VNS"."PAY_TEMPADV" 0 KB . estimated "VNS"."PAY_TOURADV" 0 KB . estimated "VNS"."TASKS_STATUS" 0 KB Total estimation using BLOCKS method: 22.12 GB Processing object type SCHEMA_EXPORT/USER Processing object type SCHEMA_EXPORT/SYSTEM_GRANT Processing object type SCHEMA_EXPORT/ROLE_GRANT Processing object type SCHEMA_EXPORT/DEFAULT_ROLE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM Processing object type SCHEMA_EXPORT/TABLE/TABLE ORA-39171: Job is experiencing a resumable wait. ORA-01691: unable to extend lob segment SYSTEM.SYS_LOB0000374957C00039$$ SYSTEM ORA-39171: Job is experiencing a resumable wait. ORA-01691: unable to extend lob segment SYSTEM.SYS_LOB0000374957C00039$$ SYSTEM ORA-39171: Job is experiencing a resumable wait. ORA-01691: unable to extend lob segment SYSTEM.SYS_LOB0000374957C00039$$ SYSTEM ORA-39171: Job is experiencing a resumable wait. ORA-01691: unable to extend lob segment SYSTEM.SYS_LOB0000374957C00039$$
Bookmark | Bottom |
by 1024 in tablespace
by 1024 in tablespace
by 1024 in tablespace
by 1024 in tablespace
Page 12 of 13
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tablespace
in tables
Page 13 of 13
When we increase the size of System Tablespace, the next job runs successful. What is the permanent remedy for this error?
Write a Review
All information and materials provided here are provided "as-is"; Oracle disclaims all express and implied warranties, including, the implied warranties of merchantability or fitness for a particular use. Oracle shall not be liable for any damages, including, direct, indirect, incidental, special or consequential damages for loss of profits, revenue, data or data use, incurred by you or any third party in connection with the use of this information or these materials.
About Oracle | Legal Notices and Terms of Use | Privacy Statement