How to Use GET Command in Snowflake: Syntax and Examples
In Snowflake, the
GET command downloads files from a stage to a local directory. Use GET @stage_name/path file:///local_directory to copy files from the cloud stage to your local machine.Syntax
The GET command syntax is simple and includes the source stage path and the target local directory.
GET: The command to download files.@stage_name/path: The cloud stage and optional path where files are stored.file:///local_directory: The local folder path where files will be saved, prefixed withfile://.
sql
GET @my_stage/path/to/files file:///local/path/
Example
This example downloads all files from the my_stage stage under data/ to the local folder /tmp/downloads/.
sql
GET @my_stage/data/ file:///tmp/downloads/
Output
Copying 3 files from @my_stage/data/ to /tmp/downloads/
3 files copied successfully.
Common Pitfalls
Common mistakes include:
- Not specifying the
file://prefix for the local directory, which is required. - Trying to use
GETwithout having the SnowSQL client installed, asGETruns in SnowSQL, not inside Snowflake SQL worksheets. - Incorrect stage or path names causing file not found errors.
sql
/* Wrong: Missing file:// prefix */ GET @my_stage/data/ /tmp/downloads/ /* Right: Correct local path with file:// prefix */ GET @my_stage/data/ file:///tmp/downloads/
Quick Reference
| Part | Description |
|---|---|
| GET | Command to download files from a stage |
| @stage_name/path | Cloud stage and optional folder path |
| file:///local/path/ | Local directory with file:// prefix |
Key Takeaways
Use the GET command in SnowSQL to download files from cloud stages to your local machine.
Always prefix the local directory path with file:// when using GET.
GET runs in SnowSQL client, not inside Snowflake SQL worksheets.
Verify stage and path names to avoid file not found errors.
GET helps move data files from Snowflake stages to local storage easily.
