Using the Sample Data Sets

The sample database, SNOWFLAKE_SAMPLE_DATA, is identical to other databases that you create in your account, except that it is read-only. As such, you cannot make changes to the sample database or any of the objects in the database, but you can use all the same commands and syntax to view the sample database and objects in the database, as well as execute queries on the tables and views in the database.

In this Topic:

Note

The sample database is available by default for new accounts only. If the database is not available for your account and you would like access to it, please email Snowflake Support.

Viewing the Sample Database

You can view the sample database and its contents either in the web interface or using SQL:

Web Interface:

Click on DatabasesSNOWFLAKE_SAMPLE_DATA:

  • Click on an object tab to view summary information about the objects in the database.
  • Click on the name of an object to view details about the object.
SQL Command:

SHOW DATABASES

You can also use the relevant SHOW commands to view the objects in the sample database.

As described in a previous topic, the sample database is a database that have been shared by Snowflake with your account. The Origin column in the Databases page in the interface (and the ORIGIN column in the SHOW DATABASES output), identifies the database as shared because the column displays the name of the shared database, including the account from which it was shared (always SFC_SAMPLES for sample data).

For example:

show databases like '%sample%';

+-------------------------------+-----------------------+------------+------------+-------------------------+--------------+---------+---------+----------------+
| created_on                    | name                  | is_default | is_current | origin                  | owner        | comment | options | retention_time |
|-------------------------------+-----------------------+------------+------------+-------------------------+--------------+---------+---------+----------------|
| 2016-07-14 14:30:21.711 -0700 | SNOWFLAKE_SAMPLE_DATA | N          | N          | SFC_SAMPLES.SAMPLE_DATA | ACCOUNTADMIN |         |         | 1              |
+-------------------------------+-----------------------+------------+------------+-------------------------+--------------+---------+---------+----------------+

Querying Tables and Views in the Sample Database

To use a table or view in the sample database, you can either:

  • Reference the fully-qualified name of the table or view in your query (in the form of <db_name>.<schema_name>.<object_name>)

    For example:

    select count(*) from snowflake_sample_data.tpch_sf1.lineitem;
    
    +----------+
    | COUNT(*) |
    |----------|
    |  6001215 |
    +----------+
    
  • Specify the sample database (and schema) for your session using the USE DATABASE and/or USE SCHEMA commands.

    For example:

    use schema snowflake_sample_data.tpch_sf1;
    
    select count(*) from lineitem;
    
    +----------+
    | COUNT(*) |
    |----------|
    |  6001215 |
    +----------+
    

Note

You must have a running, current warehouse in your session to perform queries. You set the current warehouse in a session using the USE WAREHOUSE command (or within the Worksheet in the web interface.)

Using the Tutorial SQL Scripts

Snowflake provides a set of tutorials, which are annotated SQL statements that query the sample data sets to answer a set of practical business questions. In addition to executing the tutorials, you can alter and save them as custom worksheets.

To access the tutorials:

  1. In the Worksheet page, click on the plus (+) icon beside the worksheet tabs. A menu displays the list of available tutorials.

    ../_images/ui-sql-worksheet-ws-menu.png
  2. Click on a tutorial to open it in a new tab. You can then execute the queries in the tutorial as you would in any worksheet.