首页 > 数据库 > Oracle > oracle dblink
[oracle@chen admin]$ pwd
/u01/app/oracle/product/11.2.0/network/admin
[oracle@chen admin]$ vim tnsnames.ora
222=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.222)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = aaa)
)
)
[oracle@chen admin]$ tnsping 222
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 23-AUG-2014 23:51:27
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/11.2.0/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.222)(PORT =
1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = aaa)))
OK (10 msec)
[oracle@chen ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Sat Aug 23 23:51:37 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: chen/chen@201
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show user
USER is "CHEN"
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
CHEN_T1 TABLE
SQL> select * from chen_t1;
ID
----------
1
2
SQL> select name from v$database;
NAME
---------
AAA
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@chen ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Sun Aug 24 00:18:51 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: /as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> grant create public database link,create database link to scott;
Grant succeeded.
SQL> grant drop public database link to scott;
Grant succeeded.
SQL> conn scott/tiger
Connected.
SQL> create public database link aaa_link connect to chen identified by "chen" using '222';
Database link created.
SQL> select * from chen_t1@aaa_link;
ID
----------
1
2
欢迎关注我的微信公众号"IT小Chen",共同学习,共同成长!!!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29785807/viewspace-1304344/ ,如需转载,请注明出处,否则将追究法律责任。