Export and Import Data with SAP HANA Cloud Data Lake Files
Use SAP HANA Cloud data lake Files as a storage target for exporting and importing data from both an SAP HANA Cloud, SAP HANA database and an SAP HANA Cloud, data lake Relational Engine database.
Overview
You will learn
- How to perform an local export and import of data using CSV files
- How to configure a database credential for the data lake Files container
- How to export and import data and catalog objects between an SAP HANA Cloud, SAP HANA database and data lake Files
- How to export and import data between an SAP HANA Cloud, data lake Relational Engine database and data lake Files
Prerequisites
Prerequisites
- A productive SAP HANA Cloud instance with a data lake (data lake Files is not available in the free tier service plan)
Steps
Intro
This tutorial demonstrates how data can be exported and imported using the import and export application in SAP HANA Cloud Central or through SQL statements. It focuses on using SAP HANA Cloud data lake Files as a storage target for export and import operations. Data lake Files provides a managed file store that is accessible from both the SAP HANA database and the data lake Relational Engine, making it a convenient intermediate storage layer for data movement between the two.
For a broader overview of all export and import options available, including local CSV downloads, GCS, Azure, and AWS S3, see the Export and Import Data and Schema with SAP HANA Database Explorer tutorial.
The following steps demonstrate how to export and import data from the MAINTENANCE table using the SQL console download option and the import data wizard in SAP HANA Cloud Central. For use with larger amounts of data, it is recommended to use a cloud storage provider such as SAP HANA Cloud data lake Files which is shown in the next step.
Enter the SQL statement below in the SQL console.
SQLSELECT * FROM HOTELS.MAINTENANCE;Click on the download toolbar item and choose Download.

Download There is a setting that controls the number of results displayed which may need to be adjusted for tables with larger results.

Max Rows Enter the SQL statement below to delete the rows in the table. They will be added back in the next step.
SQLDELETE FROM HOTELS.MAINTENANCE;Navigate to the Import and Export app and choose Import Data.
In Target Instance, select your SAP HANA database instance.
In Source Data, select Local Computer and browse to the previously downloaded CSV file.

Local Import In Target Table, select Use Existing Table, choose the HOTELS schema, and select the MAINTENANCE table. Complete the remaining steps of the wizard and click Import.
After completing the wizard, the contents of the MAINTENANCE table should be the same as before the delete statement was executed. Run the following SQL statement to confirm.
SQLSELECT * FROM HOTELS.MAINTENANCE;
Maintenance Table
The following steps walk through the process of exporting data to and importing data from data lake Files with a SAP HANA Cloud, SAP HANA database. This step requires a productive SAP HANA Cloud data lake instance as data lake files is currently not included in the free tier service plan.
SQL Statements used:
| Statement | Target | Format |
|---|---|---|
| Export INTO | Data lake Files, S3, Azure, GCS | CSV, Parquet, JSON |
| Import FROM | Data lake Files, S3, Azure, GCS | CSV, Parquet, JSON |
Complete steps 3 and 4 in the Getting Started with Data Lake Files HDLFSCLI tutorial to configure the trust setup of the data lake Files container.
Create a database credential for the data lake Files container by running the following SQL in your database instance as DBADMIN. Further details are described at Importing and Exporting with SAP HANA Cloud Data Lake Files Storage.
SQLSELECT * FROM PSES; CREATE PSE HTTPS; SELECT SUBJECT_COMMON_NAME, CERTIFICATE_ID, COMMENT, CERTIFICATE FROM CERTIFICATES; --cert from https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem and is the CA for HANA Cloud --https://knowledge.digicert.com/general-information/digicert-trusted-root-authority-certificates --https://cacerts.digicert.com/DigiCertTLSRSA4096RootG5.crt.pem CREATE CERTIFICATE FROM '-----BEGIN CERTIFICATE-----MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97 nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt 43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4 gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg 06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=-----END CERTIFICATE-----' COMMENT 'SAP_HC'; --DROP CERTIFICATE <CERTIFICATE_ID>;Execute the following to retrieve the certificate ID and add it to the PSE.
SQLSELECT CERTIFICATE_ID FROM CERTIFICATES WHERE COMMENT = 'SAP_HC';Remove the comma and add the certificate ID (ex: 123456) from the previous statement into
<CERTIFICATE_ID>.SQLALTER PSE HTTPS ADD CERTIFICATE <CERTIFICATE_ID>; --ALTER PSE HTTPS DROP CERTIFICATE <CERTIFICATE_ID>;Then set the own certificate using the client private key, client certificate, and Root Certification Authority of the client certificate in plain text. Make sure you have completed steps 3 and 4 in the Getting Started with Data Lake Files HDLFSCLI tutorial to configure the trust setup of the data lake Files container.
SQLALTER PSE HTTPS SET OWN CERTIFICATE '<Contents from client.key> <Contents from client.crt> <Contents from ca.crt>'; --GRANT REFERENCES ON PSE HTTPS TO USER1; SELECT * FROM PSE_CERTIFICATES;Execute the following SQL to store a credential for the data lake Files container.
SQLSELECT * FROM CREDENTIALS; CREATE CREDENTIAL FOR COMPONENT 'SAPHANAIMPORTEXPORT' PURPOSE 'DL_FILES' TYPE 'X509' PSE HTTPS;Export the
MAINTENANCEtable into the data lake Files container using the export data wizard or the SQL statement below.Navigate to the Import and Export app and choose Export Data.

