Snowflake

Snowflake Stages: The Complete Guide

2026-03-21
更新: 2026-03-27
NicheeLab Editorial Team

A Stage is the intermediate file location Snowflake uses for loading (ingest) and unloading (export) data. Bulk loads via COPY INTO, automated ingestion through Snowpipe, and data exports almost always go through a stage. Stages are a required Data Loading domain topic on the SnowPro Core exam.

Stage Types and Comparison

Snowflake offers 4 types of stages, each with its own use case, management model, and security profile.

Stage TypeReference SyntaxCreation MethodGRANT SupportPrimary Use Case
User Stage@~Automatic (per user)Not supportedPersonal scratch space for ad-hoc work
Table Stage@%table_nameAutomatic (per table)Not supportedTemporary loads dedicated to a specific table
Named Internal Stage@stage_nameCREATE STAGESupportedShared loads/unloads with permission management
External Stage@stage_nameCREATE STAGESupportedIntegration with existing data on S3, Azure Blob, or GCS

Creating and Using a Named Internal Stage

A Named Internal Stage stores files inside Snowflake's internal storage. Because it supports GRANT-based permission control, it is preferred over User and Table Stages for team operations.

-- Create a Named Internal Stage
CREATE OR REPLACE STAGE hr_load_stage
  FILE_FORMAT = (TYPE = CSV SKIP_HEADER = 1 FIELD_OPTIONALLY_ENCLOSED_BY = '"')
  COMMENT = 'CSV load stage for the HR team';

-- Upload files (SnowSQL / PUT)
PUT file:///data/employees.csv @hr_load_stage AUTO_COMPRESS = TRUE;

-- List files on the stage
LIST @hr_load_stage;

-- Load into the target table
COPY INTO hr.employees
FROM @hr_load_stage
PATTERN = '.*employees.*\.csv\.gz'
ON_ERROR = 'CONTINUE';

External Stage + Storage Integration

An External Stage references external storage on S3, Azure Blob Storage, or GCS directly. Because it does not copy data into Snowflake's internal storage, it is the ideal choice for integrating with an existing data lake.

Designing the Storage Integration

A Storage Integration is the object that securely manages access between Snowflake and cloud storage using IAM role-based delegation. It removes the need to embed long-lived keys and centralizes management under the ACCOUNTADMIN role.

-- Create the Storage Integration (ACCOUNTADMIN)
CREATE OR REPLACE STORAGE INTEGRATION s3_integration
  TYPE = EXTERNAL_STAGE
  STORAGE_PROVIDER = 'S3'
  STORAGE_AWS_ROLE_ARN = 'arn:aws:iam::123456789012:role/snowflake-access'
  ENABLED = TRUE
  STORAGE_ALLOWED_LOCATIONS = ('s3://data-lake-prod/raw/', 's3://data-lake-prod/staging/');

-- Fetch the values needed for the IAM trust relationship
DESC INTEGRATION s3_integration;

-- Create the External Stage
CREATE OR REPLACE STAGE data_lake_stage
  STORAGE_INTEGRATION = s3_integration
  URL = 's3://data-lake-prod/raw/'
  FILE_FORMAT = (TYPE = PARQUET);

COPY INTO Patterns with Stages

COPY INTO works in both directions: loading from a stage into a table, and unloading from a table to a stage.

-- Load: stage -> table
COPY INTO analytics.orders
FROM @data_lake_stage/orders/2026/03/
FILE_FORMAT = (TYPE = PARQUET)
MATCH_BY_COLUMN_NAME = CASE_INSENSITIVE;

-- Unload: table -> stage
COPY INTO @export_stage/monthly_report/
FROM (
  SELECT region, SUM(amount) AS total_amount
  FROM analytics.orders
  WHERE order_date >= '2026-03-01'
  GROUP BY region
)
FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP)
HEADER = TRUE
OVERWRITE = TRUE;

Key COPY INTO Options

OptionPurposeDefault
ON_ERRORHow to handle files with errorsABORT_STATEMENT
PURGEAuto-delete files after a successful loadFALSE
MATCH_BY_COLUMN_NAMEAuto-map source fields by column nameNONE
PATTERNFilter file names with a regular expression(none)
VALIDATION_MODEValidate input before loading(none)

Defining and Reusing FILE FORMAT

Defining a Named File Format up front lets you reuse a consistent format across multiple stages and COPY INTO statements.

