You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by mahender bigdata <Ma...@outlook.com> on 2016/05/24 19:57:29 UTC

Insert query with selective columns in Hive

Hi,

Is there a way in Hive to insert specific columns  rather than insert 
query with all columns options. Like
I have table with 10 columns, in my insert statement, i would like to 
insert only 3 columns like below

insert into tbl1 (col1,col2,col10) values (1,2,3);

insert into tbl1 (col1,col2,col10) values (4,5,6);

Above query fails due to syntactic error, I have forcefully need to 
write Insert into tbl1 values (1,2,3.....10); I'm running in Hive 1.2 
version.




Re: Insert query with selective columns in Hive

Posted by Mich Talebzadeh <mi...@gmail.com>.
This should work Mine is Hive 2

hive> create table testme (col1 int, col2 int, col3 int, col4 int);
OK
Time taken: 4.006 seconds

hive> insert into testme values(1,2,3,4);
Loading data to table test.testme
OK
Time taken: 70.844 seconds
hive> insert into testme (col1,col2,col3,col4) values(1,2,3,4);

Loading data to table test.testme
OK
--ignoring col2
hive> insert into testme (col1,col3,col4) values(1,3,4);
Loading data to table test.testme
OK
Time taken: 1.505 seconds
hive> insert into testme (col1,col3,col4) values(4,5,6);
Loading data to table test.testme
OK
-- insert only col4
hive> insert into testme (col4) values(6);

Loading data to table test.testme
OK

HTH

Dr Mich Talebzadeh



LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
<https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*



http://talebzadehmich.wordpress.com



On 24 May 2016 at 20:57, mahender bigdata <Ma...@outlook.com>
wrote:

> Hi,
>
> Is there a way in Hive to insert specific columns  rather than insert
> query with all columns options. Like
> I have table with 10 columns, in my insert statement, i would like to
> insert only 3 columns like below
>
> insert into tbl1 (col1,col2,col10) values (1,2,3);
>
> insert into tbl1 (col1,col2,col10) values (4,5,6);
>
> Above query fails due to syntactic error, I have forcefully need to write
> Insert into tbl1 values (1,2,3.....10); I'm running in Hive 1.2 version.
>
>
>
>

Re: Insert query with selective columns in Hive

Posted by mahender bigdata <Ma...@outlook.com>.
Ping..


On 5/24/2016 12:57 PM, mahender bigdata wrote:
> Hi,
>
> Is there a way in Hive to insert specific columns  rather than insert 
> query with all columns options. Like
> I have table with 10 columns, in my insert statement, i would like to 
> insert only 3 columns like below
>
> insert into tbl1 (col1,col2,col10) values (1,2,3);
>
> insert into tbl1 (col1,col2,col10) values (4,5,6);
>
> Above query fails due to syntactic error, I have forcefully need to 
> write Insert into tbl1 values (1,2,3.....10); I'm running in Hive 1.2 
> version.
>
>
>