牛骨文教育服务平台(让学习变的简单)
博文笔记

hive 中显示创建的hql语句及 desc 命令实战

创建时间:2016-11-19 投稿人: 浏览次数:1043
1、显示创建的hql语句
show tables;
show create table student_info;

hive (default)> show create table student_info;
OK
createtab_stmt
CREATE TABLE `student_info`(
  `s_id` int, 
  `course` string, 
  `score` int, 
  `class_id` int)
ROW FORMAT DELIMITED 
  FIELDS TERMINATED BY " " 
STORED AS INPUTFORMAT 
  "org.apache.hadoop.mapred.TextInputFormat" 
OUTPUTFORMAT 
  "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
LOCATION
  "hdfs://h201:9000/user/hive/warehouse/student_info"
TBLPROPERTIES (
  "COLUMN_STATS_ACCURATE"="true", 
  "numFiles"="1", 
  "totalSize"="192", 
  "transient_lastDdlTime"="1485405074")
Time taken: 0.663 seconds, Fetched: 18 row(s)


2、desc查询表结构
 show create table lxw1235;


 hive (default)> show create table lxw1235;
OK
createtab_stmt
CREATE EXTERNAL TABLE `lxw1235`(
  `cookieid` string, 
  `createtime` string, 
  `pv` int)
ROW FORMAT DELIMITED 
  FIELDS TERMINATED BY "," 
STORED AS INPUTFORMAT 
  "org.apache.hadoop.mapred.TextInputFormat" 
OUTPUTFORMAT 
  "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
LOCATION
  "hdfs://h201:9000/tmp/xxw2"
TBLPROPERTIES (
  "COLUMN_STATS_ACCURATE"="true", 
  "numFiles"="0", 
  "totalSize"="0", 
  "transient_lastDdlTime"="1485468351")
Time taken: 0.14 seconds, Fetched: 17 row(s)
2.1、desc外部表

desc lxw1235; //显示表信息(字段、分区)

desc formatted lxw1235;  //显示表详细详细(字段、分区、路径、格式等)



hive (default)> desc lxw1235;
OK
col_name         data_type    comment
cookieid                string                                      
createtime              string                                      
pv                      int                                         
Time taken: 0.169 seconds, Fetched: 3 row(s)


hive (default)> desc formatted lxw1235;
OK
col_name        data_type       comment
# col_name              data_type               comment             
                 
cookieid                string                                      
createtime              string                                      
pv                      int                                         
                 
# Detailed Table Information             
Database:               default                  
Owner:                  hadoop                   
CreateTime:             Fri Jan 27 06:05:43 CST 2017     
LastAccessTime:         UNKNOWN                  
Protect Mode:           None                     
Retention:              0                        
Location:               hdfs://h201:9000/tmp/xxw2        
Table Type:             EXTERNAL_TABLE           
Table Parameters:                
        COLUMN_STATS_ACCURATE   true                
        EXTERNAL                TRUE                
        numFiles                0                   
        totalSize               0                   
        transient_lastDdlTime   1485468351          
                 
# 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             ,                   
        serialization.format    ,                   
Time taken: 0.32 seconds, Fetched: 33 row(s)
2.2、desc内部表
desc student_info;
desc formatted student_info;

hive (default)> desc student_info;
OK
col_name        data_type       comment
s_id                    int                                         
course                  string                                      
score                   int                                         
class_id                int                                         
Time taken: 0.286 seconds, Fetched: 4 row(s)


hive (default)> desc formatted student_info;
OK
col_name        data_type       comment
# col_name              data_type               comment             
                 
s_id                    int                                         
course                  string                                      
score                   int                                         
class_id                int                                         
                 
# Detailed Table Information             
Database:               default                  
Owner:                  hadoop                   
CreateTime:             Thu Jan 26 12:26:14 CST 2017     
LastAccessTime:         UNKNOWN                  
Protect Mode:           None                     
Retention:              0                        
Location:               hdfs://h201:9000/user/hive/warehouse/student_info        
Table Type:             MANAGED_TABLE            
Table Parameters:                
        COLUMN_STATS_ACCURATE   true                
        numFiles                1                   
        totalSize               192                 
        transient_lastDdlTime   1485405074          
                 
# 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                              
        serialization.format                      
Time taken: 0.176 seconds, Fetched: 33 row(s)









声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。