如何仅从数据库中获取表计数作为输出

kadbb459  于 2021-06-27  发布在  Hive
关注(0)|答案(2)|浏览(241)

如何将数据库中的表的纯计数作为输出-将表中的列的纯计数作为输出

3hvapo4f

3hvapo4f1#

你可以从 metastore database :

hive=> SELECT "TBL_NAME", "COLUMN_NAME", "TYPE_NAME" FROM "TBLS" , "COLUMNS_V2" WHERE "TBL_ID"="CD_ID" UNION SELECT "TBL_NAME", "PKEY_NAME", "PKEY_TYPE" FROM "PARTITION_KEYS" p , "TBLS" t WHERE p."TBL_ID"=t."TBL_ID" ORDER BY "TBL_NAME";

  TBL_NAME  | COLUMN_NAME | TYPE_NAME 
------------+-------------+-----------
 tableA     | aaa         | string
 tableA     | bbb         | string
 tableB     | foo         | string
 tableB     | bar         | int
 tableC     | cola        | string
 tableD     | colb        | string
(6 rows)

如果这有帮助,请告诉我。

42fyovps

42fyovps2#

hive> select count(column_name) as NoOfColumns from information_schema.columns where table_name= "TableName";

hive> select count(table_name) as NoOfTables from information_schema.tables;

更多详情:点击这里

相关问题