Different Ways to Insert, Update Data in Hive Table

BigDataElearning
BigDataElearning
20.2 هزار بار بازدید - 7 سال پیش - Official Website:
Official Website: http://bigdataelearning.com

Different ways to insert , update data into hive table:

Insert statement:
INSERT statement is used to insert values into hive table from a local unix file, or HDFS file, or the data from another hive table.  We can also insert some hard coded values into the hive table, by specifying them directly in the query.

Use this statement to insert data from a local unix file into a hive table.
LOAD DATA LOCAL INPATH 'local-filepath' OVERWRITE INTO TABLE tablename  (for loading from a local file)

And this statement to insert data from a HDFS file into a hive table
LOAD DATA INPATH 'hdfs-filepath' OVERWRITE INTO TABLE tablename   (for loading from a HDFS file)


You can use this statement to load data into the table by querying the data from another table:
INSERT OVERWRITE TABLE tableName1 SELECT * FROM tableName2;


The below INSERT INTO statement can be used to insert few values directly into the table by specifying the data directly in the query.
INSERT INTO TABLE students  VALUES ('fred flintstone', 35, 1.28), ('barney rubble', 32, 2.32);


Update statement:
Update statement is used to update certain or all rows of the hive table using certain confitions.

Below is the statement used to update certain rows of a table based on certain conditions

UPDATE tablename SET column = value WHERE expression;

UPDATE table statement is available from hive 0.14 and above
7 سال پیش در تاریخ 1396/10/12 منتشر شده است.
20,281 بـار بازدید شده
... بیشتر