首页 > SAP > HANA > How to create tables using hdbtable in SAP HANA
2019
08-27

How to create tables using hdbtable in SAP HANA

Hello everyone, in this tutorial we will learn how to create tables using hdbtable in SAP HANA.In this tutorial i will create a table in SAP HANA Cloud Trial Instance.If you have access to your own SAP HANA system you can still follow these syntax.

Using hdbtable syntax you can create design-time file in the repository to create tables in SAP HANA.Table will be created in HANA database when you successfully activated the file.

1.Prerequisites

You have access to SAP FREE HANA Cloud Platform.if you don’t have click here to get developer access.
You should have created a new HANA Instance. To know how to create click here.

2.Step-by-Step Procedure

1. Logon to SAP HANA Cloud Platform cockpit.

2. In SAP HANA Cloud Platform cockpit, choose HANA Instance from the menu and click on development workbench tools.

HANA Web-based Development Workbench

3. You should see development workbench editor like below.

HANA Development Workbench

4. Now click on drop down beside to the plus sign to navigate to the HANA Catalog.

5. You should see the screen like below.

6. You can see the list of schema available, NEO_ is the your schema. We are going to create tables under this schema only.

7. Now go back to development workbench editor and expand your package and right click on the package → choose Create File.

8. Provide the file name EmpTable.hdbtable. “EmpTable” is your table name. Copy the below hdbtable syntax and paste it in the file.

9. Now we will look at the above syntax

table.schemaName – schema name in which you want to store the table.
table.tableType – table type of the table.

There are 2 possible values COLUMNSTORE (or) ROWSTORE.

table.temporary – this option makes the data in the table session-specific, data from the local temporary table is automatically deleted when the session is terminated.

There are 2 possible values true (or) false.

table.loggingType – this option enables logging in a table.

There are 2 possible values LOGGING (or) NOLOGGING.

table.columns – this option enables to add columns to the table

name – column name
sqlType – column data type
nullable – true/false
unique – true/false
length – length of the column
scale – E.g:- 3,10,15
precision – E.g:- 2,3,5
defaultValue
comment 

table.indexes – this option enables to create indexes to the table.

table.primaryKey.pkcolumns – this option enables to create primary keys in the table.

Below are the different SQL TYPES you can use when declaring the columns.

DATE
TIME
TIMESTAMP
SECONDDATE
INTEGER
TINYINT
SMALLINT
BIGINT
REAL
DOUBLE
FLOAT
SMALLDECIMAL
DECIMAL
VARCHAR
NVARCHAR
CHAR
NCHAR
CLOB
NCLOB
ALPHANUM
TEXT
SHORTTEXT
BLOB
VARBINARY

10. Now head back to your SAP HANA catalog to see the table which we created.

Congrats, you have successfully created table in SAP HANA.Please stay tuned to us for more SAP HANA tutorials.Please feel free to comment and let us know your feedback. You feedback will keep us alive.

最后编辑:
作者:yangsen
这个作者貌似有点懒,什么都没有留下。