Import and Export App In Source Instance, select the SAP HANA database instance you want to export data from.
Navigate to Source Data, select Data File as the export type, choose HOTELS as the schema, and select the MAINTENANCE table as the database object.

Source Data For Target Instance, select Data Lake Files as the export destination. Enter DL_FILES as the credential purpose and provide the REST API endpoint of your data lake Files instance. Enter the file path (e.g.
HOTELS/maintenance.csv).The REST API endpoint can be copied by clicking the three dots in the Actions column next to your data lake Files instance.

Data Lake Endpoint 
Target Instance Complete the remaining export options and click Export. Verify that the export was successful in the Import and Export app, under Exports.

Export Successful The wizard makes use of the
EXPORT INTOstatement. An example is shown below:SQLEXPORT INTO CSV FILE 'hdlfs://1234-567-890-1234-56789.files.hdl.prod-us10.hanacloud.ondemand.com/HOTELS/maintenance.csv' FROM MAINTENANCE WITH CREDENTIAL 'DL_FILES' COLUMN LIST IN FIRST ROW;On the final screen of the wizard, you can select View Generated SQL to see the SQL statement that will be executed.

Generated SQL Delete the rows from the table. They will be restored in the next step.
SQLDELETE FROM HOTELS.MAINTENANCE;Import the data back using the import data wizard or the SQL statement below. Navigate to the Import and Export app and choose Import Data.
In Target Instance, select the SAP HANA database instance you want to import data into.
Under Source Data, select Data Lake Files as the source type. Enter DL_FILES as the database credential, provide the REST API endpoint of your data lake Files instance (which can be copied by clicking the three dots in the Actions column next to your data lake Files instance in SAP HANA Cloud Central), and enter the file path (e.g.
HOTELS/maintenance.csv).
Source Data In Target Table select Use Existing Table and choose the HOTELS schema and MAINTENANCE table.
Complete the remaining steps for table mapping and error handling and click Import.
The wizard makes use of the import from statement. An example is shown below:
SQLIMPORT FROM CSV FILE 'hdlfs://1234-567-890-1234-56789.files.hdl.prod-us10.hanacloud.ondemand.com/HOTELS/maintenance.csv' INTO HOTELS.MAINTENANCE WITH CREDENTIAL 'DL_FILES' COLUMN LIST IN FIRST ROW;You can verify the success of the export or import operation by navigating to the Import and Export app and reviewing the job history and by executing a select against the table.

