Read inserts, deletes and update pairs
A standard stream exposes net row changes with metadata explaining the operation and row identity.
Understand the idea
Update is represented by the old row as DELETE and the new row as INSERT. Both sides have ISUPDATE true. A genuine deleted row has DELETE with ISUPDATE false. Use these facts when building change logic.
| Concept | What it means |
|---|---|
| METADATA$ACTION | INSERT or DELETE, not a separate UPDATE action. |
| METADATA$ISUPDATE | True for the delete/insert sides of an update. |
| METADATA$ROW_ID | Source row identity; not a timestamp or business ordering sequence. |
A concrete example
Expect 101/100/DELETE/true and 101/120/INSERT/true; 102/50/DELETE/false; 103/70/INSERT/false. The update pair shares its source row identity. Actual ROW_ID strings are generated by Snowflake.
Remember: Interpret operation metadata together; treating every DELETE as a business deletion would misread update pairs.
Explain it step by step · full theory
Understand the concept
Update is represented by the old row as DELETE and the new row as INSERT. Both sides have ISUPDATE true. A genuine deleted row has DELETE with ISUPDATE false. Use these facts when building change logic.
A standard stream represents the net change between offsets, not a complete chronological audit log. An insert followed by a delete before consumption can cancel out. Several updates can appear as one net before/after difference.
Walk through the behavior
The two rows in this example existed before stream creation, so changing 101 and removing 102 produces an easy-to-explain result. Adding 103 produces one new insert.
Do not sort changes by ROW_ID and call that event order. If a business process needs version ordering, store an explicit source version or event sequence.
Words used in this lesson
- METADATA$ACTION
- INSERT or DELETE, not a separate UPDATE action.
- METADATA$ISUPDATE
- True for the delete/insert sides of an update.
- METADATA$ROW_ID
- Source row identity; not a timestamp or business ordering sequence.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Read inserts, deletes and update pairs
Start with the source
A standard stream exposes net row changes with metadata explaining the operation and row identity.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Start with the source
A standard stream exposes net row changes with metadata explaining the operation and row identity.
- Follow the work
Update is represented by the old row as DELETE and the new row as INSERT. Both sides have ISUPDATE true. A genuine deleted row has DELETE with ISUPDATE false. Use these facts when building change logic.
- Explain the outcome
Interpret operation metadata together; treating every DELETE as a business deletion would misread update pairs.
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
Manual learning lab; nothing runs on this website. Complete lesson 1 setup in L2_OBJECTS_LAB.M11_LAB and follow the lesson order. Use the same authorized role and warehouse for manual SQL. Task templates use <lab_warehouse>: replace it with an approved warehouse name. Do not activate several consumers against the same stream. Each task starts suspended; running or resuming it can consume compute credits.
Make one of each change
UPDATE SOURCE_ORDERS SET AMOUNT=120 WHERE ORDER_ID=101;
DELETE FROM SOURCE_ORDERS WHERE ORDER_ID=102;
INSERT INTO SOURCE_ORDERS VALUES (103,70);
SELECT ORDER_ID,AMOUNT,METADATA$ACTION AS ACTION,
METADATA$ISUPDATE AS IS_UPDATE,METADATA$ROW_ID AS ROW_ID
FROM SOURCE_CHANGES ORDER BY ORDER_ID,ACTION;What to expect and why
Expect 101/100/DELETE/true and 101/120/INSERT/true; 102/50/DELETE/false; 103/70/INSERT/false. The update pair shares its source row identity. Actual ROW_ID strings are generated by Snowflake.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
How many change rows should this controlled example show?
Compare your reasoning
Four: two for the update, one genuine delete and one new insert.