Database Objects & SQL Foundations
Read a clear definition, compare the concepts, then try the SQL or client command. Detailed explanations and diagrams remain available when you need them.
Before you begin
Beginner · 13 lessons · About 183 minutes including detailed reading.
Prerequisite: Architecture, Warehouses & Billing Basics. Reading needs no account. Manual SQL practice requires an authorized Snowflake account, suitable role and warehouse. Commands are examples, not executed by this website.
Create the isolated L2_OBJECTS_LAB database and SALES schema in the first lesson. Run each setup once; use fresh names if objects already exist. The final business-query lab applies the earlier lessons.
Begin Module 03 →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.
What this module covers
- Object hierarchy: databases, schemas, tables, and views; fully qualified names.
- Permanent, transient, and temporary tables; standard and secure views; sequences.
- Data types: NUMBER, FLOAT, VARCHAR, BOOLEAN, BINARY, DATE, TIME, and TIMESTAMP_NTZ/LTZ/TZ.
- DDL: CREATE, ALTER, DROP, and TRUNCATE.
- DML: INSERT, UPDATE, DELETE, and MERGE.
- Queries: SELECT, WHERE, DISTINCT, ORDER BY, LIMIT, GROUP BY, and HAVING.
- Expressions: CASE, NULL handling, COALESCE, NVL, and NULLIF.
- Built-in string, numeric, date/time, conversion, and conditional functions.
- Lab: Build a small schema, load sample rows, and write business queries.
Your lesson path
- Lesson 1 · About 12 min
Databases, schemas and tables
A database groups related data objects. A schema organizes objects inside that database. A table holds rows and columns, such as one row for each order.
Read and practise → - Lesson 2 · About 15 min
Choose numeric, text, Boolean and binary types
A data type defines which values a column can hold and how Snowflake interprets them.
Read and practise → - Lesson 3 · About 15 min
Read, filter and order rows
SELECT chooses columns and expressions. WHERE filters rows; ORDER BY determines presentation; LIMIT caps the returned row count.
Read and practise → - Lesson 4 · About 15 min
CASE and missing values
CASE chooses a result from conditions. NULL means missing or unknown, so it needs explicit handling.
Read and practise → - Lesson 5 · About 15 min
Clean, calculate and convert values
Built-in functions transform text, numbers and dates. Conversion functions interpret values as a chosen type.
Read and practise → - Lesson 6 · About 15 min
Summarize groups with GROUP BY and HAVING
GROUP BY combines rows into groups. Aggregate functions summarize each group; HAVING filters the summaries.
Read and practise → - Lesson 7 · About 15 min
Dates, times and timestamp choices
DATE stores a calendar date, TIME stores a clock time, and timestamps combine date and time with different time-zone semantics.
Read and practise → - Lesson 8 · About 12 min
Choose how long a table should live
Permanent, temporary and transient tables differ in lifetime and recovery protection. Choose by how the data will be used and whether you can rebuild it.
Read and practise → - Lesson 9 · About 12 min
Views and secure views
A view is a named query that you read like a table. A secure view adds protections for its definition and underlying data exposure; it still needs correct grants and filters.
Read and practise → - Lesson 10 · About 12 min
Sequences generate identifiers
A sequence is an object that supplies numeric values. It is useful for generated identifiers, but its values are not a gap-free business counter.
Read and practise → - Lesson 11 · About 15 min
Create, change, empty and remove a table
CREATE defines an object, ALTER changes its definition, TRUNCATE removes its rows, and DROP removes the object.
Read and practise → - Lesson 12 · About 15 min
Insert, update, delete and merge rows
DML changes table rows. MERGE matches incoming rows to a target and chooses an update or insert action.
Read and practise → - Lesson 13 · About 15 min
Lab: build a small sales dataset
Apply the object and SQL concepts to a small, disposable sales table and answer a business question.
Read and practise →