Import Export Success SQLSELECT * FROM HOTELS.MAINTENANCE;
The following steps walk through exporting to and importing data from data lake Files using an SAP HANA Cloud, data lake Relational Engine database.
SQL Statements used:
| Statement | Target | Format |
|---|---|---|
| Unload | Data lake Files, S3, Azure, GCS | Parquet, Text, Binary |
| Load | Data lake Files, S3, Azure, GCS | Parquet, ASCII, Binary |
Create a database credential for the data lake Files container. This step is required if you wish to export to a data lake Files instance that is not the one associated with the data lake Relational Engine. Open a SQL Console connected to a data lake Relational Engine instance and execute the below SQL statements as HDLADMIN.
SQLSELECT * FROM SYSPSE; CREATE PSE HTTPS; SELECT * FROM SYSCERTIFICATE; CREATE CERTIFICATE DIGICERTG5 FROM '-----BEGIN CERTIFICATE----- MIIFZjCCA06gAwIBAgIQCPm0eKj6ftpqMzeJ3nzPijANBgkqhkiG9w0BAQwFADBN MQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMT HERpZ2lDZXJ0IFRMUyBSU0E0MDk2IFJvb3QgRzUwHhcNMjEwMTE1MDAwMDAwWhcN NDYwMTE0MjM1OTU5WjBNMQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQs IEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0MDk2IFJvb3QgRzUwggIi MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz0PTJeRGd/fxmgefM1eS87IE+ ajWOLrfn3q/5B03PMJ3qCQu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A+rYAQCd05JS9Yf7vSdPD3Rh9GOUrYU9DzLjtxpdRv /PNn5AeP3SYZ4Y1b+qOTEZvpyDrDVWiakuFSdjjo4bq9+0/V77PnSIMx8IIh47a+ p6tv75/fTM8BuGJqIz3nCU2AG3swpMPdB380vqQmsvZB6Akd4yCYqjdP//fx4ilw MUc/dNAUFvohigLVigmUdy7yWSiLfFCSCmZ4OIN1xLVaqBHG5cGdZlXPU8Sv13WF qUITVuwhd4GTWgzqltlJyqEI8pc7bZsEGCREjnwB8twl2F6GmrE52/WRMmrRpnCK ovfepEWFJqgejF0pW8hL2JpqA15w8oVPbEtoL8pU9ozaMv7Da4M/OMZ+ -----END CERTIFICATE-----'; SELECT * FROM SYSCERTIFICATE WHERE cert_name = 'DIGICERTG5'; ALTER PSE HTTPS ADD CERTIFICATE <object_id>;SQLSELECT * FROM SYSPSECERTIFICATE; ALTER PSE HTTPS SET OWN CERTIFICATE '<Contents from client.key> <Contents from client.crt> <Contents from ca.crt>'; ----ALTER PSE HTTPS UNSET OWN CERTIFICATE;SQLSELECT * FROM SYSCREDENTIAL; CREATE CREDENTIAL FOR COMPONENT 'SAPHDLRELOADUNLOAD' PURPOSE 'DL_FILES' TYPE 'X509' PSE HTTPS; --DROP CREDENTIAL FOR COMPONENT 'SAPHDLRELOADUNLOAD' PURPOSE 'DL_FILES' TYPE 'X509';Additional details are described at CREATE CERTIFICATE.
The HOTELS schema and MAINTENANCE table are not automatically shared with the Relational Engine. If the schema does not already exist, create it manually in the Relational Engine SQL console.
SQLCREATE SCHEMA HOTELS; CREATE TABLE HOTELS.MAINTENANCE ( MNO INTEGER NOT NULL, HNO INTEGER NOT NULL, DESCRIPTION VARCHAR(100), DATE_PERFORMED DATE, PERFORMED_BY VARCHAR(40) );Ensure you are in the HOTELS schema before performing the following inserts.
SQLINSERT INTO MAINTENANCE VALUES(10, 24, 'Replace pool liner and pump', '2019-03-21', 'Discount Pool Supplies'); INSERT INTO MAINTENANCE VALUES(11, 25, 'Renovate the bar area. Replace TV and speakers', '2020-11-29', 'TV and Audio Superstore'); INSERT INTO MAINTENANCE VALUES(12, 26, 'Roof repair due to storm', null, null);Export (unload) the data from the
MAINTENANCEtable to data lake Files using the export data wizard or the SQL statement below.Navigate to the Import and Export app and choose Export Data.
In Source Instance, select your data lake Relational Engine instance.
In Source Data, choose HOTELS as the schema, and select the MAINTENANCE table as the database object.
In Target Instance, select Data Lake Files as the export destination. Enter DL_FILES as the credential purpose, choose the REST API endpoint of your data lake Files instance, and enter the file path (e.g.
maint.csv).Complete the remaining export options and click Export.
Export or unload the data from the MAINTENANCE table to a data lake Files instance using the SQL statement. The below example targets the data lake Files instance that is attached to the data lake Relational Engine.
SQLUNLOAD SELECT * FROM HOTELS.MAINTENANCE INTO FILE 'hdlfs:///maint.csv' NULL FORMAT EMPTYThe below example targets a different data lake Files instance.
SQLUNLOAD SELECT * FROM HOTELS.MAINTENANCE INTO FILE 'hdlfs://18b4be74-a4f1-40a0-a357-60155aee5f30/maint.csv' CONNECTION_STRING 'ENDPOINT=https://18b4be74-a4f1-40a0-a357-60155aee5f30.files.hdl.prod-ca10.hanacloud.ondemand.com' WITH CREDENTIAL 'DL_FILES' NULL FORMAT EMPTY;Import (load) the data back into the
MAINTENANCEtable using the import data wizard or the SQL statement below.Remember to delete the data before testing the import by running DELETE FROM HOTELS.MAINTENANCE.
Navigate to the Import and Export app and choose Import Data.
In Target Instance, select your data lake Relational Engine instance.
In Source Data, select Data Lake Files as the source type. Enter DL_FILES as the database credential, provide the REST API endpoint of your data lake Files instance, and enter the file path (e.g.
maint.csv).In Target Table, use the existing table in schema HOTELS and search for MAINTENANCE.
Complete the remaining steps for column mapping and error handling and click Import.
The wizard makes use of the load statement. The below example targets the data lake Files instance that is attached to the data lake Relational Engine.
SQLDELETE FROM HOTELS.MAINTENANCE; LOAD TABLE HOTELS.MAINTENANCE (MNO, HNO, DESCRIPTION, DATE_PERFORMED, PERFORMED_BY) FROM 'hdlfs:///maint.csv' ESCAPES OFF; SELECT * FROM HOTELS.MAINTENANCE;The below example targets a different data lake Files instance.
SQLDELETE FROM HOTELS.MAINTENANCE; LOAD TABLE HOTELS.MAINTENANCE (MNO, HNO, DESCRIPTION, DATE_PERFORMED, PERFORMED_BY) FROM 'hdlfs://18b4be74-a4f1-40a0-a357-60155aee5f30/maint.csv' CONNECTION_STRING 'ENDPOINT=https://18b4be74-a4f1-40a0-a357-60155aee5f30.files.hdl.prod-ca10.hanacloud.ondemand.com' WITH CREDENTIAL 'DL_FILES' ESCAPES OFF; SELECT * FROM HOTELS.MAINTENANCE;Run the following SQL statement to verify the import succeeded.
SQLSELECT * FROM HOTELS.MAINTENANCE
Similar to the previous examples, the MAINTENANCE table will be exported and re-imported to an SAP HANA Cloud database. The export catalog wizard and export statement can include multiple objects in the export or import, include additional object types such as functions and procedures, and can include the SQL statements to recreate the objects.
The following tables list the different options available in SAP HANA Cloud Central to export and import catalog objects.
SQL Statements used:
| Statement | Target | Format |
|---|---|---|
| Export | Data lake Files, S3, Azure, GCS | Binary, CSV, Parquet |
| Import | Data lake Files, S3, Azure, GCS | Binary, CSV, Parquet |
To try these out, follow the steps below.
Navigate to the Import and Export app and connect to the desired SAP HANA instance you want to export data from. Under Source Data, select Database Objects. Navigate to the Add Database Objects button and search for Maintenance. Notice how you can select multiple object types.

Export Catalog Objects Wizard Choose Local Computer for the export location and provide a name for the archive. Next, select an export format such as CSV, and click Export.

Export Options Binary Raw is the binary format for SAP HANA Cloud and Binary Data is the format option for SAP HANA as a Service and SAP HANA on-premise.
The archive file contains the SQL to recreate the table as well as the data of the table.
Enter the SQL statement below to drop the table. It will be added back in the next step.
SQLDROP TABLE HOTELS.MAINTENANCE;Navigate to the Import and Export app and choose Import Database Objects. Browse to the previously downloaded archive file and complete the wizard.

Import Catalog Wizard You can also rename the schema if desired.

Rename Schema The contents of the MAINTENANCE table should now be the same as before the drop statement was executed.
SQLSELECT * FROM HOTELS.MAINTENANCE;
Congratulations! You have exported and imported data using SAP HANA Cloud data lake Files from both an SAP HANA Cloud, SAP HANA database and a data lake Relational Engine database, and exported and imported catalog objects using SAP HANA Cloud Central.
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.