Snowflake 简明教程
Snowflake - Database
数据库是模式的逻辑分组,其中包含表和列。在此章节中,我们将讨论如何创建 database ,以及如何查看详细信息。
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 为用户提供 two 种创建 database 的方法,第一种方法是使用用户界面,第二种方法是执行 SQL 查询。
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
Snowflake 中的所有数据都保存 databases 。每个数据库包含一个或多个模式,这是数据库对象的逻辑分组,如表和视图。 Snowflake 没有限制数据库的数量,您可以在数据库中创建模式(在模式内),或创建对象(在模式内)。
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 limits on the number of databases, you can create schemas (within a database), or objects (within a schema).
Creating a Database
使用唯一 URL 登入 Snowflake 账户。点击顶部功能区上方的 Databases ,如下图所示 −
Login into Snowflake account using unique URL. Click Databases present at top ribbon as shown in the following screenshot −

它将导航到下一个屏幕。点击数据库列表上方的 Create 按钮,如下所示。
It will navigate to the next screen. Click the Create button above the list of databases as shown below.

它将带您到 Create Database 对话框。输入数据库 Name 和 Comment ,然后点击 Finish 按钮。
It will take you to the Create Database dialog box. Enter the Database Name and Comment, then click the Finish button.

数据库创建后,用户可以在列表中查看,如下图所示 −
Once the database is created, user can view in the list as shown in the following screenshot −

View Warehouse
现在要查看所有创建的 databases ,点击顶部功能区上方的数据库。它将显示数据库的视图面板,其中包含所有已创建的数据库。
Now for viewing all the created databases, click Databases present at the top ribbon. It displays the View panel of the database where all the created databases are present.
使用 Create 按钮创建新仓库。通过选择一个数据库并点击 Clone ,用户还可以克隆数据库,如下图所示 −
Use the Create button for creating a new warehouse. User can clone a database as well, by selecting a database and clicking Clone as shown in the following screenshot −

它弹出 Clone Database 对话框,要求输入名称、来源、注释等信息。输入这些详细信息后,点击 Finish 按钮,如下图所示 −
It pops up a Clone Database dialog box to enter some information like Name, Source, Comment. After entering those details click Finish button as shown in the following screenshot −

用户可以看到另一个数据库已创建,并且它将在视图面板中可见。通过选择一个数据库并点击 Drop 按钮,用户还可以 delete 数据库,如下图所示 −
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 clicking on Drop button as shown in the following screenshot −

它弹出确认对话框。点击 Yes 删除,否则点击 No 。
It pops up a dialog box for confirmation. Click Yes for deletion, else No.

Working on Databases using Snowflake’s SQL Interface
此处,我们将了解如何使用 Snowflake 的 SQL 界面创建并查看数据库。
Here, we will learn how to create and view the databases by using the SQL interface of Snowflake.
Create Database
要创建数据库,首先需要登入 Snowflake 并导航到 Worksheets 。在默认情况下,用户登入后工作表将打开,否则点击顶部功能区上的 Worksheets 图标。
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 click the Worksheets icon present at the top ribbon.
写下如下查询,以创建数据库 “TEST_DB_2”
Write the following query to create a database "TEST_DB_2"
CREATE DATABASE "TEST_DB_2"
现在点击 Run 按钮来执行查询。当 TEST_DB_2 数据库创建成功后, Result 将显示在结果面板中。下图显示了使用 SQL 处理的输出 −
Now click 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 −

View Databases
要 view 所有列出的仓库,用户可以使用如下 SQL。它会呈现所有列出的仓库的详细信息。
To view all the listed warehouses, user can use the following SQL. It brings the details of all listed warehouses.
SHOW DATABASES
要创建一个数据库,用户可以使用以下 SQL,此处的“TEST_DB_3”是一个新命名的数据库,而 DEMO_DB 用于克隆它。
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"
要创建数据库,请使用以下 SQL。
To delete database, use the following SQL −
DROP DATABASE "TEST_DB_3"
用户可以在每次操作后运行 SHOW DATABSE 查询以验证操作是否完成。
User can run SHOW DATABSE query after each operation to verify whether operation is completed.