Working with Tables in SAP HANA

Working with Tables in SAP HANA
  • In this article, we will learn following:
  • How to create, update and delete tables in SAP HANA.
  • How to see definition and data preview of tables.
  • How to change column type of a table.
Create Table in SAP HANA:

Create a table using standard SQL
1. Select your Schema. Right click and select "SQL Console". Otherwise you can also click on "SQL" button on top panel as shown in below figure.


2. Copy the SQL statement below in SQL editor. 

CREATE COLUMN TABLE TEST_TABLE1 ( 
        ID INTEGER, 
        NAME VARCHAR(10), 
        DESCRIPTION VARCHAR(100), 
        PRIMARY KEY (ID) ); 

* Click on Execute (or F8) 


* Right-click on Tables under the Navigator Tab and click on Refresh to display the name of the newly created table. 


 * Right click on the table and click on "Open Definition" to see the table details. 


Create a table with the SAP HANA Studio tools:
1. Select your Schema. Right click and select "New Table" 


2.Enter the Table Name
3.Choose the Table Type, e.g. "Column Store"
4.Enter the required table fields, data types, Key characteristics, etc. by clicking on the "+" sign below, and click on the Create table icon (or F8) when ready. 


Enter data in table and display data preview:

1. Open SQL Editor and copy below SQL statements. Click on Execute icon (or F8).
INSERT INTO TEST_TABLE1 VALUES (1, 'A', 'A12345'); 
INSERT INTO TEST_TABLE1 VALUES (2, 'B', 'B12345');


2. Right click on the table and select "Open Content". This will show the content of the table as shown in image below. 


Change Column Type of Tables:

1. You can change the table type from COLUMN to ROW or vice-versa. Open the SQL editor and copy the below SQL statement. Click on Execute (or F8). 
ALTER TABLE TEST_TABLE1 ALTER TYPE ROW;

2. Open the table definition by right clicking on table and selecting "Open Definition". Check that the table type has been changed from COLUMN to ROW.


You should now be able to create and work with tables in SAP HANA. If you still have any doubt or question please leave a comment or contact us using "Contact Us" option in the Menu.. 

Note: In HANA there are 2 types of tables. Row based and Column based. 
For more details on these, read Row based and Column based tables in HANA 

2 comments: