天天看點

基于存儲過程實作批量複制表(Procedure)的方案實作

利用存儲過程結合DBLink批量複制表(Procedure),具體實作代碼如下:

create or replace procedure "SP_CREATETABLE" authid current_user

as

v_tmp varchar2(50);

cursor cur_table is select table_name from user_tables@DBLINK_217;

begin

dbms_output.put_line('------ 開始 ------');

for tableName in cur_table loop

v_tmp := tableName.Table_Name;
dbms_output.put_line('------ create table start ------' ||v_tmp);
execute immediate 'create table '||v_tmp||' as select * from '||v_tmp||'@DBLINK_217 ';
dbms_output.put_line('------ create table finished ------' ||v_tmp);           

end loop;

exception

when others then
dbms_output.put_line(v_tmp);
           

end;