views:

292

answers:

5

Using Toad for Oracle, I can generate full DDL files describing all tables, views, source code (procedures, functions, packages), sequences, and grants of an Oracle schema. A great feature is that it separates each DDL declaration into different files (a file for each object, be it a table, a procedure, a view, etc.) so I can write code and see the structure of the database without a DB connection. The other benefit of working with DDL files is that I don't have to connect to the database to generate a DDL each time I need to review table definitions. In Toad for Oracle, the way to do this is to go to Database -> Export and select the appropriate menu item depending on what you want to export. It gives you a nice picture of the database at that point in time.

Is there a "batch" tool that exports
- all table DDLs (including indexes, check/referential constraints)
- all source code (separate files for each procedure, function)
- all views
- all sequences
from SQL Server?

What about PostgreSQL?
What about MySQL?
What about Ingres?

I have no preference as to whether the tool is Open Source or Commercial.

+3  A: 

MySQL has a great tool called MySQL workbench that lets you reverse and forward engineer databases, as well as synchronize, which I really like. You can view the DDL when executing these functions.

Andy West
+4  A: 

For mysql, I use mysqldump. The command is pretty simple.

$ mysqldump [options] db_name [tables]

$ mysqldump [options] --databases db_name1 [db_name2 db_name3...]

$ mysqldump [options] --all-databases

Plenty of options for this. Take a look here for a good reference.

Carl
+4  A: 

For SQL Server:

In SQL Server Management Studio, right click on your database and choose 'Tasks' -> 'Generate Scripts'.

You will be asked to choose which DDL objects to include in your script.

Daniel Vassallo
A: 

I wrote SMOscript which does what you are asking for (referring to MSSQL Server)

devio
+3  A: 

In PostgreSQL, simply use the -s option to pg_dump. You can get it as a plain sql script (one file for the whole database) on in a custom format that you can then throw a script at to get one file per object if you want it.

The PgAdmin tool will also show you each object's SQL dump, but I don't think there's a nice way to get them all at once from there.

Magnus Hagander