How do you work with Snowflake streams?
💡 Model Answer
To work with a Snowflake stream you first create it on a base table: CREATE OR REPLACE STREAM my_stream ON TABLE my_table; Then you can query the stream: SELECT * FROM my_stream; The result set contains all changes since the last read. You typically use the stream in a MERGE statement to apply changes to a target table: MERGE INTO target USING my_stream ON target.id = my_stream.id WHEN MATCHED THEN UPDATE SET ... WHEN NOT MATCHED THEN INSERT ... After the MERGE you can TRUNCATE the stream to mark the changes as consumed. Streams can also be used in Snowpipe or Tasks for automated processing. Remember to handle the METADATA$ACTION column to distinguish INSERT, UPDATE, DELETE.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500