Oracle同義字+dblink的實際應用

來源:互聯網
上載者:User

Oracle同義字+dblink的實際應用

Oracle同義字+dblink的實際應用

業務需求:原資料庫(10.2.0.4.0),新資料庫(11.2.0.3)
由於程式的需求原因,現在需要把新庫上的某個使用者直接映射到老庫使用者下:

1. 備份原庫的使用者
nohup exp scott/scott OWNER=scott BUFFER=10240000 STATISTICS=none RESUMABLE=y FILE=scott_all_exp.dmp LOG=scott_all_exp.log &

2. 刪除原庫的使用者下的表
set linesize 180 pagesize 1000
SELECT 'DROP TABLE '||table_name||' CASCADE CONSTRAINTS PURGE;' FROM user_tables;

得出SQL的命令vi儲存到droptable.sql
然後SQL> @droptable

3. 在原庫上建立到新庫的dblink
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;

4. 在原庫上建立同義字
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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.