HiveQL:資料操作(四) 阿新 • • 發佈:2019-01-31 向管理表中載入資料: hive> load data local inpath '/home/zkpk/test' overwrite into table testpar partition (day='0925');//0925分割槽內的資料會先刪除 通過查詢語句向表中插入資料: hive> insert into table testpar > partition (day='0926') > select * from test; hive> select * from testpar; hive> insert into table testpar > partition (day='0922') > select * from test > where age >20; hive> from test > insert into table testpar > partition (day='0921') > select * where age>22; hive> from test ts > insert into table testpar > partition (day='0920') > select * where ts.age>20 > insert into table testpar > partition (day='0919') > select * where ts.name='張三'; ===動態分割槽插入==== 在test表中新增一列day hive> alter table test add columns(day string); 1 張三 20 0921 2 李四 22 0922 3 Jarrey 25 0923 載入資料: hive> load data local inpath '/home/zkpk/test' overwrite into table test; 動態分割槽(下面兩種方式實現的效果是一樣的): hive> set hive.exec.dynamic.partition=true; hive> set hive.exec.dynamic.partition.mode=nonstrict; hive> set hive.exec.max.dynamic.partitions.pernode=1000; hive> insert into table testpar > partition(day) > select * from test; hive> insert into table testpar > partition(day) > select id,name,age,day from test; 單個查詢語句中建立表並載入資料:(注意關鍵字as) hive> create table newtest > as select id,name,age from test > where name='李四'; hive> select * from newtest; =======匯出資料========== hadoop fs –cp source_path target_path cp scp -r /jdk slave://home/zkpk/ Sqoop工具(T15)