查看Hive中表的所有信息(结构、字段、存放路径、属性)

            查看Hive中表的所有信息(结构、字段、存放路径、属性)

目录

1. 查询创建表信息(show create table)

2. 查询表的字段信息(desc)

3. 查看表的详细属性信息(desc formatted)

4.  查看表的详细信息(describe extended)

5. 查看表的partitions信息(show partitions )

1. 查询创建表信息(show create table)

hive> show create table alpha_sales_staff_info;
OK
CREATE TABLE `alpha_sales_staff_info`(
  `staff` string COMMENT '客服pin',
  `mall_id` string COMMENT '服务商ID',
  `brand_name` string COMMENT '品牌名称',
  `category` string COMMENT '品类名称',
  `level` string COMMENT '客服评级',
  `group` string COMMENT 'AB test组别')
PARTITIONED BY (
  `dt` string)
ROW FORMAT DELIMITED
  FIELDS TERMINATED BY ' '
  LINES TERMINATED BY '\n'
STORED AS INPUTFORMAT
  'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
  'hdfs://ns7/user/mart_ai/app.db/alpha_sales_staff_info'
TBLPROPERTIES (
  'mart_name'='mart_ai',
  'transient_lastDdlTime'='1542188102')
Time taken: 0.149 seconds, Fetched: 21 row(s)

2. 查询表的字段信息(desc)

hive> desc alpha_sales_staff_info;
OK
staff                   string                  客服pin
mall_id                 string                  服务商ID
brand_name              string                  品牌名称
category                string                  品类名称
level                   string                  客服评级
group                   string                  AB test组别
dt                      string
 
# Partition Information
# col_name                data_type               comment
 
dt                      string
Time taken: 0.053 seconds, Fetched: 12 row(s)

3. 查看表的详细属性信息(desc formatted)

 
hive> desc formatted alpha_sales_staff_info;
 
# col_name                data_type               comment
 
staff                   string                  客服pin
mall_id                 string                  服务商ID
brand_name              string                  品牌名称
category                string                  品类名称
level                   string                  客服评级
group                   string                  AB test组别
 
# Partition Information
# col_name                data_type               comment
 
dt                      string
 
# Detailed Table Information
Database:               app
Owner:                  mart_ai
CreateTime:             Wed Nov 14 17:35:02 CST 2018
LastAccessTime:         UNKNOWN
Retention:              0
Location:               hdfs://ns7/user/mart_ai/app.db/alpha_sales_staff_info
Table Type:             MANAGED_TABLE
Table Parameters:
    mart_name               mart_ai
    transient_lastDdlTime    1542188102
 
# Storage Information
SerDe Library:          org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
InputFormat:            org.apache.hadoop.mapred.TextInputFormat
OutputFormat:           org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
Compressed:             No
Num Buckets:            -1
Bucket Columns:         []
Sort Columns:           []
Storage Desc Params:
    field.delim
    line.delim              \n
    serialization.format
Time taken: 0.082 seconds, Fetched: 38 row(s)

4.  查看表的详细信息(describe extended)

hive> describe extended alpha_sales_staff_info;
OK
staff                   string                  客服pin
mall_id                 string                  服务商ID
brand_name              string                  品牌名称
category                string                  品类名称
level                   string                  客服评级
group                   string                  AB test组别
dt                      string
 
# Partition Information
# col_name                data_type               comment
 
dt                      string
 
Detailed Table Information    
Table(tableName:alpha_sales_staff_info, dbName:app, owner:mart_ai, createTime:1542188102, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:staff, type:string, comment:客服pin), FieldSchema(name:mall_id, type:string, comment:服务商ID), FieldSchema(name:brand_name, type:string, comment:品牌名称), FieldSchema(name:category, type:string, comment:品类名称), FieldSchema(name:level, type:string, comment:客服评级), FieldSchema(name:group, type:string, comment:AB test组别), FieldSchema(name:dt, type:string, comment:null)], location:hdfs://ns7/user/mart_ai/app.db/alpha_sales_staff_info, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format= , field.delim= , line.delim=
}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[FieldSchema(name:dt, type:string, comment:null)], parameters:{mart_name=mart_ai, transient_lastDdlTime=1542188102}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)
Time taken: 0.078 seconds, Fetched: 15 row(s)

5. 查看表的partitions信息(show partitions )

#a.表不是partition表
 
hive> show partitions dpc_test;
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Table dpc_test is not a partitioned table
 
 
#b. 表有partition
 
hive> show partitions alpha_sales_staff_info;
OK
dt=v1
dt=v2
dt=v3
Time taken: 0.075 seconds, Fetched: 3 row(s)

 

    原文作者:AcceptedLin
    原文地址: https://blog.csdn.net/u013185349/article/details/107204521
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