Chapter 1. Query Primer
Let’s roll up our sleeves and look at some queries using the select statement, which is the SQL statement used to execute queries.
Query Basics
If you followed the steps listed in the Preface, then you have created a Snowflake account and have created your sample database. To enter queries using Snowsight, create a new worksheet by selecting the Worksheets button on the left side of the screen, and then click the “+” button at the top right. Your new worksheet will appear in the left pane with a name using the current date and time, but you can rename it to Learning_Snowflake_SQL to use for the examples in this book. Before running any queries in your new worksheet, set the schema to the Public schema in the Learning_SQL database: use schema learning_sql.public;.
After entering this command into your worksheet, click on the right arrow at the top right of the screen to execute the command, as shown in Figure 1-1.
Every time you log in to Snowsight, you will want to execute this use schema statement before executing queries against the sample database.
Figure 1-1. Setting the schema using Snowflake’s web interface (Snowsight)
Snowflake Web Interface Versus SnowSQL CLI
For most examples shown in this book, I will be using Snowflake’s CLI, known as SnowSQL, rather than the Snowsight web interface. This allows the SQL statements in the examples to be copied ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access