Retrieve Autonomous AI Database OCIDs and region information
When using the OCI SDK, you may need to programmatically retrieve Autonomous AI Database metadata from within an OML Notebook, including the tenancy OCID, database OCID, compartment OCID, database name, and region.
You can retrieve this information by querying the
DBA_PDBS
view.
Note:
You must have the ADMIN role to perform this task.Run the following command in an OML Notebook or Database Actions SQL Worksheet:
SELECT JSON_VALUE(cloud_identity, '$.TENANT_OCID') AS tenancy_ocid,
JSON_VALUE(cloud_identity, '$.DATABASE_NAME') AS database_name,
JSON_VALUE(cloud_identity, '$.DATABASE_OCID') AS database_ocid,
JSON_VALUE(cloud_identity, '$.COMPARTMENT_OCID') AS compartment_ocid,
JSON_VALUE(cloud_identity, '$.REGION') AS region FROM dba_pdbs;
This returns values such as the tenancy OCID, database name, database OCID, compartment OCID, and region associated with the Autonomous AI Database.
Note:
Access to theDBA_PDBS view is restricted to privileged
users. While the ADMIN user can retrieve this information, non-ADMIN users
cannot query DBA_PDBS and therefore cannot obtain these values
by using this method.