Oracle DBlink related

1. The local service has been configured
  create public database link link_name
connect to username identified by password
using 'connect_string';
Note: link_name is the connection name, which can be customized;
username is the user name for
logging in to the database; password is the user password for logging in to the database;
connect_string is the database connection string.
The database connection string is the alias name defined in the TNSNAMES.ORA file in the current client database. You can use NET8 EASY CONFIG or directly modify the definition in TNSNAMES.ORA.
  2. Directly establish a link
  create database link link_name
  connect to username identified by password
  using '(DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = XXXX )(PORT = 1521))
  )
  (CONNECT_DATA =
  (SERVICE_NAME = SSID)
  )
  )';
  host = database ip address, service_name = database ssid.
  In fact, the two methods of configuring dblink are similar, and I personally feel that the second method is better, so that it is not affected by local services.
  Note: If you create a global dblink, you must use the systm or sys user, and add public before database.
dblink query
to view all database links, enter the system administrator SQL> operator, run the command:
SQL>select owner,object_name from dba_objects where object_type='DATABASE LINK';
  or
select * from dba_db_links;
dblink delete

  DROP PUBLIC DATABASE LINK link_name;
dblink uses
SELECT...FROM table name@database link name;
querying, deleting and inserting data is the same as operating a local database, except that the table name needs to be written as "table name@dblink server".
Example: query the emp table data in the Beijing database select * from emp@BeiJing;
set the database connection string of the Beijing database here as BeiJing;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325298078&siteId=291194637