Check if is column nullable in Teradata database

This query returns nullability information of the specified column.

Query

SELECT  COL.DatabaseName,
        COL.TableName,
        COL.ColumnName,
        CASE COL.Nullable
            WHEN 'Y' then 'IS NULLABLE'
            ELSE 'NOT NULLABLE'
            END AS Nullable
FROM    DBC.ColumnsV COL
JOIN    DBC.Tablesv TAB
ON      TAB.DatabaseName = COL.DatabaseName
AND     TAB.TableName = COL.TableName
AND     TAB.TableKind = 'T'
WHERE   COL.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', 'TDStats',
        'TD_SYSGPL', 'TD_SYSXML', 'TDMaps', 'TDPUSER', 'TDQCD',
        'tdwm', 'SQLJ', 'TD_SYSFNLIB', 'SYSSPATIAL')
ORDER BY    COL.DatabaseName,
            COL.TableName,
            COL.ColumnName;

Columns

  • DatabaseName - name of schema
  • TableName - name of table
  • ColumnName - name of column
  • Nullable - nullability attribute for the column:
    • IS NULLABLE - is nullable
    • NOT NULLABLE - is not nullable

Rows

  • One row nullability of the specified column
  • Scope of rows - all columns in the database
  • Order by - table schema, table_name, column 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.