Connect to Remote Database with PL/SQL
To connect to a remote database, you can use the Database Link feature in PL/SQL. Here are the steps to connect to a remote database:
- Firstly, create a database connection in the local database by using the following statement:
CREATE DATABASE LINK remote_db
CONNECT TO remote_user IDENTIFIED BY password
USING 'remote_db';
In which, remote_db is the connection name of the remote database, remote_user is the username of the remote database, password is the password of the remote database, ‘remote_db’ is the connection string of the remote database.
- To connect to a remote database and execute SQL statements, you can use the following command:
SELECT * FROM table_name@remote_db;
table_name is the name of the table in the remote database, and remote_db is the database connection created in step 1.
By following the above steps, you can connect to a remote database and execute SQL statements in PL/SQL.