Oracle同义词+dblink的实际应用
业务需求:原数据库(10.2.0.4.0),新数据库(11.2.0.3) 由于程序的需求原因,现在需要把新库上的某个用户直接映射到老库用户下:
nohup exp scott/scott OWNER=scott BUFFER=10240000 STATISTICS=none RESUMABLE=y FILE=scott_all_exp.dmp LOG=scott_all_exp.log &
set linesize 180 pagesize 1000
SELECT 'DROP TABLE '||table_name||' CASCADE CONSTRAINTS PURGE;' FROM user_tables;
得出SQL的命令vi保存到droptable.sql 然后SQL> @droptable
create public database link link167 connect to scott identified by scott using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.167)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = NEWDB)
)
)';
测试dblink可用:
select * from dual@link167;
create synonym MDRT_12E92$ for MDRT_12E92$@link167;
在新库查询user_tables得到table_name的列表,
set pagesize 1500
select table_name from user_tables;
命令用UE列编辑处理好,vi保存到createsynonym.sql 然后SQL> @createsynonym
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有