如何过滤 Teradata 帮助表

发布于 2024-09-19 12:30:48 字数 185 浏览 2 评论 0原文

我想根据 teradata 的“帮助表”功能生成的数据集创建一个表,以便我可以添加有关该表的更多信息,并能够按条件过滤行。该表有400+列,这样管理起来非常方便。我希望能够执行类似于创建表作为选择的操作,但它不适用于帮助表语法。缺少将数据导出到 excel,然后手动创建表架构并将表重新导入,有谁知道如何将帮助表查询的输出转换为 teradata 中的表?

I'd like 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野稚 2024-09-26 12:30:48

HELP TABLE 命令的输出来自数据字典。

如果我理解正确,您想创建一个具有以下输出的新表。

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   ?

您可以从表 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   ?

但首先我们需要找出DatabaseId 和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

现在您可以列出您需要的所有列并相应地存储它们。

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

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文