msc mobile emerging technologies blog

How to export/import data from and to a SQL Anywhere database

Posted by Valantis Giogiakas on Jan 13, 2016 3:00:00 PM

In order to move certain data from a SQL Anywhere database from the development system to the productive system, we found a way which suits perfectly to us. This blog describes the required steps.

In our scenario we had to move customizing data from one MobiLink/SQL Anywhere powered server to the other (development to the productive system).

How to export and import data from and to a SQL Anywhere database

In order to transport the data, we had to export it from the development system and then import it in the productive database. The way we found was to use csv (comma separated values) files.

This csv-file has been transferred to the productive system where the empty database table has been filled with that data. This was a manual process, but it can (and will be) automated in the future.

The following describes the steps for this process:

1. Export the data into a csv-file.

The commands shown here can be executed with any SQL tool against the database. In our case we used InteractiveSQL, which is shipped together with SQL Anywhere. To export the data, use the following SQL statement:

UNLOAD TABLE <your table you want to export data> TO ‘<absolute path incl. the name of the file you want to store it (.csv)’>

This is generating the csv file.

2. Import data from a csv-file

To get the data from the csv-file and fill the table with the data in the other system, run the following statement:

INPUT INTO <your table you want to import data> FROM ‘<absolute path to your file incl. the filename’


Export data in a csv-file

UNLOAD TABLE ZODB_USERS TO 'C:\MobiLink\ dev_system\zodb_users_data.csv'

Import data from that csv-file in your empty database table

INPUT INTO ZODB_USERS FROM 'C:\MobiLink\ prod_system\zodb_users_data.csv'

I hope that this blog is helpful for you and that you can make good use of it.


Topics: MobiLink, SQL Anywhere