'Load Data' loads the csv file into Machbase.
The first line field of the csv file is automatically created as a VARCHAR (32767) type with the column name of the table without creating the table in advance. The data file path uses $ MACHBASE_HOME as the relative path. If it is in another directory, it should indicate the absolute path.
For more information on using LOAD DATA, refer to Import/Export page.
Note that you can use the SAVE DATA statement to save the SQL results as a csv file.
If you know the data type for each field in the csv file, you can create and load the table in advance.
When the file, 'load_sample.csv' is loaded with the table, 'load_sample' is automatically created.
Load Data
LOAD DATA INFILE 'sample/quickstart/load_sample.csv' INTO TABLE load_sample AUTO HEADUSE;
Check input data
SELECT * FROM load_sample;
Using the sample file, you can do the following.
[mach@localhost ~]$ cd $MACHBASE_HOME/sample/quickstart [mach@localhost ~]$ ls -l load_sample.csv -rw-r --r--- 1 root root 2827 2017-02-23 15:01 load_sample.csv Load Data 133 [mach@localhost ~]$ machsql ================================================================ = Machbase Client Query Utility Release Version 3.5.0 Copyright 2014, Machbase Inc. or its subsidiaries. All Rights Reserved ================================================================ = Machbase server address (Default:127.0.0.1) : Machbase user ID (Default:SYS) Machbase User Password : MACH_CONNECT_MODE=INET, PORT=5656 mach> LOAD DATA INFILE 'sample/quickstart/load_sample.csv' INTO TABLE load_sample AUTO HEADUSE; 50 row(s) loaded. Failed to load 0 row(s). Elapsed time: 0.344 mach> DESC load_sample; ---------------------------------------------------------------NAME TYPE LENGTH ---------------------------------------------------------------SENSOR_ID varchar 32767 EPOCH_TIME varchar 32767 E_YEAR varchar 32767 E_MONTH varchar 32767 E_DAY varchar 32767 E_HOUR varchar 32767 E_MINUTE varchar 32767 E_SECOND varchar 32767 VALUE varchar 32767 mach> SELECT COUNT(*) FROM load_sample; COUNT(*) ----------------------50 [1] row(s) selected. Elapsed time: 0.000 mach>