Ever find yourself working in an unfamiliar Database or table and in need of knowing what are the data types for the different columns? Well that recently happened to me when I had to expand some queries in a DB2 environment.
As it turns out there exists the Describe command that outputs the columns of a table and their data type. The basic command is as follows that can be used on a TABLE or VIEW:
DESCRIBE TABLE schema.table_name
The command will output the following information for each column.
- Column Name
- Type Schema
- Type Name
- Nulls(is nullable)
In addition to obtaining the column information you can also use the command to get a table’s indexes.
DESCRIBE INDEXES FOR TABLE schema.table_name
- DB2 Universal Database – Describe Command