create directory clone_auto as '';
2. create user
create user dba_clone_user identified by test123;
grant connect, create database link, resource, create view to dba_clone_user;
grant unlimited tablespace to dba_clone_user;
grant exp_full_database to dba_clone_user;
grant read,write on directory clone_auto to dba_clone_user;
grant execute on dbms_flashback to dba_clone_user;
grant create table to dba_clone_user;
grant FLASHBACK ANY TABLE to dba_clone_user;
2. create procedure
CREATE OR REPLACE PROCEDURE dba_clone_user.start_export
IS
hdl_job NUMBER;
l_cur_scn NUMBER;
l_job_state VARCHAR2 (20);
l_status SYS.ku$_status1010;
l_job_status SYS.ku$_jobstatus1010;
BEGIN
begin
execute immediate 'drop table DBA_CLONE_USER.AUTO_EXPORT';
exception when others then null;
end;
hdl_job := DBMS_DATAPUMP.OPEN ( operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'AUTO_EXPORT');
dbms_datapump.set_parameter(hdl_job, 'FLASHBACK_SCN', dbms_flashback.get_system_change_number);
dbms_datapump.set_parameter(hdl_job, 'COMPRESSION', 'METADATA_ONLY');
dbms_datapump.metadata_filter (handle => hdl_job, name => 'SCHEMA_LIST', value => '''USER1''');
dbms_datapump.set_parallel(hdl_job, 5);
DBMS_DATAPUMP.add_file (handle => hdl_job,
filename => 'user1%U.dmp',
directory => 'CLONE_AUTO',
--filesize IN VARCHAR2 DEFAULT NULL,
filetype => DBMS_DATAPUMP.ku$_file_type_dump_file,
reusefile => 1
);
DBMS_DATAPUMP.add_file (handle => hdl_job,
filename => 'auto_export.log',
DIRECTORY => 'CLONE_AUTO',
--filesize IN VARCHAR2 DEFAULT NULL,
filetype => DBMS_DATAPUMP.ku$_file_type_log_file,
reusefile => 1
);
DBMS_DATAPUMP.start_job (handle => hdl_job);
DBMS_DATAPUMP.wait_for_job (handle => hdl_job, job_state => l_job_state);
DBMS_OUTPUT.put_line ('Job exited with status:' || l_job_state);
END;
/
No comments:
Post a Comment