简体   繁体   English

Oracle sql developer - export DDL - 只创建表sql

[英]Oracle sql developer - export DDL - only create table sql

I want to run unit tests by generating all tables in HSQLDB, present in my oracle database. 我想通过在我的oracle数据库中生成HSQLDB中的所有表来运行单元测试。

For that I want to export all DDL create table statements from oracle tables. 为此,我想从oracle表导出所有DDL create table语句。

I tried export database, but along with create table sql I am getting lot other SQLs like, 我试过导出数据库,但是随着创建表sql我得到了很多其他的SQL,比如

" PARTITION BY RANGE ("CREATION_DATE") " etc. “按比例分区(”CREATION_DATE“)”等

How do I export all oracle tables(schema) to HSQLDB? 如何将所有oracle表(模式)导出到HSQLDB? is there any better way? 有没有更好的方法?

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. 您可以使用DBMS_METADATA.GET_DDL()函数来获取表定义,并修改SET_TRANSFORM_PARAM()选项中包含的内容 ,特别是在此情况下为PARTITIONING参数。

There are lots of examples for you to search for, but here's one that shows the DDL being simplified with similar transformations. 您可以搜索许多示例,但这里有一个显示DDL被简化为类似转换的示例。

It's some work, but you can implement your own tool to create the DDL. 这是一些工作,但您可以实现自己的工具来创建DDL。

All you need is stored in the Oracle database catalogue. 您所需要的只是存储在Oracle数据库目录中。

To create just tables (without index and constraints) you need these 2 tables: 要只创建表(没有索引和约束),您需要这两个表:

  • USER_TAB_COLUMNS USER_TAB_COLUMNS
  • USER_TABLES USER_TABLES

You will find a detailed documentation of these tablese here: Oracle Database Reference 您可以在此处找到这些表的详细文档: Oracle数据库参考

Other usefull Oracle tables are 其他有用的Oracle表是

  • USER_CONSTRAINTS USER_CONSTRAINTS
  • USER_INDEXES USER_INDEXES

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM