Find all string (character) columns in Teradata database

In Teradata string values can be stored in columns with following data types: CHARACTER, VARCHAR and CLOB.

The query below lists all character data types.

Query

SELECT  DatabaseName,
        TableName,
        ColumnName,
        CASE ColumnType
            WHEN 'CV' THEN 'Character Varying'
            WHEN 'CO' THEN 'Character Large Object'
            WHEN 'CF' THEN 'Character Fixed'
            END AS DataType,
        CASE CharType
            WHEN '1' THEN 'Latin'
            WHEN '2' THEN 'Unicode'
            WHEN '3' THEN 'KanjiSJIS'
            WHEN '4' THEN 'Graphic'
            WHEN '5' THEN 'Kanji1'
            END AS CharType,
            ColumnLength
FROM    DBC.ColumnsV
WHERE   ColumnType in ('CV', 'CF', 'CO')
        AND DatabaseName NOT IN ('All', 'Crashdumps', 'DBC', 'dbcmngr',
    'Default', 'External_AP', 'EXTUSER', 'LockLogShredder', 'PUBLIC',
    'Sys_Calendar', 'SysAdmin', 'SYSBAR', 'SYSJDBC', 'SYSLIB',
    'SystemFe', 'SYSUDTLIB', 'SYSUIF', 'TD_SERVER_DB', 
    'TD_SYSGPL', 'TD_SYSXML', 'TDMaps', 'TDPUSER', 'TDQCD',
    'TDStats', 'tdwm', 'SQLJ', 'SYSSPATIAL','TD_SYSFNLIB')
ORDER BY    DatabaseName,
            TableName;

Columns

  • DatabaseName - name of the schema
  • TableName - name of the table
  • ColumnName - name of the column
  • DataType - type of data
  • CharType - character set name
  • ColumnLength - maximum length in characters

Rows

  • One row represents one column with a string data type
  • Scope of rows: all columns containing string data types in the database
  • Ordered by database name, table name

Sample results