INSERT in table Hive

391 Views Asked by At

I have created the following table in hive:

hive> CREATE TABLE IF NOT EXISTS Sensorreading ( recvtime String, nodeid int, sensorid int, systemid int, value float);
OK
Time taken: 3.007 seconds
hive> describe Sensorreading;
OK
recvtime        string
nodeid  int
sensorid        int
systemid        int
value   float
Time taken: 0.381 seconds
hive>

And now I need to insert data in it. I have tried this but it don't work:

INSERT INTO TABLE Sensorreading (recvtime, nodeid, sensorid, systemid, value) VALUES ('2015-05-29 11:10:00',1,1,1,-45.4);

How is the syntax of INSERT? Thanks

2

There are 2 best solutions below

5
On

INSERT...VALUES is available starting in Hive 0.14.

Check if your Hive version is 0.14 or later.

0
On

Insert is possible in hive 0.14. But if you need to insert something than there are two ways for it (manual methods , not any paticular command): 1. First you can load it from text file(changes only done in it i.e including your rows in it) 2. You can copy the part file to local and than do changes and then again revert back to regular path.