simple DBMS_DATAPUMP extract of list of tables

declare

  h1 number;

  v_job_state varchar2(4000);

begin

  h1 := dbms_datapump.open(operation => 'EXPORT', job_mode => 'TABLE');

  dbms_datapump.add_file(h1,
                         'example1.dmp',
                         'DATA_PUMP_DIR',
                         reusefile => 1);

  dbms_datapump.add_file(h1,
                         'example1.log',
                         'DATA_PUMP_DIR',
                         reusefile      => 1,
                         filetype       => dbms_datapump.ku$_file_type_log_file);

  dbms_datapump.metadata_filter(handle      => h1,
                                name        => 'NAME_EXPR',
                                value       => 'IN (''TEST'',''TEST2'')',
                                object_type => 'TABLE');

  dbms_datapump.start_job(h1);

  DBMS_DATAPUMP.WAIT_FOR_JOB(h1, v_job_state);

  DBMS_OUTPUT.PUT_LINE(v_job_state);

end;

/

Comments