Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Extracting complete DDL from DB2 6 databases

Use this technique to get DDL statements for various DB2 database objects to recreate them on some other server.

You may often need to get DDL statements for various DB2 database objects in order to recreate them on another server. For example, while setting up test systems, DBAs usually try to create a copy of the production database on test servers.

Usually, to do this you use the DB2LOOK utility to extract the DDL of various database objects like tables and views. But unfortunately for those who are using DB2 version 6, DB2LOOK will not support the extraction of many DB2 database objects like such as triggers, UDFs, authorization DDL statements (GRANTs for example), user defined tablespaces, nodegroups and buffer pools. So if you want the complete database DDL, you need to run DB2LOOK on the database and then write special scripts to extract the DDL for all the above objects from system catalog tables.

You can overcome this problem with a simple technique. In DB2 version 7.x DB2LOOK is expanded to extract DDL statements for all the above objects.

So, do the following:

  1. Catalog your version 6 database from a system where DB2 version 7 is installed.
  2. Issue DB2LOOK on the cataloged database from the system where version 7 is installed (using options -e -x -a).
  3. Now you are using version 7 DB2LOOK features for a version 6 database. So you will get complete DDL for the database including triggers, UDFs, authorization DDL, user defined tablespaces, buffer pools, and node groups.

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free DB2 tips and scripts.
  • Tip contest: Have a DB2 tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical DB2 questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: DB2 tips, tutorials, and scripts from around the Web.

Dig Deeper on DB2 UDB (universal databases)

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.