开发者

How to filter teradata help table

I'd li开发者_运维问答ke to create a table out of the dataset generated by teradata's "help table" function so i can add some more information about the table, and be able to filter the rows by conditions. the table has 400+ columns, so this would be very convenient for management. I'd like to be able to do something similar to creating a table as select, but it doesn't work with the help table syntax. short of exporting the data to excel, then manually creating the table schema and importing the table back in, does anyone know how to convert the output of a help table query into a table in teradata?


The output from the HELP TABLE command comes from Data Dictionary.

If I understand correctly, you want to create a new table with the following output.

help table t1;

 *** Help information returned. 4 rows.
 *** Total elapsed time was 1 second.

Column Name                    Type Comment
------------------------------ ---- --------
a1                             I    ?
b1                             CF   ?
c1                             D    ?
d1                             DA   ?

You can get all of those three columns (or even more) from the table DBC.TVFields.

help table dbc.tvfields;

help table dbc.tvfields;

 *** Help information returned. 37 rows.
 *** Total elapsed time was 1 second.

Column Name                    Type Comment
------------------------------ ---- ----------------
TableId                        BF   ?
FieldName                      CV   ?
FieldId                        I2   ?
Nullable                       CF   ?
FieldType                      CF   ?
MaxLength                      I    ?
DefaultValue                   CV   ?
DefaultValueI                  BV   ?
TotalDigits                    I2   ?
ImpliedPoint                   I2   ?
FieldFormat                    CV   ?
FieldTitle                     CV   ?
CommentString                  CV   ?
CollationFlag                  CF   ?
UpperCaseFlag                  CF   ?
DatabaseId                     BF   ?
Compressible                   CF   ?
CompressValueList              CV   ?
FieldStatistics                BV   ?
ColumnCheck                    CV   ?
CheckCount                     I2   ?
CreateUID                      BF   ?
CreateTimeStamp                TS   ?
LastAlterUID                   BF   ?
LastAlterTimeStamp             TS   ?
LastAccessTimeStamp            TS   ?
AccessCount                    I    ?
SPParameterType                CF   ?
CharType                       I2   ?
LobSequenceNo                  I2   ?
IdColType                      CF   ?
UDTypeId                       BF   ?
UDTName                        CV   ?
TimeDimension                  CF   ?
VTCheckType                    CF   ?
TTCheckType                    CF   ?
ConstraintId                   BF   ?

But first we need to find out DatabaseId and TableId.

select databaseid
from dbc.dbase
where databasename='db1';

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

DatabaseId
----------
00000F04
select TVMId
from dbc.tables2
where databaseid='00000F04'xb
and TVMName='t1';

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

TVMId
------------
0000D8070000

Now you can list all the columns you need and store them correspondingly.

select * from dbc.tvfields
where databaseid='00000F04'xb
and tableid='0000D8070000'xb;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