Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view DB2 Table structure

Tags:

db2

How to view the table structure in DB2 database

like image 902
Ambat bhath Avatar asked Jun 04 '10 10:06

Ambat bhath


People also ask

How do you display the structure of a table?

So desc or describe command shows the structure of table which include name of the column, data-type of column and the nullability which means, that column can contain null values or not. All of these features of table are described at the time of Creation of table.

How do you describe a table structure in DB2?

Tables are logical structure maintained by Database manager. In a table each vertical block called as column (Tuple) and each horizontal block called as row (Entity). The collection of data stored in the form of columns and rows is known as a table. In tables, each column has different data type.

How do you get DDL of a table in DB2?

Right-click the table in DB2 Control Center and chose Generate DDL... That will give you everything you need and more.


2 Answers

I got the answer from the sysibm.syscolumns

Select distinct(name), ColType, Length from Sysibm.syscolumns where tbname = 'employee'; 
like image 169
Ambat bhath Avatar answered Oct 12 '22 11:10

Ambat bhath


Generally it's easiest to use DESCRIBE.

DESCRIBE TABLE MYSCHEMA.TABLE 

or

DESCRIBE INDEXES FOR MYSCHEMA.TABLE SHOW DETAIL 

etc.

See the documentation: DESCRIBE command

like image 22
Ian Bjorhovde Avatar answered Oct 12 '22 12:10

Ian Bjorhovde