Example I The following example defines a current-user database link: CREATE DATABASE LINK sales.hq.acme.com CONNECT TO CURRENT_USER USING 'sales'; Example II The following statement defines a fixed-user database link named SALES.HQ.ACME.COM: CREATE DATABASE LINK sales.hq.acme.com CONNECT TO scott IDENTIFIED BY tiger USING 'sales' Once this database link is created, you can query tables in the schema SCOTT on the remote database in this manner: SELECT * FROM [email protected] You can also use DML commands to modify data on the remote database: INSERT INTO [email protected](acc_no, acc_name, balance) VALUES (5001, 'BOWER', 2000) UPDATE [email protected] SET balance = balance + 500 DELETE FROM [email protected] WHERE acc_name = 'BOWER' You can also access tables owned by other users on the same database. This example assumes SCOTT has access to ADAM's DEPT table: SELECT * FROM [email protected] The previous statement connects to the user SCOTT on the remote database and then queries ADAM's DEPT table. A synonym may be created to hide the fact that SCOTT's EMP table is on a remote database. The following statement causes all future references to EMP to access a remote EMP table owned by SCOTT: CREATE SYNONYM emp FOR [email protected]; Example III The following statement defines a shared public fixed user database link named SALES.HQ.ACME.COM that refers to user SCOTT with password TIGER on the database specified by the string service name 'SALES': CREATE SHARED PUBLIC DATABASE LINK sales.hq.acme.com CONNECT TO scott IDENTIFIED BY tiger AUTHENTICATED BY anupam IDENTIFIED BY bhide USING 'sales'; Example IV The following example creates a current user database link: CREATE DATABASE LINK sales.hq.acme.com CONNECT TO CURRENT_USER USING 'sales';
v_Info是lk_book上的表的名称
book是lk_book上的用户名,也是v_info的拥有者
Create synonym v_info for book.v_Info@lk_book ;
以后就不用麻烦了book表示schema
v_Info表示表名
lk_book 表示dblink
设置自定义社区可以设置你登入到那个社区.
请问db_link在ORACLE里面怎么建?
The following example defines a current-user database link: CREATE DATABASE LINK sales.hq.acme.com
CONNECT TO CURRENT_USER
USING 'sales';
Example II
The following statement defines a fixed-user database link named SALES.HQ.ACME.COM: CREATE DATABASE LINK sales.hq.acme.com
CONNECT TO scott IDENTIFIED BY tiger
USING 'sales' Once this database link is created, you can query tables in the schema SCOTT on the remote database in this manner: SELECT *
FROM [email protected] You can also use DML commands to modify data on the remote database: INSERT INTO [email protected](acc_no, acc_name, balance)
VALUES (5001, 'BOWER', 2000) UPDATE [email protected]
SET balance = balance + 500 DELETE FROM [email protected]
WHERE acc_name = 'BOWER' You can also access tables owned by other users on the same database. This example assumes SCOTT has access to ADAM's DEPT table: SELECT *
FROM [email protected] The previous statement connects to the user SCOTT on the remote database and then queries ADAM's DEPT table.
A synonym may be created to hide the fact that SCOTT's EMP table is on a remote database. The following statement causes all future references to EMP to access a remote EMP table owned by SCOTT: CREATE SYNONYM emp
FOR [email protected];
Example III
The following statement defines a shared public fixed user database link named SALES.HQ.ACME.COM that refers to user SCOTT with password TIGER on the database specified by the string service name 'SALES': CREATE SHARED PUBLIC DATABASE LINK sales.hq.acme.com
CONNECT TO scott IDENTIFIED BY tiger
AUTHENTICATED BY anupam IDENTIFIED BY bhide
USING 'sales';
Example IV
The following example creates a current user database link: CREATE DATABASE LINK sales.hq.acme.com
CONNECT TO CURRENT_USER
USING 'sales';