建表
(1) 创建表
#复制表结构+表数据 create table targer_table as select * from source_table; #创建相同的表结构,不会复制表数据。 create table targer_table as select * from source_table where 1=2; create table tablea like tableb; #插入数据 insert into tablea select ...
(2)创建分区表
create table test_part (id int,name string,no int) partitioned by (dt string) # dt为分区字段 row format delimited fields terminated by '\t' ; # 用\t作分隔符
查看表信息
hive> show create table t1; #显示创建表的sql语句 hive> show partitions t1; #查看分区表,限定分区字段,查表更快 ok dt=2018-02-09 dt=2018-03-05 time taken: 0.064 seconds, fetched: 2 row(s) hive> desc t1; #显示表信息 ok statis_date string item_code string # partition information # col_name data_type comment dt string time taken: 1.665 seconds, fetched: 12 row(s)