Differences from RDBMS tables

Streams resemble database tables in several ways. They have columns and rows, and you can use SELECT or INSERT on a stream. However, tables are finite; you always know how many rows are present in a table. In contrast, streams are infinite; you never know exactly how many rows are present, or have been present, or will be present.

To make processing manageable, you will often use windows of either time or number of rows.

All streams must be created within schemas.

The example below first creates and sets a schema called “Test”, then creates a stream called “logstream”, then selects from this stream.

CREATE OR REPLACE SCHEMA "Test";
SET SCHEMA '"Test"';
CREATE OR REPLACE STREAM logStream (
source VARCHAR(20),
message VARCHAR(3072))
DESCRIPTION 'Example stream';

SELECT STREAM * FROM logStream;
INSERT INTO logStream VALUES('test', 'message1');
INSERT INTO logStream (source, message)
VALUES('test', 'message1');

Because streams always involve time, when you query streams you will need to keep in mind what window of time you want to query. This could be “everything until now” or “the past day” or “the past hour”.