Install and Configure SnowSQL
Install and Configure SnowSQL
Installation
After logging into your Snowflake web interface, the SnowSQL installer is
available via Help -> Download:
Configuration
Create ~/.snowsql/config
$ touch ~/.snowsql/config
The first few lines of your ~/.snowsql/config file should look like the following:
[connections]
accountname = YOUR_ACCOUNT_NAME
username = YOUR_USERNAME
password = YOUR_PASSWORD
Connect SnowSQL from prompt:
User: sreenivaskalahasti
Password:
* SnowSQL * v1.2.21
Type SQL statements or !help
sreenivaskalahasti#COMPUTE_WH@(no database).(no schema)>!help
+------------+-------------------------------------------+-------------+------------------------------------------------------------------------------------------
--+
| Command | Use | Aliases | Description |
|------------+-------------------------------------------+-------------+-------------------------------------------------------------------------------------------
-|
| !abort | !abort <query id> | | Abort a query |
| !connect | !connect <connection_name> | | Create a new connection
|
| !define | !define <variable>=<value> | | Define a variable as the given value
|
| !edit | !edit <query> | | Opens up a text editor. Useful for writing longer queries. Defaults
to last query |
| !exit | !exit | !disconnect | Drop the current connection
|
| !help | !help | !helps, !h | Show the client help. |
| !options | !options | !opts | Show all options and their values
|
| !pause | !pause | | Pauses running queries. |
| !print | !print <message> | | Print given text |
| !queries | !queries help, <filter>=<value>, <filter> | | Lists queries matching the specified filters. Write
<!queries> help for a list of filters. |
| !quit | !quit | !q | Drop all connections and quit SnowSQL
|
| !rehash | !rehash | | Refresh autocompletion |
| !result | !result <query id> | | See the result of a query |
| !set | !set <option>=<value> | | Set an option to the given value
|
| !source | !source <filename>, <url> | !load | Execute given sql file
|
| !spool | !spool <filename>, off | | Turn on or off writing results to file
|
| !system | !system <system command> | | Run a system command in the shell
|
| !variables | !variables | !vars | Show all variables and their values
|
+------------+-------------------------------------------+-------------+------------------------------------------------------------------------------------------
--+
sreenivaskalahasti#COMPUTE_WH@(no database).(no schema)>use TRAINING_DB;
+----------------------------------+
| status |
|----------------------------------|
| Statement executed successfully. |
+----------------------------------+
1 Row(s) produced. Time Elapsed: 0.740s
sreenivaskalahasti#COMPUTE_WH@TRAINING_DB.PUBLIC>show databases;
+-------------------------------+-----------------------+------------+------------+-------------------------+--------------+------------------------------------
---------------+---------+----------------+
| created_on | name | is_default | is_current | origin | owner | comment
| options | retention_time |
|-------------------------------+-----------------------+------------+------------+-------------------------+--------------+-------------------------------------
--------------+---------+----------------|
| 2022-01-09 05:50:52.078 -0800 | OUR_FIRST_DATABASE | N |N | | ACCOUNTADMIN |
| |1 |
| 2022-01-02 08:12:50.161 -0800 | S3_TO_SNOWFLAKE |N |N | | ACCOUNTADMIN |
| |1 |
| 2022-01-01 06:52:23.299 -0800 | SNOWFLAKE |N |N | SNOWFLAKE.ACCOUNT_USAGE | |
| |1 |
| 2022-01-01 06:52:27.797 -0800 | SNOWFLAKE_SAMPLE_DATA | N |N | SFC_SAMPLES.SAMPLE_DATA |
ACCOUNTADMIN | Provided by Snowflake during account provisioning | |1 |
| 2022-01-09 05:47:44.610 -0800 | TRAINING_DB |N |Y | | ACCOUNTADMIN |
| |1 |
+-------------------------------+-----------------------+------------+------------+-------------------------+--------------+------------------------------------
---------------+---------+----------------+
5 Row(s) produced. Time Elapsed: 0.156s
sreenivaskalahasti#COMPUTE_WH@TRAINING_DB.PUBLIC>show TABLES;
+-------------------------------+-----------+---------------+-------------+-------+---------+------------+------+-------+--------------+----------------+---
-------------------+-----------------+---------------------+------------------------------+---------------------------+-------------+
| created_on | name | database_name | schema_name | kind | comment | cluster_by | rows | bytes |
owner | retention_time | automatic_clustering | change_tracking | search_optimization |
search_optimization_progress | search_optimization_bytes | is_external |
|-------------------------------+-----------+---------------+-------------+-------+---------+------------+------+-------+--------------+----------------+----
------------------+-----------------+---------------------+------------------------------+---------------------------+-------------|
| 2022-01-09 05:49:55.808 -0800 | EMP_BASIC | TRAINING_DB | PUBLIC | TABLE | | | 0| 0|
ACCOUNTADMIN | 1 | OFF | OFF | OFF | NULL | NULL |
N |
+-------------------------------+-----------+---------------+-------------+-------+---------+------------+------+-------+--------------+----------------+---
-------------------+-----------------+---------------------+------------------------------+---------------------------+-------------+
1 Row(s) produced. Time Elapsed: 0.163s
sreenivaskalahasti#COMPUTE_WH@TRAINING_DB.PUBLIC>use OUR_FIRST_DATABASE;
+----------------------------------+
| status |
|----------------------------------|
| Statement executed successfully. |
+----------------------------------+
1 Row(s) produced. Time Elapsed: 0.143s
sreenivaskalahasti#COMPUTE_WH@OUR_FIRST_DATABASE.PUBLIC>show tables;
+-------------------------------+--------------+--------------------+-------------+-------+---------+------------+------+-------+--------------+-------------
---+----------------------+-----------------+---------------------+------------------------------+---------------------------+-------------+
| created_on | name | database_name | schema_name | kind | comment | cluster_by | rows |
bytes | owner | retention_time | automatic_clustering | change_tracking | search_optimization |
search_optimization_progress | search_optimization_bytes | is_external |
|-------------------------------+--------------+--------------------+-------------+-------+---------+------------+------+-------+--------------+--------------
--+----------------------+-----------------+---------------------+------------------------------+---------------------------+-------------|
| 2022-01-09 05:52:24.313 -0800 | LOAN_PAYMENT | OUR_FIRST_DATABASE | PUBLIC | TABLE | | | 0
| 0 | ACCOUNTADMIN | 1 | OFF | OFF | OFF | NULL |
NULL | N |
+-------------------------------+--------------+--------------------+-------------+-------+---------+------------+------+-------+--------------+-------------
---+----------------------+-----------------+---------------------+------------------------------+---------------------------+-------------+
1 Row(s) produced. Time Elapsed: 0.144s
sreenivaskalahasti#COMPUTE_WH@OUR_FIRST_DATABASE.PUBLIC>SELECT CURRENT_WAREHOUSE();
+---------------------+
| CURRENT_WAREHOUSE() |
|---------------------|
| COMPUTE_WH |
+---------------------+
1 Row(s) produced. Time Elapsed: 0.144s
sreenivaskalahasti#COMPUTE_WH@OUR_FIRST_DATABASE.PUBLIC>use WAREHOUSE TRAINING_WH;
+----------------------------------+
| status |
|----------------------------------|
| Statement executed successfully. |
+----------------------------------+
1 Row(s) produced. Time Elapsed: 0.146s
sreenivaskalahasti#TRAINING_WH@OUR_FIRST_DATABASE.PUBLIC>SELECT CURRENT_WAREHOUSE();
+---------------------+
| CURRENT_WAREHOUSE() |
|---------------------|
| TRAINING_WH |
+---------------------+
1 Row(s) produced. Time Elapsed: 0.290s
sreenivaskalahasti#TRAINING_WH@OUR_FIRST_DATABASE.PUBLIC>SELECT CURRENT_SCHEMA();
+------------------+
| CURRENT_SCHEMA() |
|------------------|
| PUBLIC |
+------------------+
1 Row(s) produced. Time Elapsed: 2.137s
sreenivaskalahasti#TRAINING_WH@OUR_FIRST_DATABASE.PUBLIC>