从整个Oracle DB获取DDL的有效方法

前端之家收集整理的这篇文章主要介绍了从整个Oracle DB获取DDL的有效方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
目前,Oracle 11.1数据库中大约有30个表.

有没有办法用一个命令生成所有ddl? (或者一些命令?)

编辑:
根据下面的建议,我试过:

SELECT dbms_Metadata.get_ddl( 'TABLE',table_name,owner )
  FROM all_tables;

得到了:

ORA-31603: object "HS_PARTITION_COL_NAME" of type TABLE not found in schema "SYS"
ORA-06512: at "SYS.DBMS_SYS_ERROR",line 105
ORA-06512: at "SYS.DBMS_MetaDATA",line 3241
ORA-06512: at "SYS.DBMS_MetaDATA",line 4812
ORA-06512: at line 1
31603. 00000 -  "object \"%s\" of type %s not found in schema \"%s\""
*Cause:    The specified object was not found in the database.
*Action:   Correct the object specification and try the call again.

很明显,我不了解dbms_Metadata有一些非常基本的东西.

解决方法

这对我有用:

SELECT dbms_Metadata.get_ddl('TABLE',table_name)
  FROM user_tables;

如果这是错误的,请低估我.我对Oracle知之甚少,所以我不明白为什么没有一个答案只是提供了一个有效的查询.

猜你在找的Oracle相关文章