Oracle Autonomous Database: Self-Driving Cloud Database Guide
Oracle Autonomous Database is a fully managed, self-driving database service that uses machine learning to automate database tuning, security, backups, updates, and other routine management tasks. This comprehensive guide covers both Autonomous Transaction Processing (ATP) and Autonomous Data Warehouse (ADW).
What is Oracle Autonomous Database?
Oracle Autonomous Database is the world’s first self-driving database that automates key management tasks previously performed by DBAs:
Key Features
- Self-Driving: Automatic tuning, patching, and upgrades
- Self-Securing: Automatic encryption, patching of security vulnerabilities
- Self-Repairing: Automatic failover with < 2.5 minutes downtime per month
- High Performance: In-memory processing, intelligent query optimization
- Elasticity: Scale compute and storage independently in seconds
- Cost-Effective: Pay only for resources you consume
ATP vs. ADW
| Feature | ATP (Transaction Processing) | ADW (Data Warehouse) |
|---|---|---|
| Primary Use Case | OLTP workloads | Analytics and DW |
| Query Patterns | Short, frequent transactions | Complex analytical queries |
| Concurrency | High concurrent users | Lower concurrency, higher throughput |
| Indexing | B-tree indexes | Columnar storage, bitmap indexes |
| Typical Workload | ERP, CRM, e-commerce | BI, reporting, data lakes |
Creating an Autonomous Database
Using OCI Console
- Navigate to Autonomous Database in OCI Console
- Click Create Autonomous Database
- Choose workload type (ATP or ADW)
- Configure database settings
- Set admin password
- Choose network access (Public or Private)
Using OCI CLI
# Create Autonomous Transaction Processing Databaseoci db autonomous-database create \ --compartment-id $COMPARTMENT_ID \ --db-name ATPDB \ --display-name "Production ATP Database" \ --admin-password "SecurePassword123!" \ --cpu-core-count 2 \ --data-storage-size-in-tbs 1 \ --db-version "19c" \ --db-workload OLTP \ --is-auto-scaling-enabled true \ --is-free-tier false \ --license-model LICENSE_INCLUDED \ --is-mtls-connection-required true
# Create Autonomous Data Warehouseoci db autonomous-database create \ --compartment-id $COMPARTMENT_ID \ --db-name ADWDB \ --display-name "Production ADW Database" \ --admin-password "SecurePassword123!" \ --cpu-core-count 4 \ --data-storage-size-in-tbs 2 \ --db-version "19c" \ --db-workload DW \ --is-auto-scaling-enabled true \ --is-free-tier false \ --license-model LICENSE_INCLUDEDUsing Terraform
resource "oci_database_autonomous_database" "atp_production" { compartment_id = var.compartment_id db_name = "ATPDB" display_name = "Production ATP Database" admin_password = var.db_admin_password cpu_core_count = 2 data_storage_size_in_tbs = 1 db_version = "19c" db_workload = "OLTP"
# Auto-scaling is_auto_scaling_enabled = true is_auto_scaling_for_storage_enabled = true
# Networking subnet_id = oci_core_subnet.private_subnet.id nsg_ids = [oci_core_network_security_group.adb_nsg.id] private_endpoint_label = "atpdb" is_mtls_connection_required = true
# High Availability is_data_guard_enabled = true
# Backup is_local_data_guard_enabled = false backup_retention_period_in_days = 60
# License license_model = "LICENSE_INCLUDED"
# Tags freeform_tags = { "Environment" = "Production" "Application" = "Core-Banking" "ManagedBy" = "Terraform" }
# Whitelisting whitelisted_ips = ["10.0.0.0/16"]}
# Autonomous Data Warehouseresource "oci_database_autonomous_database" "adw_production" { compartment_id = var.compartment_id db_name = "ADWDB" display_name = "Production ADW Database" admin_password = var.db_admin_password cpu_core_count = 4 data_storage_size_in_tbs = 2 db_version = "19c" db_workload = "DW"
is_auto_scaling_enabled = true
subnet_id = oci_core_subnet.private_subnet.id nsg_ids = [oci_core_network_security_group.adb_nsg.id] private_endpoint_label = "adwdb" is_mtls_connection_required = false # Simplified for BI tools
license_model = "LICENSE_INCLUDED"
freeform_tags = { "Environment" = "Production" "Application" = "Analytics" }}
# Backupresource "oci_database_autonomous_database_backup" "atp_manual_backup" { autonomous_database_id = oci_database_autonomous_database.atp_production.id display_name = "manual-backup-${formatdate("YYYY-MM-DD", timestamp())}"}Connecting to Autonomous Database
Download Wallet
# Download database walletoci db autonomous-database generate-wallet \ --autonomous-database-id $ADB_OCID \ --password "WalletPassword123!" \ --file wallet.zip
# Extract walletunzip wallet.zip -d /path/to/walletConnection Strings
The wallet contains multiple service names:
- HIGH: Highest resources, lowest concurrency
- MEDIUM: Balanced resources and concurrency
- LOW: Lowest resources, highest concurrency (background jobs)
- TP/TPURGENT: Transaction processing optimized
- PARALLEL: For parallel queries
Python Connection
import cx_Oracleimport os
# Set wallet locationos.environ['TNS_ADMIN'] = '/path/to/wallet'
# Connection parametersusername = 'ADMIN'password = 'YourPassword123!'dsn = 'atpdb_high' # From tnsnames.ora
try: # Connect connection = cx_Oracle.connect( user=username, password=password, dsn=dsn )
print("Successfully connected to Oracle Autonomous Database")
# Create cursor cursor = connection.cursor()
# Execute query cursor.execute(""" SELECT table_name FROM user_tables ORDER BY table_name """)
print("\nTables in database:") for row in cursor: print(row[0])
cursor.close() connection.close()
except cx_Oracle.Error as error: print(f"Error connecting to database: {error}")Java Connection (JDBC)
import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;import java.util.Properties;
public class DatabaseConnection { public static void main(String[] args) { String url = "jdbc:oracle:thin:@atpdb_high?TNS_ADMIN=/path/to/wallet"; String username = "ADMIN"; String password = "YourPassword123!";
Properties props = new Properties(); props.setProperty("user", username); props.setProperty("password", password);
try { // Register driver Class.forName("oracle.jdbc.driver.OracleDriver");
// Connect Connection conn = DriverManager.getConnection(url, props); System.out.println("Connected to Autonomous Database");
// Execute query Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM user_tables");
System.out.println("\nTables:"); while (rs.next()) { System.out.println(rs.getString(1)); }
rs.close(); stmt.close(); conn.close();
} catch (Exception e) { e.printStackTrace(); } }}Node.js Connection
const oracledb = require('oracledb');
async function connect() { try { // Initialize Oracle Client oracledb.initOracleClient({ configDir: '/path/to/wallet' });
// Connection configuration const connection = await oracledb.getConnection({ user: 'ADMIN', password: 'YourPassword123!', connectString: 'atpdb_high' });
console.log('Successfully connected to Autonomous Database');
// Execute query const result = await connection.execute( `SELECT table_name FROM user_tables ORDER BY table_name` );
console.log('\nTables:'); result.rows.forEach(row => { console.log(row[0]); });
await connection.close();
} catch (err) { console.error('Error:', err); }}
connect();Advanced Features
1. JSON Support
-- Create table with JSON columnCREATE TABLE products ( id NUMBER GENERATED ALWAYS AS IDENTITY, product_data JSON, CONSTRAINT products_pk PRIMARY KEY (id));
-- Insert JSON dataINSERT INTO products (product_data) VALUES ( JSON_OBJECT( 'name' VALUE 'Laptop', 'price' VALUE 1299.99, 'specs' VALUE JSON_OBJECT( 'cpu' VALUE 'Intel i7', 'ram' VALUE '16GB', 'storage' VALUE '512GB SSD' ), 'tags' VALUE JSON_ARRAY('electronics', 'computers', 'laptops') ));
-- Query JSON dataSELECT id, JSON_VALUE(product_data, '$.name') as product_name, JSON_VALUE(product_data, '$.price' RETURNING NUMBER) as price, JSON_VALUE(product_data, '$.specs.cpu') as cpuFROM products;
-- JSON searchSELECT * FROM productsWHERE JSON_EXISTS(product_data, '$.tags[*]?(@ == "laptops")');2. Machine Learning (OML)
-- Create ML model for predictionBEGIN DBMS_DATA_MINING.CREATE_MODEL( model_name => 'CUSTOMER_CHURN_MODEL', mining_function => DBMS_DATA_MINING.CLASSIFICATION, data_table_name => 'CUSTOMER_DATA', case_id_column_name => 'CUSTOMER_ID', target_column_name => 'CHURNED', settings_table_name => 'MODEL_SETTINGS' );END;/
-- Use model for predictionsSELECT customer_id, PREDICTION(CUSTOMER_CHURN_MODEL USING *) as predicted_churn, PREDICTION_PROBABILITY(CUSTOMER_CHURN_MODEL USING *) as confidenceFROM customer_data_new;3. REST API (ORDS)
-- Enable REST on tableBEGIN ORDS.ENABLE_OBJECT( p_enabled => TRUE, p_schema => 'ADMIN', p_object => 'PRODUCTS', p_object_type => 'TABLE', p_object_alias => 'products' );END;/
-- Create custom REST endpointBEGIN ORDS.DEFINE_SERVICE( p_module_name => 'api.v1', p_base_path => '/api/v1/', p_items_per_page => 25, p_status => 'PUBLISHED' );
ORDS.DEFINE_TEMPLATE( p_module_name => 'api.v1', p_pattern => 'products/:id' );
ORDS.DEFINE_HANDLER( p_module_name => 'api.v1', p_pattern => 'products/:id', p_method => 'GET', p_source_type => ORDS.source_type_collection_feed, p_source => 'SELECT * FROM products WHERE id = :id' );END;/Access via HTTPS:
curl -X GET https://your-adb-url/ords/admin/api/v1/products/14. Automatic Indexing
-- Enable automatic indexing (enabled by default)EXEC DBMS_AUTO_INDEX.CONFIGURE('AUTO_INDEX_MODE', 'IMPLEMENT');
-- Monitor automatic indexesSELECT index_name, auto_index_type, auto_index_status, last_usedFROM dba_auto_index_statisticsWHERE owner = 'ADMIN';
-- View automatic indexing recommendationsSELECT sql_text, improvement_percent, recommendationFROM dba_auto_index_sql_recommendationsWHERE owner = 'ADMIN';Performance Optimization
1. Parallelism
-- Enable parallel executionALTER SESSION ENABLE PARALLEL DML;
-- Parallel query hintSELECT /*+ PARALLEL(t, 8) */ region, SUM(sales_amount) as total_salesFROM sales_fact tGROUP BY region;
-- Check parallel executionSELECT sql_id, px_servers_requested, px_servers_allocatedFROM v$sqlWHERE sql_text LIKE 'SELECT%sales_fact%';2. In-Memory Column Store
-- Enable in-memory for table (ADW only)ALTER TABLE sales_fact INMEMORY;
-- Set inmemory priorityALTER TABLE sales_fact INMEMORY PRIORITY HIGH;
-- Check in-memory statusSELECT segment_name, inmemory_size, bytes_not_populated, populate_statusFROM v$im_segmentsWHERE segment_name = 'SALES_FACT';3. Result Cache
-- Enable result cache for querySELECT /*+ RESULT_CACHE */ product_category, COUNT(*) as product_count, AVG(price) as avg_priceFROM productsGROUP BY product_category;
-- Monitor result cacheSELECT cache_id, name, status, block_count, scan_countFROM v$result_cache_objectsWHERE type = 'Result';Data Loading
Using Data Pump
-- Create directoryCREATE DIRECTORY data_pump_dir AS 'DATA_PUMP_DIR';
-- ExportBEGIN DBMS_DATAPUMP.CREATE_JOB( job_name => 'EXPORT_JOB', operation => 'EXPORT', job_mode => 'SCHEMA' );END;/
-- Import from Object StorageBEGIN DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'OBJ_STORE_CRED', username => 'tenancy@namespace', password => 'auth_token' );END;/
BEGIN DBMS_CLOUD.PUT_OBJECT( credential_name => 'OBJ_STORE_CRED', object_uri => 'https://objectstorage.region.oraclecloud.com/n/namespace/b/bucket/o/export.dmp', directory_name => 'DATA_PUMP_DIR', file_name => 'export.dmp' );END;/Loading CSV from Object Storage
-- Create credentialBEGIN DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'OBJ_STORE_CRED', username => 'tenancy@namespace', password => 'auth_token' );END;/
-- Create external tableBEGIN DBMS_CLOUD.CREATE_EXTERNAL_TABLE( table_name => 'SALES_DATA_EXT', credential_name => 'OBJ_STORE_CRED', file_uri_list => 'https://objectstorage.region.oraclecloud.com/n/namespace/b/bucket/o/sales*.csv', format => JSON_OBJECT( 'type' VALUE 'csv', 'skipheaders' VALUE '1', 'delimiter' VALUE ',', 'ignoremissingcolumns' VALUE 'true' ), column_list => 'order_id NUMBER, order_date DATE, customer_id NUMBER, amount NUMBER' );END;/
-- Load data from external tableCREATE TABLE sales_data ASSELECT * FROM sales_data_ext;Monitoring and Management
Performance Hub
-- Top SQL by execution timeSELECT sql_id, sql_text, elapsed_time/1000000 as elapsed_seconds, executions, cpu_time/1000000 as cpu_secondsFROM v$sqlORDER BY elapsed_time DESCFETCH FIRST 10 ROWS ONLY;
-- Session statisticsSELECT username, status, machine, program, sql_id, event, wait_timeFROM v$sessionWHERE username IS NOT NULL;Resource Usage
-- Check OCPU usageSELECT metric_name, value, begin_time, end_timeFROM v$metricWHERE metric_name IN ('CPU Usage Per Sec', 'CPU Usage Per Txn')ORDER BY begin_time DESC;
-- Storage usageSELECT SUM(bytes)/1024/1024/1024 as total_gb, tablespace_nameFROM user_segmentsGROUP BY tablespace_name;Backup and Recovery
Automatic Backups
Automatic backups are enabled by default with 60-day retention.
Manual Backup
# Create manual backupoci db autonomous-database-backup create \ --autonomous-database-id $ADB_OCID \ --display-name "Pre-Upgrade-Backup-$(date +%Y%m%d)"
# List backupsoci db autonomous-database-backup list \ --autonomous-database-id $ADB_OCIDPoint-in-Time Recovery
# Restore to specific timestampoci db autonomous-database restore \ --autonomous-database-id $ADB_OCID \ --timestamp "2026-02-10T10:00:00Z"Security Best Practices
1. Network Access Control
-- Update access control listBEGIN DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACL( host => '10.0.1.0/24', lower_port => 443, upper_port => 443, ace => xs$ace_type( privilege_list => xs$name_list('http'), principal_name => 'ADMIN', principal_type => xs_acl.ptype_db ) );END;/2. Data Encryption
All data is encrypted by default with TDE (Transparent Data Encryption).
3. Database Vault
-- Enable Database VaultEXEC DBMS_MACADM.ENABLE_DV;
-- Create realmBEGIN DVSYS.DBMS_MACADM.CREATE_REALM( realm_name => 'HR_DATA_REALM', description => 'Protect HR tables', enabled => DBMS_MACUTL.G_YES, audit_options => DBMS_MACUTL.G_REALM_AUDIT_FAIL );END;/Cost Optimization
Auto-Scaling
Auto-scaling automatically scales OCPUs based on workload:
- Scales up to 3x base OCPU count
- Scales down during idle periods
- Pay only for actual usage
Stop/Start Database
# Stop database (billing stops)oci db autonomous-database stop \ --autonomous-database-id $ADB_OCID
# Start databaseoci db autonomous-database start \ --autonomous-database-id $ADB_OCIDStorage Auto-Scaling
Enable storage auto-scaling to prevent outages:
oci db autonomous-database update \ --autonomous-database-id $ADB_OCID \ --is-auto-scaling-for-storage-enabled trueProduction Checklist
- Private endpoint configured
- Network Security Groups applied
- Auto-scaling enabled
- Data Guard enabled (HA)
- Backup retention configured
- Access control lists defined
- Monitoring and alerts configured
- Database Vault enabled (if required)
- Performance baselines captured
- Disaster recovery plan documented
Conclusion
Oracle Autonomous Database represents a significant leap in database technology, offering true autonomous operation with machine learning-driven automation. Whether you choose ATP for transaction processing or ADW for analytics, the self-driving, self-securing, and self-repairing capabilities dramatically reduce operational overhead while delivering exceptional performance and availability.
The combination of Oracle’s database expertise and cloud automation makes Autonomous Database ideal for organizations seeking to modernize their data infrastructure while reducing costs and complexity.
Master Oracle technologies including Autonomous Database with our database training programs. Contact us for customized training designed for your team’s needs.