hive 常用sql记录

记录一些hive常用的sql

hive sql

创建表,分区表,查看建表语句:
CREATE TABLE IF NOT EXISTS t1( 
    id INT,                 // 整型
    name STRING,            // 字符型
    money decimal(10,2),    // 浮点型
    log_time TIMESTAMP,     // 时间类型
    log_date DATE           // 时间date
    )
    using parquet 
    partitioned by (log_date)
    LOCATION '/test/t1'     // 文件挂载的路径

show create table {table_name}

修复分区,查看分区:
msck repair table {table_name}
show partitions {table_name}

删除表:
drop table {table_name}

查询:
select * from t1 where log_date = to_date('2011-01-01') # 必须用to_date函数,至于为什么还不清楚
Life is more than the present.