Get actual column name not alias via DBC/system tables

Database
Teradata Employee

Get actual column name not alias via DBC/system tables

Hi,

Other than  doing a "show view" to get the actual column, is there any other way to get that information in the dbc or system table? Note I am not asking for the alias but the actual columnn which is being referenced.

thanks

Tags (1)
3 REPLIES
Enthusiast

Re: Get actual column name not alias via DBC/system tables

Below query will provide the actual column name 

SEL TableName, ColumnName FROM DBC.COLUMNS WHERE TableName = 'T_NAME' AND DatabaseName = 'DB_NAME' ORDER BY ColumnId;

Teradata Employee

Re: Get actual column name not alias via DBC/system tables

Hi Chinmay,

I appreciate the reply, this is ok if I am querying a table but what if I am querying a view and I need the actual view column name referenced not the alias? 

SEL TableName, ColumnName FROM DBC.COLUMNS WHERE TableName = 'ViewName' AND DatabaseName = 'ViewDatabase' ORDER BY ColumnId;

thanks 

Enthusiast

Re: Get actual column name not alias via DBC/system tables

You may use 

Show select * from <view_name>;

this result contains complete hirerchy starting from the actual base table till the view_name that we have queried on.

Thanks,

Narasimha Sarma.