Complete the code to create a stream on the table 'orders' to capture changes.
CREATE OR REPLACE STREAM orders_stream ON TABLE orders [1] = FALSE;The APPEND_ONLY = FALSE option captures all changes (inserts, updates, deletes) on the table.
Complete the code to query the stream 'orders_stream' for inserted rows only.
SELECT * FROM orders_stream WHERE [1] = 'INSERT';
The METADATA$ACTION column indicates the type of change: 'INSERT', 'UPDATE', or 'DELETE'.
Fix the error in the stream creation by choosing the correct option for the stream type.
CREATE STREAM customer_stream ON TABLE customers [1] = TRUE;The APPEND_ONLY = TRUE stream type is valid and captures only inserts. Other options like CHANGE_TRACKING are invalid in Snowflake.
Fill both blanks to create a stream showing initial rows on the 'products' table.
CREATE OR REPLACE STREAM products_stream ON TABLE products [1] = [2];
The SHOW_INITIAL_ROWS = TRUE option allows the stream to include initial rows of the table in addition to capturing changes.
Fill all three blanks to query the stream 'inventory_stream' for deleted rows and select the metadata column, the product_id, and quantity.
SELECT [1], product_id, quantity FROM inventory_stream WHERE [2] = 'DELETE' ORDER BY [3];
The METADATA$ACTION column is used to filter for deletes and also selected. Ordering by product_id organizes the output.