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:

  1. Using the graphical method which will be discussed here.
  2. Using the SQL Script method discussed in a separate tutorial.
  3. Using the HDB tables method discussed in a separate tutorial.
  4. Using the HDBDD method discussed in a separate tutorial.(Recommended method in non XSA projects).
  5. 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.

SAP HANA TABLE

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.

SAP HANA TABLE

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.

SAP HANA TABLE

The new SQL editor that opened up below is where we will type in the code.

SAP HANA TABLE



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.

SAP HANA TABLE

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.

SAP HANA TABLE

As seen below, our schema is now available.

SAP HANA TABLE SCHEMA

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.

SAP HANA TABLE SCHEMA

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)

SAP HANA TABLE SCHEMA



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.

SAP HANA TABLE SCHEMA

After adding all the fields, press the green Execute button to create the table.

SAP HANA TABLE SCHEMA

The messages on top confirm our success in doing so.

SAP HANA TABLE SCHEMA

Refreshing the “Tables” folder under our schema would reveal this new achievement.

 SAP HANA TABLE SCHEMA

Congrats! You just created your very first HANA table as shown below.

SAP HANA TABLE SCHEMA

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!

<<Previous Tutorial                                                                                                                 Next Tutorial>>

Content Protection by DMCA.com
Tagged , , , , , , , , , , .

13 Comments

  1. Hi Shyam,
    i beginning with HANA, and this material is easy and very clear, thanks a lot for share this information.

  2. Hi Shyam,

    I have been following your blogs bw bex and now HANA. Great Job.I have a question here.How to declare foreign key in graphical table creation method?

  3. Hello Shyam, I totally agree with everyone that it is a great tutorial, but what I don’t understand is what is the difference between HANA Table vs Analytic View. It is always good idea to explain the objective of the writing/tutorial and the purpose of this tutorial. Again good job!! Thanks Jay

  4. Beautiful Tutorial Shyam Sir! Thank you for all your efforts.. 🙂 Can you please provide me link to tutorial – create tables via SQL script, HDB tables and CDS tables ?

Leave a Reply