Oracle10g create DBLink

Source: Internet
Author: User
In Oracle, DBlink is used to associate tables with different databases ). There are two ways to create DBlink: creating through SQL statements and using the visualization Interface

In Oracle, database links are used to associate tables with different databases ). There are two ways to create a DB link: SQL statement creation and Visualization

In some cases, you need to associate different databases for Data Query and operations.

In Oracle, database links are used to associate tables with different databases ).

There are two ways to create a DB link: Creating an SQL statement and creating it on a visual interface (actually an executed SQL statement ).

1. Create a project using PL/SQL Developer

Name: The Name of this DBLINK. For example, DEMO

UserName: User Name for database Login

Password: Database Login Password

Database :( DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.1) (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = DEMO )))

The above red font content can be queried from the following places: \ product \ 10.2.0 \ client_1 \ network \ admin \ tnsnames. ora

DEMO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.1) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DEMO)
)
)

Remove the above "DEMO =" and remove the linefeeds and spaces from the rest to form a string.

Click "Apply.

After it is created, it will be displayed under the Database links menu.

Test whether the DB link is valid. Execute the statement: Select * from student @ DEMO.

Student indicates the table name of the remote database.

2. Create an SQL statement

Create public databaselink V_SERVICE_NAMEconnect to V_USERNAMEidentified by V_PASSWORD using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.1) (PORT = 1521 ))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = V_SERVICE_NAME )))';

Where:

V_SERVICE_NAME indicates the service name. You can use the SQL statement to query: SELECT * FROM GLOBAL_NAME; -- view the service name.

V_USERNAME indicates the account used to log on to the remote database.

V_PASSWORD indicates the password used to log on to the remote database.

PS: In my test, the DB link is invalid when the tns string contains a line break. If the DB link name is not a service name, the DB link is invalid.

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.