创建public dblink 。
create public database link test_link connect to csservicedb identified by huawei123 using ' (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.119)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )' ; Database link created.
sql> desc cs_user; ERROR: ORA-04043: object cs_user does not exist sql> desc cs_user@test_link; Name Null? Type ----------------------------------------- -------- ---------------------------- PK_BUR_USERID NOT NULL VARCHAR2(18) BUR_USER_FLAG NOT NULL VARCHAR2(32)
select * from dba_objects where object_type='DATABASE LINK'; select owner, db_link from dba_db_links; -- 查看dblink的owner及link名字
删除dblink 。
sql> DROP PUBLIC DATABASE LINK csmain; Database link dropped. sql> DROP PUBLIC DATABASE LINK csserver; Database link dropped. sql>
如果语句中不加public,则创建的owner就是现连接的用户 。
sql> create database link CSMAIN connect to csmaindb identified by huawei123 using ' (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.119)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )' ; sql> select owner, db_link from dba_db_links; OWNER DB_LINK ------------------------------ --------------- CS_AUX CSMAIN CS_AUX CSSERVER