views:

101

answers:

2

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).

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?

Any pointers greatly appreciated.

Thanks...

+2  A: 

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.

For example, to get all the tables in schema X, you can do:

SELECT table_name FROM all_tables  WHERE owner = 'X'

To get all the columns for table 'T', owner 'U', you can do:

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:

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.

dcp
Unfortunately, I don't have anything in the database yet. I'm still workiing with the ER design tool.
Steve
@Steve - Are you aware that you can run your own instance of Oracle absolutely free? It's called the Oracle Express Edition, and you can get it here: http://www.oracle.com/technology/products/database/xe/index.html I highly recommend it, and it's great for doing the thing you are doing now, because you don't have to wait on DBA's to create your schema, you can do it on your sandbox DB. Plus, this allows you to make all the tweaks, etc. to your design and get it like you want it before bothering the DBA's. If you do that, you'll be able to use the solution above.
dcp
@Steve, you could import the DDLs into the Oracle SQL Developer's sister tool - Oracle Data Modeler and get relational model reports, although I have no idea of whether those reports will be useful.
Vineet Reynolds
+1  A: 

Table reports among others, can be obtained from Oracle SQL Developer. However, one needs the access to the schema, to obtain the relevant information.

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).

Vineet Reynolds
At this point, I'm still in ER design mode. The admin guys haven't created the Oracle database yet, so I don't have an instance to work against.
Steve
Yeah, I figured that out from the other comment. I've edited my answer to reflect the same - you could attempt using Oracle Data Modeler.
Vineet Reynolds
+1: I've only seen the desired output from Oracle Designer, myself, though I can't remember it being Word or just a text file.
OMG Ponies
@OMGPonies - Designer didn't work with Word out of the box, although I recall some third party selling a plug-in which converted Des2K output into Word docs.
APC
@APC: Thx, been a long time.
OMG Ponies