English 中文(简体)
Snowflake - Database
  • 时间:2024-12-22

Snowflake - Database


Previous Page Next Page  

A database is a logical grouping of schemas where tables and columns resides. In this chapter, we will discuss about how to create a database, and view details.

Snowflake provides the user two ways to create a database, first way is by using user interface and the second way is by applying SQL query.

Working with Databases using Snowflake s UI

All data in Snowflake is maintained in databases. Each database consists of one or more schemas, which are logical groupings of database objects, such as tables and views. Snowflake does not restrict the pmits on the number of databases, you can create schemas (within a database), or objects (within a schema).

Creating a Database

Login into Snowflake account using unique URL. Cpck Databases present at top ribbon as shown in the following screenshot −

Cpck Databases

It will navigate to the next screen. Cpck the Create button above the pst of databases as shown below.

Cpck Create Button

It will take you to the Create Database dialog box. Enter the Database Name and Comment, then cpck the Finish button.

Cpck Create a Database

Once the database is created, user can view in the pst as shown in the following screenshot −

Database List

View Warehouse

Now for viewing all the created databases, cpck Databases present at the top ribbon. It displays the View panel of the database where all the created databases are present.

Use the Create button for creating a new warehouse. User can clone a database as well, by selecting a database and cpcking Clone as shown in the following screenshot −

Clone

It pops up a Clone Database dialog box to enter some information pke Name, Source, Comment. After entering those details cpck Finish button as shown in the following screenshot −

Clone Database

User can see another database is created and it will be visible in view panel. User can also delete a database, by selecting a database and cpcking on Drop button as shown in the following screenshot −

Deleting Database

It pops up a dialog box for confirmation. Cpck Yes for deletion, else No.

Drop Database Pop-Up

Working on Databases using Snowflake s SQL Interface

Here, we will learn how to create and view the databases by using the SQL interface of Snowflake.

Create Database

For creating a database, first you need to Login into Snowflake and navigate to Worksheets. By default, Worksheet is opened once the user logs in, else cpck the Worksheets icon present at the top ribbon.

Write the following query to create a database "TEST_DB_2"


CREATE DATABASE "TEST_DB_2" 

Now cpck the Run button to execute the query. Result will be displayed in the the Results panel as the TEST_DB_2 database was successfully created. The following screenshot displays the output processed by using SQL −

Create Database TEST_DB_2

View Databases

To view all the psted warehouses, user can use the following SQL. It brings the details of all psted warehouses.


SHOW DATABASES

To clone a database, user can use the following SQL, here “TEST_DB_3” is a new database named while DEMO_DB is used to clone it −


CREATE DATABASE TEST_DB_3 CLONE "DEMO_DB"

To delete database, use the following SQL −


DROP DATABASE "TEST_DB_3"

User can run SHOW DATABSE query after each operation to verify whether operation is completed.

Advertisements