Oracle Db Link test

Source: Internet
Author: User

Source database:
Computer Name: bkjia
Database Name: orcl

Target database:
Computer Name: suzhou
Database Name: ocp

0. Create a test table for the target database
SQL> conn scott/password
Connected.
SQL> show user;
The USER is SCOTT"
SQL> create table t1
2 (
3 sid int not null,
4 sno int
5 );

The table has been created.

SQL> insert into t1 values (101,201 );

One row has been created.

SQL> commit;

Submitted.

SQL> select * from t1;

SID SNO
--------------------
101 201

1. Modify tnames. ora on the source database

To_suzhou =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.90.20) (PORT = 1521 ))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ocp)
)
)

2. Create a link on the source database

Create public database link DB_LINK_NAME connect to TargetDatabaseUserName identified by TargetDatabasePassword using 'targetdatabasesidname ';
Note: TargetDatabaseSIDName is the database connection string () defined in the tnsnames. ora file on the host where the Oracle database is located ().

Create public database link to_sz connect to scott identified by password using 'to _ suzhou ';

3. Test db link

SQL> select * from t1 @ to_sz;

SID SNO
--------------------
101 201

4. Create synonyms,

SQL> create synonym dblinktest for t1 @ to_sz;

Synonym created.


SQL> select * from dblinktest;

5. view the database link

SQL> select owner, object_name from dba_objects where object_type = 'database link ';

6. delete a database connection

SQL> drop public database link to_sz;

For more information about Oracle, see Oracle topics page http://www.bkjia.com/topicnews.aspx? Tid = 12

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.