CREATE STREAM stream ( column_name data_type [ TIMESTAMPCOLUMN ] [, ... ] ) TYPE [ ARCHIVED | UNARCHIVED ]
CREATE STREAM will create a new archived or unarchived stream in the current database. At present the historical contents of an archived stream cannot be queried. A stream can participate in one or more continuous queries in the system. For a stream stream three wrapper user-defined functions must be created. These must have the names stream_init,stream_next and stream_close and are responsible for converting incoming data from a network connection into fields of tuples in PostgreSQL format.
A TIMESTAMPCOLUMN constraint is used to specify that a particular column of the stream identifies the creation time of the tuples in the stream. It is assumed that creation time of tuples entering the system is monotonically increasing. There may be other columns in the stream of type TIMESTAMP. This column is used whenever a stream is used in a query with a "window" expression. A stream must have precisely one TIMESTAMPCOLUMN constraint.
It is not possible to update, insert or delete records in streams. Aggregate queries over streams must involve window expressions.
The name of a stream to be created.
The name of a column of a stream
The type of a column of a stream
A special constraint that identifies the column containing creation time of tuples in the stream. In the current release, the name of the column must be tcqtime.
The name of the column for which the TIMESTAMPCOLUMN constraint is set must be tcqtime.
Creating and installing the three wrapper functions is the responsibility of the user.
Create an archived stream measurements and an unarchived stream tinydb:
CREATE STREAM measurements ( tcqtime TIMESTAMP TIMESTAMPCOLUMN, stationid INTEGER, speed REAL) TYPE ARCHIVED;
CREATE STREAM tinydb ( tcqtime TIMESTAMP TIMESTAMPCOLUMN, light REAL, temperature REAL) TYPE UNARCHIVED;