Creating an SAP HANA table without coding-Graphical Method
Welcome folks to the next HANA tutorial on how to create SAP HANA table without any coding required. These tables can be easily created for testing and quick analysis. However these are not the preferred method of creating tables when the intention is create a custom table for transport from your development environment to quality assurance systems and productive systems.
The main methods to create a table are:
- Using the graphical method which will be discussed here.
- Using the SQL Script method discussed in a separate tutorial.
- Using the HDB tables method discussed in a separate tutorial.
- Using the HDBDD method discussed in a separate tutorial.(Recommended method in non XSA projects).
- Using the HDBCDS method which would be discussed in a future tutorial(Recommended method in XSA projects).
Be sure to read all in the same order to fully understand the concept.
Creating our first SAP HANA Schema
Coming back to the graphical method, this can create a HANA table in a matter of minutes and is my usual way of creating them if I want to test any logic that needs us to create a table in SAP HANA. To do this, we expand the catalog folder as all the tables are always grouped in catalogs.
On expansion, you would see another kind of folder shown by the red arrow below. These are called “Schemas”. These are usually used to group tables of a similar source/ similar purpose. Each username by default gets its own schema but you can also create one.
To create a schema is quite a simple activity. It involves a line of SQL.
Click anywhere in this tree of folders and you’ll see the SQL button marked below become active. Click on it to open the SQL editor.
The new SQL editor that opened up below is where we will type in the code.
The code is as simple as basic English.
The syntax is CREATE SCHEMA “<Schema_Name>” . Let’s call the schema 0TEACHMEHANA. I am using the 0 prefix so that when the system sorts schemas, this one comes up somewhere at the top making it easier for me to screenshot. You are free to use any naming applicable to your project.
Note: Any system object like table names, field names, procedure names etc. should be enclosed in a double quote and any values for character fields like ‘Apples’ go in single quotes.
Press the execute button marked below or F8 on your keyboard to create this schema. The log below confirms that the execution was performed without any errors.
HANA doesn’t auto refresh folder trees and we have to manually do it to see new objects that are created. Right click on catalog and select Refresh from the context menu as shown below.
As seen below, our schema is now available.
Creating a SAP HANA table using the graphical method
Now that we have a schema, let’s create a HANA table under it using the graphical method and name it CUST_REV_GRAPH.
To do this, expand the schema and right click on the Tables folder and select “New Table” from the context menu.
This brings up the screen shown below. Here we need to provide a table name and the fields that are required along with their data types (If you are not aware of the major data types in SQL, click here for my tutorial on the topic). The schema name is pre-filled as we right clicked on options inside this schema. Also, the type is always column store by default (You can choose to switch to row store by clicking the drop down but is not recommended for analytical applications. To know more about Row and Column stores, follow this link)
As seen below, I’ve filled up the table name, the first column name as CUST_ID, data type as NVARCHAR (as discussed in our data type tutorial, we don’t use VARCHAR as it has no Unicode storage), a length as 10 for this string and mark this field as key to the table. A key should be marked when the field can by itself or with other key fields, identify a row of data uniquely. Since there will be only one row per customer ID in my table, I mark this as key. As soon as you enable the Key column, the Not Null auto enables as a key field can never be Null. Also, an optional comment field can be added which is a description of the field. When done, press the green plus symbol marked below to add another field and similarly add all required fields for the table.
Note: Null denoted by ‘?’ in HANA default settings denotes the non-existence of a value for that field. Null is not zero or blank ‘’ but is a symbol for non-existence of any value.
After adding all the fields, press the green Execute button to create the table.
The messages on top confirm our success in doing so.
Refreshing the “Tables” folder under our schema would reveal this new achievement.
Congrats! You just created your very first HANA table as shown below.
Be sure to check out the tutorials to create tables via SQL script, HDB tables and CDS tables. Those are alternate methods and are really important to your growth as a HANA developer.
Please share this document on social media using the share buttons below to show your support for the website and subscribe to our newsletter for the latest updates.
Until Next time – Happy learning!