zoukankan      html  css  js  c++  java
  • 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');    

  • 相关阅读:
    May Lunchtime 2021 Division 1
    June Cook-Off 2021 Division 1
    Codeforces Round #733 (Div. 1 + Div. 2)
    腾讯云TDSQL MySQL版
    腾讯云TDSQL PostgreSQL版-产品优势
    腾讯云TDSQL PostgreSQL版 -应用场景
    腾讯云TDSQL PostgreSQL版 -最佳实践 |优化 SQL 语句
    腾讯云TDSQL PostgreSQL版 -最佳实践 |优化 SQL 语句
    腾讯云TDSQL监控库密码忘记问题解决实战
    腾讯云分布式数据库TDSQL在银行传统核心系统中的应用实践
  • 原文地址:https://www.cnblogs.com/hjianguo/p/5765816.html
Copyright © 2011-2022 走看看