在 Oracle pl-sql 上生成数据库和表模式 (ddl)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1628541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
generate database & tables schema (ddl) on Oracle pl-sql
提问by Dels
Anyone have a PL-SQL statement that i can use to generate database & tables schema for specific database on Oracle 10g? I need the schema in .sql file and if possible compatible with ANSI-92/99 sql implementation, so i can use the generated .sql directly on sql server 2005.
任何人都可以使用 PL-SQL 语句为 Oracle 10g 上的特定数据库生成数据库和表模式?我需要 .sql 文件中的架构,并且如果可能与 ANSI-92/99 sql 实现兼容,所以我可以直接在 sql server 2005 上使用生成的 .sql。
Already heard about exp/imp, but it seems generated dump file, what i need just a simple ddl on .sql file.
已经听说过 exp/imp,但它似乎生成了转储文件,我只需要一个简单的 .sql 文件上的 ddl。
Thanks
谢谢
采纳答案by devio
I wrote oraddlscriptwhich calls dbms_metadata.get_ddl (Pop's answer) for each database object owned by a user and writes the DDL to a file.
我编写了oraddlscript,它为用户拥有的每个数据库对象调用 dbms_metadata.get_ddl(Pop 的答案)并将 DDL 写入文件。
Update: Answered comment
更新:回复评论
回答by Pop
You could try:
你可以试试:
select dbms_metadata.get_ddl('TABLE',table_name,owner)
from dba_tables where owner='schema name';
It returns longs, so you may want to play with the long buffer.
它返回 longs,所以你可能想使用 long 缓冲区。
More about dbms_metadata
here: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm
更多关于dbms_metadata
这里:http: //download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm
回答by Mark Harrison
If you just need to dump your schema, this free package does a very nice job. We use it in daily production.
如果您只需要转储您的架构,这个免费包做得非常好。我们在日常生产中使用它。
If you need to convert from Oracle to SQL Server, this software might do a better job. We've used it to convert between Oracle, MySql, and Postgreqsql.
如果您需要从 Oracle 转换为 SQL Server,该软件可能会做得更好。我们已经使用它在 Oracle、MySql 和 Postgreqsql 之间进行转换。
回答by Jesus A. Sanchez
Greetings, I'd recomend using Oracle SQL Developer Data Modelersince it's from Oracle, it can read the DDL information directly from the Data Dictionary. It creates an ERD and then you can produce DDL for SQL Server 2000/2005, some versions of DB2 and Oracle 9i/10g/11g.
您好,我建议使用Oracle SQL Developer Data Modeler,因为它来自 Oracle,它可以直接从数据字典中读取 DDL 信息。它会创建一个 ERD,然后您可以为 SQL Server 2000/2005、某些版本的 DB2 和 Oracle 9i/10g/11g 生成 DDL。