Monday 26 September 2022

Hana Table Migration using Export & Import

Requirement –


One of most common requirement in Hana is to move user defined table from one Hana environment to another (Ex: Dev > QA > Prod). Here is one of the method i.e. Export & Import we can use.

Solution –


Will migrate the Hana Table from Source Hana Environment to Target Hana Environment.

Step 1 Export Table – First we have to export the table from source system.

Connect to source Hana system and create sample table and load data using below script or any other script.

CREATE COLUMN TABLE XX.IMPORT_EXPORT (ID INTEGER, NAME NVARCHAR (100), AMOUNT DECIMAL (38, 18));

DO BEGIN
DECLARE v_NEW_ID INTEGER;
DECLARE v_COUNTER INTEGER;
DECLARE v_NAME NVARCHAR (100);
v_COUNTER = 1;
WHILE v_COUNTER <= 100000
DO
INSERT INTO XX.IMPORT_EXPORT VALUES (:v_COUNTER, 'A', 100);
v_COUNTER = :v_COUNTER + 1;
END WHILE;
END;

Click on File menu in Hana Studio -> Select Export Option.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

Export screen will appear. Type Catalog in the search box and Catalog Object will come on the screen. Select this option and hit Next

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

Select Source Hana Database on next screen and click next.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

Now, select which table needs to be exported.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

On next screen we will see additional configuration for the Export.

i. Column Table Format – We can choose the Export format as Binary or CSV.
ii. Including Data – Checking this checkbox will Export table with data.
iii. Including Dependencies – Checking this checkbox will Export table with it’s dependent objects like Triggers.
iv. Export Location – We can save the exported table to Server or to Local System.
v. Export Options – We can define the Number for Parallel Threads can be used during export.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

After clicking finish, table we get exported to provided location and create folders like below.

Export of table completed now.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

Step 2 Import Table – As table is exported now we can import the table into target Hana environment using below steps.

Connect to Target Hana system. Click on File menu in Hana Studio -> Select Import Option.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

Import screen will appear. Type Catalog in the search box and Catalog Object will come on the screen. Select this option and hit Next

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

Select Target Hana Database on next screen and click next.

Note – Here, I have used same System as Target and Source for testing purpose. Before Importing, I have dropped the table from database.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

On next screen we have to choose location at which we exported the table in Step 1.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

Next screen will show the exported table name.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

On next screen we will see additional configuration for the Import.

1. Including Data – Checking this checkbox will Import table with data.
2. Including Dependencies – Checking this checkbox will Import table with it’s dependent objects like Triggers.
3. Import Options – We can define the Number for Parallel Threads can be used during Import.
4. Replace Existing Catalog Objects – This option will overwrite the existing objects during import.

SAP HANA Exam, SAP HANA Career, SAP HANA Tutorial and Material, SAP HANA News, SAP HANA Guides, SAP HANA Prep, SAP HANA Preparation

After clicking finish table will get imported in the target system.

No comments:

Post a Comment