Database, table, and virtual warehouse are basic Snowflake objects required for most Snowflake activities. Setting them will be the first step in all our exercises! Let’s see how to do that!
Create a Snowflake account
Click here to create your new Snowflake account. It should be configured to use Amazon Web Services (AWS) and your user has the ACCOUNTADMIN role. In this way, you can create a database, tables, and virtual warehouse objects. You can use the 30-day free trial! But remember that everything will expire! So, please, save all! The exceeding £400 in credits can be another reason to lose everything before 30 days. Again, be careful! Working with a X-small warehouse is sufficient for our exercises.
Create your database and warehouse
By means of the CREATE (OR REPLACE) DATABASE stament we create our database. It includes automatically a SCHEMA, i.e. the PUBLIC one. If you want another one, you can CREATE (OR REPLACE) SCHEMA ‘myschema’ and your tables and views will be there!
--Create your database
CREATE OR REPLACE DATABASE mydatabase;
--Create your warehouse
CREATE OR REPLACE WAREHOUSE mywarehouse WITH
WAREHOUSE_SIZE='X-SMALL
SCALING_POLICY = STANDARD
AUTO_SUSPEND = 120
AUTO_RESUME = TRUE;
In the CREATE (OR REPLACE) WAREHOUSE statement we can add some object properties. By default we have a standard type warehouse. We can set the size of our warehouse. The bigger is the size, the bigger is the amount of compute resources in each cluster.. actually the bigger is the amount of money you «spend»! By deafult, the size of warehouse is XSMALL!
You can set the policy for the starting and shutting down cluster in a multi-cluster warehouse, especially when it is set in Auto-scale mode. There are two values: standard and economy. By default the valid value set is STANDARD. This just minimizes queuing by starting clusters.
As for the AUTO_SUSPEND property it declares the amount of seconds of inactivity before that the warehouse automatically suspends. By default the warehouse suspends after 10 minutes. If you set NULL, the warehouse never suspends.
If you want that your warehouse resumes automatically when a new query is submitted, you can set TRUE value to the AUTO_RESUME property. Generally, this statement is set to TRUE. You can add as many properties as you like, but read through the documentation about warehouses.
Create a table or a view
You can create a new TABLE into your schema or you can replace an existing one. Remember that there are several commands which are linked to CREATE TABLE. Be sure to select the one best suited for your needs. But keep things easy here: