SQL quick reference

CREATE STREAM

Create a new HStreamDB stream with stream name given. An exception will be thrown if the stream is already created. See CREATE STREAM.

  1. CREATE STREAM stream_name [AS select_query] [WITH (stream_option [, ...])];

CREATE VIEW

Create a new view with view name given. A view is a physical object like a stream and it is updated with time. An exception will be thrown if the view is already created. The name of a view can either be the same as a stream. See CREATE VIEW

  1. CREATE VIEW view_name AS select_query;

CREATE CONNECTOR

Create a new connector for fetching data from or writing data to an external system. A connector can be either a source or a sink one. Note that source connector is not supported yet. When creating a connector, its type and binded stream must be specified in the WITH clause. There can be other options such as database name, user name and password. There can be an optional IF NOT EXIST config to only create the given connector if it does not exist. See CREATE CONNECTOR

  1. CREATE CONNECTOR <SOURCE|SINK> CONNECTOR connector_name [IF NOT EXIST] WITH (connector_option [, ...]);

SELECT (from streams)

Continuously get records from the stream(s) specified as streaming data flows in. It is usually used in an interactive CLI to monitor realtime changes of data. Note that the query writes these records to a random-named stream. See SELECT (Stream).

  1. SELECT <* | expression [ AS field_alias ] [, ...]>
  2. FROM stream_name_1
  3. [ join_type JOIN stream_name_2
  4. WITHIN (some_interval)
  5. ON stream_name_1.field_1 = stream_name_2.field_2 ]
  6. [ WHERE search_condition ]
  7. [ GROUP BY field_name [, window_type] ]
  8. EMIT CHANGES;

SELECT (from views)

Get a record from the specified view. The fields to get have to be already in the view. It produces one or zero static record and costs little time. See Select (View).

  1. SELECT <* | expression [ AS field_alias ] [, ...]>
  2. FROM view_name
  3. WHERE field_name = value_expression;

INSERT

Insert data into the specified stream. It can be a data record, a JSON value or binary data. See INSERT.

  1. INSERT INTO stream_name (field_name [, ...]) VALUES (field_value [, ...]);
  2. INSERT INTO stream_name VALUES 'json_value';
  3. INSERT INTO stream_name VALUES "binary_value";

DROP

Delete a given stream or view. There can be an optional IF EXISTS config to only delete the given category if it exists.

  1. DROP STREAM stream_name [IF EXISTS];
  2. DROP VIEW view_name [IF EXISTS];

SHOW

Show the information of all streams, queries, views or connectors.

  1. SHOW STREAMS;
  2. SHOW QUERIES;
  3. SHOW VIEWS;
  4. SHOW CONNECTORS;