1. To establish a Database connection, you must have the PCREATE Database link system permission. to connect to a remote account, you must also have the CREATE session common permission;
2. Ensure that connected users have the permission to access the tables or views of the connected database.
3. Add the connection characters to the connected database in the [TNSNAMES. ORA] file.
LIMS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.126.6.14) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = LIMS)
)
)
Or use the second method to create a connection.
3. Create Database Connection syntax
CREATE [public] database link database connection name
Connect to username identified by password
USING 'database connection string ';
Create database link "Oracle_13"
Connect to "TOTALPLANT"
Identified "********"
USING 'oracle _ Server'
Or:
-- Create database link
Create database link TOCCIC
Connect to ZTRY identified by ZTRY
Using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = fengwenwei) (PORT = 1521 ))
)
(CONNECT_DATA = (SID = ZTRY ))
)';
4. Generally, PUBLIC is created by the database administrator. Individual users can access a private database without public;
5. In the configuration file init. in ora, when the database parameter global_name = true, the database connection name must be the same as the remote database name; when the database parameter global_name = false, the database connection name can be different from the remote database name; restart the database to take effect. Alternatively, you do not need to restart the database by modifying alter system set global_names = false;
6. In the configuration file init. ora, the number of database connections is limited. The default number of concurrent connections is 4, which is limited by OP_LINKS;
====================================
You can use the following command to check the global name of the database:
SELECT * FROM GLOBAL_NAME;
Query tables in a remote database
SELECT ...... FROM table name @ database connection name;
Query database connections
Select * from user_db_links;
Delete database connection
DELETE USER_DB_LINKS;
DROP (PUBLIC) database link DBaseLinkToCompany