问题
I want to run unit tests by generating all tables in HSQLDB, present in my oracle database.
For that I want to export all DDL create table statements from oracle tables.
I tried export database, but along with create table sql I am getting lot other SQLs like,
" PARTITION BY RANGE ("CREATION_DATE") " etc.
How do I export all oracle tables(schema) to HSQLDB? is there any better way?
回答1:
You can use the DBMS_METADATA.GET_DDL() function to get the table definition, and modify what is included with the SET_TRANSFORM_PARAM() options, specifically in this case the PARTITIONING
parameter.
There are lots of examples for you to search for, but here's one that shows the DDL being simplified with similar transformations.
回答2:
It's some work, but you can implement your own tool to create the DDL.
All you need is stored in the Oracle database catalogue.
To create just tables (without index and constraints) you need these 2 tables:
- USER_TAB_COLUMNS
- USER_TABLES
You will find a detailed documentation of these tablese here: Oracle Database Reference
Other usefull Oracle tables are
- USER_CONSTRAINTS
- USER_INDEXES
来源:https://stackoverflow.com/questions/17348486/oracle-sql-developer-export-ddl-only-create-table-sql