向管理表中加载数据: 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); [zkpk@master ~]$ vi test [zkpk@master ~]$ cat test 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)