Oracle 19c DBA Features Guide - New Features for Database Administrators
Oracle 19c DBA Features Guide
Section titled “Oracle 19c DBA Features Guide”Key Oracle 19c features every DBA should know, with practical examples.
Automatic Indexing
Section titled “Automatic Indexing”Oracle 19c introduces fully automatic index management.
Enable Automatic Indexing
Section titled “Enable Automatic Indexing”-- Enable automatic indexingEXEC DBMS_AUTO_INDEX.CONFIGURE('AUTO_INDEX_MODE', 'IMPLEMENT');
-- Options:-- 'OFF' - Disabled-- 'REPORT ONLY' - Creates invisible indexes, generates reports-- 'IMPLEMENT' - Creates and drops indexes automatically
-- Configure schemasEXEC DBMS_AUTO_INDEX.CONFIGURE('AUTO_INDEX_SCHEMA', 'HR', TRUE);
-- Set retention period (days)EXEC DBMS_AUTO_INDEX.CONFIGURE('AUTO_INDEX_RETENTION_FOR_AUTO', 373);EXEC DBMS_AUTO_INDEX.CONFIGURE('AUTO_INDEX_RETENTION_FOR_MANUAL', NULL);Monitor Automatic Indexes
Section titled “Monitor Automatic Indexes”-- View auto index configurationSELECT * FROM DBA_AUTO_INDEX_CONFIG;
-- View automatic indexesSELECT INDEX_NAME, TABLE_NAME, AUTO, CONSTRAINT_INDEX, VISIBILITYFROM DBA_INDEXESWHERE AUTO = 'YES';
-- Auto index activity reportSELECT DBMS_AUTO_INDEX.REPORT_ACTIVITY() FROM DUAL;
-- Last auto index reportSELECT DBMS_AUTO_INDEX.REPORT_LAST_ACTIVITY() FROM DUAL;SQL Quarantine
Section titled “SQL Quarantine”Prevent resource-intensive SQL from running.
Create SQL Quarantine
Section titled “Create SQL Quarantine”-- Quarantine by SQL_IDBEGIN DBMS_SQLQ.CREATE_QUARANTINE_BY_SQL_ID( SQL_ID => 'abc123xyz' );END;/
-- Quarantine by SQL textBEGIN DBMS_SQLQ.CREATE_QUARANTINE_BY_SQL_TEXT( SQL_TEXT => 'SELECT * FROM large_table WHERE col = :1' );END;/
-- Set resource limitsDECLARE l_quarantine VARCHAR2(30);BEGIN l_quarantine := DBMS_SQLQ.CREATE_QUARANTINE_BY_SQL_ID(SQL_ID => 'abc123xyz');
DBMS_SQLQ.ALTER_QUARANTINE( QUARANTINE_NAME => l_quarantine, PARAMETER_NAME => 'ELAPSED_TIME', PARAMETER_VALUE => '60' -- 60 seconds );END;/Manage Quarantines
Section titled “Manage Quarantines”-- View quarantined SQLSELECT * FROM DBA_SQL_QUARANTINE;
-- Drop quarantineEXEC DBMS_SQLQ.DROP_QUARANTINE('quarantine_name');
-- Temporarily disableALTER SYSTEM SET OPTIMIZER_CAPTURE_SQL_QUARANTINE = FALSE;Real-Time Statistics
Section titled “Real-Time Statistics”Statistics gathered during DML operations.
Check Real-Time Statistics
Section titled “Check Real-Time Statistics”-- View real-time stats statusSELECT TABLE_NAME, NOTES FROM DBA_TAB_STATISTICSWHERE OWNER = 'HR'ORDER BY TABLE_NAME;
-- Stats gathered during bulk loadSELECT * FROM DBA_TAB_COL_STATISTICSWHERE OWNER = 'HR' AND TABLE_NAME = 'EMPLOYEES'AND NOTES LIKE '%STATS_ON_LOAD%';Configure Real-Time Statistics
Section titled “Configure Real-Time Statistics”-- Enable at table levelEXEC DBMS_STATS.SET_TABLE_PREFS('HR', 'EMPLOYEES', 'APPROXIMATE_NDV_ALGORITHM', 'HYPERLOGLOG');
-- Disable real-time stats if neededALTER SESSION SET OPTIMIZER_REAL_TIME_STATISTICS = FALSE;High-Frequency Statistics Collection
Section titled “High-Frequency Statistics Collection”-- Collect statistics for volatile tables more frequentlyEXEC DBMS_STATS.SET_TABLE_PREFS('HR', 'VOLATILE_TABLE', 'STALE_PERCENT', '5');
-- Auto task for high-frequency collectionBEGIN DBMS_STATS.SET_GLOBAL_PREFS('CONCURRENT', 'AUTOMATIC'); DBMS_STATS.SET_GLOBAL_PREFS('INCREMENTAL', 'TRUE');END;/JSON Improvements
Section titled “JSON Improvements”JSON Data Type (19c+)
Section titled “JSON Data Type (19c+)”-- Create table with JSON data typeCREATE TABLE products ( id NUMBER, data JSON);
-- Insert JSONINSERT INTO products VALUES (1, JSON('{"name": "Widget", "price": 19.99}'));
-- Query with dot notationSELECT p.data.name, p.data.priceFROM products p;
-- JSON path expressionsSELECT JSON_VALUE(data, '$.name') FROM products;Simplified JSON Syntax
Section titled “Simplified JSON Syntax”-- JSON_OBJECT and JSON_ARRAYSELECT JSON_OBJECT( 'employee_id' VALUE employee_id, 'name' VALUE first_name || ' ' || last_name, 'salary' VALUE salary) AS emp_jsonFROM employees;Private Temporary Tables
Section titled “Private Temporary Tables”-- Create private temp table (visible only in session)CREATE PRIVATE TEMPORARY TABLE ORA$PTT_temp_data ( id NUMBER, value VARCHAR2(100)) ON COMMIT DROP DEFINITION;
-- Options:-- ON COMMIT DROP DEFINITION - Drops table and data on commit-- ON COMMIT PRESERVE DEFINITION - Drops data, keeps structure until session end
-- Insert dataINSERT INTO ORA$PTT_temp_data VALUES (1, 'Test');
-- QuerySELECT * FROM ORA$PTT_temp_data;Schema-Only Accounts
Section titled “Schema-Only Accounts”-- Create account that cannot log in but owns objectsCREATE USER app_schema NO AUTHENTICATION;
-- Grant privilegesGRANT CREATE TABLE, CREATE VIEW TO app_schema;
-- Application user connects and uses schemaALTER SESSION SET CURRENT_SCHEMA = app_schema;Hybrid Partitioned Tables
Section titled “Hybrid Partitioned Tables”-- Table with both internal and external partitionsCREATE TABLE sales_hybrid ( sale_id NUMBER, sale_date DATE, amount NUMBER)PARTITION BY RANGE (sale_date) ( PARTITION p_2023 VALUES LESS THAN (DATE '2024-01-01'), PARTITION p_2024 VALUES LESS THAN (DATE '2025-01-01'), PARTITION p_external VALUES LESS THAN (MAXVALUE) EXTERNAL LOCATION ('/data/external_sales/'));Active Data Guard DML Redirect
Section titled “Active Data Guard DML Redirect”-- On Standby: Enable DML redirectALTER SYSTEM SET ADG_REDIRECT_DML = TRUE;
-- DML on standby is automatically redirected to primaryINSERT INTO hr.employees VALUES (...); -- Redirected to primaryIn-Memory Expressions
Section titled “In-Memory Expressions”-- Populate expressions in memoryALTER TABLE employees INMEMORY INMEMORY_EXPRESSIONS ( (salary * 12) AS annual_salary);
-- Check in-memory expressionsSELECT COLUMN_NAME, INMEMORY_COMPRESSIONFROM V$IM_COLUMN_LEVELWHERE TABLE_NAME = 'EMPLOYEES';Easy Connect Plus
Section titled “Easy Connect Plus”-- Enhanced connection string syntaxsqlplus hr/password@//hostname:1521/service_name?connect_timeout=10&retry_count=3
-- With walletsqlplus /@alias?wallet_location=/path/to/wallet
-- With SSLsqlplus hr/password@tcps://hostname:2484/service_nameMemoptimized Rowstore
Section titled “Memoptimized Rowstore”-- Fast lookup for key-value accessALTER TABLE fast_lookup MEMOPTIMIZE FOR READ;
-- Fast ingestALTER TABLE staging MEMOPTIMIZE FOR WRITE;
-- Check statusSELECT TABLE_NAME, MEMOPTIMIZE_READ, MEMOPTIMIZE_WRITEFROM DBA_TABLESWHERE OWNER = 'HR';Query Performance Improvements
Section titled “Query Performance Improvements”SQL Macros (21c backported to 19c RU)
Section titled “SQL Macros (21c backported to 19c RU)”CREATE OR REPLACE FUNCTION mask_ssn RETURN VARCHAR2 SQL_MACRO ISBEGIN RETURN q'[CONCAT('XXX-XX-', SUBSTR(ssn, -4))]';END;/
-- Use in querySELECT employee_id, mask_ssn(ssn) FROM employees;Approximate Count Distinct
Section titled “Approximate Count Distinct”-- Faster count distinctSELECT APPROX_COUNT_DISTINCT(customer_id) FROM orders;
-- With precisionSELECT APPROX_COUNT_DISTINCT(customer_id, 'MAX_ERROR', 0.01) FROM orders;Useful 19c DBA Queries
Section titled “Useful 19c DBA Queries”-- Check 19c specific featuresSELECT * FROM V$OPTION WHERE PARAMETER LIKE '%19%';
-- Database version detailsSELECT * FROM V$VERSION;
-- Patch informationSELECT * FROM DBA_REGISTRY_SQLPATCH;
-- Check component statusSELECT COMP_NAME, VERSION, STATUS FROM DBA_REGISTRY;