[英]Find all uncompressed tables in Teradata
Is there a way to find all the uncompressed tables in teradata ? 有没有办法在Teradata中找到所有未压缩的表?
So far I am doing it manually by using 到目前为止,我是通过手动进行操作的
SHOW TABLE <TABLE_NAME>
and checking if a column has COMPRESS
keyword. 并检查一列是否具有
COMPRESS
关键字。 This gets a lot tedious if I have 100s of tables. 如果我有100张桌子,这将变得非常乏味。
Is there a column or table where I can query for such tables something like I can check for Macro - 是否有一列或表格可以查询此类表格,就像可以检查宏一样?
SELECT * FROM dbc.tables WHERE tablekind='M' AND databasename='database'
Any help is appreciated. 任何帮助表示赞赏。
You can find all compressed columns: 您可以找到所有压缩列:
select * from dbc.ColumnsV
where CompressValueList is not null
To get tables without any compress: 要获取没有任何压缩的表:
SELECT * FROM dbc.TablesV
WHERE TableKind IN ('T', 'O') -- both PI and NoPI tables
AND (DatabaseName, TableName) NOT IN
(
SELECT DatabaseName, TableName
FROM dbc.columnsv
WHERE CompressValueList IS NOT NULL
)
As you mentioned, compression is more a "column thing" rather than a "table thing", so you'd better check in the column metadata: 如您所提到的,压缩更像是一个“列事物”,而不是“表事物”,因此最好检查列元数据:
That's a possible query (to be improved): 这是一个可能的查询(有待改进):
select t.tablename, sum(case when compressvaluelist is null then 0 else 1 end) compressed_cols, count(*) cols
from dbc.ColumnsV c join dbc.TablesV t on (c.tablename=t.tablename and c.databasename=t.databasename)
where t.databasename='<databasename>'
and t.tablekind in ('T','O')
group by 1
having compressed_cols=0
You can use dbc table columns for that . 您可以为此使用dbc表列。 Compressible = 'C' will give you those values.
可压缩='C'将为您提供这些值。
select databasename,tablename,columnname,compressible
from dbc.columns
where compressible in ('A','C')
by the way in y our query why you are choosing tablekind='M', it will not return details of table but will return detail of macro. 顺便说一下,在您查询我们为什么要选择tablekind ='M'的查询中,它不会返回表的详细信息,但会返回宏的详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.