Hello everybody I am learning DB2 and would like to know how to see a table's characteristics after I create one.
Similar to the EXPLAIN TABLE command in MySQL.
Thank you.
In addition to DESCRIBE TABLE
, you can use the command below
DESCRIBE INDEXES FOR TABLE *tablename* SHOW DETAIL
to get information about the table's indexes.
The most comprehensive detail about a table on Db2 for Linux, UNIX, and Windows can be obtained from the db2look utility, which you can run from a remote client or directly on the Db2 server as a local user. The tool produces the DDL and other information necessary to mimic tables and their statistical data. The docs for db2look in Db2 11.5 are here.
The following db2look
command will connect to the SALESDB database and obtain the DDL statements necessary to recreate the ORDERS table
db2look -d SALESDB -e -t ORDERS