Is there a tool to generate a full database DDL for SQL Server? What about Postgres and MySQL?

user78706 picture user78706 · Dec 18, 2009 · Viewed 45.2k times · Source

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.

Answer

Daniel Vassallo picture Daniel Vassallo · Dec 18, 2009

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.