Archive for June 13th, 2007

In our previous blog posts, we had discussed how to generate DDLs in Oracle and SQL Server. In this one, we will cover the same feature in DB2 LUW. One of the ways to do this is to use the db2look command. When executed with proper parameters, it extracts DDL from the database it is connected to and puts it into an output file. We can use this file later on with some changes to create objects in new database.

To see what parameters can be passed to db2look, invoke it by simply typing db2look from command window. You can pick and choose command parameters you need. Following is the command to generate DDL in its simplest form followed by a output generated by command.

When db2look utility is used with appropriate parameters, it can also
• generate update statements to replicate statistics.
• omit extracting DDL for views.
• generate db2set, UPDATE DATABASE CONFIGURATION and UPDATE DATABASE MANAGER CONFIGURATION commands so that the new database has exact same registry variables and configuration parameters to simulate the source database environment as close as possible.