oracle 跨库访问

创建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');    

阅读更多
上一篇XML和实体类之间相互转换(序列化和反序列化)
下一篇Oracle 取某段时间的每一天的日期
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