Question

I am working on a web project,where i will access Db2 table and display the contents of table.Now i am in need of generating the DDL schema of the tables when the users click "Generate DDL" option from the web page.Is there any command or JAVA API's to get the DDL of the Db2 tables?

No correct solution

OTHER TIPS

Take a look at my project http://code.google.com/p/db2-scheme2ddl/ for code samples. I can get table DDL for IBM DB2 with pure JDBC.

In short,

  1. Invoke undocumented DB2 function CALL SYSPROC.DB2LK_GENERATE_DDL('-e -z SAMPLE', ?)
  2. Store second INOUT parameter for later use
  3. Find primary object's DDL with query

    select OP_SEQUENCE, SQL_STMT, OBJ_SCHEMA, OBJ_TYPE, OBJ_NAME, SQL_OPERATION FROM SYSTOOLS.DB2LOOK_INFO where OP_TOKEN=? and OBJ_SCHEMA=? and OBJ_TYPE=? and OBJ_NAME=?

You can use db2look to dump table ddl like this:

db2look -z <table schema> -d <database name> -noview -nofed -e -x -t <table name>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top