Find all numeric columns in Teradata database

Numeric in Teradata are columns with the following data types: BYTEINT, SMALLINT, INTEGER, BIGINT, DECIMAL/NUMERIC, FLOAT/REAL/DOUBLE PRECISION, NUMBER.

The query below lists all columns with numeric data types.

Query

SELECT  DatabaseName,
        TableName,
        ColumnName,
        CASE ColumnType
            WHEN 'I' THEN '4 Byte Integer'
            WHEN 'I1' THEN '1 Byte Integer'
            WHEN 'I2' THEN '2 Byte Integer'
            WHEN 'I8' THEN '8 Byte Integer'
            WHEN 'N' THEN 'Number'
            WHEN 'D' THEN 'Decimal'
            WHEN 'F' THEN 'Float'
            END AS DataType,
            DecimalTotalDigits,
            DecimalFractionalDigits
FROM    DBC.ColumnsV
WHERE   ColumnType in ('I1', 'I2', 'I8', 'I', 'N', 'D', 'F')
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 database
  • TableName - name of the table
  • ColumnName - name of the column
  • DataType - type of data
  • DecimalTotalDigits - precision of the numeric column
  • DecimalFractionalDigits - scale of the numeric column

Rows

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

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.