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))
)
)';
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)
)
)';
select * from tbl_ost_notebook@dblink;
说明:只需在表名的后面加上"@DBLINK名字"即可。
select * from dba_db_links;
如果创建的是一个public的DBLINK,删除时需要用
drop public database link dblink;
如果创建的是一个private的DBLINK,删除时需要用
drop database link dblink;
说明:drop public database link DBLINK名字;
SELECT DISTINCT PRIVILEGE AS "Database Link Privileges"
FROM ROLE_SYS_PRIVS
WHERE PRIVILEGE IN ( 'CREATE SESSION','CREATE DATABASE LINK', 'CREATE PUBLIC DATABASE LINK');
http://wenku.baidu.com/view/6c2dcc42a8956bec0975e3d0.html