我如何获得 -仅将数据库中的表计数为输出 -仅将表中的列数作为输出
答案 0 :(得分:0)
您可以从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)
让我知道这是否有帮助。
答案 1 :(得分:0)
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;
了解更多详细信息:click here