Links between databases are built on database link. To create a DB link, you must first set up the link string on each database server.
1, configure TNS, $ORACLE _home/network/admin/tnsname.ora
10gstandby =
(DESCRIPTION =
(address = (PROTOCOL = TCP) (HOST = hfcc-kf-3068) (PORT = 1522))
(Connect_data =
(SERVER = dedicated)
(service_name = 10gstandby)
)
)
2, create a database link,
Create Public database link Db_link_name connect to targetdatabaseusername identified by Targetdatabasepassword using ' Tar Getdatabasesidname ';
Note: Targetdatabasesidname the database connection string defined inside the Tnsnames.ora file on the host where the Oracle database resides.
Sql>create Public Database link DVD connect to system identified by system using ' orcl10g ';
or use:
Create Public database link Link_name
Connect to USER identified by PWD
Using ' (DESCRIPTION =
(Address_list =
(address = (PROTOCOL = TCP) (HOST = 192.168.1.1) (PORT = 1521))
)
(Connect_data =
(service_name = ORCL)
)
)';
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/
We created a link DVD with the system user and orcl10g database, and we queried the DVD data:
Sql>select * from All_users@dvd;
This allows the local and remote data to be processed as a whole.
3, to establish synonyms, in order to make more transparent about distributed operations, the Oracle database has synonyms for objects synonym
Sql>create synonym syntest for all_users@dvd;
So we can use Syntest to replace the Distributed link operation All_users@dvd with @ symbol;
4, see all the database links:
Sql>select owner,object_name from dba_objects where object_type= ' DATABASE LINK ';
5. View database connection
Sql> Select owner, db_link from Dba_db_links;
Ower Db_link
Public DVD. Regress. Rdbms. DEV. US. Oracle.com
6. Delete database connection
First view the database connection from step 5th to get the name of the Db_link
Sql>drop Public Database link DVD. Regress. Rdbms. DEV. US. Oracle.com
Database connection has been discarded
51cto Blog Oracle Little Bastard