Step 2. Create a Named Stage Object

Execute CREATE STAGE to create a named external stage. An external stage references data files stored in a S3 bucket. In this case, we are creating a stage that references the sample data files necessary to complete the tutorial.

This step is recommended when you plan to load data files regularly from the same source.

The following examples create external stages that specify the file formats you created in Step 1. Note that if you specify file format options (or a named file format object) for the stage, it isn’t necessary to later specify the same file format options in the COPY command used to load data from the stage.

Stage for CSV Data Files

The following example creates an external stage named my_csv_stage. Parameter values that aren’t specified use the default values (DATE_FORMAT = AUTO, COMPRESSION = AUTO, etc.).

CREATE OR REPLACE STAGE my_csv_stage
  FILE_FORMAT = mycsvformat
  URL = 's3://snowflake-docs';

Stage for JSON Data Files

The following example creates an external stage named my_json_stage. Parameter values that aren’t specified use the default values (DATE_FORMAT = AUTO, COMPRESSION = AUTO, etc.).

CREATE OR REPLACE STAGE my_json_stage
  FILE_FORMAT = myjsonformat
  URL = 's3://snowflake-docs';

Note

In regular use, if you were creating a stage that pointed to your private data files, you would provide an AWS key and secret key:

CREATE OR REPLACE STAGE external_stage
  FILE_FORMAT = mycsvformat
  URL = 's3://private-bucket'
  CREDENTIALS = (AWS_KEY_ID='1a2b3c' AWS_SECRET_KEY='1a2b3c');

Next: Step 3. Copy Data Into the Target Table