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

时间:2022-09-15 16:01:00

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,

我试过导出数据库,但是随着create table sql我得到了很多其他的SQL,比如

" PARTITION BY RANGE ("CREATION_DATE") " etc.

“按比例分区(”CREATION_DATE“)”等

How do I export all oracle tables(schema) to HSQLDB? is there any better way?

如何将所有oracle表(模式)导出到HSQLDB?有没有更好的方法?

2 个解决方案

#1


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.

您可以使用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被简化为类似转换的示例。

#2


0  

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

#1


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.

您可以使用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被简化为类似转换的示例。

#2


0  

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