TRUNCATE remote database table contents

rahuldbhandare
Padawan

We are exporting data from Exasol database to SAP HANA database by executing export SQL script in Exasol.

Before exporting data from Exasol to HANA, we need to add a step to truncate entire contents of HANA table.

What is the EXASOL syntax to be used to TRUNCATE entire contents of  SAP HANA table.

 

2 REPLIES 2

jens_areto
SQL-Fighter

Hey rahuldbhandare,

I don´t have an SAP HANA DB for testing, so I can only test it for an Oracle DB but it should also work for SAP HANA DB the same way if you use a jdbc connection.

First you create a JDCB Connection inside your Exasol DB to the SAP HANA DB, which is the target for your export. If the connection is created successfully and it works you can use the Syntax of the Export clause to truncate the target table before inserting the new values inside the table.

My Example for Oracle worked like this:

EXPORT (select 1 a FROM dual where 1=2) INTO jdbc AT ORACLE_JDBC_CONNECTION
Table HR.TEST_JSC
TRUNCATE;

If you want to export data from exasol and truncate the table in one command just change the command like this:

EXPORT (<SELECT YOUR DATA TO EXPORT>) INTO jdbc AT <YOUR JDBC CONNECTION TO SAP HANA>
Table <TARGET TABLE IN SAP>
TRUNCATE;

This should truncate the target table inside the HANA DB first and then insert the data from Exasol.

Kindly regards

Jens

create connections:https://docs.exasol.com/sql/create_connection.htm?Highlight=connection

use export: https://docs.exasol.com/sql/export.htm

mwellbro
Xpert

Hi all,

I just tested the TRUNCATE option of the EXPORT command on a HANA target, works as expected.

 

Cheers,
Malte