From a file to a table: understand the journey
A file holds source bytes, a stage locates files, and a table holds loaded rows.
Understand the idea
Imagine an online shop sends you an orders spreadsheet every morning. Yesterday you queried an ORDERS table with SELECT. Today you have a file on your laptop. Those are different starting points: having a file does not mean its rows already exist inside a Snowflake table.
| Concept | What it means |
|---|---|
| File | The delivered source, such as orders.csv. |
| Stage | A named or built-in file location. |
| Table | Typed records created or loaded separately. |
A concrete example
A teammate says “the orders are in Snowflake” after uploading orders.csv. Ask whether they mean that the file is staged or that its records have been loaded into ORDERS. That distinction prevents a dashboard team from querying a table that has not been refreshed.
Remember: Ask where the file is, how it is read and where its records should go. These are three separate decisions.
Explain it step by step · full theory
Start with a familiar situation
Imagine an online shop sends you an orders spreadsheet every morning. Yesterday you queried an ORDERS table with SELECT. Today you have a file on your laptop. Those are different starting points: having a file does not mean its rows already exist inside a Snowflake table.
Think of receiving a parcel. The delivery area tells you where the parcel is. The packing instructions explain how to unpack it. The shelf is where the unpacked items belong. A stage, a file format and a table play these separate roles in our example.
Four pieces, four responsibilities
The source file contains the actual bytes: letters, commas, quotes and line breaks. A stage makes a file location available to Snowflake. A file format describes how to interpret those bytes. A table stores the loaded records in typed columns.
A named file format is a database object containing settings. It contains neither the orders nor their storage location. Creating it does not inspect your file or prove that the settings match the producer’s export.
| Part | Example | Question it answers |
|---|---|---|
| Source file | orders.csv | What data did the shop send? |
| Stage | @orders_stage/incoming/ | Where can Snowflake find it? |
| File format | orders_csv_v1 | How should those bytes be read? |
| Destination table | ORDERS | Where should typed records be stored? |
Upload, preview and load are separate actions
Uploading places a local file in an internal stage. Previewing reads staged data through a SELECT. Loading with COPY INTO writes records into a destination table. A successful upload therefore proves only that the transfer worked; it says nothing yet about whether the amount column is valid.
In this module we stop at understanding and previewing files. Module 06 will cover COPY INTO, load validation and load outcomes. You do not need a destination table to follow the staged-file previews here.
- Inspect the source file and its agreed layout.
- Choose a stage and place or locate the file there.
- Apply a file format that matches the source.
- Preview the values and check their meaning.
- Only then prepare the table-loading step.
Read the shared example before touching SQL
Our CSV has one header line followed by four order records. The name Asha, Rao contains a comma inside double quotes. Ben’s amount is empty. Cara’s amount contains the literal text NULL. Dev’s amount is zero. These are deliberate differences, not typing mistakes.
Before continuing, predict two things: how many data records should appear, and whether Ben’s unknown amount should mean the same thing as Dev’s zero. The intended answers are four records and no: unknown is different from a known zero.
Words used in this lesson
- Stage
- An internal file storage location or a named reference to external cloud storage.
- File format
- Rules for interpreting or writing a file.
- Loading
- Writing records from a source into a destination table.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
From a file to a table: understand the journey
Source
The shop exports four orders plus a header.
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
- Source
The shop exports four orders plus a header.
- Location
The stage provides access to the file.
- Interpretation
The format tells the reader about the header, commas, quotes and missing amounts.
- Destination
A later load operation writes typed rows into a table.
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.
Shared orders.csv and internal-stage setup
Four orders, one CSV contract
Every CSV lesson uses this fictional orders.csv. One data record represents one order. The first line is a header; the four remaining lines are data. All amounts use the same fictional currency.
order_id,customer_name,amount,order_date
101,"Asha, Rao",120.50,2025-01-01
102,Ben,,2025-01-02
103,Cara,NULL,2025-01-03
104,Dev,0,2025-01-04Notice the comma inside Asha’s quoted name, Ben’s empty amount, Cara’s literal NULL marker and Dev’s zero. We will follow these exact values from file bytes to parsed fields.
Setup order for optional manual practice
- Select an authorized sandbox database and schema. Keep this context consistent across your client sessions.
- Create orders_csv_v1 using lesson 3, then orders_stage using lesson 5. Use fresh sandbox names; do not replace existing shared objects.
- Save the text above as a UTF-8 file named orders.csv. Upload it with a supported local client or the named-stage upload interface.
- Keep only this sample file under the incoming/ prefix when following the four-row expected results.
- Select an authorized warehouse for the staged SELECT examples. File previews use compute; this website runs no SQL.
The examples assume the required role privileges described in the lessons. The external-stage and JSON examples have their own additional setup and are clearly marked.
Before running this lesson
Internal-stage learning path. Use L2_OBJECTS_LAB.SALES from Module 03, with an authorized role and warehouse. Create orders_csv_v1 in lesson 3, then orders_stage in lesson 5. Save the exact sample as UTF-8 orders.csv. Keep only this file in incoming/ for the illustrated four-row results. Use fresh names if a setup object already exists.
Save this source as orders.csv
order_id,customer_name,amount,order_date
101,"Asha, Rao",120.50,2025-01-01
102,Ben,,2025-01-02
103,Cara,NULL,2025-01-03
104,Dev,0,2025-01-04What to expect and why
Save these five lines as UTF-8 orders.csv on your client machine. The first line is a header. The file has four data records; do not execute this text as SQL.
Choose the existing learning schema
USE DATABASE L2_OBJECTS_LAB;
USE SCHEMA SALES;What to expect and why
Requires the Module 03 setup and role access. Later examples create objects in this selected schema.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Explain the roles of orders.csv, orders_stage, orders_csv_v1 and ORDERS to someone who has never loaded data.
Compare your reasoning
orders.csv holds the source bytes. orders_stage gives Snowflake a location to access. orders_csv_v1 explains the layout. ORDERS is the eventual destination for typed records.
Official sources and curriculum
Module 05 · See module scope