To ingest data from local files:
- Create the destination table.
- Use the PUT command to copy the local file(s) into the Snowflake staging area for the table.
- Use the COPY command to copy data from the data source into the Snowflake table.
For more details about the PUT and COPY commands, see DML - Loading and Unloading in the SQL Reference.
If the specified source location ends in a ‘/’, Snowflake attempts to copy all the files in that directory.
Create a Snowflake table:
CREATE OR REPLACE TABLE mytable ( name string, id string, amount number ) STAGE_FILE_FORMAT = ( TYPE = 'csv' FIELD_DELIMITER= '\t' );
Copy the local file ‘mydatafile.csv’ to the table’s data source (the staging area in S3):
PUT file://tmp/mydatafile.csv @%mytable
Copy data from data source into the table:
COPY INTO mytable;
To see the files that have been loaded for the table: