0 votes
1 view
in Big Data Hadoop & Spark by (11.5k points)

I am new to the hive and want to know if there is any way to insert data into hive table as we do in SQL. I want to insert my data into hive like

INSERT INTO <tablename> VALUES (val1,val2..)

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?

1 Answer

0 votes
by (31.4k points)
edited by

Since the previous Hive version faced a lot of problems in inserting values in a table in Hive.

The latest updated version of Hive(with ACID support) has arrived, where we can directly insert values into Hive table.

CREATE TABLE player (name VARCHAR(64), age INT);


 VALUES ('Amit', 25), ('Prateek', 24);

But still, if your system doesn’t support the queries, just follow the syntax below and make sure that you have a minimum 0.14 version of Hive.

Standard Syntax:

INSERT INTO TABLE tablename [PARTITION (partcol1[=val1], partcol2[=val2] ...)] VALUES values_row [, values_row ...]


Where values_row is:

( value [, value ...] )

where value is either null or any valid SQL literal

If you are a beginner in Hive, you can refer to the following video which will teach you Hive from scratch: 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !