OraSchemaGen is a powerful Python utility for generating Oracle database schema exports with realistic tables, data, and advanced PL/SQL objects. It's particularly useful for development environments, testing, and educational purposes where an actual Oracle database may not be available.
- Complete Schema Generation: Creates tables, constraints, indexes, and sequences that mimic real Oracle databases
- Realistic Test Data: Generates appropriate sample data based on column names and types
- Advanced PL/SQL Objects: Produces triggers, procedures, functions, packages, and LOB operations
- Japanese Language Support: Full support for Japanese text with Shift-JIS encoding
- Modular Architecture: Select which object types to generate based on your needs
- Progress Tracking: Visual progress indicators for lengthy generation tasks
- Flexible Output Options: Generate a single file or split by object type
# Clone the repository
git clone https://github.com/yourusername/OraSchemaGen.git
cd OraSchemaGen
# Install required dependencies
pip install -r requirements.txt- Python 3.6+
- Required packages:
- faker
- tqdm
Generate a complete Oracle schema export with default settings:
python modular_OraSchemaGen.pyThis will create oracle_export.sql with 6 tables, 20 rows per table, and all PL/SQL object types in Shift-JIS encoding.
usage: modular_OraSchemaGen.py [-h] [--tables TABLES] [--rows ROWS] [--output OUTPUT]
[--encoding {shift-jis,utf-8}] [--objects OBJECTS] [--no-header]
[--no-storage] [--split] [--output-dir OUTPUT_DIR]
Generate Oracle schema and objects with Shift-JIS encoding
optional arguments:
-h, --help Show this help message and exit
--tables TABLES Number of tables to generate (max 8) [default: 6]
--rows ROWS Number of rows per table [default: 20]
--output OUTPUT Output SQL file name [default: oracle_export.sql]
--encoding {shift-jis,utf-8}
Output file encoding [default: shift-jis]
--objects OBJECTS Comma-separated list of object types to generate
(table,data,trigger,procedure,function,package,lob,all)
[default: all]
--no-header Skip export header and footer
--no-storage Skip storage clauses in CREATE statements
--split Split output into multiple files by object type
--output-dir OUTPUT_DIR Output directory for split files
Generate a large schema with 1,000 rows per table:
python modular_OraSchemaGen.py --rows 1000 --output large_export.sqlGenerate only tables and data, no PL/SQL objects:
python modular_OraSchemaGen.py --objects table,data --output simple_export.sqlGenerate only tables with triggers and procedures:
python modular_OraSchemaGen.py --objects table,trigger,procedureGenerate a schema with separate files for each object type:
python modular_OraSchemaGen.py --split --output-dir ./export_filesGenerate a UTF-8 encoded export instead of Shift-JIS:
python modular_OraSchemaGen.py --encoding utf-8Create a clean schema without storage clauses:
python modular_OraSchemaGen.py --no-storageThe following object types can be generated:
- EMPLOYEES - Employee information with Japanese name fields
- DEPARTMENTS - Department information
- JOBS - Job titles and salary ranges
- LOCATIONS - Location information
- PRODUCTS - Product details
- CUSTOMERS - Customer information with Japanese name fields
- ORDERS - Order header information
- ORDER_ITEMS - Order line items
- Triggers: Complex compound triggers, before/after triggers, system event triggers
- Procedures: Employee management, department operations, data validation, test data generation
- Functions: Date handling, financial calculations, employee metrics, customer analysis
- Packages: Employee management, Japanese text utilities, data processing utilities
- LOB Handling: Document storage and retrieval, text extraction, thumbnail generation
OraSchemaGen employs a modular design with these key components:
- Generators: Specialized classes for each object type (SchemaGenerator, TriggerGenerator, etc.)
- OracleObject: Represents an individual Oracle database object
- OracleObjectFactory: Creates appropriate generators based on requested object types
- OutputHandler: Manages writing objects to files with proper dependency ordering
- EncodingHandler: Handles character encoding conversion
The code is designed to be easily extensible:
- Add new object generators by extending the
OracleObjectGeneratorbase class - Modify existing generators to add new object types
- Expand the data generation logic to produce more specialized data
- Development Environments: Create test Oracle schemas without needing a full Oracle installation
- Migration Testing: Test Oracle-to-PostgreSQL migrations with ora2pg
- Education: Learn Oracle database programming with realistic examples
- Demos: Generate sample data for application demos
- Localization Testing: Test applications with mixed English/Japanese data
This project is licensed under the MIT License - see the LICENSE file for details.
- The Faker library for realistic data generation
- The tqdm library for progress visualization