SnowPro Core Prep

Lab 02 · Domain 1 objects · You are Priya

Object catalog — what lives where

Read every Teach first section before you copy SQL. Snowflake has many object types. Today you touch the ones Core loves to name-drop — and learn which ones sit at account level vs inside a schema.

Business problem Riley says “put it on a stage,” Kai says “isn’t that a table?”, Morgan asks “is a share a database?” Mixing object types = wrong grant, wrong load path, wrong exam answer.
Solution you will build Create a tiny PRODUCTS table, a view, a sequence, a CSV file format, and an internal named stage in ALPINE_RETAIL.LAB — then SHOW them so the catalog feels real.
Before
Everything is “a table”
  • View ≈ materialized view blur
  • User stage vs named stage blur
  • No idea what’s account-level
After
Labeled toolbox
  • Table / view / sequence / format / stage
  • Named stage = shared folder recipe
  • WH, roles, users → account level

Episode 02 · Start here

Riley names five objects. Kai hears “files.”

RileyEngineer — pipelines
Priya, we need a table for products, a view for cheap SKUs, a sequence for order IDs, a file format, and a stage for inbound CSVs.
KaiAnalyst — still learning
That’s… five different things? I thought Snowflake was just tables and SQL.

Dev (off-panel): Each object has a job. The exam asks “which object?” constantly.

See it — objects as jobs

Data
TABLE vs VIEW

Table stores rows. View stores a saved SELECT (no private copy of the result).

LAB.PRODUCTS
LAB.V_PRODUCTS_CHEAP
MV awareness
Materialized view

Stores precomputed results — refresh/cost tradeoff. Not the same as a normal view.

Exam: “precomputed” → MV
“just a saved query” → view
Load path
STAGE + FILE FORMAT

Stage = folder pointer. File format = CSV/JSON recipe. Used together on COPY.

@LAB.STG_INBOUND
+ FF_CSV_STD
Numbers
SEQUENCE

Hands out unique numbers (order IDs) without racing inserts.

SEQ_ORDER_ID.NEXTVAL
1000, 1001, …
Later labs
Pipe · Stream · Task · Share

Continuous load, change feed, schedule, outbound share — know the names today.

PIPE / STREAM / TASK
SHARE (account collab)
Code
UDF · Procedure

Functions return values; procedures run multi-step logic (often scripting).

UDF in SELECT
CALL my_procedure()

Account-level vs schema-level

Account WH · Roles · Users also shares, integrations…
Database ALPINE_RETAIL contains schemas
Schema LAB Tables · Views · Stages sequences · formats · …

Before Step 1

Dev: “Start with SHOW.”

KaiAnalyst
Do I memorize every object type before creating anything?
DevCoach
No. SHOW warehouses/databases/schemas first — see the tree. Then create one of each common schema object.

1 Orient with SHOW

What this does: Lists Alpine’s warehouse, database, and schemas — account vs DB vs schema awareness.

SQL · SHOW catalog
USE ROLE ROLE_CORE_LAB_ADMIN;
USE WAREHOUSE WH_CORE_XS;
USE DATABASE ALPINE_RETAIL;

SHOW WAREHOUSES LIKE 'WH_CORE%';
SHOW DATABASES LIKE 'ALPINE%';
SHOW SCHEMAS IN DATABASE ALPINE_RETAIL;
✓ See WH_CORE_XS, ALPINE_RETAIL, schemas LAB / SECURE / PIPELINE / SHARE_DEMO

Before Step 2

Riley: “Table first, then view.”

RileyEngineer
A view is a window on a table. If someone drops the table, the window shows nothing useful.
DevCoach
Exact. Materialized views are different — they store results. Exam distractor: treating MV like a free normal view.

2 Table + view

What this does: Creates PRODUCTS and a cheap-SKU view.

SQL · table + view
USE SCHEMA LAB;

