CREATE STREAM

Name

CREATE STREAM  --  define a new stream

Synopsis

CREATE STREAM stream ( column_name data_type [ TIMESTAMPCOLUMN ] [, ... ] )
TYPE [ ARCHIVED | UNARCHIVED ] 

Description

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.

Inputs

stream

The name of a stream to be created.

column_name

The name of a column of a stream

data_type

The type of a column of a stream

TIMESTAMPCOLUMN

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.

Diagnostics

CREATE

Message returned if stream is successfully created.

ERROR

Message returned if stream creation failed. This is usually accompanied by some descriptive text, such as: ERROR: Relation 'stream' already exists, which occurs at runtime if the stream specified already exists in the database.

Notes

Examples

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;
   

Compatibility

The CREATE STREAM is a TelegraphCQ extension and is not part of either SQL99 or SQL99. It is subject to change in future releases of TelegraphCQ.

See Also

DROP STREAM