Insert Data

Like other conventional RDBMS, you need to create a table first and enter the data using INSERT INTO statement. Machbase provides 'machsql' as an interactive tool.

Create table

Syntax:

CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
   ....
);

Example:

CREATE TABLE sensor_data 
(
 id VARCHAR(32),
 val DOUBLE
);

Insert data

Syntax:

INSERT INTO table_name
VALUES (value1, value2, value3, ...);

Example:

INSERT INTO sensor_data VALUES('sensor1', 10.1);
INSERT INTO sensor_data VALUES('sensor2', 20.2);
INSERT INTO sensor_data VALUES('sensor3', 30.3);

Check inserted data

Syntax:

SELECT column1, column2, ...
FROM table_name;

Example:

SELECT * FROM sensor_data;

'machsql' is run as follows.

[mach@localhost ~]$ machsql
=================================================================
     Machbase Client Query Utility
     Release Version 3.5.0.826b8f2.official
     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> CREATE TABLE sensor_data
     (
       id    VARCHAR(32),
       val   DOUBLE
     );
Created successfully.
Elapsed time: 0.162
mach> INSERT INTO sensor_data VALUES('sensor1', 10.1);
1 row(s) inserted.
Elapsed time: 0.000
mach> INSERT INTO sensor_data VALUES('sensor2', 20.2);
1 row(s) inserted.
Elapsed time: 0.000
mach> INSERT INTO sensor_data VALUES('sensor3', 30.3);
1 row(s) inserted.
Elapsed time: 0.000
mach> SELECT * FROM sensor_data;
ID                                VAL
-----------------------------------------------------------------
sensor3                           30.3
sensor2                           20.2
sensor1                           10.1
[3] row(s) selected.
Elapsed time: 0.000

results matching ""

    No results matching ""