tee / insights
LEARNING / SNOWFLAKEHome

Snowflake / Data operations

Snowflake Data Operations Study Guide

Learn access scope, data changes, recovery, loading, automation, and validation as one workflow. The goal is not to memorize syntax, but to know what to verify before a change, how to recover, and what to validate after a rerun.

This is an independent learning resource. It does not reproduce the scope or questions of any official Snowflake certification exam.

Specifications checked 2026-10-08

Treat the five areas as one operation

The five areas are connected. Identify who may change which object, control the change boundary, load or rerun work, and validate the resulting data.

A

Access and structure

Check roles, databases, schemas, tables, views, and session context.

B

Data changes

Reason about INSERT, UPDATE, DELETE, MERGE, scope, duplicates, and reruns.

C

Transactions and recovery

Separate BEGIN / COMMIT / ROLLBACK from Time Travel and UNDROP.

D

Loading and automation

Connect stages, file formats, COPY INTO, tasks, and stored procedures.

E

Validation and operations

Check JOIN grain, NULLs, late data, counts, keys, values, and reprocessing.

Five checks before you run a change

Read data-changing work in this order.

StepCheck
1. ContextCheck CURRENT_ROLE(), CURRENT_DATABASE(), and CURRENT_SCHEMA().
2. ScopeUse a fully qualified object name and a precise WHERE clause.
3. BoundaryIf several DML statements must succeed or fail together, define a transaction boundary.
4. Re-runAsk whether a second run causes duplicates or repeated changes.
5. ValidateDo not stop at a success status; validate counts, keys, and values.

A. Confirm role and object scope

Snowflake users operate through roles, and privileges granted to those roles authorize object access. Correct SQL can still fail for lack of privilege. Checking the current role, database, and schema first also reduces the chance of changing the wrong environment or a same-named table.

SELECT
  CURRENT_ROLE(),
  CURRENT_DATABASE(),
  CURRENT_SCHEMA();

Schema objects can be referenced as database.schema.object. For data-changing statements, a fully qualified name such as SALES_DB.CORE.ORDERS reduces reliance on the session's current database and schema.

SELECT *
FROM SALES_DB.CORE.ORDERS;

For read-only work, a typical least-privilege design grants only what is required, such as USAGE on the database and schema and SELECT on the table. Check the required operation before switching to a stronger role.

B. Change data safely

INSERT adds rows, UPDATE changes existing rows, and DELETE removes rows. UPDATE and DELETE without a WHERE clause target every row, so previewing the same predicate with SELECT helps verify the row count and keys first.

SELECT ORDER_ID, CUSTOMER_ID, STATUS
FROM SALES_DB.CORE.ORDERS
WHERE CUSTOMER_ID = 1001;

UPDATE SALES_DB.CORE.ORDERS
SET STATUS = 'CANCELLED'
WHERE CUSTOMER_ID = 1001;
StatementPurposeSafety question
INSERTAdd new rowsCan the same input be inserted twice?
UPDATEChange matching rowsIs the WHERE clause broader than intended?
DELETERemove matching rowsCan you preview the exact rows with SELECT?
MERGEUpdate, insert, or delete by matchAre the ON key and source uniqueness clear?

MERGE can combine UPDATE, INSERT, and DELETE according to source-target matches. It does not make a duplicated source unique by itself. Choose a business key and verify source uniqueness before merging.

MERGE INTO SALES_DB.CORE.ORDERS AS t
USING LANDING_DB.RAW.ORDERS_STAGE AS s
  ON t.ORDER_ID = s.ORDER_ID
WHEN MATCHED THEN
  UPDATE SET t.STATUS = s.STATUS, t.AMOUNT = s.AMOUNT
WHEN NOT MATCHED THEN
  INSERT (ORDER_ID, CUSTOMER_ID, AMOUNT, STATUS)
  VALUES (s.ORDER_ID, s.CUSTOMER_ID, s.AMOUNT, s.STATUS);

NULL is different from zero and an empty string. Use IS NULL / IS NOT NULL to test it. For reruns, check idempotency: running the same input again should not create unintended duplicates or additional changes.

C. Separate transactions from recovery

BEGIN starts an explicit transaction, COMMIT makes it durable, and ROLLBACK cancels changes in that transaction. Use an explicit transaction when several DML statements belong to one success-or-failure unit.

