문제

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