Is There a Tool to Generate a Full Database Ddl for SQL Server? What About Postgres and MySQL

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

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.

Open source tool to generate generic DDL scripts

I'd check first the --no-data and --compatible=name options of mysqldump.

Tools to generate SQL DDL and Content from an existing database

Have you had a look at SQL Publishing Wizard? It will create all the DDL statements you require for all database elements (tables, views, SPs, users etc).

If you're using SQL 2008, it comes built into the management studio. More info on 2008.

Script schema of the entire database with Datagrip

From 2018.2 there is a feature called SQL generator. It will generate the whole DDL for the database/schema with several available options.

Sample Image

The result is:

Sample Image

BUT:
If you want just to understand where the table is used, please use the dedicated functionality which is called Find Usages (Alt+F7 or context menu on a table name)

Sample Image

Whats the best build system for building a database?

Just a shell script that runs all the create statements and imports in the proper order. You may also find migrations (comes with rails) interesting. It provides a make like infrastructure that let's you maintain a database the structure of which evolves over time.

Say you add a new column to some table. In migrations you'd write a snippet of code which describes the requirements for adding the column and also to rollback the change so you can switch to different versions of your schema automatically.

I'm not a big fan of the tight integration with rails, though, but the principles behind it are very interesting.

Generate DDL programmatically on Postgresql

The answer is to check the source code for pg_dump and follow the switches it uses to generate the DDL. Somewhere inside the code there's a number of queries used to retrieve the metadata used to generate the DDL.



Related Topics



Leave a reply



Submit