Exporting DDLs from Your Database

Posted 955 days ago

It's often useful to be able to recreate an empty copy of your database. Most popular database systems come with utilities to export your database's DDL to a flat file so you can recreate the structure elsewhere. Here's a list of how to do it on various popular database systems:

IBM DB2

db2look -d databasename [-z schemaname] -e -o outputfile

I've only tested this one on DB2 8.1, but I believe the db2look utility also comes with DB2 7.

PostgreSQL

pg_dump -s dbname > outputfile

MySQL

mysqldump --no-data databasename > outputfile

I've never had to do this in SQL Server or Oracle. If anyone knows the commands for those - or any other popular DB - please post comments!

About

My name is Tim Fanelli, I am a software engineer in Northern NY. I spend most of my time working, and when I can, I try to post interesting things here.

Cigar Dossiers