PLSQL_Database Link的基本概念和用法(概念)

2014-06-08 Created By BaoXinjian

一、总结


1. 建立数据库连接的方式

2. 查询方式

3. 连接类型

4. 常用的查询

 

二、具体分析


1. 建立数据库连接的方式

    (1).使用tns进行建立

                CREATE DATABASE LINK linkname

                    CONNECT TO user_name IDENTIFIED BY password

                    USING tns_dbname 

    (2).直接建立

                CREATE DATABASE LINK linkname

                     CONNECT TO user_nameIDENTIFIED BY password

                    USING '(DESCRIPTION =

                                           (ADDRESS_LIST =

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

                                            )

                                            (CONNECT_DATA =

                                                    (SERVICE_NAME = dbname)

                                            )

                                 )'    

 

2. 查询方式

    (1).直接使用select * form tablename@dblink    

    (2).建立同义词,按同义词方式进行查询

    (3).建立物化视图,提高执行效率

        create public synonym syn_name for tablename@linknam

 

3. 连接类型

    (1).私有Private

    (2).共有Public

        建立共有的数据库连接时必须是有sysadmin和sys账户

                CREATE PUBLIC DATABASE LINK linkname

                    CONNECT TO user_name IDENTIFIED BY password

                    USING tns_dbname

 

4. 常用的查询

    (1).查询当前账户所有的dblink连接

                select * from user_db_links; 

    (2).查询当前系统所有的dblink连接

                select * from dba_db_links  

    (3).查询当前正在连接的dblink连接

                select * from v$dblink

 

Thanks and Regards

posted on 2014-12-03 09:55  东方瀚海  阅读(2567)  评论(1编辑  收藏  举报