# Databases > DB2 - Query to get table structure

## Divya.B.V

Hi friends, i want a query to know the table structure in db2 listing all its columns, primary keys and all. I tried using the query *describe table table_name* i get the following o/p --------------------- column type type name schema name length scale nulls ------------------------------ --------- ------------------ -------- ---- 0 record(s) selected. Sql0100w no row was found for fetch, update or delete; or the result of a query is an empty table. Sqlstate=02000 please help me.

----------


## Chandra Veenapoosa

The following example shows how to describe a SELECT statement: 

   db2 "describe output 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

----------


## Divya.B.V

> The following example shows how to describe a SELECT statement: 
> 
>    db2 "describe output select * from staff" SQLDA Information
> 
> sqldaid :SQLDA sqldabc:896 sqln:20 sqld:7
> 
> Column Information
> 
> sqltype               sqllen  sqlname.data                    sqlname.length
> ...




Thanks Beena. Is there any query describing the primary keys of the table??

----------


## Jyelamanchili

You can use describe indexes for table <<< table name>>> show detail thank you

----------


## dbadb2udb

Hi,
As per my knowledge you have searched for the table which is not available.
If you use the bellow mentioned query then it will definitely work.
$ db2 "describe table schema-name.table-name"
Please check the table is cataloged or not...
Regards,
Shubhrojyoti
dbashubhrojyoti@gmail.com

----------

