Search code examples
sqlteradataddl

Get All Columns with Table Information from Teradata DB


This one works, producing the column names only:

SELECT ColumnName 
FROM dbc.columnsV
WHERE DatabaseName = 'DB_NAME';

but I want to see the table name and the column type as well.


Solution

  • Ok... This one was an easy one, I managed to answer it myself:

    SELECT *
    FROM dbc.columnsV
    WHERE DatabaseName = 'DB_NAME';
    

    produces the needed table with all the stuff that one may need, including these columns:

    DatabaseName
    TableName
    ColumnName
    ColumnFormat
    ColumnTitle
    SPParameterType
    ColumnType
    ColumnUDTName
    ColumnLength
    DefaultValue
    Nullable
    CommentString
    DecimalTotalDigits
    DecimalFractionalDigits
    ColumnId
    UpperCaseFlag
    Compressible
    CompressValue
    ColumnConstraint
    ConstraintCount
    CreatorName
    CreateTimeStamp
    LastAlterName
    LastAlterTimeStamp
    CharType
    IdColType
    AccessCount
    LastAccessTimeStamp
    CompressValueList
    TimeDimension
    VTCheckType
    TTCheckType
    ConstraintId
    ArrayColNumberOfDimensions
    ArrayColScope
    ArrayColElementType
    ArrayColElementUdtName
    PartitioningColumn
    ColumnPartitionNumber
    ColumnPartitionFormat
    ColumnPartitionAC
    PseudoUDTFieldId
    PseudoUDTFieldType
    StorageFormat
    DatasetSchemaName
    InlineLength
    TSColumnType
    AutoColumn
    RowVersionNo
    

    So, the needed query is:

    SELECT DatabaseName, TABLENAME, ColumnName, ColumnType
    FROM dbc.columnsV
    WHERE DatabaseName = 'DB_NAME';