As more and more customers are moving their databases to Oracle cloud, they have a mix of on-premises, Oracle database cloud services and Oracle Autonomous database in their environments. DBAs and developers usually use sql scripts to automate several task in the database, in some cases, they may want to execute some tasks only on the Autonomous and others only on non-Autonomous database. It is always a good practice to have just one version of scripts to maintain consistency and avoid the maintenance overhead of different versions, customers often ask how to determine from within SQL if we are running on Autonomous database or not? and then based on that execute a specific SQL or PL/SQL code or not
- Oracle Autonomous database on Shared Infrastructure
- Oracle database running on-premises database.
The following SQL will help us to identify Autonomous database.
----------------------------------------------------------------------------------------------------------------------
{
"DATABASE_NAME" : "ORA19C",
"REGION" : "us-phoenix-1",
"TENANT_OCID" : "OCID1.TENANCY.OC1..AAAAAAAAIGT4UTAJPQLCW7OFSUZ6M33BUFL3NREM3KK6MHRYZOZDCYJFVTMA",
"DATABASE_OCID" : "OCID1.AUTONOMOUSDATABASE.OC1.PHX.ANYHQLJSH7AFZ4IAJ5XHAINXEBQD42BFJ73K46PP5HQACM36FE7D4ITXWJHQ",
"COMPARTMENT_OCID" : "ocid1.compartment.oc1..aaaaaaaaeqlrjzpcjmjeku6e2qlqjnotcurkuvcgwtrdcmu3zh3hensrhqra",
"OUTBOUND_IP_ADDRESS" :
[
"129.146.198.199"
],
"PUBLIC_DOMAIN_NAME" : "adb.us-phoenix-1.oraclecloud.com",
"TENANT_ACCOUNT_NAME" : "xxxxxxxxxx",
"AUTOSCALABLE_STORAGE" : false,
"BASE_SIZE" : 1099511627776,
"INFRASTRUCTURE" : "Shared",
"SERVICE" : "ATP",
"APPLICATIONS" :
[
"GRAPH",
"OMLMOD",
"ORDS",
"APEX",
"OML",
"ODI"
],
"AVAILABILITY_DOMAIN" : "iRbP:PHX-AD-1"
}
--------------------
2 from v$pdbs t;
----------
ATP
2 with conditional array wrapper) outbound_ip,
3 json_value(cloud_identity,'$.INFRASTRUCTURE' returning varchar2(10) ) as infra_type,
4 json_value(cloud_identity,'$.AVAILABILITY_DOMAIN' returning varchar2(20) ) as domain_availbale
5 from v$pdbs t;
------------------------------ ---------- --------------------
["129.146.198.199"] Shared iRbP:PHX-AD-1
----------
OLTP
No comments:
Post a Comment