#创建新表
Hive> CREATE TABLE t_hive (a int, b int, c int) ROW FORMAT delimited fields TERMINATED by ' \ t ';
#导入数据t_hive. txt to t_hive table
hive> LOAD DATA LOCAL inpath '/home/cos/demo/t_hive.txt ' OVERWRITE into TABLE t_hive;
#正则匹配表名
Hive>show tables ' *t* ';
#增加一个字段
hive> ALTER TABLE t_hive ADD COLUMNS (New_col String);
#重命令表名
hive> ALTER TABLE t_hive RENAME to T_hadoop;
#从HDFS加载数据
hive> LOAD DATA inpath '/user/hive/warehouse/t_hive/t_hive.txt ' OVERWRITE into TABLE t_hive2;
#从其他表导入数据
hive> INSERT OVERWRITE TABLE t_hive2 SELECT * from t_hive;
#创建表并从其他表导入数据
Hive> CREATE TABLE t_hive as SELECT * from T_hive2;
#仅复制表结构不导数据
Hive> CREATE TABLE t_hive3 like t_hive;
#通过Hive导出到本地文件系统
hive> INSERT OVERWRITE LOCAL DIRECTORY '/tmp/t_hive ' SELECT * from t_hive;
#Hive查询HiveQL
From (select B,c as C2 from t_hive) t select t.b, T.C2 limit 2;
Select B,c from t_hive limit 2;
#创建视图
Hive> CREATE VIEW v_hive as SELECT A, from t_hive;
#删表
drop table if exists t_hft;
#创建分区表
DROP TABLE IF EXISTS t_hft;
CREATE TABLE T_HFT (
Securityid STRING,
Tradetime STRING,
PRECLOSEPX DOUBLE
) partitioned by (Tradedate INT)
ROW FORMAT delimited TERMINATED by ', ';
#导入分区数据
hive> Load Data local inpath '/home/bluebreeze/data/t_hft_1.csv ' overwrite into table T_HFT partition (tradedate= 20130627);
#查看分区表
hive> SHOW partitions t_hft;
Hive Common Commands