create public database link link_mm_dev
connect to stl identified by fosssit
using ‘(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.111)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = fossdbsb)
)
)‘;
--1 link_mm_dev dblink名称
--2 %MM% 外部数据库 需要的表
declare
num number(1);
begin
for v_row in (select t.table_name
from [email protected]_mm_dev t
where t.table_name like ‘%MM%‘) loop
select count(1)
into num
from user_tables t
where t.table_name = v_row.table_name;
if num > 0 then
execute immediate ‘drop table ‘ || v_row.table_name;
num:=0;
end if;
execute immediate ‘create table ‘ || v_row.table_name ||
‘ as select * from ‘ || v_row.table_name||‘@link_mm_dev‘;
end loop;
end;