Insert Into HANA Table Specifying Columns

Viewed 211

I'm coming from a Teradata environment where

create table mytable  
(  
first_column varchar(50),  
second_column varchar(50),  
third_column varchar(50)  
)  

insert into mytable values (first_column = 'one', second_column = 'first')  
insert into mytable values (first_column = 'two', third_column = 'second')

is possible. This does not seem to be possible in HANA even with default specified

create column table mytable 
(  
"FIRST_COLUMN" varchar(50) default null,  
"SECOND_COLUMN" varchar(50) default null,  
"THIRD_COLUMN" varchar(50) default null  
)

I could create a row with a unique ID specifying NULLs for all the fields and then UPDATE the columns I want using the ID which seems time consuming and awkward or is there a better way?

1 Answers

Use the standard syntax:

insert into mytable (first_column, second_column)
    values ('one', 'first');

This should work both in Hana and Teradata -- and any other database.

Related