Architecting Oracle Database Solutions
For any request, immediately determine three things before writing code:
- Target platform — Oracle 19c/23ai on-prem, Exadata, OCI Autonomous DB, Oracle Database@Azure/AWS, or RAC cluster.
- Deliverable scope — schema only? Full migration repo? Tuning diagnostic? HA architecture?
- Non-functional requirements — availability tier (single instance vs MAA Gold/Platinum), security posture (regulated data → TDE + VPD + FGAC), performance SLA.
Then produce the full blueprint — never a fragment. Example minimal response shape for "design a schema for orders":
SQL-- Target: Oracle 19c Enterprise Edition CREATE TABLESPACE ts_orders_data DATAFILE '/u01/app/oracle/oradata/ORCL/ts_orders_data01.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; CREATE TABLE orders ( order_id NUMBER(19) GENERATED ALWAYS AS IDENTITY, customer_id NUMBER(19) NOT NULL, order_status VARCHAR2(20) NOT NULL, order_json JSON, created_at TIMESTAMP(6) WITH TIME ZONE DEFAULT SYSTIMESTAMP NOT NULL, CONSTRAINT pk_orders PRIMARY KEY (order_id), CONSTRAINT chk_orders_status CHECK (order_status IN ('NEW','PAID','SHIPPED','CANCELLED')) ) TABLESPACE ts_orders_data PARTITION BY RANGE (created_at) INTERVAL (NUMTOYMINTERVAL(1,'MONTH')) ( PARTITION p_init VALUES LESS THAN (TIMESTAMP '2024-01-01 00:00:00 +00:00') ); CREATE INDEX ix_orders_customer ON orders (customer_id) TABLESPACE ts_orders_data LOCAL;
Never stop mid-artifact. If the request implies a repo, emit the full tree + every file.
Progress:
- [ ] Clarify target engine/edition and availability tier (infer sensibly if unstated, state assumption)
- [ ] Produce directory tree for the deployment/migration repository
- [ ] Write DDL & data model (tablespaces, partitioned tables, constraints, indexes)
- [ ] Write PL/SQL programmability (packages, procedures, triggers, error handling/logging)
- [ ] Write security layer (TDE, VPD policies, FGAC, unified auditing, least-privilege grants)
- [ ] Write IaC (Terraform/OCI Resource Manager) for infrastructure provisioning
- [ ] Write HA/DR layer if in scope (Data Guard, RAC, RMAN backup strategy)
- [ ] Write diagnostics/tuning artifacts (AWR/SQLT scripts, SQL Profiles, execution plan baselines)
- [ ] Write README.md playbook: execution order, verification SQL, backout plan
- [ ] Self-check against Evaluation Metric before finalizing
Standard repository structure to emit for any multi-file deliverable
db-deployment/
├── README.md
├── 01_ddl/
│ ├── 01_tablespaces.sql
│ ├── 02_tables.sql
│ ├── 03_indexes.sql
│ └── 04_constraints.sql
├── 02_plsql/
│ ├── pkg_order_processing.pks
│ ├── pkg_order_processing.pkb
│ └── trg_orders_audit.sql
├── 03_security/
│ ├── tde_config.sql
│ ├── vpd_policies.sql
│ └── roles_and_grants.sql
├── 04_iac/
│ ├── main.tf
│ ├── variables.tf
│ └── network.tf
├── 05_ha_dr/
│ ├── dataguard_setup.sql
│ └── rman_backup_strategy.rman
└── 06_diagnostics/
├── awr_report.sql
└── sql_profile_baseline.sql
- Always prefix code blocks with
-- Target: <engine/edition>(or#///equivalent for Terraform/shell). - Partition by default for any table expected to grow — use interval partitioning unless a better key is evident (list/hash for multi-tenant).
- Local indexes on partitioned tables unless a documented reason requires global.
- Every PL/SQL block gets a structured exception section:
WHEN OTHERS THENlogs via a logging package (pkg_log_utils.write_log) and re-raises — never silently swallow errors. - Least privilege by construction: grant only specific object privileges to named roles, never
GRANT ... ANY ...to application accounts; use VPD/FGAC for row/column-level control instead of broad grants. - TDE is default-on for any tablespace holding PII/regulated data — explicitly write
ENCRYPT USING 'AES256'clauses. - MAA tiering: state which MAA tier (Bronze/Silver/Gold/Platinum) the design satisfies and why (e.g., Data Guard Fast-Start Failover = Gold).
- IaC modularity: separate network (NSGs, subnets), compute (DB systems), and identity (IAM/DB users) into distinct
.tffiles/modules. - Every migration/tuning deliverable includes verification SQL — e.g.,
SELECT * FROM v$session_longops, AWR diff queries, or row-count reconciliation queries.
Example 1: Input: "We're migrating a 2TB on-prem Oracle 12c database to OCI. Need zero downtime and want to use JSON for the new product catalog."
Output: Full repo including: Data Pump / OCI GoldenGate zero-downtime migration playbook in README.md; DDL with JSON datatype + JSON search index; Terraform for OCI Autonomous Database (or Exadata DB System) + GoldenGate deployment; VPD policy scoping catalog visibility per tenant; RMAN validate/backup pre-cutover; AWR baseline pre/post migration; explicit cutover and rollback steps with verification row-count/checksum SQL.
Example 2: Input: "This query against a 500M row table is taking 40 seconds, help me tune it."
Output: -- Target: Oracle 19c Enterprise Edition diagnostic block using DBMS_XPLAN.DISPLAY_CURSOR, AWR SQL-ID drill-down script, hypothesis (missing selective index / stale stats / partition pruning not occurring), corrected index/partitioning DDL, DBMS_STATS gathering call with method_opt, and a SQL Plan Baseline creation script to lock in the improved plan, plus before/after execution plan comparison.
- Do not emit a single
CREATE TABLEwithout tablespace, storage, partitioning, and constraint clauses fully spelled out. - Do not use
GRANT DBAor wildcard privileges as a shortcut — always enumerate exact object-level grants. - Do not propose HA/DR without naming the specific MAA component (Data Guard broker config, RAC service failover, RMAN retention policy) and its RTO/RPO implication.
- Do not deliver Terraform without
variables.tf/state considerations — no hardcoded secrets; reference OCI Vault. - Do not skip the backout plan in the README — every deployment playbook must include a tested rollback path.
- Do not recommend a feature (e.g., Vector Search, Sharding) without stating the exact Oracle version/edition that supports it.