- Schema (owner) and table names
- Column names (using LISTAGG for composite keys)
- Primary key definitions
- Uses
all_constraintswhereconstraint_type = 'P' - Ordered by column position
Overview
Oracle Database is a multi-model database management system with:- Enterprise-level reliability
- Advanced security features
- High performance and scalability
- Comprehensive SQL support
- Multi-schema architecture
Smart Query Import
The Oracle Smart Query uses data dictionary views and JSON functions for metadata extraction.Oracle Query
What the Smart Query Retrieves
Foreign Keys (fk_info)
Foreign Keys (fk_info)
- Schema (owner) and table names
- Column names from
all_cons_columns - Foreign key constraint names
- Referenced schema, table, and column
- Delete rules (CASCADE, SET NULL, RESTRICT, NO ACTION)
- Full FK definitions
- Uses
all_constraintswhereconstraint_type = 'R'
Primary Keys (pk_info)
Primary Keys (pk_info)
Columns (cols)
Columns (cols)
- Schema (owner), table, and column names
- Data types (converted to lowercase)
- Character maximum length (for CHAR, VARCHAR, etc.)
- Numeric precision and scale (for NUMBER, FLOAT, DECIMAL)
- Ordinal position (column_id)
- Nullable constraints
- From
all_tab_columns
Indexes (indexes)
Indexes (indexes)
- Schema (owner), table, and index names
- Indexed columns from
all_ind_columns - Index types (NORMAL, BITMAP, FUNCTION-BASED, etc.)
- Uniqueness flags
- Sort direction (ASC/DESC)
- Column positions in composite indexes
- Uses
all_indexesandall_ind_columns
Tables (tbls)
Tables (tbls)
- Schema (owner) and table names
- Row counts (num_rows from statistics)
- Table type (always ‘TABLE’)
- From
all_tables
Views
Views
- Schema (owner) and view names
- From
all_views - View definitions are empty (not extracted)
Current Schema Context
Current Schema Context
Uses
SYS_CONTEXT('USERENV','CURRENT_SCHEMA') to filter objects in the current schema only.Oracle-Specific Features
Data Dictionary Views
Oracle provides three levels of data dictionary views:- USER_ views*: Objects owned by the current user
- ALL_ views*: Objects accessible to the current user (used by ChartDB)
- DBA_ views*: All objects in the database (requires DBA privileges)
ALL_* views to access metadata for the current schema.
Schema Context
Oracle usesSYS_CONTEXT('USERENV','CURRENT_SCHEMA') to determine the active schema:
Data Types
Oracle-specific data types: Character Types:- CHAR(n)
- VARCHAR2(n) - Oracle’s primary variable-length string type
- NCHAR(n), NVARCHAR2(n) - Unicode strings
- CLOB, NCLOB - Large character objects
- NUMBER(p,s) - General numeric type
- FLOAT(p)
- BINARY_FLOAT, BINARY_DOUBLE
- DATE - Date and time (no fractional seconds)
- TIMESTAMP(p) - Date and time with fractional seconds
- TIMESTAMP(p) WITH TIME ZONE
- INTERVAL YEAR TO MONTH
- INTERVAL DAY TO SECOND
- RAW(n)
- BLOB - Binary large object
- XMLTYPE - XML documents
- JSON - JSON documents (Oracle 21c+)
- ROWID - Physical row address
- UROWID - Universal row ID
Sequences
Oracle uses sequences for auto-increment:Indexes
Oracle supports various index types: B-Tree Indexes (default):Constraints
Oracle constraint syntax:Tablespaces
Oracle organizes data into tablespaces:Tablespace information is not captured by the Smart Query but can be queried from
all_tables.SQL Import/Export Limitations
ChartDB’s Oracle support has some limitations:What Works
- Importing metadata via Smart Query
- Visualizing table structures
- Understanding primary keys and foreign keys
- Viewing indexes and constraints
What Has Limited Support
- Complex Oracle CREATE TABLE syntax
- Tablespace specifications
- Partitioning clauses
- Storage parameters
- Advanced constraints (deferred, initially deferred)
- Triggers and procedures
Best Practices
Leverage identity columns
Use GENERATED AS IDENTITY (Oracle 12c+) instead of manual sequences where possible
Common Use Cases
Schema Documentation
Use ChartDB to:- Extract and visualize Oracle database schemas
- Generate data dictionaries
- Document table relationships
- Export to ERD diagrams
Migration Planning
Plan migrations from Oracle to other databases:- Extract schema with Smart Query
- Visualize in ChartDB
- Identify Oracle-specific features
- Export to target database (PostgreSQL, MySQL, etc.)
- Manual adjustment for incompatible features
Schema Review
Review and optimize database designs:- Identify missing indexes
- Review foreign key relationships
- Analyze table structures
- Document schema changes
Data Type Mapping
When migrating from Oracle to other databases:| Oracle Type | PostgreSQL | MySQL | SQL Server |
|---|---|---|---|
| VARCHAR2(n) | VARCHAR(n) | VARCHAR(n) | NVARCHAR(n) |
| NUMBER(p,s) | NUMERIC(p,s) | DECIMAL(p,s) | DECIMAL(p,s) |
| NUMBER | NUMERIC | DECIMAL(65,0) | DECIMAL(38,0) |
| DATE | TIMESTAMP | DATETIME | DATETIME2 |
| TIMESTAMP | TIMESTAMP | DATETIME(6) | DATETIME2(7) |
| CLOB | TEXT | LONGTEXT | NVARCHAR(MAX) |
| BLOB | BYTEA | LONGBLOB | VARBINARY(MAX) |
| RAW(n) | BYTEA | VARBINARY(n) | VARBINARY(n) |
Troubleshooting
Permission denied errors
Permission denied errors
Ensure your user has SELECT permissions on:
all_constraintsall_cons_columnsall_tab_columnsall_indexesall_ind_columnsall_tablesall_views
No tables returned
No tables returned
Check that you’re querying the correct schema:
ORA-00904: invalid identifier
ORA-00904: invalid identifier
Ensure you’re using Oracle 12c+ for JSON functions. For older versions, the query won’t work.
Row count is NULL
Row count is NULL
Table statistics may not be current. Gather statistics:
Query is slow
Query is slow
For large schemas:
- Add WHERE clauses to filter specific tables
- Run during off-peak hours
- Consider querying one table at a time
Oracle Versions
The Smart Query requires:- Oracle 12c Release 1 (12.1) or higher for JSON functions
- Earlier versions are not supported
- Oracle 19c or higher for best compatibility and performance
Additional Resources
Oracle Documentation
Official Oracle Database documentation
SQL Language Reference
Oracle SQL language reference
Data Dictionary Views
Reference guide for data dictionary views
JSON in Oracle
Using JSON in Oracle Database
