Oracle sql developer - export DDL - only create table sql

醉酒当歌 提交于 2020-02-02 15:10:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!