CREATE STREAM Syntax
- a table (external tables not supported)
- a materialized view (insert monitoring only)
- an external Apache Kafka broker
- an external webhook
- a local database table
Parameters
<stream schema name>
<stream schema name>
Name of the schema that will contain the created stream; if no schema is specified, the
stream will be created in the user’s default schema
<stream name>
<stream name>
Name of the stream to create; must adhere to the supported
naming criteria
TABLE
TABLE
Optional keyword for clarity, in creating a stream on a table.
<table schema name>
<table schema name>
Name of the schema containing the table or materialized view to monitor.
<table name>
<table name>
Name of the table or materialized view to monitor for changes.
QUERY
QUERY
Optional keyword for clarity, in creating a stream on a join.
<query>
<query>
Join query to which the stream will be applied, using the following form:{{< code “sql” “linenos=true” “Query Syntax” >}}
SELECT *
FROM <delta_table> dt
LEFT SEMI JOIN <lookup_table> lt
ON <join_clause>
{{< /code >}}Here, See below for a table-driven geofence example using a query-based stream.
<delta_table> is the data table being monitored and <lookup_table> contains the
criteria for whether a <delta_table> record should be streamed or not, as determined by
the given <join_clause>.The marked delta table must be a regular table—it cannot be any of the
following:The join must also meet sharding requirements for joins—either both
tables need to have shard keys on their equality-based joined
columns, or at least one of the tables needs to be replicated.See CREATE TABLE for syntax for creating a replicated table or a
sharded table with a shard key column.
REFRESH
REFRESH
Specifies the reporting scheme for monitored changes. The following schemes are available:
| Constant | Description |
|---|---|
ON CHANGE | Will cause notifications to be streamed any time a record is added, modified, or deleted from the monitored table |
EVERY | Allows specification of an interval in seconds, minutes, hours, or days, with the optional specification of a starting time at which the first monitor interval will run; if no start time is specified, the default will be an interval’s worth of time from the point at which the stream was created |
<filter expression>
<filter expression>
Boolean expression that can be used to monitor for only a specific set of inserts.
WITH OPTIONS
WITH OPTIONS
Indicator that a comma-delimited list of configuration option/value assignments will follow.
See Options for the full list of options.
One of either
DATASINK_NAME or DESTINATION is required.Examples
To create a stream,kin_stream, that publishes inserts into the
order_stream table of orders over $10,000 via the kin_dsink data sink:
CREATE STREAM Example
kin_stream, that publishes inserts into the
order_stream table of orders, placed within a given string-literal geofence,
via the kin_dsink data sink:
CREATE STREAM Single Geometry Geofence Example
kin_stream, that publishes inserts into the
order_stream table of orders, placed within a table-driven geofence defined
in order_location, via the kin_dsink data sink; noting that the
order_location table in this example is
replicated:
CREATE STREAM Table-Driven Geofence Example
kin_stream, that inserts into the local
order_target table any orders over $10,000 inserted into the
order_stream table:
CREATE STREAM to Local Table Example