<aside> š”
In Snowflake, a stage represents a named object that acts as a temporary holding area for data files being loaded into a Snowflake table. The data can be stored in either Snowflake internal storage or external storage services like Amazon S3 or Microsoft Azure. A stage provides a way to manage and control access to the data being loaded into Snowflake.
</aside>
TheĀ Snowflake Data CloudĀ is a cloud-based data warehousing platform that allows businesses to store and query data for analytical purposes. In order to do this, Snowflake leverages several different stages, allowing businesses to move their data from one place to another.
Snowflake Stages are locations where data files are stored (staged) for loading and unloading data. They are used to move data from one place to another, and the locations for the stages could be internal or external to the Snowflake environment.
Snowflake supports two different types of data stages: external stages and internal stages.
The Snowflake COPY INTO
is a command that allows users to load data from a stage (internal/external) into a table. This further allows users to control the data transfer process and protect their data from unauthorized access.
COPY INTO
command, users need to create a stage table and then use the COPY INTO
command to load the data into the table.COPY INTO
command allows users to specify the data source, target table, and data format. Once the data is loaded into the staging table, users can use the SELECT
command to move the data from the staging table to the main Snowflake table (move into production).// Create stage table
CREATE OR REPLACE TABLE MENU
(
menu_id NUMBER(19,0),
...
);
// Create external stage
CREATE OR REPLACE STAGE my_stage
url = 's3://path_to_file/'
file_format = (type = csv);
// Load from external stage into stage table
COPY INTO menu
FROM @my_stage/file.csv;
LIST
command.CREATE OR REPLACE STAGE my_stage
url = 's3://path_to_file/'
---> query the Stage to find file
LIST @my_stage
Some of the best practices to manage Snowflake stages are as follows: