I am new to hive, and want to know if there is anyway to insert data into hive table like we do in SQL. I want to insert my data into hive like
INSERT INTO tablename VALUES (value1,value2..)
I have read that you can load the data from a file to hive table or you can import data from one table to hive table but is there any way to append the data as in SQL?
Some of the answers here are out of date as of Hive 0.14
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-InsertingvaluesintotablesfromSQL
It is now possible to insert using syntax such as:
No. This
INSERT INTO tablename VALUES (x,y,z)
syntax is currently not supported in Hive.To insert entire data of
table2
intable1
. Below is a query:I think in such scenarios you should be using HBASE which facilitates such kind of insertion but it does not provide any SQL kind of query language. You need you use Java API of HBASE like the put method to do such kind of insertion. Moreover HBASE is column oriented no-sql database.
You can use the table generating function stack to insert literal values into a table.
First you need a dummy table which contains only one line. You can generate it with the help of limit.
Now you can create a new table with literal values like this:
The first argument of stack is the number of rows you are generating.
You can also add values to an existing table:
Enter the following command to insert data into the testlog table with some condition: