While Snowflake comes with a good deal of sample data, let’s create our own sample database.  I’m going to call mine dbSample.  Note that the name of the database I have chosen describes what it is (a “sample” database) and starts with “db” so that anyone looking at the name can guess it is a database.  You are not required to provide descriptive names for your Snowflake objects, but it helps keep them straight.

Okay, let’s write some code:

Create or alter database dbSample;

This code does pretty much just like it looks – it will create a database called dbSample, and if it already exists, it will simply alter it.  Use an alter statement to rename it, for instance.  

Type that code into a worksheet (you may copy paste if you like.)  Run that code by highlighting the code with your cursor, and clicking the blue triangle in the upper right of your screen.  You should get a success message below your code, and if you refresh the dashboard, you will now see your database.  

Now, we would like to create two schemas — we will call them schTest1 and schTest2 (creative names, I know.)  But first, we have to be “in” the database dbSample.  To do this, run this code here:

Use dbSample;

This tells Snowflake that you are going to be working in the dbSample database.

Once you have established that you are in the dbSample database (and you should see an indicator of this at the top of your worksheet) run these two lines:

Create schema schTest1;

Create schema schTest2;

If you would like to use the “Create or Alter” syntax, you may do so.  Note that the names immediately inform readers what type of objects they are.

Now that we have created two schemas, we have places to put things like tables and views.  In our next post, we will do just that!