cancel
Showing results for 
Search instead for 
Did you mean: 

want to add column in HANA Tables

sreelatha_reddy2
Participant
0 Kudos

Hi ,

I have created a table with few columns and loaded the data.Now I would like to add a new column and load the data to it .Could you please let me know how to do it.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sreelatha-

There are some posts already related to adding/removing a column . Please check before posting a new thread.

Adding a new column:


    ALTER TABLE <tablename> ADD (<columnname> <datatype>);

Example:


ALTER TABLE emp_t ADD(emp_id nvarchar(10));


Removing an existing column:


ALTER TABLE <tablename> DROP (<columnname> <datatype>);

Example:


ALTER TABLE emp_t DROP(emp_id nvarchar(10));

Thanks

Happy learning

sreelatha_reddy2
Participant
0 Kudos

Hi All,

I tried adding column to the table using Alter command and it was successful. But when I am trying to drop the column I am getting the syntax error.

alter table "ID42588"."CUSTOMER" add (custphone nvarchar(10));

alter table "ID42588"."CUSTOMER" drop (custphone nvarchar(10));

Error  Message

sql syntax error: incorrect syntax near "nvarchar": line 1 col 50 (at pos 50);

Please help

sreelatha_reddy2
Participant
0 Kudos

Hi,

I dropped the column by the below syntax:

alter table "ID42588"."CUSTOMER" drop (custphone);

Former Member
0 Kudos

Hi Sreelatha-

Yes. I did not notice when I was copy-paste. This would be correct.

Removing an existing column:

  1. ALTER TABLE <tablename> DROP (<columnname>);

Example:


ALTER TABLE emp_t DROP(emp_id );

Thanks

Happy learning

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sreelatha,

Please read some developer guides before posting a query like this.You can make use of SQL Scripts for performing this operations.

Please refer:UPDATE - SAP HANA SQL and System Views Reference - SAP Library

Regards,

Kannan

Former Member
0 Kudos

Hi Kannan,

This can not be done using Update statement. For adding or removing a column you need to make use of DDL statement "ALTER". "UPDATE" is a DML statement and is to update the content of the table and not the structure of the table.

Regards,

Piyush