How to see a schema of a table (file) db2

Like the subject ... is there a way to look at an empty table schema without inserting any rows and issuing SELECT?

+7
file db2 schema
source share
4 answers

Are you looking for DESCRIBE ?

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 
+8
source share
 SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = 'tablename'; 
+9
source share

For DB2 AS / 400 (here V5R4), I used the following queries to view the database / table / column metadata:

SELECT * FROM SYSIBM.TABLES - provides all tables

SELECT * FROM SYSIBM.VIEWS - provides all views and their original (!!) definition

SELECT * FROM SYSIBM.COLUMNS - provides all columns, their types and data sizes, default values, etc.

SELECT * FROM SYSIBM.SQLPRIMARYKEYS - contains a list of primary keys and their order

+7
source share

Looking at your other question , DESCRIBE may not work. I believe that there is a system table that stores all the information about the field.

Maybe this will help you . A little more, but much more accurate.

+1
source share

All Articles