netezza几个实用小查询

2022-04-28 00:00:00 专区 订阅 付费 交易 评论

查询视图属性
SELECT VIEWNAME,
OWNER,
CREATEDATE,
DEFINITION
FROM _V_VIEW a
WHERE OBJTYPE = 'VIEW';

查询表结构:
SELECT DATABASE,
OWNER,
NAME,
ATTNUM,
ATTNAME,
FORMAT_TYPE
FROM _V_RELATION_COLUMN
WHERE DATABASE <> Upper('system')
ORDER BY 2,3,4;


数据表记录数:
SELECT RELNAME TABLE_NAME,
CASE
WHEN RELTUPLES < 0 THEN ( ( 2^32 ) * RELREFS ) + ( ( 2^32 ) + RELTUPLES )
ELSE ( ( 2^32 ) * RELREFS ) + ( RELTUPLES )
END NUM_ROWS
FROM _T_CLASS,
_T_OBJECT
WHERE _T_OBJECT.OBJID = _T_CLASS.OID
AND _T_OBJECT.OBJCLASS = 4905;

数据倾斜信息:
SELECT TABLENAME,
OBJTYPE,
OWNER,
CREATEDATE,
USED_BYTES,
SKEW,
USED_BYTES * SKEW * 100
FROM _V_TABLE_ONLY_STORAGE_STAT
WHERE OBJCLASS = 4905
OR OBJCLASS = 4911
ORDER BY TABLENAME;  

相关文章