首页 > 开发 > 综合 > 正文

PL/SQL 快速建立DB_LINK

2024-07-21 02:33:19
字体:
来源:转载
供稿:网友

  本地数据库SID=T2
  
  远程数据库SID=LIFE02
  
  假设你的网络设定无误
  
  1) vi local database tnsname.ora
  
  life02 =
  (description =
  (address = (PRotocol = tcp)(host = 192.168.1.1)(port = 1521))
  (connect_data = (sid = life02))
  )
  
  2)建立属于公开的(public)或者是专属的db link object
  
  SQL> CREATE PUBLIC DATABASE LINK MYTEST
  2 CONNECT TO APPLE IDENTIFIED BY APPLE
  3 USING 'life02'
  
  Database link created.
  
  3)复制远程数据库的table到本地数据库来
  
  SQL> COPY FROM APPLE/APPLE@LIFE02 -
  > CREATE ABC -
  > USING SELECT * FROM TEST;
  
  Array fetch/bind size is 15. (arraysize is 15)
  Will commit when done. (copycommit is 0)
  Maximum long size is 80. (long is 80)
  Table ABC created.
  
  3 rows selected from APPLE@LIFE02.
  3 rows inserted into ABC.
  3 rows committed into ABC at DEFAULT HOST connection.
  
  SQL> SELECT * FROM ABC;
  
  ID
  ----------
  100
  200
  333
  
  SQL>
  
  4)从本地端表格复制数据到远程数据库表格上
  
  SQL> COPY FROM JACK/JACK@T2 TO APPLE/APPLE@LIFE02 -
  > INSERT TEST -
  > USING SELECT * FROM T1;
  Array fetch/bind size is 15. (arraysize is 15)
  Will commit when done. (copycommit is 0)
  Maximum long size is 80. (long is 80)
  2 rows selected from JACK@T2.
  2 rows inserted into TEST.
  2 rows committed into TEST at APPLE@LIFE02.
  
  具体资料请参考SQL*Plus User's Guide and Reference

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表