cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert values into newly created column of a table

0 Kudos

Hi,

I have created a table in hana through hana studio and inserted data.

Later I have added one more new column to that table,

Now I want to insert values only  to that new column

What is the syntax for that.

Can any one help me in this.

Thanks In Advance

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi All,

I tried in this way and it solved my problem.

I took whole table data in to excel and deleted the records in table.

Now I added new column to this excel and copied the data for it into the excel and then reloaded the data into table using flat file.

I got the required data in to my table.

But this went well as I have only few thousand records in my table.

former_member184768
Active Contributor
0 Kudos

Glad to know that it worked for you. But imagine if your table contains few million records. In that case UPDATE will come handy.

Having said that, whatever works is always a good solution.

Ravi

former_member182302
Active Contributor
0 Kudos

+1 to Ravindra's reply.

Hi Chandrakala,

Am curious to know why you wouldn't want to use UPDATE statement and do the steps as you mentioned. Wanted to know if you tried it and it didn't work for you or any-other reasons?

Regards,

Krishna Tangudu

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Kala,

For the Insertion :

create column table x ( a int, b int );

insert into x values (1,1);

insert into x values (2,2);

create column table y ( a int, b int );

insert into y values (1,1);

insert into y values (2,2);

For Update:

<update_column_name_list>> ::= ( <column_name>[{, <column_name>}...] ).

Try this as well.

Thanks.

Rajesh Bikkasani

0 Kudos

Hi ..

Thanks for your reply..

I want to insert the values for the new column only..Not all other columns.

I want insert all the values at once..

Plz suggest

Thanku

former_member184768
Active Contributor
0 Kudos

Hi,

Please understand that in the relational world, if the table already contains data, then any additional column needs to be UPDATED. You can "insert" data only in one column in a table which already contains data using "update table" operation.

As mentioned, you can do one thing.. create another table dept_b with key columns and the additional columns like dept_id and salary and insert the data in the dept_b table. Then update your original DEPT table for the salary from dept_b table comparing the dept_id from both the tables.

As mentioned please refer to the syntax on the link mentioned below. It will help you learn HANA more effectively rather than asking for the "readymade" answer on the forum.

Ravi

Former Member
0 Kudos

Hi ,

Try the below syntax.

0 Kudos

I want to insert the values directly to that column only...

Example let us take department table..

perviously I have Dept ID, Dept name and respective data.

Now I have added Salary to that table.

I want insert  all values for Salary column only..

Please suggest on this

former_member184768
Active Contributor
0 Kudos

Please UPDATE the table with the data for the new column. So you need to do something like:

UPDATE DEPT set SALARY = value where DEPT_ID = dept_id_value;

UPDATE - SQL Reference - SAP Library

There are multiple ways to update. Refer to the documentation and use the appropriate option.

Regards,

Ravi

0 Kudos

Hi ..

Thanks for your reply..

I want to insert the values for the new column only..Not all.

I want insert all the values at once..

Thanku