This command:
Authorization
To display the SQLDA information about a SELECT statement, one of the privileges or authorities listed below for each table or view referenced in the SELECT statement is required.
To display the columns or indexes of a table or a view, one of the privileges or authorities listed below for the system catalogs SYSCAT.COLUMNS (DESCRIBE TABLE) and SYSCAT.INDEXES (DESCRIBE INDEXES FOR TABLE) is required:
Required Connection
Database. If implicit connect is enabled, a connection to the default database is established.
Command Syntax
>>-DESCRIBE-----------------------------------------------------> >-----+-select-statement---------------------------------------+->< '--+-TABLE--table-name--------------+---+--------------+-' '-INDEXES FOR TABLE--table-name--' '-SHOW DETAIL--'
Command Parameters
The DESCRIBE TABLE command lists the following information about each column:
Note: | This option is not supported for declared temporary tables. |
The DESCRIBE INDEXES FOR TABLE command lists the following information about each index of the table or view:
For the DESCRIBE TABLE command, specifies that output include the following additional information:
For the DESCRIBE INDEXES FOR TABLE command, specifies that output include the following additional information:
Examples
Describing a SELECT Statement
The following example shows how to describe a SELECT statement:
db2 "describe select * from staff"
SQLDA Information sqldaid : SQLDA sqldabc: 896 sqln: 20 sqld: 7 Column Information sqltype sqllen sqlname.data sqlname.length -------------------- ------ ------------------------------ -------------- 500 SMALLINT 2 ID 2 449 VARCHAR 9 NAME 4 501 SMALLINT 2 DEPT 4 453 CHARACTER 5 JOB 3 501 SMALLINT 2 YEARS 5 485 DECIMAL 7, 2 SALARY 6 485 DECIMAL 7, 2 COMM 4 |
Describing a Table
The following example shows how to describe a table:
db2 describe table user1.department
Table: USER1.DEPARTMENT Column Type Type name schema name Length Scale Nulls ------------------ ----------- ------------------ -------- -------- -------- AREA SYSIBM SMALLINT 2 0 No DEPT SYSIBM CHARACTER 3 0 No DEPTNAME SYSIBM CHARACTER 20 0 Yes |
Describing a Table Index
The following example shows how to describe a table index:
db2 describe indexes for table user1.department
Table: USER1.DEPARTMENT Index Index Unique Number of schema name rule columns -------------- ------------------ -------------- -------------- USER1 IDX1 U 2 |