DBMS_CLOUD_ADMIN Package
This section
covers the DBMS_CLOUD_ADMIN subprograms provided with Autonomous AI Database.
| Subprogram | Description |
|---|---|
|
This procedure attaches a file system in a directory on your database. |
|
|
This procedure creates a database link to a target database. There are options to create a database link to another Autonomous AI Database instance, to an Oracle Database that is not an Autonomous AI Database, or to a non-Oracle Database using Oracle-managed heterogeneous connectivity. |
|
|
This procedure detaches a file system from a directory on your database. |
|
|
This procedure disables external authentication for the Autonomous AI Database instance. |
|
|
This procedure drops a database link. |
|
|
This procedure enables a user to logon to Autonomous AI Database using the specified external authentication scheme. |
ATTACH_FILE_SYSTEM Procedure
This procedure attaches a file system in the database.
The DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM
procedure attaches a file system in your database and stores information about the file
system in the DBA_CLOUD_FILE_SYSTEMS view.
Syntax
DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM (
file_system_name IN VARCHAR2,
file_system_location IN VARCHAR2,
directory_name IN VARCHAR2,
description IN VARCHAR2 DEFAULT NULL,
params IN CLOB DEFAULT NULL
);Parameters
| Parameter | Description |
|---|---|
|
|
Specifies the name of the file system. This parameter is mandatory. |
|
|
Specifies the location of the file system. The value you supply with For example:
This parameter is mandatory. |
|
|
Specifies the directory name for the attached file system. The directory must exist. This parameter is mandatory. |
|
|
(Optional) Provides a description of the task. |
|
|
A JSON string that provides an additional parameter for the file system.
|
Examples:
Attach to an NFSv3 file system:
BEGIN
DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM (
file_system_name => 'FSS',
file_system_location => 'myhost.sub000445.myvcn.oraclevcn.com:/results',
directory_name => 'FSS_DIR',
description => 'Source NFS for sales data'
);
END;
/
Attach to an NFSv4 file system:
BEGIN
DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM (
file_system_name => 'FSS',
file_system_location => 'myhost.sub000445.myvcn.oraclevcn.com:/results',
directory_name => 'FSS_DIR',
description => 'Source NFS for sales data',
params => JSON_OBJECT('nfs_version' value 4)
);
END;
/Usage Notes
-
To run this procedure you must be logged in as the ADMIN user or have the
EXECUTEprivilege onDBMS_CLOUD_ADMIN. -
You must have
WRITEprivilege on the directory object in the database to attach a file system usingDBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM. -
The
DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEMprocedure can only attach a private File Storage Service in databases with Private Endpoints enabled.See OCI File Storage Service and Configure a Development System to Access the Database for more information.
-
The
DBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEMprocedure looks up the Network File System hostname on the customer's virtual cloud network (VCN). The error"ORA-20000: Mounting NFS fails"is returned if the hostname specified in the location cannot be located. -
Oracle Cloud Infrastructure File Storage uses NFSv3 to share
-
If you attach to non-Oracle Cloud Infrastructure File Storage systems, the procedure supports NFSv3 and NFSv4
-
If you have an attached NFS server that uses NFSv3 and the NFS version is updated to NFSv4 in the NFS server, you must run
DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEMand thenDBMS_CLOUD_ADMIN.ATTACH_FILE_SYSTEM(using theparamsparameter withnfs_versionset to 4). This attaches NFS with the matching protocol so that Autonomous AI Database can access the NFSv4 Server. Without detaching and then reattaching, the NFS server will be inaccessible and you may see an error such as:"Protocol not supported".
CREATE_DATABASE_LINK Procedure
The overloaded forms support the following:
-
When you use the
gateway_paramsparameter, this enables you to create a database link with Oracle-managed heterogeneous connectivity where the link is to a supported non-Oracle database. -
When you use the
rac_hostnamesparameter, this enables you to create a database link from an Autonomous AI Database on a private endpoint to a target Oracle RAC database. In this case, you use therac_hostnamesparameter to specify the host names of one or more individual nodes of the target Oracle RAC database.
Syntax
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
db_link_name IN VARCHAR2,
hostname IN VARCHAR2,
port IN NUMBER,
service_name IN VARCHAR2,
ssl_server_cert_dn IN VARCHAR2 DEFAULT,
credential_name IN VARCHAR2 DEFAULT,
directory_name IN VARCHAR2 DEFAULT,
gateway_link IN BOOLEAN DEFAULT,
public_link IN BOOLEAN DEFAULT,
private_target IN BOOLEAN DEFAULT
gateway_params IN CLOB DEFAULT);
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
db_link_name IN VARCHAR2,
rac_hostnames IN CLOB,
port IN NUMBER,
service_name IN VARCHAR2,
ssl_server_cert_dn IN VARCHAR2 DEFAULT,
credential_name IN VARCHAR2 DEFAULT,
directory_name IN VARCHAR2 DEFAULT,
gateway_link IN BOOLEAN DEFAULT,
public_link IN BOOLEAN DEFAULT,
private_target IN BOOLEAN DEFAULT);
Parameters
| Parameter | Description |
|---|---|
|
|
The name of the database link to create. |
|
|
The hostname for the target database. Specifying When you specify a connection with Oracle-managed heterogeneous connectivity by supplying the
Use this parameter or The |
|
|
Specifies hostnames for the target Oracle RAC database. The value is a JSON
array that specifies one or more individual host names for the
nodes of the target Oracle RAC database. Multiple host names can
be passed in JSON, separated by a "
When the target is an Oracle RAC database, use the When you specify a list of host names in the Use this parameter or Specifying |
port |
Specifies the port for the connections to the target database. When you specify a connection with Oracle-managed heterogeneous connectivity using the
|
|
|
The
When you specify a connection with Oracle-managed heterogeneous connectivity using the |
ssl_server_cert_dn |
The DN value found in the server certificate. Oracle-managed heterogeneous connectivity is preconfigured with a wallet that
contains most of the common trusted root and intermediate SSL
certificates. The Public Endpoint Link to an Autonomous AI Database Target without a Wallet: To connect to an Autonomous AI Database target on a public endpoint without a wallet (TLS):
Private Endpoint Link without a Wallet: To connect to an Oracle Database on a private endpoint without a wallet:
|
credential_name |
The name of a stored credential created with |
directory_name |
The directory for the Oracle-managed heterogeneous connectivity is preconfigured with a wallet that
contains most of the common trusted root and intermediate SSL
certificates. The Public Endpoint Link to an Autonomous AI Database Target without a Wallet: To connect to an Autonomous AI Database on a public endpoint without a wallet (TLS):
In addition, to connect to an Autonomous AI Database with TCP, the
Private Endpoint Link without a Wallet: To connect to a target Oracle Database on a private endpoint without a wallet:
|
gateway_link |
Indicates if the database link is created to another Oracle Database or to an Oracle Database Gateway. If If When The default value for this parameter is
|
public_link |
Indicates if the database link is created as a public database link. To run The default value for this parameter is
|
private_target |
When a database link accesses a hostname that needs
to be resolved in a VCN DNS server, specify the
When The default value for this parameter is
|
|
|
Specify the parameter with the
For example:
When When |
Usage Notes
-
When you specify the
gateway_paramsparameter, for somedb_typevalues, additionalgateway_paramsparameters are supported:db_typeAdditional gateway_paramsValuesgoogle_analyticsWhen the
db_typeisgoogle_analytics, the credential you specify must be a Google OAuth credential (gcp_oauth2)See CREATE_CREDENTIAL Procedure for more information.google_bigqueryWhen the
db_typeisgoogle_bigquery, the credential you specify must be a Google OAuth credential (gcp_oauth2)See CREATE_CREDENTIAL Procedure for more information.When
db_typeisgoogle_bigquery, the parameterprojectis valid. This parameter specifies the project name forgoogle_bigqueryand is required.The table name you specify when you use
SELECTwith Google BigQuery must be in quotes. For example:SELECT * FROM "sales"@GOOGLE_BIGQUERY_LINKhiveWhen
db_typeishive, the parameterhttp_pathis valid. This parameter specifies the HttpPath value, if required, to connect to the Hive instance.salesforceWhen the
db_typeissalesforce, the parameter:security_tokenis valid. A security token is a case-sensitive alphanumeric code. Supplying asecurity_tokenvalue is required to access Salesforce. For example:gateway_params => JSON_OBJECT( 'db_type' value 'salesforce', 'security_token' value 'security_token_value' )See Reset Your Security Token for more information.
servicenowTo connect to ServiceNow and get data you must supply the gateway parameters
directory_nameandfile_name. These parameters specify a model file (REST config file) that maps the JSON response to the relational model. The model file specifies the endpoints, table mapping, and HTTP response code for processing the JSON response. See Model file syntax and Example Model file for more information.When you use
gateway_paramsparameter withdb_typeservicenow, there are two supported options:-
Basic Authentication: you must supply the
gateway_paramsparameterdb_typewith the value'servicenow', and supply thedirectory_nameandfile_nameparameters along with username/password type credentials. -
OAuth 2.0 Authentication: you must supply the
gateway_paramsparameterdb_typewith the value'servicenow', and thedirectory_name,file_name, andtoken_uriparameters, along with OAuth type credentials.
The
directory_nameparameter specifies the directory with the ServiceNow REST config file. You could create this directory as follows:create or replace directory servicenow_dir as 'SERVICENOW_DIR';Obtain and download the ServiceNow REST config file to the specified directory. For example:
exec DBMS_CLOUD.get_object('servicenow_dir_cred', 'https://objectstorage.<...>/servicenow.rest','SERVICENOW_DIR');Set the
file_namevalue to the name of the REST config file you downloaded, "servicenow.rest".Then you can use the ServiceNow REST config file with either basic authentication or OAuth2.0.
snowflakeWhen the
db_typeisSNOWFLAKE, the optional parameters:role,schema, andwarehouseare valid. These values specify a different schema, role, or warehouse value, other than the default. For example:gateway_params => JSON_OBJECT( 'db_type' value 'snowflake', 'role' value 'ADMIN', 'schema' value 'PUBLIC', 'warehouse' value 'TEST' ) -
-
When you use the
private_targetparameter, note that database links from an Autonomous AI Database to a database service that is on a private endpoint are only supported in commercial regions and US Government regions.This feature is enabled by default in all commercial regions.
This feature is enabled by default in US Government regions for newly provisioned databases.
For existing US Government databases on a private endpoint, if you want to create database links from an Autonomous AI Database to a target in a US Government region, please file a Service Request at Oracle Cloud Support and request to enable the private endpoint in government regions database linking feature.
US Government regions include the following:
- When connecting to a non-Oracle database, database linking is only supported if the target database is accessible through a public IP or a public hostname.
-
To run
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINKwith a user other than ADMIN, you need to grantEXECUTEandCREATE DATABASE LINKprivileges to that user. For example, run the following command as ADMIN to grant privileges toatpc_user:GRANT EXECUTE ON DBMS_CLOUD_ADMIN TO atpc_user; GRANT CREATE DATABASE LINK TO atpc_user;In addition, when you create a Database Link in a schema other than the ADMIN schema, for example in a schema named
atpc_user, theatpc_userschema must own the credential you use withDBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK. -
Only one wallet file is valid per directory specified with the
directory_nameparameter. You can only upload onecwallet.ssoat a time to the directory you choose for wallet files. This means with acwallet.ssoin a directory, you can only create database links to the databases for which the wallet in that directory is valid. To use multiplecwallet.ssofiles with database links you need to create additional directories and put eachcwallet.ssoin a different directory.See Create Directory in Autonomous AI Database for information on creating directories.
-
To create a database link to an Autonomous AI Database, set
GLOBAL_NAMEStoFALSEon the source database (non-Autonomous AI Database).SQL> ALTER SYSTEM SET GLOBAL_NAMES = FALSE; System altered. SQL> SHOW PARAMETER GLOBAL_NAMES NAME TYPE VALUE ---------------------- ----------- ----------- global_names boolean FALSE -
When the
private_targetparameter isTRUE, thehostnameparameter specifies a private host inside the VCN.
Examples
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'DB_LINK_CRED',
username => 'adb_user',
password => 'password');
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
db_link_name => 'SALESLINK',
hostname => 'adb.eu-frankfurt-1.oraclecloud.com',
port => '1522',
service_name => 'example_medium.atpc.example.oraclecloud.com',
ssl_server_cert_dn => 'CN=atpc.example.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US',
credential_name => 'DB_LINK_CRED');
END;
/
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'AWS_REDSHIFT_LINK_CRED',
username => 'NICK',
password => 'password'
);
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
db_link_name => 'AWSREDSHIFT_LINK',
hostname => 'example.com',
port => '5439',
service_name => 'example_service_name',
ssl_server_cert_dn => NULL,
credential_name => 'AWS_REDSHIFT_LINK_CRED',
gateway_params => JSON_OBJECT('db_type' value 'awsredshift'));
END;
/
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'PRIVATE_ENDPOINT_CRED',
username => 'db_user',
password => 'password'
);
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
db_link_name => 'PRIVATE_ENDPOINT_DB_LINK',
hostname => 'exampleHostname',
port => '1521',
service_name => 'exampleServiceName',
credential_name => 'PRIVATE_ENDPOINT_CRED',
ssl_server_cert_dn => NULL,
directory_name => NULL,
private_target => TRUE);
END;
/
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'GOOGLE_BIGQUERY_CRED',
params => JSON_OBJECT( 'gcp_oauth2' value JSON_OBJECT(
'client_id' value 'client_id',
'client_secret' value 'client_secret',
'refresh_token' value 'refresh_token' )));
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
db_link_name => 'GOOGLE_BIGQUERY_LINK',
hostname => 'example.com',
port => '443',
service_name => 'example_service_name',
credential_name => 'GOOGLE_BIGQUERY_CRED',
gateway_params => JSON_OBJECT(
'db_type' value 'google_bigquery',
'project' value 'project_name1' ));
END;
/
The table name you specify when you use SELECT with
Google BigQuery or Google Analytics must be in quotes. For example:
SELECT * FROM "sales"@GOOGLE_BIGQUERY_LINK
Use the rac_hostnames parameter with a target Oracle RAC database on
a private endpoint.
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'DB_LINK_CRED1',
username => 'adb_user',
password => 'password');
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
db_link_name => 'SALESLINK',
rac_hostnames => '["sales1-svr1.example.adb.us-ashburn-1.oraclecloud.com",
"sales1-svr2.example.adb.us-ashburn-1.oraclecloud.com",
"sales1-svr3.example.adb.us-ashburn-1.oraclecloud.com"]',
port => '1522',
service_name => 'example_high.adb.oraclecloud.com',
ssl_server_cert_dn => 'CN=adb.example.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US',
credential_name => 'DB_LINK_CRED1',
directory_name => 'EXAMPLE_WALLET_DIR',
private_target => TRUE);
END;
/
DETACH_FILE_SYSTEM Procedure
This procedure detaches a file system from the database.
The DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM
procedure detaches a file system from your database. In addition to that, the DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM procedure
also removes the information about the file system from the
DBA_CLOUD_FILE_SYSTEMS view.
Syntax
DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM(
file_system_name IN VARCHAR2
);Parameters
| Parameter | Description |
|---|---|
|
|
Specifies the name of the file system. This parameter is mandatory. |
Example:
BEGIN
DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEM (
file_system_name => 'FSS'
);
END;
/ Usage Notes
-
To run this procedure, you must be logged in as the ADMIN user or have the
EXECUTEprivilege onDBMS_CLOUD_ADMIN. -
You must have the
WRITEprivilege on the directory object in the database, to detach a file system from a directory using theDBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEMprocedure. -
The
DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEMprocedure can only detach a private File Storage Service in databases with Private Endpoints enabled.See OCI File Storage Service and Configure a Development System to Access the Database for more information.
-
The
DBMS_CLOUD_ADMIN.DETACH_FILE_SYSTEMprocedure looks up the Network File System hostname on the customer's virtual cloud network (VCN). The error"ORA-20000: Mounting NFS fails"is returned if the hostname specified in the location cannot be located.
DISABLE_EXTERNAL_AUTHENTICATION Procedure
Disables user authentication with external authentication schemes for the database.
Syntax
DBMS_CLOUD_ADMIN.DISABLE_EXTERNAL_AUTHENTICATION;
Exceptions
| Exception | Error | Description |
|---|---|---|
invalid_ext_auth |
ORA-20004 |
See the accompanying message for a detailed explanation. |
Example
BEGIN
DBMS_CLOUD_ADMIN.DISABLE_EXTERNAL_AUTHENTICATION;
END;
/
PL/SQL procedure successfully completed.
DROP_DATABASE_LINK Procedure
This procedure drops a database link.
Syntax
DBMS_CLOUD_ADMIN.DROP_DATABASE_LINK(
db_link_name IN VARCHAR2,
public_link IN BOOLEAN DEFAULT);
Parameters
| Parameter | Description |
|---|---|
|
|
The name of the database link to drop. |
|
|
To run The default value for this parameter is
|
Example
BEGIN
DBMS_CLOUD_ADMIN.DROP_DATABASE_LINK(
db_link_name => 'SALESLINK' );
END;
/Usage Notes
After you are done using a database link and you run DBMS_CLOUD_ADMIN.DROP_DATABASE_LINK, to ensure security
of your Oracle database remove any stored wallet files. For example:
-
Remove the wallet file in Object Store.
-
Use
DBMS_CLOUD.DELETE_FILEto remove the wallet file from thedata_pump_dirdirectory or from the user defined directory where the wallet file was uploaded.
ENABLE_EXTERNAL_AUTHENTICATION Procedure
Enable users to login to the database with external authentication schemes.
Syntax
DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type IN VARCHAR2,
force IN BOOLEAN DEFAULT FALSE,
params IN CLOB DEFAULT NULL
);
Parameter
| Parameter | Description |
|---|---|
|
|
Specifies the external authentication type. Valid values: or .
|
|
|
(Optional) Override a currently enabled external
authentication scheme. Valid values are The default value is |
params |
A JSON string that provides additional parameters for the external authentication.
|
Exceptions
| Exception | Error | Description |
|---|---|---|
invalid_ext_auth |
ORA-20004 |
See the accompanying message for a detailed explanation. |
Usage Notes
-
With
typeOCI_IAM, if the resource principal is not enabled on the Autonomous AI Database instance, this routine enables resource principal withDBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL. -
This procedure sets the system parameters
IDENTITY_PROVIDER_TYPEandIDENTITY_PROVIDER_CONFIGto required users to access the instance with Oracle Cloud Infrastructure Identity and Access Management authentication and authorization.
Examples
Enable OCI_IAM
Authentication
BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'OCI_IAM',
force=> TRUE );
END;
/
PL/SQL procedure successfully completed.
Enable CMU Authentication for Microsoft Active Directory
You pass in a directory name that contains the CMU configuration files
through params JSON argument.
BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'CMU',
force => TRUE,
params => JSON_OBJECT('directory_name' value 'CMU_DIR'); // CMU_DIR directory object already exists
END;
/
PL/SQL procedure successfully completed.
You pass in a location URI pointing to an Object Storage location that
contains CMU configuration files through params JSON argument.
BEGIN
DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'CMU',
params => JSON_OBJECT('location_uri' value 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/namespace-string/b/bucketname/o',
'credential_name' value 'my_credential_name')
);
END;
/
PL/SQL procedure successfully completed.
Enable Azure AD Authentication
BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'AZURE_AD',
force => TRUE,
params => JSON_OBJECT( 'tenant_id' VALUE '....',
'application_id' VALUE '...',
'application_id_uri' VALUE '.....' ));
END;
/
PL/SQL procedure successfully completed.
Enable Kerberos Authentication
You pass in a directory name that contains Kerberos configuration files
through params JSON argument.
BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'KERBEROS',
force => TRUE,
params => JSON_OBJECT('directory_name' value 'KERBEROS_DIR'); // KERBEROS_DIR directory object already exists
END;
/
PL/SQL procedure successfully completed.
You pass in a location URI pointing to an Object Storage location that
contains Kerberos configuration files through params JSON
argument:
BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'KERBEROS',
force => TRUE,
params => JSON_OBJECT('location_uri' value 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/namespace-string/b/bucketname/o',
'credential_name' value 'my_credential_name');
END;
/
You pass in a service name with the
kerberos_service_name in the params JSON
argument:
BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION(
type => 'KERBEROS',
force => TRUE,
params => JSON_OBJECT('directory_name' value 'KERBEROS_DIR', // KERBEROS_DIR directory object already exists
'kerberos_service_name' value 'oracle' ));
END;
/
After Kerberos is enabled on your Autonomous AI Database instance, use the following query to view the Kerberos service name:
SELECT SYS_CONTEXT('USERENV','KERBEROS_SERVICE_NAME') FROM DUAL;
DBMS_CLOUD_ADMIN Exceptions
The
following table describes exceptions for DBMS_CLOUD_ADMIN.
| Exception | Code | Description |
|---|---|---|
invalid_service |
20001 | An invalid service was specified. |
service_not_exist |
20002 | A service specified does not exist. |
default_service |
20003 | A service specified cannot be modified. |
invalid_char_set |
20029 | Missing precondition or invalid (national) character set. |
invalid_enc_key_attr |
20030 | Missing or invalid argument for key management. |
Already Using Oracle Managed
Key |
000000 |
The Database is already using an Oracle managed key. You are trying to call the procedure while already using an Oracle managed key. |
Argument Provided for the
procedure |
ORA-0000 |
An argument is provided for the procedure. Expected error message:No arguments required for this procedure. |