KSnow: SNOWSQL – II

Reading Time: 2 minutes

In our previous blog SNOWSQL – I, we introduced you to SnowSQL – a new modern command-line tool. Today we are going to talk about how SnowSQL helps to query data interactively.

SnowSQL Customization

SnowSQL works well after its installation, we can make customizations to get full advantage of SnowSQL.

For example, by defining connections in the config file, we can preset my environment (account, warehouse, database, etc…) and don’t have to worry about connection strings or exposed passwords.

To keep track of which environment we are in, we can customize the prompt to show only the information we need.

Using SnowSQL

SnowSQL also includes very powerful line editing commands to simplify the manipulation of queries. All the usual shortcuts are there: CTRL-R to search the history and Arrow keys to navigate up/down in history. By using the !edit command, we can modify large queries.

snowsql-2-editor

Queries taking a long time to run can be executed concurrently to avoid disrupting workflow. To run a query in the background, just add > after the semicolon.

We can then check all the queries that are running or finished by using the !QUERIES command. With variable_substitution turned on, the !queries command will bind a variable to each query ID.

We can abort any running query by writing !abort &. To get the result of a query, I use !result &. If the query is running, it will wait until the result comes back. If the query is finished, it will just fetch the result, so we can always go back to previous queries.

snowsql-2-prompt

References:-

Written by 

Bhavya is CTO at Knoldus Inc. with 16+ years of experience. He is a Java & Scala expert and experienced in managing large customers. He is currently focused on Bigdata and Reactive Stack. Technology and process improvements have been a forte of Bhavya and he has worked on varied technology stack starting from COBOL, Mainframe, JAVA, Scala, Dataware House, Oracle, PL/SQL Salesforce, JMS - Active MQ etc. His hobbies include reading and playing badminton.