IBM DB2 Query Toolbox - List all columns in specific table in Db2 database



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

IBM Db2 Query Toolbox - List all columns in specific table in Db2 database

A consulta abaixo retorna uma lista de todas as colunas em uma tabela específica no banco de dados IBM DB2.
Query below returns a list of all columns in a specific table in IBM DB2 database.

Consulta - Query

SELECT COLNO AS POSITION
,      COLNAME AS COLUMN_NAME
,      TYPENAME AS DATA_TYPE
,      LENGTH
,      SCALE
,      DEFAULT
,      REMARKS AS DESCRIPTION
,      CASE WHEN NULLS='Y' THEN 1 ELSE 0 END AS NULLABLE
,      CASE WHEN IDENTITY ='Y' THEN 1 ELSE 0 END AS IS_IDENTITY
,      CASE WHEN GENERATED ='' THEN 0 ELSE 1 END AS  IS_COMPUTED
,      TEXT AS COMPUTED_FORMULA
  FROM SYSCAT.COLUMNS
 WHERE TABNAME = 'PROJECT'            -- ENTER TABLE NAME HERE
       --AND TABSCHEMA = 'SCHEMA NAME'
 ORDER BY COLNO;

Colunas

  • posição - número desta coluna na tabela (começando com 0)
  • column_name - nome de uma coluna em uma tabela
  • data_type - tipo de dados da coluna
  • comprimento - comprimento máximo dos dados; 0 para tipos distintos.
  • escala:
    • escala se o tipo de coluna for DECIMAL,
    • número de dígitos de segundos fracionários se o tipo de coluna for TIMESTAMP,
    • 0 caso contrário
  • padrão - expressão padrão da coluna
  • descrição - descrição da coluna
  • nullable - atributo nullability para a coluna
  • is_identity - atributo de identidade para a coluna
  • is_computed - atributo computado (gerado) para a coluna
  • computed_formula - o texto da expressão da coluna computada
  • Linhas

  • Uma linha representa uma única coluna
  • Escopo das linhas: representam todas as colunas em uma tabela nomeada
  • Ordenado pela posição ordinal da coluna na tabela

Columns

  • position - number of this column in the table (starting with 0)
  • column_name - name of a column in a table
  • data_type - type of column data
  • length - maximum length of the data; 0 for distinct types.
  • scale:
    • scale if the column type is DECIMAL,
    • number of digits of fractional seconds if the column type is TIMESTAMP,
    • 0 otherwise
  • default - default expression of the colum
  • description - description of column
  • nullable - nullability attribute for the column
  • is_identity - identity attribute for the column
  • is_computed - computed (generated) attribute for the column
  • computed_formula - the text of the computed column expression

Rows

  • One row represents a single column
  • Scope of rows: represent all columns in a named table
  • Ordered by column's ordinal position in table

Resultado - Sample results


Copyright © Dataedo.