You can create database links to Oracle databases that are accessible from an Autonomous Data Warehouse database.
Create Database Links
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK to create database
To use database links with Autonomous Data Warehouse the target database must be configured to use TCP/IP with SSL (TCPS) authentication. Autonomous Databases use TCP/IP with SSL (TCPS) authentication by default, so you do not need to do any additional configuration in your target database for an Autonomous Transaction Processing or Autonomous Data Warehouse database. Other databases must be configured to use TCP/IP with SSL (TCPS) authentication. See Configuring Secure Sockets Layer Authentication for more information.
To ensure security, the database link port is restricted to the range
1521-1525. You specify the target database port when you create a
database link with
To use database links the target database must be accessible. Some databases, including Autonomous Databases may limit access, for example using Access Control Lists. If access to the target database is limited and does not include the database where you are creating the database link, this would prevent using database links with those target databases. See Set Access Control List with Autonomous Data Warehouse for more information.
To create database links to a target database do the following:
- Copy your target database wallet,
cwallet.sso, containing the certificates for the target database to Object Store.
Note:The wallet file, along with the Database user ID and password provide access to data in the target Oracle database. Store wallet files in a secure location. Share wallet files only with authorized users.
- Create credentials to access your Object Store where you store the
cwallet.sso. See CREATE_CREDENTIAL Procedure for information about the username and password parameters for different object storage services.
- Upload the target database wallet to the
data_pump_dirdirectory, or to another directory where you have write privileges, using
DBMS_CLOUD.GET_OBJECT( credential_name => 'DEF_CRED_NAME', object_uri => 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/adwc/b/adwc_user/o/cwallet.sso', directory_name => 'DATA_PUMP_DIR'); END; /
credential_nameyou use in this step is the credentials for the Object Store. In the next step create the credentials to access the target database.
- On Autonomous Data Warehouse create
credentials to access the target database. The
passwordyou specify with
DBMS_CLOUD.CREATE_CREDENTIALare the credentials for the target database that you use to create the database link.
credential_nameparameter is optional if you use the same credentials on the target database. If
credential_nameis not supplied in the following step, or is supplied with a
NULLvalue, the database link is created using the connected user credentials (the link is created and uses the credentials,
password, of the user who is accessing the link).
DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'DB_LINK_CRED', username => 'NICK', password => 'password' ); END; /
The characters in the
usernameparameter must be all uppercase letters.
This operation stores the credentials in the database in an encrypted format. You can use any name for the credential name.
- Create the database link to the target database using
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK( db_link_name => 'SALESLINK', hostname => 'adb.eu-frankfurt-1.oraclecloud.com', port => '1522', service_name => 'example_medium.adwc.example.oraclecloud.com', ssl_server_cert_dn => 'CN=adwc.example.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US', credential_name => 'DB_LINK_CRED', directory_name => 'DATA_PUMP_DIR'); END; /
Users other than ADMIN require privileges to run
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK. See CREATE_DATABASE_LINK Procedure for more information.
- Use the database link you created to access data on the target database.
SELECT * FROM employees@SALESLINK;
Notes for database links:
- Only one wallet file is valid per directory for use with database links.
You can only upload one
cwallet.ssoat a time to the
DATA_PUMP_DIRdirectory. This means with a
DATA_PUMP_DIRyou can only create database links to the databases for which the wallet is valid. To use multiple
cwallet.ssofiles with database links you need to create additional directories and put each
cwallet.ssoin a different directory. When you create database links with
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK, specify the directory that contains the wallet with the
directory_nameparameter. See Create Directory in Autonomous Database for information on creating directories.
DATA_PUMP_DIRis the only available predefined directory for uploading the target database wallet with
DBMS_CLOUD.GET_OBJECT. You can specify a different directory as the directory argument if you previously created the directory and you have write privileges on the directory. See Create Directory in Autonomous Database for information on creating directories.
- Supported target database versions are: 19c, 18c, 12.2.0, 12.1.0, and
Note:For complete information on supported versions, see Client Server Interoperability Support Matrix for Different Oracle Versions (Doc ID 207303.1)
- To list the database links accessible to the connected user, use the
ALL_DB_LINKSview. See ALL_DB_LINKS for more information.
For the credentials you create in Step 4, the target database credentials, if the password of the target user changes you can update the credential that contains the target user's credentials as follows:
DBMS_CLOUD.UPDATE_CREDENTIAL( credential_name => 'DB_LINK_CRED', attribute => 'PASSWORD', value => 'password'); END; /
Where password is the new password.
After this operation, the existing database links that use this credential continue to work without having to drop and recreate the database links.
For additional information, see:
Drop Database Links
After you create a database link you can drop the database link.
- Drop a database link to a target database using
DBMS_CLOUD_ADMIN.DROP_DATABASE_LINK( db_link_name => 'SALESLINK' ); END; /
See DROP_DATABASE_LINK Procedure for detailed information about the procedure.