SnowSQL, Snowflake’s command-line interface (CLI), is a versatile tool that goes far beyond loading data into Snowflake’s cloud data platform. While it’s great for transferring local files to Snowflake, SnowSQL also empowers you to execute SQL queries, manage database objects, automate workflows, and handle advanced data operations—all from your terminal. In this blog, we’ll explore SnowSQL’s full range of capabilities with practical examples, making it easy for beginners and seasoned data professionals to harness its power.
SnowSQL is a powerful CLI tool designed to connect to snowflake’s cloud platform. It allows users to:
Before diving into queries, let’s set up SnowSQL on your machine.
Download SnowSQL:
Visit the Snowflake SnowSQL download page and select the installer for your operating system(Windows, macOS, or Linux).
Run the installer and follow the wizard prompts.
After the installation by checking the version in your terminal by using below syntax.
Enter the give command. The account name or identifier and login name are shown in snowflake Account Details. Copy and past the account identifier and username in the command and click enter.
Type your password and click enter. If your password is correct, then you will see like this.
If successful, you can have access to snowflake.
Loading Data from local to snowflake Using SnowSQL
Loading data into Snowflake involves two main steps: staging the file and copying it into a table. Follow these steps:
After connecting to the Snowflake, create a database and use public schema(default).can also access the other database, according to the role privileges.
Create a Target to store the data:
Create Stage for storing the file:
Stage the File:
Copy Data into the Table:
Load the staged file into the table.
This command specifies the file format (CSV), skips the header row.
Verifying the load
To ensure the data loaded correctly, query the table:
What else can do with snowsql?
By using SnowSQL, can also manage roles, user, warehouses and so many. Showing you some basic uses of the SnowSQL.
A basic command to show all the roles in snowflake.
What else can do with snowsql?
By using SnowSQL, can also manage roles, user, warehouses and so many. Showing you some basic uses of the SnowSQL.
A basic command to show all the roles in snowflake.
To Create a Role
A role in Snowflake defines a set of permissions that can be assigned to users. Use the CREATE ROLE command to create a new role.
Grant Usage to the Role
To have access to database or schema, role should have privileges to access. To give access to roles:
Creating a schema using SnowSQL.
Create a user and grant to role
Granting user to the role
To access the user, again start from command prompt and login using the new user login details with same account identifier.
Creating a warehouse
Use the below syntax to see all the warehouses in the account.
Conclusion
SnowSQL is more than a data-loading tool. It’s a gateway to managing and interacting with Snowflake from the command line. From executing SQL queries and managing objects to automating tasks and handling advanced data operations, SnowSQL empowers you to streamline your data workflows. Try these examples, experiment with scripts, and explore SnowSQL’s features to unlock Snowflake’s full potential.