hive(一) hive表操作,
查看hive版本号:
hive> set hive.hwi.war.file
创建外表:
hive> create external table table_name (
> name string,
> type string,
> comment string
> )
> partitioned by (dt string)
> row format delimited
> fields terminated by '\t'
> location hdfs_path;
添加外部表分区:
hive> alter table table_name add partition (dt='2018-01-22')
> location hdfs_path;
分区可以通过多个维度来进行。例如通过日期划分之后,我们可以根据国家进一步划分,使用 PARTITIONED BY从句,该从句接受一个字段列表:
hive> CREATE TABLE logs (ts BIGINT , line STRING)
> PARTITIONED BY (dt STRING,country STRING);
当导入数据到分区表时,分区的值被显式指定:
hive> LOAD DATA INPATH '/user/root/path'
> INTO TABLE logs
> PARTITION (dt='2001-01-01',country='GB');
查看外表信息:
hive> desc extended table_name;
查看表分区:
hive> show partitions table_name;
更改列属性:
hive> alter table table_name change column col_name_old col_name_new col_type;
删除表:
hive> drop table if exists table_name;
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。