码迷,mamicode.com
首页 > 数据库 > 详细

oracle 跨库访问

时间:2016-08-12 18:11:13      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

 创建DBLINK的方法:

    1. create public database link dblink

       connect to totalplant identified by totalplant 

       using ‘(DESCRIPTION =

                (ADDRESS_LIST =

                  (ADDRESS = (PROTOCOL = TCP)(HOST = LOCALHOST)(PORT = 1521))

                )

                (CONNECT_DATA =

                  (SERVICE_NAME = prd.gdc)

                )

              )‘;

        语法解释:create public database link DBLINK名字(自己随便起)

                  connect to 用户名 identified by 密码

                  using ‘(DESCRIPTION =

                            (ADDRESS_LIST =

                              (ADDRESS = (PROTOCOL = TCP)(HOST = 要连接的数据库所在服务器的IP地址)(PORT = 1521))

                            )

                            (CONNECT_DATA =

                              (SERVICE_NAME = 要连接的数据库的在本地的服务名(即要连接的数据库的SID))

                            )

                          )‘;

     2. 如果创建private的DBLINK

        create database link dblink

        connect to totalplant identified by totalplant 

        using ‘(DESCRIPTION =

                (ADDRESS_LIST =

                  (ADDRESS = (PROTOCOL = TCP)(HOST = LOCALHOST)(PORT = 1521))

                )

                (CONNECT_DATA =

                  (SERVICE_NAME = prd.gdc)

                )

              )‘;                        

四. 连接成功后从所连接的数据库中取数的方法:

     1. select * from tbl_ost_notebook@dblink;

     说明:只需在表名的后面加上"@DBLINK名字"即可。    

五. 在当前数据库下查看所有的DBLINK的方法:

     1. select * from dba_db_links;     

六. 删除当前数据库下的一个指定的DBLINK的方法:

     1. 如果创建的是一个public的DBLINK,删除时需要用

        drop public database link dblink;

     2. 如果创建的是一个private的DBLINK,删除时需要用

        drop database link dblink;

     说明:drop public database link DBLINK名字;     

七. 查看当前数据库的全局数据库名的方法:

     1. select * from global_name;   

八. 查看当前用户具有哪些针对DBLINK的权限的方法:

     1. SELECT DISTINCT PRIVILEGE AS "Database Link Privileges"

        FROM ROLE_SYS_PRIVS

        WHERE PRIVILEGE IN ( ‘CREATE SESSION‘,‘CREATE DATABASE LINK‘,

                             ‘CREATE PUBLIC DATABASE LINK‘);    

oracle 跨库访问

标签:

原文地址:http://www.cnblogs.com/hjianguo/p/5765816.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!