machbase-neo shell

machbase-neo shell

Syntax

Lists and explains the commands of the machbase-neo shell.

machbase-neo shell --help

machbase-neo shell [flags] <sub-command> [args...]

shell flags:
  -s, --server=<addr>     server address (default unix:///home/liunx/work/neo/neo-server/tmp/mach-grpc.sock)

shell sub-commands:
  bridge command [options]
        commands:
          list                            shows registered bridges
          add [options] <name>  <conn>    add bridge
...
  show [options] <object>
        objects:
          info                   show server info
          license                show license info
          ports                  show service ports
          users                  list users
          tables [-a]            list tables
          table [-a] <table>     describe the table
...

Interactive mode

It will start interactive mode shell if there are no other arguments.

A machbase-neo operation command and a machbase query may be executed through the interactive shell mode.

Flags

flag (long)flag (short)desc
--server-smachbase-neo’s gRPC address.
default: --server tcp://127.0.0.1:5655
e.g. -s unix://./mach-grpc.sock

connect internal server

machbase-neo shell
machbase-neo» 

connect external server

machbase-neo shell --server tcp://*.*.*.*:5655
machbase-neo» 

Run Query

machbase-neo» select binary_signature from v$version;
┌────────┬─────────────────────────────────────────────┐
│ ROWNUM │ BINARY_SIGNATURE                            │
├────────┼─────────────────────────────────────────────┤
1 │ 8.0.2.develop-LINUX-X86-64-release-standard │
└────────┴─────────────────────────────────────────────┘
a row fetched.

Create Table

machbase-neo» create tag table if not exists example (name varchar(20) primary key, time datetime basetime, value double summarized);
executed.

Schema Table

machbase-neo» desc example;
┌────────┬───────┬──────────┬────────┐
│ ROWNUM │ NAME  │ TYPE     │ LENGTH │
├────────┼───────┼──────────┼────────┤
1 │ NAME  │ varchar  │     202 │ TIME  │ datetime │      83 │ VALUE │ double   │      8└────────┴───────┴──────────┴────────┘

Insert Table

machbase-neo» insert into example values('tag0', to_date('2021-08-12'), 100);
a row inserted.

Select Table

machbase-neo» select * from example;
┌────────┬──────┬─────────────────────┬───────┐
│ ROWNUM │ NAME │ TIME(LOCAL)         │ VALUE │
├────────┼──────┼─────────────────────┼───────┤
1 │ tag0 │ 2021-08-12 00:00:00 │ 100└────────┴──────┴─────────────────────┴───────┘
a row fetched.

Drop Table

machbase-neo» drop table example;
executed.

Show

Display information.

show [options] <object>
        objects:
          info                   show server info
          license                show license info
          ports                  show service ports
          users                  list users
          tables [-a]            list tables
          table [-a] <table>     describe the table
          meta-tables            list meta tables
...
        options:
          -a,--all               includes all hidden tables/columns

show info

machbase-neo» show info;
┌────────────────────┬─────────────────────────────┐
│ NAME               │ VALUE                       │
├────────────────────┼─────────────────────────────┤
│ build.version      │ v2.0.0                      │
│ build.hash         │ #c953293f                   │
│ build.timestamp    │ 2023-08-29T08:08:00         │
│ build.engine       │ static_standard_linux_amd64 │
│ runtime.os         │ linux                       │
│ runtime.arch       │ amd64                       │
│ runtime.pid        │ 57814│ runtime.uptime     │ 2h 30m 57s                  │
│ runtime.goroutines │ 45│ mem.sys            │ 32.6 MB                     │
│ mem.heap.sys       │ 19.0 MB                     │
│ mem.heap.alloc     │ 9.7 MB                      │
│ mem.heap.in-use    │ 13.0 MB                     │
│ mem.stack.sys      │ 1,024.0 KB                  │
│ mem.stack.in-use   │ 1,024.0 KB                  │
└────────────────────┴─────────────────────────────┘

Desc

Describe table structure.

machbase-neo» desc example;
┌────────┬───────┬──────────┬────────┐
│ ROWNUM │ NAME  │ TYPE     │ LENGTH │
├────────┼───────┼──────────┼────────┤
1 │ NAME  │ varchar  │     202 │ TIME  │ datetime │      83 │ VALUE │ double   │      8└────────┴───────┴──────────┴────────┘

Run a .sql file

machbase-neo shell run <file> executes multiple comands in the given file.

Make a script file

Make an example script file like below.

  • cat batch.sh
#
# comments starts with `#` or `--`
# A statement should be ends with semi-colon `;`
#

CREATE TAG TABLE IF NOT EXISTS EXAMPLE (NAME VARCHAR(20) PRIMARY KEY, TIME DATETIME BASETIME, VALUE DOUBLE SUMMARIZED);

-- Insert
INSERT INTO EXAMPLE VALUES('tag0', TO_DATE('2021-08-12'), 100);

-- Count
SELECT * FROM EXAMPLE;

Run the script file

machbase-neo shell run batch.sh
  • result
CREATE TAG TABLE IF NOT EXISTS EXAMPLE (NAME VARCHAR(20) PRIMARY KEY, TIME DATETIME BASETIME, VALUE DOUBLE SUMMARIZED)
executed.

INSERT INTO EXAMPLE VALUES('tag0', TO_DATE('2021-08-12'), 100)
a row inserted.

SELECT * FROM EXAMPLE
 ROWNUM  NAME  TIME(LOCAL)          VALUE 
──────────────────────────────────────────
      1  tag0  2021-08-12 00:00:00  100   
a row fetched.
Last updated on