oracle 从SQL文件生成数据字典的工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3302899/
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
Tool to generate data dictionary from SQL file
提问by Steve
Ok, so I got duped into doing some database design for an Oracle database where I work. The problem is, I'm not much of a DB guy :-). I'm currently using Rational Application Developer (RAD) to do the modeling of my database schema. What I'd ideally like to do is generate a series of Word documents, containing information from my DB schema (primarily table/column information, constraints, and triggers as tables in a Word doc).
好的,所以我被骗对我来说有效的 Oracle 数据库做一些数据库设计。问题是,我不是一个数据库人:-)。我目前正在使用 Rational Application Developer (RAD) 对我的数据库模式进行建模。理想情况下,我想做的是生成一系列 Word 文档,其中包含来自我的数据库架构的信息(主要是表/列信息、约束和触发器作为 Word 文档中的表)。
I can't seem to find any way to do this with RAD, so I was wondering if anyone knows of a tool that can take an SQL DDL script file (containing the CREATE commands for the schema), and generate Word-type reports?
我似乎找不到使用 RAD 执行此操作的任何方法,所以我想知道是否有人知道可以获取 SQL DDL 脚本文件(包含模式的 CREATE 命令)并生成 Word 类型报告的工具?
Any pointers greatly appreciated.
任何指针都非常感谢。
Thanks...
谢谢...
回答by dcp
It's probably easiest just to run commands directly against the Oracle data dictionary tables themselves rather than trying to parse SQL files containing create statements.
直接针对 Oracle 数据字典表本身运行命令,而不是尝试解析包含 create 语句的 SQL 文件,这可能是最简单的。
For example, to get all the tables in schema X, you can do:
例如,要获取模式 X 中的所有表,您可以执行以下操作:
SELECT table_name FROM all_tables WHERE owner = 'X'
To get all the columns for table 'T', owner 'U', you can do:
要获取表 'T'、所有者 'U' 的所有列,您可以执行以下操作:
SELECT column_name FROM all_tab_columns WHERE table_name = 'T' AND owner = 'U'
Complete Example
完整示例
Here's a complete example that would allow you to get all the tables and their columns back for all tables owned by 'owner'. It can be done with a single SQL statement:
这是一个完整的示例,它允许您为“所有者”拥有的所有表取回所有表及其列。它可以通过一条 SQL 语句完成:
SELECT t.table_name
, c.column_name
FROM all_tables t
, all_tab_columns c
WHERE t.TABLE_NAME = c.TABLE_NAME
AND t.OWNER = c.OWNER
AND t.OWNER = 'owner'
ORDER BY t.TABLE_NAME
, c.COLUMN_NAME
As far as getting the data into Word documents, I'd just start with getting the data into text files first, then you can use other means to get it into Word if necessary. To get it into a text file, you can just run the above command in sql*plus
, and just spool to a text file (i.e. issue a spool file.txt
command in sql*plus
) before running the SQL statement. Then your output will be written to a file.
至于将数据导入Word文档,我只是先将数据导入文本文件,然后根据需要使用其他方式将其导入Word。要将其放入文本文件,您只需在 中运行上述命令sql*plus
,然后在运行 SQL 语句之前将其假脱机到文本文件(即在 中发出spool file.txt
命令sql*plus
)。然后你的输出将被写入一个文件。
回答by Vineet Reynolds
Table reportsamong others, can be obtained from Oracle SQL Developer. However, one needs the access to the schema, to obtain the relevant information.
可以从 Oracle SQL Developer 获得表报告等。但是,需要访问模式,以获取相关信息。
If you're modelling the database, and therefore, do not have access to a working schema, you could load the DDL file in a model maintained by Oracle Data Modeler(you might want to check the license of this first) and then obtain the relational model report (the report that reflects the physical database model in most parts).
如果您正在对数据库进行建模,因此无法访问工作模式,您可以在Oracle Data Modeler维护的模型中加载 DDL 文件(您可能需要先检查它的许可证),然后获取关系模型报告(大部分反映物理数据库模型的报告)。