🎓beginner⏱10 min.SAP HANA CloudBeginnerSAP HANA CloudSAP HANA DatabaseSAP Business Application Studio
You will learn
โHow to change table definition in an HDBTABLE object
โHow to recreate the table using an HDBMIGRATIONTABLE object
โHow to change table definition in an HDBMIGRATIONTABLE object
โHow to insert migration definition in an HDBMIGRATIONTABLE object Are you wondering what the best way is to manage changing data structures? Do you want to know how to collaborate more efficiently when working in development projects?
To answer the first question, learn what benefits different table types in SAP HANA Cloud, SAP HANA database can offer you based on your needs. The following 3 tutorials in this tutorial group will help you navigate through your challenges with the managing data structures:
Get started to collaborate in SAP Business Application Studio
Import data into a table in SAP HANA Database Project
You are here โChange data structures using HDBTABLE and HDBMIGRATIONTABLE objects
To answer the second question, create template projects that help you set up service connections, handle synonyms and prepare authorization management. You can create these templates once in the beginning and give your project team members a head-start. Using the template, they can build on your work and can quickly start working productively.
The following 4 tutorials in this tutorial group will help you learn how to collaborate efficiently:
Prepare your SAP HANA Database Project for collaboration
Generate users and roles for assigning privileges
Enhance your project with services, synonyms, and grants
Collaborate on an SAP HANA Database Project template
This tutorial will show you how to change data structures using HDBTABLE and HDBMIGRATIONTABLE objects.
Step 1Change data structures using `HDBTABLE` and `HDBMIGRATIONTABLE` objects
โ
Now that your table is created and the data is imported, we will change the structure of this table by adding two columns. You can then examine in the terminal how this type of object handles data structure changes, which we will compare to other table types later.
Go back to SAP Business Application Studio and select your inventory.hdbtable.
Add two columns to the table definition by copying the following code and pasting at the end of the line 30.
SQL
“ADDITIONALATTRIBUTESTRING” NVARCHAR(10),
“ADDITIONALATTRIBUTESTRINGNN” NVARCHAR(10) NOT NULL DEFAULT ‘TEST’
Code
Make sure to paste these lines in between the last column definitions and the closing parenthesis `')'` in **line 31**. The last previous line of column definitions needs to have a ',' at the end.
The new table definition should look like this image:

3. Now you can deploy this updated object again to your database by clicking on the  deploy icon in the SAP HANA Projects panel. You can either deploy only the file `inventory.hdbtable` or the whole project.
### Verify the changes to the data structure using Database Explorer
1. Once the table was successfully deployed, you can check if the data is still in the table by going back to the SAP HANA Database Explorer and refreshing the table.
2. In the table definitions, you should now see that two additional columns have been added to the table and opening the data should not result in any changes to the number of rows in the previous graph.

You may also check the data in the table to verify that it contains the same data as it had earlier. You can do this by comparing the output graph of [Step 5 from the previous tutorial](hana-cloud-collaborative-database-development-2) to what you get with the current table.
> ### **Important**
> While making changes to data structure using `HDBTABLE`, your database recreates the existing table with the updated table definition and copies the existing data into it. This is not the most efficient way to use your database capability if you have large amounts of data present in these tables.
> To highlight how to make changes to data structures efficiently, you will use an `HDBMIGRATIONTABLE` in the next section. In comparison to using an `HDBTABLE`, an `HDBMIGRATIONTABLE` can save considerable time and resources while handling changes in data structures.
### Recreate the table using an HDBMIGRATIONTABLE object
Now that you know how `HDBTABLE` objects handle data changes, you can use a different type of object to add two more rows to this table.
1. Go back to SAP Business Application Studio. Right-click your `inventory.hdbtable` and select Duplicate.

2. Now, you can see a new file named `inventory_copy.hdbtable` in your `src` folder. Right-click on this file and select Rename. Rename the file as `'inventory.hdbmigrationtable'`.
>**Important:**
> Before you deploy the new file `inventory.hdbmigrationtable`, you must make a change to the already existing `inventory.hdbtable` file. Otherwise, the deployment will result in an error. Adding the ending `'.txt' ` to the file name will signal to SAP Business Application Studio, that this file shall not be deployed to create an HDI object in the database.
3. Rename the `inventory.hdbtable` as `inventory.hdbtable.txt` to facilitate the deployment of `inventory.hdbmigrationtable`.
4. Now, click on the `inventory.hdbmigrationtable` file. Copy and paste the following code at the beginning of the file such that it comes before the table definition.
```SQL
== version = 1

On the bottom left corner, you can see the file inventory.hdbmigrationtable in the SAP HANA Projects panel. Click on the deploy icon for the file to deploy the changes to your HDI container.
In the terminal you can see that the table was successfully deployed.
Go back to the SAP HANA Database Explorer, right-click on Tables and select Refresh to update the changes you made to the table.
Click on the INVENTORY table to view the list of all the columns present. Here, you can verify that deploying the inventory.hdbmigrationtable has produced exactly the same results as with inventory.hdbtable.
Step 2Change table definition in HDBMIGRATIONTABLE object
+
The next step is to change the data structure of the table by adding two new columns. We will again duplicate our table change the previous version of this file to a .txt file that will not be deployed. Then, we will adjust the code of the hdbmigration object to define how to migrate from Version 1 of hdbmigrationtable to Version 2. For this, follow the next steps.
Go back to SAP Business Application Studio.
In the Explorer panel, right-click on the inventory.hdbmigrationtable and select Duplicate.
Now, you can see a new file named inventory_copy.hdbmigrationtable in your src folder.
Right-click on the original inventory.hdbmigration file and rename this file as 'inventory.hdbmigrationtable.V1.txt' to facilitate the deployment of the new copy of the hdbmigrationtable.
Rename to text file
Next, right-click on the inventory_copy.hdbmigrationtable file and select Rename. Rename this file as inventory.hdbmigrationtable.
Now, click on the inventory.hdbmigrationtable file. Adjust the first line of code to version 2 and paste the following two lines of code at the end of the file.
Step 3Insert migration definition in HDBMIGRATIONTABLE object
+
An hdbmigrationtable object also needs to have a block of code at the very end that defines all migration steps. The following code will do just that, so paste it below the closing parenthesis of the table definition.
The above step changes the data structure by adding two new columns into the table by using the ALTER command. In this way you can efficiently avoid the need to recreate the table and copy data into it.
Now, deploy your project to the database by clicking on theDeploydeploy icon on the project level WS3_1/db. In the terminal you can see that the table was successfully deployed. Follow the next steps to verify the changes made to the column definition.
Go back to the SAP HANA Database Explorer and Refresh your table to update the changes made to the table.
Click on the INVENTORY table to view the list of all the columns present. Here, you can see that two additional columns have been added to the table.
Updated INVENTORY table
And now you know how to manage changing data structures using HDBTABLE and HDBMIGRATIONTABLE design-time objects.
You have successfully completed the third tutorial. In the next tutorial, you will prepare your project for collaboration by creating HDBROLEs and synchronizing your SAP HANA Database Project with Git.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 4
1. Change data structures using `HDBTABLE` and `HDBMIGRATIONTABLE` objects2. Change table definition in HDBMIGRATIONTABLE object3. Insert migration definition in HDBMIGRATIONTABLE object4. Test yourself
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.