View, create, and delete a DB Link

Source: Internet
Author: User

1. View dblink

select owner,object_name from dba_objects where object_type='DATABASE LINK';

Or

select * from dba_db_links;

2. Create a dblink
Prerequisites:
The user who created dblink has the corresponding database permissions.
Create public database link or CREATE DATABASE LINK
Available

grant create public database link,create database link to myAccount;

To authorize.

Create public database link dblinkname connect to username identified by password
Using '(description =
(Address_list =
(Address = (Protocol = TCP) (host = database_ip) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = servicename)
)
)';
If public is not added after create, the created dblink is not public and can only be used by the creator.
Supplement: How to Determine the database servicename:
1. Use in sqlplus

show parameter[s] service_names;

Both parameter and parameters can be used.
2. Use

select name,value from v$parameter where name='service_names'


3. Use dB Link
For example, if a public dblink of scott_rmthost is created on the local database (connected by Scott user of the remote host), sqlplus is used to connect to the local database and select * from Scott. EMP @ scott_rmthot: You can obtain the data in the EMP table of the Scott user in the remote database.
You can also create a synonym locally to point to Scott. EMP @ scott_rmthost. This makes the value more convenient.

4. Delete
Note: You have the create public database link or create database link permission.

drop public database link dblinkname;

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.