1、使用tnsname方式

在tnsnames.ora中添加服务信息

$ cd $ORACLE_HOME/network/admin
$ vi tnsnames.ora
...
buju18 =
(DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = X.X.X.X)(PORT = 1521))
    )
    (CONNECT_DATA =(SID = ORCL))
)
...

测试配置

$ tnsping buju18

创建连接

SQL> create database link lk_buju18 connect to ztry identified by ztrypwd using 'buju18';

2、使用直接连接方式

可以直接在SQL中指定连接串

SQL> create database link lk_buju18 connect to ztry identified by ztrypwd using  '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = X.X.X.X )(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = ORCL) )';

3、使用连接

在SQL中使用连接

SQL> select count(*) from qg_ztry_jbxx@lk_buju18;

相关内容

· oracle database link

[ 编辑 | 历史 ]
最近由“jilili”在“2013-04-19 09:12:58”修改