CREATE OR REPLACE TABLE LAB.PRODUCTS (
  PRODUCT_ID NUMBER, SKU STRING,
  NAME STRING, UNIT_PRICE NUMBER(10,2)
);
INSERT INTO LAB.PRODUCTS VALUES
  (1, 'ALP-TEE', 'Alpine Tee', 29.00),
  (2, 'ALP-HAT', 'Trail Hat', 19.50);
SQL · view
CREATE OR REPLACE VIEW LAB.V_PRODUCTS_CHEAP AS
SELECT PRODUCT_ID, SKU, NAME, UNIT_PRICE
FROM LAB.PRODUCTS
WHERE UNIT_PRICE < 25;

SELECT * FROM LAB.V_PRODUCTS_CHEAP;
✓ View returns Trail Hat only (19.50)

Before Step 3

Kai: “What’s NEXTVAL?”

KaiAnalyst
Can two inserts grab the same order ID if they run at once?
DevCoach
Sequences hand out unique numbers safely. Gaps can happen — uniqueness matters more than “no gaps.”

3 Sequence

What this does: Creates SEQ_ORDER_ID starting at 1000 and pulls two values.

SQL · sequence
CREATE OR REPLACE SEQUENCE LAB.SEQ_ORDER_ID
  START = 1000 INCREMENT = 1;

SELECT LAB.SEQ_ORDER_ID.NEXTVAL AS next_id;
SELECT LAB.SEQ_ORDER_ID.NEXTVAL AS next_id;
✓ First call ≈ 1000, second ≈ 1001

Before Step 4

Named stage vs user stage

MorganManager
Can everyone dump files into Kai’s personal user stage for production loads?
DevCoach
No. User stage (@~) is personal. Named stage in a schema is shareable with roles — that’s what teams use.

4 File format + internal named stage

What this does: Creates a CSV recipe and an internal stage that references it.

SQL · format + stage
CREATE OR REPLACE FILE FORMAT LAB.FF_CSV_STD
  TYPE = CSV FIELD_DELIMITER = ','
  SKIP_HEADER = 1
  FIELD_OPTIONALLY_ENCLOSED_BY = '"';

CREATE OR REPLACE STAGE LAB.STG_INBOUND
  FILE_FORMAT = LAB.FF_CSV_STD;

SHOW STAGES IN SCHEMA LAB;
SHOW FILE FORMATS IN SCHEMA LAB;
✓ STG_INBOUND and FF_CSV_STD listed under LAB

Exam presses further — say these out loud

Cover each answer before you open it.

Q1. View vs materialized view — what’s the difference?

Say: A view is a saved query with no stored result set. A materialized view stores precomputed results and has refresh/cost implications. Don’t call every view an MV.

Q2. Named stage vs user stage?

Say: User stage (@~) is private to the user. A named stage is a schema object you can grant to roles — preferred for shared pipelines.

Q3. What objects are typically account-level?

Say: Warehouses, users, roles, and (among others) shares and account-level integrations. Tables/views/stages usually live in a schema inside a database.

Q4. Why attach a FILE FORMAT to a stage?

Say: So COPY / LIST consumers inherit the CSV/JSON parsing recipe. You can still override per statement — defaults reduce mistakes.

Q5. Pipe vs Task vs Stream — one sentence each?

Say: Pipe = continuous/auto load from stage. Stream = change-data feed on a table. Task = scheduled SQL (often after streams). Different jobs, different CREATE statements.

Priya’s wrap-up (say this out loud)
“In ALPINE_RETAIL.LAB I created PRODUCTS, view V_PRODUCTS_CHEAP, sequence SEQ_ORDER_ID, file format FF_CSV_STD, and named stage STG_INBOUND. Views don’t store results; MVs do. Named stages are shareable; user stages are personal. Warehouses and roles live at account level.”
Next Lab 03 — micro-partitions, pruning, and clustering keys.
← Lab 01 Lab 03 — micro-partitions →