-- Create a Named File Format
CREATE OR REPLACE FILE FORMAT csv_standard
  TYPE = CSV
  SKIP_HEADER = 1
  FIELD_DELIMITER = ','
  FIELD_OPTIONALLY_ENCLOSED_BY = '"'
  NULL_IF = ('NULL', 'null', '')
  EMPTY_FIELD_AS_NULL = TRUE;

-- Reference the file format from a stage
CREATE OR REPLACE STAGE shared_csv_stage
  FILE_FORMAT = csv_standard;

Directory Tables

Directory Tables let you query file metadata on a stage (file path, size, last modified, etc.) as if it were a table. Enable the feature by specifying DIRECTORY = (ENABLE = TRUE) when you create the stage.

-- Enable the Directory Table
ALTER STAGE data_lake_stage SET DIRECTORY = (ENABLE = TRUE);

-- Manually refresh the metadata
ALTER STAGE data_lake_stage REFRESH;

-- Query the Directory Table
SELECT *
FROM DIRECTORY(@data_lake_stage)
WHERE FILE_URL LIKE '%2026/03%'
ORDER BY LAST_MODIFIED DESC;

Security Best Practices

  • Always use a Storage Integration for External Stages: avoid embedding long-lived keys and delegate access via an IAM role
  • Scope access with STORAGE_ALLOWED_LOCATIONS: restrict the allowed buckets/paths on the Storage Integration to the minimum required
  • Apply appropriate GRANTs to Named Stages: for team operations, control USAGE / READ / WRITE privileges at the role level
  • Internal Stage encryption: Snowflake automatically applies AES-256 encryption with no additional configuration required

Check Your Understanding

Data Loading / Security

問題 1

You are designing a configuration to load Parquet files from a shared S3 bucket into Snowflake. The security requirement states that long-lived keys must not be stored in Snowflake. Which configuration is most appropriate?

  1. Have each member PUT files to a User Stage and run COPY INTO individually
  2. Create a Storage Integration with IAM role delegation and reference it from an External Stage
  3. Create an External Stage on a Table Stage by specifying AWS_KEY_ID and AWS_SECRET_KEY directly
  4. Create a Named Internal Stage and PUT files from S3 into Snowflake before loading

正解: B

To satisfy the requirement that long-lived keys must not be stored in Snowflake, the best fit is to configure IAM role-based delegation through a Storage Integration and reference it from an External Stage. Passing AWS_KEY_ID directly embeds a long-lived key and fails the requirement. An Internal Stage requires files to be PUT into Snowflake first and does not reference the existing S3 location directly.

Frequently Asked Questions

Can you create an External Stage without a Storage Integration?

Yes, it is technically possible to create an External Stage by passing AWS_KEY_ID and AWS_SECRET_KEY directly. However, embedding credentials in the stage definition creates a serious security risk. Snowflake's official documentation strongly recommends using a Storage Integration, which delegates access via an IAM role and eliminates the need to manage long-lived keys. The exam consistently frames Storage Integration as the 'more secure choice.'

What are the limitations of User Stages and Table Stages?

A User Stage (@~) is auto-provisioned per user as a personal area and cannot be accessed by other users. A Table Stage (@%table_name) is auto-provisioned per table and is dedicated to COPY INTO that table. Both are convenient because they require no CREATE STAGE statement, but unlike Named Stages they cannot pre-define a file format or accept GRANTs. For team operations, a Named Internal Stage is the recommended choice.

Does COPY INTO automatically delete files from the stage after loading?

By default, loaded files remain in the stage. If you set PURGE = TRUE on COPY INTO, the target files are automatically removed from the stage after a successful load. PURGE can struggle to judge partially loaded files, however, so if you need strict file management, consider using the REMOVE command for manual cleanup instead.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Snowflake

Snowflake Certifications: All 11 Exams Explained (2026)

Every SnowPro certification — Associate, Core, Specialty, Ad...

Snowflake

Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)

All 11 SnowPro exams ranked by difficulty with study-time es...

Snowflake

Snowflake Study Guide: Fastest Pass Route by Exam (2026)

How to pass SnowPro certifications efficiently — official ma...

Snowflake

SnowPro Core (COF-C03): Complete Exam Guide (2026)

Pass the SnowPro Core exam — six domains, scope, sample ques...

Snowflake

SnowPro Associate Platform (SOL-C01): Complete Guide (2026)

The entry-level SnowPro Associate exam — scope, weighting, s...

Browse all Snowflake articles (103)
© 2026 NicheeLab All rights reserved.