Ways to insert data into hive table:
for demonstration, I am using table name as table1 and table2
1) create table table2 as select * from table1 where 1=1;
or
create table table2 as select * from table1;
2) insert overwrite table table2 select * from table1;
--it will insert data from one to another. Note: It will refresh the target.
3) insert into table table2 select * from table1;
--it will insert data from one to another. Note: It will append into the target.
4) load data local inpath 'local_path' overwrite into table table1;
--it will load data from local into the target table and also refresh the target table.
5) load data inpath 'hdfs_path' overwrite into table table1;
--it will load data from hdfs location iand also refresh the target table.
or
create table table2(
col1 string,
col2 string,
col3 string)
row format delimited fields terminated by ','
location 'hdfs_location';
6) load data local inpath 'local_path' into table table1;
--it will load data from local and also append into the target table.
7) load data inpath 'hdfs_path' into table table1;
--it will load data from hdfs location and also append into the target table.
8) insert into table2 values('aa','bb','cc');
--Lets say table2 have 3 columns only.
9) Multiple insertion into hive table