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 '\t'
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 \t
serialization.format \t
Time taken: 0.176 seconds, Fetched: 33 row(s)