to get datatypes of all column from table

UDA

to get datatypes of all column from table

Hi,

i want to get all columnnames from a table A & its respective datatype.

i could get it columnname
from below query

sel columnname from dbc.columns
where tablename ='A'
and databasename = 'dtbs'

how can i get respective datatype?
Please help me.

Thanks,
altruist
8 REPLIES
Teradata Employee

Re: to get datatypes of all column from table

SELECT TRIM(DatabaseName) AS "DatabaseName", TRIM(TableName) AS "TableName", TRIM(ColumnName) AS "ColumnName", ColumnType FROM DBC.COLUMNS WHERE TableName = 'TableName';

For exact data-types and there respective code in the ColumnType column, consult the manuals.

Regards,

Adeel

Re: to get datatypes of all column from table

thanks!
but still from column type i can know char/varchar if i want to know its length then?
hey...
could you please send me the link where i can get teradata manual? it would be gr8

thanks
Teradata Employee

Re: to get datatypes of all column from table

Usually it is good to try your best as well! :)

Here is the link: http://www.info.teradata.com/

Why don't you just do a "SELECT * FROM DBC.COLUMNS" and checkout the columns .... they are pretty self-explanatory.

Regards,

Adeel
Enthusiast

Re: to get datatypes of all column from table

Why don't you try SHOW TABLE table_name;

It will give the entire table definition.
Enthusiast

Re: to get datatypes of all column from table

Hi Adeel,

I have added a new topic 'how to check if data is in upper case' in 'Teradata Database'.
Please reply.

Thanks & Regrds,
Venkatesh G

Enthusiast

Re: to get datatypes of all column from table

HELP TABLE tblname will also give the details of each column in the same order as in the table DDL.

Hope this helps.
N/A

Re: to get datatypes of all column from table

Click on Tools menu select 'List Columns' from that list. It will ask for table or view name which give the details of each column

Re: to get datatypes of all column from table

Thanks Tamil, that did the trick.