How to Add / Drop Table Column in HANA database

To be honest, we never experience any activity which required of removing or adding the table column in HANA database. SAP Basis might be rarely involved with the table modification kind of works. We think so, at least for us!

But, there will no harm of getting this how-to published and we all get to learn a new thing, correct?

Dropping HANA Table Column (Command)

We’ll start with drop first so, below command will remove the specified column from the table.

ALTER TABLE "SAPABAP1"."BUDU" DROP(BELACAN);

Statement 'ALTER TABLE "SAPABAP1"."BUDU" DROP(BELACAN)' 
successfully executed in 8 ms 404 µs  
(server processing time: 6 ms 730 µs) 
- Rows Affected: 0

Adding HANA Table Column (Command)

You can testing it out by adding back the deleted column from above step.

ALTER TABLE "SAPABAP1"."BUDU" ADD(BELACAN NVARCHAR(10))

Statement 'ALTER TABLE "SAPABAP1"."BUDU" ADD(BELACAN NVARCHAR(10))' 
successfully executed in 10 ms 1 µs  
(server processing time: 8 ms 231 µs) 
- Rows Affected: 0 

Syntax

  • ADD = Add new column
  • DROP = Remove the existing column
  • SAPABAP1 = Schema
  • BUDU = Table Name
  • BELACAN = Data Type
  • 10 = Dimension

Alternatively, you can also use the SAP HANA Studio to execute above tasks.

Dropping HANA Table Column (HANA Studio)

Step 1: Double click on the table and right click to select Edit.

Step 2: To remove a column, right click on the column (BELACAN, for this example) and select Remove Column.

Step 3: Once done, press F8 (Alter Table) to commit the change.

 Statement 'alter table "SAPABAP1"."BUDU" drop ("BELACAN")'
successfully executed 
Affected Rows:0 in 12 ms 672 µs 

Adding HANA Table Column (HANA Studio)

Step 1: Click on the + icon. You can now type in the Column name, select the Data Type and enter the Dimension.

Step 2: To commit the change, press F8 and you will get below message if it’s successful.

Statement 'alter table "SAPABAP1"."BUDU" add ("BELACAN" VARCHAR (1) not null)' 
successfully executed 
Affected Rows:0 in 7 ms 7 µs 

You May Also Like

Leave a Reply?