Module 05 · Lesson 7 of 15Detailed study · about 20 min

Download and remove staged files

GET downloads files from an internal stage to your client machine. REMOVE deletes staged files. Neither command is a table-row operation.

Understand the idea

First distinguish downloading a file from querying its records. GET works with internal stages and a supported client such as SnowSQL. For an external stage, use the cloud provider’s download tools instead. A worksheet cannot write directly to your laptop folder.

Key ideas in simple English
ConceptWhat it means
GETCopy internal-stage files to a local folder using a supported client.
LISTInspect the exact file path before acting.
REMOVEDelete matching files in a stage; this can delete source cloud objects on an external stage.

A concrete example

In a supported local client, expect the matching staged file to be downloaded. Check its local content; GET does not create a table.

Remember: GET is for internal stages. REMOVE targets files, so inspect its scope before running it.

Explain it step by step · full theory

Understand the idea

First distinguish downloading a file from querying its records. GET works with internal stages and a supported client such as SnowSQL. For an external stage, use the cloud provider’s download tools instead. A worksheet cannot write directly to your laptop folder.

REMOVE is destructive. A stage path is a prefix, so a narrow-looking path can still match several names. Inspect LIST and use an anchored pattern for the exact learning file. Keep the original local file so you can upload it again.

Follow the workflow

The sample orders_stage and orders.csv come from the preceding upload lesson. Replace the local destination with a folder on the machine running your client. Download first and open the file before practising removal.

After removing the file, the later preview lesson needs a new upload. Do this cleanup after you have finished previews, not in the middle of the shared workflow. Removing an external file also requires provider-side delete permission; read-only integration access should not have it.

Words used in this lesson
GET
Copy internal-stage files to a local folder using a supported client.
LIST
Inspect the exact file path before acting.
REMOVE
Delete matching files in a stage; this can delete source cloud objects on an external stage.

See how it works

Choose a step to explore the idea at your own pace.

Open the interactive explanation
Interactive explainer1 / 3

Download and remove staged files

Source files
Storage location

Locate the data

GET downloads files from an internal stage to your client machine. REMOVE deletes staged files. Neither command is a table-row operation.

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
  1. Locate the data

    GET downloads files from an internal stage to your client machine. REMOVE deletes staged files. Neither command is a table-row operation.

  2. Configure the boundary

    First distinguish downloading a file from querying its records. GET works with internal stages and a supported client such as SnowSQL. For an external stage, use the cloud provider’s download tools instead. A worksheet cannot write directly to your laptop folder.

  3. Observe the outcome

    GET is for internal stages. REMOVE targets files, so inspect its scope before running it.

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.

  1. No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
  2. 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.
  3. 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.
  4. 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
Our shared source file

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-04

Notice 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
  1. Select an authorized sandbox database and schema. Keep this context consistent across your client sessions.
  2. Create orders_csv_v1 using lesson 3, then orders_stage using lesson 5. Use fresh sandbox names; do not replace existing shared objects.
  3. 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.
  4. Keep only this sample file under the incoming/ prefix when following the four-row expected results.
  5. 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

Manual learning examples, not executed here. Use L2_OBJECTS_LAB.SALES from Module 03 and an authorized warehouse for previews. Run shared format/stage setup once. Cloud examples are templates: replace every <placeholder>, use approved cloud resources, and follow the provider setup before running SQL. No credentials belong in this website.

Download the internal-stage file

SnowSQL client command · example
GET @orders_stage/incoming/orders.csv file:///tmp/learnsnowflake/download/;

What to expect and why

In a supported local client, expect the matching staged file to be downloaded. Check its local content; GET does not create a table.

Inspect, then remove only the sample file

SQL · example
LIST @orders_stage/incoming/ PATTERN='.*[/]orders[.]csv$';
-- After verifying the intended file and keeping your local original:
REMOVE @orders_stage/incoming/ PATTERN='.*[/]orders[.]csv$';
LIST @orders_stage/incoming/;

What to expect and why

After successful removal, orders.csv is no longer listed under this prefix. No table rows are deleted. Re-upload the original before repeating file previews.

Check your understanding

Choose an answer, then check your reasoning. This is practice, not a scored test.

Can GET download an external S3 stage to your laptop?

Try it yourself

What should you do before continuing previews after cleanup?

Compare your reasoning

Upload the saved original orders.csv back into orders_stage/incoming/ using the earlier PUT command.

Official sources and curriculum

Module 05 · See module scope