Snowflake Stage
Snowflake Stages
Snowflake stages are locations where data files are stored ("Staged") which helps in loading data into and unloading data out of database tables.
we use this staging areas for both inbound and outbound process
The stage locations could be internal or external to snowflake environment.
max file size that is allowed to be uploaded from webUI 20 MB. That is the reason we generally use this snowSQL command to put and get files from any stage.
Upload file into stage :
put file://<source_path>//<Source file Name> @~; -- User Stage
put file://<source_path>//<Source file Name> @~; -- User Stage
put file://<source_path>//<Source file Name> @%<table name>; -- Table Stage
put file://<source_path>//<Source file Name> @<Internal Stage Name>; -- Internal Named Stage
Internal Stages or 3 Types :
Internal Stages or 3 Types :
1. Table Space :
2. User Space :
3. Named Space : we will be discussing about this next chapter
Externall Stages:
1. Named Stage (AWS / GCP / Azure) : We will be discussing about this in upcoming chapters.
Example of Creating named internal stage :
When we know the files we are planning to stage has a specific file format, we can create a stage as below.
CREATE OR REPLACE STAGE emp_pipe_csv_stage
file_format = (type = 'CSV' FIELD_DELIMITER = '|' SKIP_HEADER = 1);
list @MY_CSV_PIPE_STAGE;
select
$1::int as emp_ID,
$2::varchar(20) as NAME ,
$3::varchar(20) as job,
$4::int as manager,
$5::date as doj,
$6::int as sal,
$7::int as comm
from @MY_CSV_PIPE_STAGE;
Comments
Post a Comment