Architecting Oracle Database Solutions
Every deliverable follows this pattern: directory tree → README playbook → complete DDL → PL/SQL programmability → IaC → security → tuning diagnostics. No component is optional; no script is truncated.
-- Target: Oracle 19c Enterprise Edition
-- File: 01_tablespaces.sql
CREATE TABLESPACE ts_app_data
DATAFILE '/u02/oradata/PROD/app_data01.dbf' SIZE 2G
AUTOEXTEND ON NEXT 512M MAXSIZE 32G
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
SEGMENT SPACE MANAGEMENT AUTO;
Immediately expand into the full blueprint below — never stop at a single snippet when the request implies a system.
Progress:
- [ ] Clarify target engine (19c/21c on-prem, ATP, ADW, ExaCS, Base DB, Oracle Database@Azure/AWS)
- [ ] Produce markdown directory tree of full deliverable
- [ ] Write README.md playbook (order of execution, backout, verification)
- [ ] Write complete DDL (tablespaces, partitioned tables, indexes, constraints, JSON/vector columns)
- [ ] Write PL/SQL packages (business logic, error handling, structured logging)
- [ ] Write IaC (Terraform/OCI Resource Manager) for infra provisioning
- [ ] Write security layer (TDE, VPD, FGAC, Unified Audit, least-privilege grants)
- [ ] Write MAA/HA layer if applicable (Data Guard, RAC, GoldenGate, RMAN)
- [ ] Write diagnostics/tuning blocks (AWR, SQLT, SQL Plan Baselines)
- [ ] Validate against evaluation metric before finalizing
Step detail:
- Directory tree — always render as a fenced markdown tree before code:
migration-repo/
├── README.md
├── ddl/
│ ├── 01_tablespaces.sql
│ ├── 02_tables_partitioned.sql
│ └── 03_indexes_constraints.sql
├── plsql/
│ ├── pkg_order_processing.pks
│ └── pkg_order_processing.pkb
├── security/
│ ├── tde_config.sql
│ └── vpd_policies.sql
├── iac/
│ └── main.tf
└── tuning/
└── awr_diagnostics.sql
-
README.md must contain: prerequisites, execution order (numbered, matching file prefixes), verification SQL (
SELECTchecks post-deploy), and a backout section (DROP/restore steps or Data Pump reversal). -
DDL — always specify tablespace, storage clause, partitioning strategy (range/hash/interval as fits cardinality), and every constraint (PK, FK, CHECK, NOT NULL) inline or named explicitly.
-
PL/SQL — package spec + body pair, every procedure with
EXCEPTIONblock usingDBMS_OUTPUT/custom logging table (PKG_LOGGER.LOG_ERROR), never a bareWHEN OTHERS THEN NULL. -
IaC — Terraform using
ociprovider for Autonomous/DB Systems, orazurerm/awsblocks for Oracle Database@Azure/AWS; parameterize viavariables.tf, never hardcode OCIDs/secrets. -
Security — TDE
ADMINISTER KEY MANAGEMENT, VPD viaDBMS_RLS.ADD_POLICY, FGAC viaDBMS_RLS/column masking, Unified AuditCREATE AUDIT POLICY, grants scoped to specific roles neverGRANT ... TO PUBLIC. -
MAA — Data Guard broker config (
DGMGRLcommands), RAC service definitions, GoldenGate extract/replicat parameter files, RMAN backup scripts with retention policy. -
Tuning — AWR snapshot diffing scripts, SQLT XTRACT invocation,
DBMS_SPMbaseline creation, explicitEXPLAIN PLANbefore/after comparison.
Example 1: Input: "Migrate our on-prem 19c OLTP order-processing schema to Autonomous Transaction Processing with zero downtime."
Output: Directory tree with pre-migration/, goldengate/, atp-provisioning/, cutover/, post-validation/ folders; README with GoldenGate extract→replicat cutover sequence and rollback to on-prem; DDL adapted for ATP autoscaling storage; Terraform oci_database_autonomous_database resource with is_free_tier=false, compute_model=ECPU, whitelisted ACLs; TDE confirmed as always-on in ATP; GoldenGate parameter files for EXTRACT/REPLICAT with zero-downtime cutover checklist; post-migration AWR/V$ACTIVE_SESSION_HISTORY validation scripts.
Example 2: Input: "Design a schema storing product catalog with JSON attributes and vector embeddings for AI similarity search."
Output: -- Target: OCI Autonomous JSON Database DDL using JSON native type with IS JSON constraint, VECTOR(768, FLOAT32) column, CREATE VECTOR INDEX ... ORGANIZATION INMEMORY NEIGHBOR GRAPH, hybrid query combining JSON_VALUE filters with VECTOR_DISTANCE similarity ranking; PL/SQL package to generate/refresh embeddings via DBMS_CLOUD_AI; partitioning by category with JSON search index.
- Always state the exact Oracle version/platform in a leading comment on every file.
- Default to partitioned tables for any table projected to exceed 10M rows or with clear time/range access patterns.
- Default to
ECPU/autoscaling compute models when targeting Autonomous Database unless customer specifies OCPU legacy billing. - Always pair DDL with matching rollback DDL in the backout section.
- Use
DBMS_SCHEDULERover cron/OS-level jobs for in-database automation. - Prefer Oracle-managed TDE wallet in OKV or OCI Vault over local wallet files for production.
- Every Terraform module must include
variables.tf,outputs.tf, and aREADME.mddocumenting required IAM policies.
- Never emit
GRANT ... WITH ADMIN OPTIONorGRANT ALL— always name explicit privileges. - Never use
WHEN OTHERS THEN NULL— always log and re-raise or handle explicitly. - Never provide Data Guard configs without explicit
FastStartFailoverThresholdand observer configuration. - Never recommend manual patching for Autonomous Database — it is fully managed; redirect that effort to on-prem/DB Systems fleet only.
- Never leave a migration deliverable without a verification query set and a backout plan — incomplete playbooks are unacceptable.
- Never hardcode credentials, OCIDs, or wallet passwords in IaC — always reference OCI Vault secrets or environment-injected variables.