Road to Snowflake SnowPro Core Certification: PUT & GET commands
Ninth Chapter: PUT and GET commands
The first step to load data into Snowflake tables is to send it to the Stages. In this chapter, we are going to understand how to do that. Once there, we will copy the data into the tables using either the COPY INTO command for batch files or SnowPipe for continuous data, as we saw in the previous chapter.
Remember that all the chapters from the course can be found in the following link.
PUT COMMAND
We will use the PUT command to UPLOAD files from a local directory/folder on a client machine into INTERNAL STAGES (named internal stage, user stage, or table stage). It does NOT work with external stages. It doesn’t copy the files in the tables; it copies them into the internal stages. After this command, if you want to move the data into tables, you need to use the COPY INTO command. You cannot use the PUT command from the Snowflake Web UI (and this is a typical exam question).
As we can see in the following diagram, the files are in the Local File System from the user. Using the PUT command using SnowSQL, the files are moved to the internal stages, but they are not in the tables yet. We can move them from the internal stages into the tables using the COPY INTO command.
The code from this command is straightforward. We are moving the file called “mydata.csv” into the internal stage called “my_int_stage”.
PUT file:///tmp/data/mydata.csv @my_int_stage;
GET COMMAND
We will use the GET command to DOWNLOAD files from a Snowflake internal stage (named internal stage, user stage, or table stage) into a directory/folder on a client machine. It doesn’t download the data from the table; it downloads the data from the stage, so first of all, you need to unload the data from the table using the COPY INTO command to the internal stage. As with the PUT command, you cannot use it with the Snowflake Web UI; you need to use SnowSQL.
In the following diagram, we can see that the files are in a Snowflake table. You cannot use the command GET yet; they need to be sent to a Snowflake internal stage first using the COPY INTO command (I remark it because it’s really important). Once they are in the internal stages, we can download them into the user’s Local File System with the GET command.
The code is straightforward; in this case, we are downloading the files from the internal stage called “my_int_stage” into the “data” folder.
GET @my_int_stage file:///tmp/data/;
TYPICAL EXAM QUESTIONS
Which of the following commands cannot be executed from the Snowflake UI?
- SHOW
- LIST <stages>
- GET
- COPY INTO
- PUT
Solution: 3, 5.
Which command will we use to download the files from the stage/location loaded through the COPY INTO <LOCATION> command?
- GET
- PUT
- UNLOAD
- INSERT INTO
Solution. 1
Does GET support downloading files from external stages?
- True
- False
Solution: 2. If you want to download data from external stages, you need to use the cloud provider; for example, download them directly from AWS S3.
Can you load data using the PUT command through worksheets in the Snowflake UI?
- True
- False
Solution: 2.
When data is staged to a Snowflake internal staging area using the PUT command, is the data automatically encrypted?
- True
- False
Solution: 1. Uploaded files are automatically encrypted with 128-bit or 256-bit keys.
Thanks for Reading!
If you like my work and want to support me…
- The BEST way is to follow me on Medium here.
- Feel free to clap if this post is helpful for you! :)
- More Snowflake SnowPro Core practice exam questions? Find them at FullCertified.com!