BEGIN TRANSACTION;

UPDATE SALES_DB.CORE.ORDERS
SET STATUS = 'CLOSED'
WHERE ORDER_DATE < '2026-01-01';

COMMIT;

In Snowflake, executing DDL implicitly commits an active transaction, and the DDL runs as its own transaction. DDL cannot be rolled back. Do not mix DML and DDL while assuming one later ROLLBACK will undo everything.

ROLLBACK is for the current uncommitted transaction. Recovery after committed changes or a dropped object is different. Within the applicable retention period, Time Travel can expose historical data, and UNDROP can restore supported dropped objects.

MechanismTargetUse
ROLLBACKCurrent uncommitted explicit transactionCancel the current unit of work.
Time TravelHistorical data within retentionQuery or use a prior state for recovery.
UNDROPSupported dropped objects within retentionRestore the most recently dropped object where allowed.

D. Connect file loading and automation

A useful loading model is Stage → File Format → COPY INTO → Table. A stage identifies the file location, a file format defines how CSV, JSON, and other files are interpreted, and COPY INTO loads the table.

StageFile FormatCOPY INTOTableTask / Stored Procedure
COPY INTO SALES_DB.CORE.ORDERS
FROM @LANDING_DB.RAW.ORDER_STAGE
FILE_FORMAT = (
  FORMAT_NAME = 'LANDING_DB.RAW.ORDER_CSV'
);

For automation, a Task answers when work runs, while a Stored Procedure can package what the work does. A task may call a stored procedure that performs a MERGE and validation steps.

E. Validate counts, keys, and values

A larger row count after a JOIN is not automatically an error. If ORDERS has one row per order and ORDER_ITEMS has one row per item, a one-to-many join naturally repeats an order. Confirm what one row means in each table before judging the result.

COUNT(*) counts rows, while COUNT(column) excludes rows where that column is NULL. Equal source and target row counts are still not complete validation because keys or values may differ.

SELECT COUNT(*) AS row_count,
       COUNT(AMOUNT) AS amount_count
FROM SALES_DB.CORE.ORDERS;

SELECT ORDER_ID, COUNT(*) AS duplicate_count
FROM SALES_DB.CORE.ORDERS
GROUP BY ORDER_ID
HAVING COUNT(*) > 1;

For late-arriving data, separate the business/event time from the ingestion time. If processing windows overlap to catch late records, combine that overlap with rerun-safe deduplication or merging.

LevelWhat to check
1. CountUse COUNT(*) to catch large missing or extra sets.
2. KeyCheck missing, extra, and duplicated business keys.
3. ValueCompare important columns and aggregates such as SUM, MIN, and MAX.

Knowledge check

Before opening an answer, reason in this order: scope, transaction boundary, rerun behavior, and validation.

01You want to cancel only customer 1001's orders, but the UPDATE has no WHERE clause. What is wrong?

Every row becomes a target. Preview the intended predicate with SELECT, then limit the UPDATE with a precise WHERE clause.

02COUNT(AMOUNT) is 95 while COUNT(*) is 100. What should you check first?

Five rows may have AMOUNT = NULL. COUNT(column) excludes NULL values.

03You rerun the same staged input. Is INSERT SELECT alone rerun-safe?

Not necessarily. The same rows may be inserted again. Define the business key and use deduplication or a suitable MERGE design.

04You BEGIN, run UPDATE, then CREATE TABLE, then ROLLBACK. Is the UPDATE guaranteed to roll back?

No. Snowflake DDL implicitly commits an active transaction, so you must not assume the later ROLLBACK reverses everything.

05MERGE matches on ORDER_ID, but the source contains the same ORDER_ID more than once. What should you verify?

Make the source unique at the business-key grain so one target row does not depend on multiple competing source rows.

06Source and target both contain 10,000 rows. Is that enough to declare success?

No. Also check missing or duplicate keys and the important values associated with them.

Final review checklist

For each scenario, check the object, privilege, row scope, transaction boundary, rerun behavior, and validation. Knowing the SQL syntax is not enough if the intended target is not constrained.

OBJECTPRIVILEGEWHERETRANSACTIONRE-RUNVALIDATE

Official references

The behavior described here is checked against Snowflake documentation. Account-specific settings, including retention and grants, still need to be verified in the actual environment.