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?

没有正确的解决方案

其他提示

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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top