Executing a query and viewing the results
1. Executing a query and viewing the results
In this exercise, we'll learn how to execute a query in Snowsight. We will begin by creating a new SQL worksheet. There's a database called student_db. To see which tables exist, we can expand the public schema. There are two tables called countries and sales transactions. You can hover over a table to view more details, such as the number of rows and size and when it was created. You can also see the table's schema, including the column names and data types, by going to the definitions tab. Let's run a query to view sample data of sales transactions. First, we will select the database and schema. Now, let's get three rows of the sales transactions. You can press the play button, or alternatively to run the query. The results are returned below. On the right panel, you can see the query duration, how long it took to complete, and the rows returned. You have the option to download the results to a csv or tsv file by clicking on the download icon and can view the query history of the SQL worksheet. Additionally, Snowsight will generate a chart of the results to help visualize the data. As you can see, there's also a built-in feature called Ask Copilot. You can use this feature to ask more questions about the table you're querying. When you hover over the worksheet tab, go to Show Shortcuts to view the available shortcut keys. You can also choose Format Query to improve the readability of your query. Next, let's save our SQL worksheet to a new project folder. A project folder will be a repository that you can use to save your worksheets. We'll rename the worksheet and call it sample transactions, then move it to a new folder and name it as sales analysis project. You have the option to share the folder with other users within the Snowflake account by entering their usernames. Alternatively, you can share a link with them as well and give the option to view and run the results or just view the results. Lastly, when you open the worksheet again, you'll see a feature called "Code Versions",. This feature allows you to track over time what queries were run and when they were executed. When you want to remember what queries were run and revert back to that specific version, you can use Code Versions. This concludes how to execute a query using Snowsight.2. Let's practice!
Let's review what we discussed!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.