Quantcast
Channel: SCN : Blog List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 676

EXPORT SCHEMA – RENAME OFFLINE – IMPORT SCHEMA

$
0
0

INTRODUCTION:

 

This document is regarding a solution for a specific requirement (mentioned below) that I had when working on a SAP HANA project for a client.

 

REQUIREMENT:

 

I had a requirement to export a complete schema (SCHEMA X) from one system (Development  - BD2) and import to another schema (SCHEMA Y) (Quality system – BQ2) so as to make all tables available in target schema as available in source.

 

SCHEMA X in target system has all the catalog objects as in source system.

 

Therefore when SCHEMA X is exported from source and imported into target system, HANA system raises an error that the catalog objects (in my case - tables) already exist in target system (as the exported file contains references to SCHEMA X and not to SCHEMA Y).

 

PROCESS:

 

To achieve the above requirement, just exporting and importing catalog object will not work as the source schema name is different from the target schema.

 

Also there is SCHEMA MAPPING option from HANA Modeler perspective which is suitable for modeling views but the method I used is a common approach for moving the catalog objects from one schema to another.

 

Source schema: ARJUN (Development)

Target schema: SRIVATSAN (Quality)

 

All the tables available in ARJUN schema of DEV system has to be exported and imported to SRIVATSAN schema of Quality system.

 

Both the schemas are available in Quality system.

 

ARJUN schema in quality system already has all the tables as development system so there is a requirement to rename all the occurrences of ARJUN to SRIVATSAN in the table creation code after the EXPORT.

 

 

 

Step 1: EXPORT the source schema (ARJUN)


  • Right click the schema and choose EXPORT

1.jpg

 

2.jpg

  • Click Next.

 

3.jpg

 


  • Choose Type as BINARY.
  • Provide an empty folder path for the export.
  • Click Finish.


4.jpg

 

Step 2 : Renaming the exported schema (from ARJUN to SRIVATSAN).


  • Open NOTEPAD++ (Advanced text editor that I used for renaming)
  • Press Ctrl + F
  • Go to Find in Files
  • Enter the text to be found and text to be replaced with.
  • Choose the Directory in which the exported file is present.

 

5.jpg


  • Click Find All.
  • All occurrences of the search text are displayed.


6.jpg

 


  • Again press Ctrl + F , open  “Find in Files” tab.


7.jpg

 

  • Click “Replace in Files”.


8.jpg

 

  • Click OK.
  • Now, all the table creation statements of the exported schema will have SRIVATSAN instead of ARJUN.


 

9.jpg

 

 


  • Also it is necessary to RENAME the folder present inside the index folder to the name of the SCHEMA to which the file has to be imported.


10.jpg

Now, the exported binary file is ready to be imported to the target schema (SRIVATSAN) of target system (Quality).

 

Step 3 : Import the catalog object.


  • Go to HANA studio.
  • Click FILE -> IMPORT.


11.jpg

 

  • Choose “Catalog objects” under SAP HANA.


12.jpg

 


  • Choose the target system (Quality).


13.jpg

 


  • Click NEXT.
  • Choose the Location of the exported file.


14.jpg

 

  • Click Next.
  • Choose the required tables that are to be imported to target system.


15.jpg

 


  • Click Next.
  • Choose the required options for DATA and THREADS.


16.jpg

 

  • Click Finish.

 

Now, the tables that are required are imported to SRIVATSAN schema.

 

Conclusion:

 

This approach is a general method to  copy tables from one system to other (different schemas). This might be achieved even through SCHEMA MAPPING which I haven’t tried practically.


Please share your views and comments.


Viewing all articles
Browse latest Browse all 676

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>