在hive的元数据库hivedb内
1.统计test库下所有的表的个数
SELECT COUNT(*) AS table_count
FROM TBLS
WHERE DB_ID = (SELECT DB_ID FROM DBS WHERE NAME = 'test');
2.统计test库下所有字段的个数
SELECT SUM(columns_count)
FROM (
SELECT COUNT(*) AS columns_count
FROM columns_v2
JOIN tbls ON (columns_v2.CD_ID = tbls.TBL_ID)
JOIN DBS ON (tbls.DB_ID = DBS.DB_ID)
WHERE DBS.NAME = 'test'
) subquery;