Export Data in 1 minute

In this tutorial, you will learn how to export data from Machbase.
Machbase provides csvexport, machloader and SAVE syntax to export data.

Step 1 : csvexport
'csvexport' exports data in csv file format and saves it as a file. You can create a table name and a file name to be saved as an option.

$ csvexport -t sample_table -d sample.exp

Step 2 : machloader
The machloader is available in a variety of forms than csvexport. The following example is not formatted as csv file, but the delimiter ',' is set to output and store in.

$ machloader -o -t sample_table -d sample.out -r raw -D ','

Step 3 : SAVE syntax
'csvexport' and 'machloader' are exporting full table data at once. However if you want to save the results of a specific SELECT query in csv format, you can use SAVE DATA clause.
It works on machsql and requires a file name to save and SELECT query statement.

[mach@localhost ~]$ machsql -s localhost -u sys -p manager
=================================================================
     Machbase Client Query Utility
     Release Version 3.5.0.826b8f2.official
     Copyright 2014 Machbase Corporation or its subsidiaries.
     All Rights Reserved.
=================================================================
MACHBASE_CONNECT_MODE=INET, PORT=5656
Type 'help' to display a list of available commands.

Mach> SAVE DATA INTO 'tutorials/export_data/sample.dat' AS SELECT SRCIP, DSTIP, EVENTSIZE FROM SAMPLE_TABLE WHERE EVENTSIZE < 1000;
Mach> quit


# check the sample.data file
$ cd $MACHBASE_HOME/tutorials/expor_data
$ more sample.dat

results matching ""

    No results matching ""