Oracle quickly creates a global dblink

-- If you create a global dblink, you must use the systm or sys user, and add public before database.  
create  public  database link dblink1  
  connect to dbusername identified by dbpassword  
  using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = orcl)))';  
  
-- When the database parameter global_name=true, the database link name is required to be the same as the remote database name. The database global name can be found out with the following command  
select * from global_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".  
select xxx FROM table name@database link name;  

-- delete dblink
drop /* public */ database link dblink1;  

-- create and delete synonyms
create or replace synonym synonym name for table name;  
create or replace synonym synonym name for user.table name;  
create or replace synonym synonym name for table name@database link name;  
drop synonym synonym name;  

-- create and delete views
create or replace view view name as (select field from user. table name @dblink1);  
drop view view name;  

 
-- Notice:
-- Creating a DBLink is very simple, but there is a lock in the background during use. To view this lock, you can go to the console to see or query the database.
-- Every time you use dblink to query, a connection will be created with the remote database, and dblink should not automatically release this connection. If you use dblink to query a lot, the number of connections in the web project will be insufficient, resulting in the system not running normally. cause the system to malfunction.
 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326676325&siteId=291194637