欢迎投稿

今日深度:

hive(一) hive表操作,

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;

www.htsjk.Com true http://www.htsjk.com/hive/31654.html NewsArticle 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 ter...
相关文章
    暂无相关文章
评论暂时关闭