How to view DB2 Table structure

后端 未结 19 2309
深忆病人
深忆病人 2020-12-24 00:59

How to view the table structure in DB2 database

相关标签:
19条回答
  • 2020-12-24 01:39

    1.use db2 describe table

      db2 describe table tabschema.tabname
    

    2.use db2 describe output

      db2 "describe select * from tabschema.tabname"
    

    3.use db2look utility

      db2look -d dbname -e -t tabname
    

    4.find rows in db2 syscat

      db2 "Select * from syscat.columns wher tabname='' and tabschema =''"
    
    0 讨论(0)
  • 2020-12-24 01:39

    Control Center already got the feature of that. It's just below the table list.

    enter image description here

    0 讨论(0)
  • 2020-12-24 01:39

    I am using Aquadata Studio 12.0.23, which is several versions short of the newest. So your experience may be better than mine. I found that the best way to get an overview was to use the ERD generator. It took a couple of hours, since normalization was not a concept used in the design of this database almost 30 years ago. I was able to get definitions for all of the objects in a few hours, with a file for each.

    0 讨论(0)
  • 2020-12-24 01:40

    I am running DB2/LINUXX8664 10.5.3 and describe select * from schema_name.table_name works for me.

    However, describe table schema_name.table_name fails with this error:

    SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000

    0 讨论(0)
  • 2020-12-24 01:42

    How to view the table structure in db2 database

    Open db2 command window, connect to db2 with following command.

    > db2 connect to DATABASE_NAME USER USERNAME USING PASSWORD
    

    Once you connected successfully, issue the following command to view the table structure.

    > db2 "describe select * from SCHEMA_NAME.TABLE_NAME"
    

    The above command will display db2 table structure in tabular format.

    Note: Tested on DB2 Client 9.7.11

    0 讨论(0)
  • 2020-12-24 01:47
    drop view lawmod9t.vdesc
    
    create view lawmod9t.vDesc as select 
           upper(t.table_cat) as Catalog, 
           upper(t.table_schem) as Schema, 
           upper(t.table_name) as table, 
           t.table_text as tableDesc, 
           c.system_column_name as colname_short, 
           c.column_name as colname_long, 
           c.column_text as coldesc, 
           c.Type_Name as type, 
           c.column_Size as size
    from sysibm.SQLColumns c
    inner join sysibm.sqltables t
    on c.table_schem = t.table_schem
    and c.table_name = t.table_name
    
    select * from vdesc where table = 'YPPPOPL'
    
    0 讨论(0)
提交回复
热议问题