If you query tables from dbc.columns
, you will get full metadata for every column, especially data type, length, nullable/non-nullable, etc. When querying views, you only get the database, table, and column names. All the other fields are null.
If I have a view that's doing nothing but select * from table
, it seems that the underlying table's metadata would propagate to the view when it's compiled to database objects. This makes sense even for calculated columns since my experiments have shown that Teradata analyzes all possible logic paths to determine a calculated column's type. Here's an example:
replace view mydb.testview as
select case when 1 = 1 then 'a' else 'aaaa' end a;
create table mydb.testviewtotable as (select * from mydb.testview) with data;
show table mydb.testviewtotable;
In that case statement, only the first condition will ever return true, so the result will always be 'a'
. However, when you look at the table DDL, you can see that it calculates the column as VARCHAR(4)
which proves that it analyzes all cases:
a VARCHAR(4) CHARACTER SET UNICODE NOT CASESPECIFIC
Therefore, it seems reasonable to assume that this view metadata exists somewhere even though querying that view through DBC results in nulls for all but the aforementioned columns.