Cross-database queries --dblink

 

Now build a local dblink

Database Link the Create
the Create Database Link public DBLINKTEST (Name)
Connect to MGP (user name) IDENTIFIED by MGP (password)
a using '(the DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.80.223 (external address database ) ) (pORT = 1521 (external database port) ))) (the CONNECT_DATA = (SERVICE_NAME = ORCL (external database name) ))) ';

Such code can be found with an external database table it.

For example, there is a local user database user tables, fields id, identity_card, name. There is a role external database role tables, fields id, role_name, identity_card

Find all the information so you can write: select a.id, a.identity_card, a.name, b.id, b.role_name from user a, role @ DBLINKTEST b where a.identity_card = b.identity_card;

 

If the tables of other databases locally generated again, we need to deal with local excision of the table, to be a trigger.

Guess you like

Origin www.cnblogs.com/xlj227/p/12052703.html