Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use dblink is established in Oracle

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Oracle Application Server OS

1. View the global_name of the database

SELECT * FROM GLOBAL_NAME

two。 Check whether the global_name parameter is true or false

Show parameter global_name

If true, the locally established dblink name must be the same as the remote global_name.

3. Create dblink

CREATE DATABASE LINK database link name CONNECT TO username IDENTIFIED BY password USING 'database connection string'

Example 1:

CREATE PUBLIC DATABASE LINK CONN_MY_LINK CONNECT TO MYUSER IDENTIFIED BY MYPASSWORD USING 'MYORAL'

Where MYORAL is the local name of the access server established for the client server

LINK CONN_MY_LINK is a locally established dblink name

Example 2:

CREATE PUBLIC DATABASE LINK LINK_HSMIS CONNECT TO BI IDENTIFIED BY BI USING'(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.188.245.201) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = hsmis)'

Directly replace local naming with a local named connection string.

/ / Grant creation permission grant CREATE DATABASE LINK to smis; grant CREATE SYNONYM to smis

4. Query whether the dblink is created successfully

SELECT * FROM DUAL@ database link name or SELECT * FROM table name @ database link name

5. Delete dblink

Drop public database link CONN_MY_LINK

6. Use synonyms to simplify:

CREATE SYNONYM S_MY_TABLE FOR TABLENAME@ database link name

The solution of Lock in 7.db_link query

To release the connection each time you use a db_link query, call the close function in the dbms_session package

Example: dbms_session.close_database_link (CONN_MY_LINK)

Or when using dblink, even the select text should be commit, or rollback, otherwise a long time will hinder other processes.

8. There is a solution that cannot process the server name when querying dblink

To establish the corresponding connection on the server in the corresponding database, for example, A database is on A1 server, B database is on b1 server, if you want to connect B database in A database, then establish the corresponding tnsnames configuration item on server A1 as follows:

(in Oracle under Win environment, configure it in the file Oracle\ Network\ ADMIN\ tnsnames.ora)

A_TO_B = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = IP of A2 server) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = service name of B database)

Then set up the corresponding dblink, and the easy mistakes are:

Establish a connection in your own client's tnsname.ora, but not in all of the A database

A connection is established in the tnsname.ora of server A1.

9. View the table locking process and unlock

(1) method 1:

Select sess.sid, sess.serial#, lo.oracle_username, lo.os_user_name, ao.object_name, lo.locked_mode from v$locked_object lo, dba_objects ao, v$session sess where ao.object_id = lo.object_id and lo.session_id = sess.sid

(2) method 2:

Select * from v$session T1, v$locked_object T2 where t1.sid = t2.SESSION_ID

(3) unlock the process

If there is a record, it indicates that there is a lock. Record the SID and serial#, and replace the recorded ID with the SID and serial below, and then the LOCK can be removed.

Alter system kill session 'SID,serial'

The above is a summary of the dblink application in oracle introduced by the editor. I hope it will be helpful to you. If you have any questions, you are welcome to leave a message. The editor will reply you in time. Thank you very much for your support to the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report