I am looking for an equivalent of bellow query for Hive version 0.13.1.
INSERT INTO TABLE table1 VALUES
(151, 'cash', 'lunch'),
(152, 'credit', 'lunch'),
(153, 'cash', 'dinner');
from this answer it is clear "INSERT.... VALUES" query available after version 0.14.
so what is equivalent of above query for given hive version?
Syntax: INSERT INTO TABLE <table_name> VALUES (<add values as per column entity>); Example: To insert data into the table let's create a table with the name student (By default hive uses its default database to store hive tables).
Insert the same data into multiple cells using Ctrl+Enter Select all the blank cells in a column. Press Ctrl+Enter instead of Enter. All the selected cells will be filled with the data that you typed.
INSERT-SELECT-UNION query to insert multiple records Thus, we can use INSERT-SELECT-UNION query to insert data into multiple rows of the table. The SQL UNION query helps to select all the data that has been enclosed by the SELECT query through the INSERT statement.
Yes, instead of inserting each row in a separate INSERT statement, you can actually insert multiple rows in a single statement. To do this, you can list the values for each row separated by commas, following the VALUES clause of the statement.
If you want to insert multiple values then you can union selects
INSERT INTO TABLE table1
select 151, 'cash', 'lunch'
union all
select 152, 'credit', 'lunch'
union all
select 153, 'cash', 'dinner';
When using the "stack" function, the first number represents the number of rows
INSERT INTO TABLE table1
select stack
(
3
,151 ,'cash' ,'lunch'
,152 ,'credit' ,'lunch'
,153 ,'cash' ,'dinner'
)
or
INSERT INTO TABLE table1
select inline(array
(
struct (151 ,'cash' ,'lunch')
,struct (152 ,'credit' ,'lunch')
,struct (153 ,'cash' ,'dinner')
))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With