Snowflake 简明教程
Snowflake - Warehouse
由于仓库对于计算很重要。我们来讨论如何创建仓库,修改仓库以及查看仓库详细信息。
As Warehouse is important for computing. Let’s discuss about how to create warehouse, alter it and view details of warehouse.
Snowflake 提供两种方式来创建/修改/查看仓库 - 第一种方式是 UI,另一种是 SQL 语句。
Snowflake provides two ways to create/modify/view warehouses – first way is UI and the another one is SQL statements.
Working on Warehouses using Snowflake’s UI
让我们从创建仓库开始 −
Let’s start with creating a warehouse −
Create Warehouse
使用唯一的 URL 登录到 Snowflake。单击以下屏幕截图中所示的顶部功能区上的 Warehouses −
Login into Snowflake using unique URL. Click Warehouses present at top ribbon as shown in the following screenshot −

它导航到下一个屏幕。单击仓库列表上方的 Create ,如下所示。
It navigates to the next screen. Click Create above the list of warehouses as shown in the below.

它将打开 Create 仓库对话框。应该输入以下字段来创建仓库。
It opens the Create warehouse dialog box. The following fields should be entered to create a warehouse.
-
Name − test_WH
-
Size − Small
-
Set Auto-Suspend to 5 minutes
然后单击 Finish 按钮。
Then click the Finish button.

一旦创建仓库,用户就可以在列表中查看,如下面的屏幕截图所示 −
Once the warehouse is created, user can view in the list as shown in the following screenshot −

Edit/Modify/Alter Warehouse
Snowflake 提供根据要求修改或更改 Warehouses 的功能。例如,在创建和使用后,用户可以更新仓库大小、集群、暂停时间。
Snowflake provides the facility to modify or alter the Warehouses based on the requirements. For example, after creation and usage, user can update warehouse size, clusters, suspension time.
单击顶部功能区上的 Warehouse 按钮。它将显示仓库页面详细信息。从仓库列表中选择需要更改的 warehouse 。点击 Configure ,如下面的屏幕截图所示 −
Click the Warehouse button present at the top ribbon. It displays the warehouse page details. Select the warehouse that requires to be altered from the list of warehouses. Click Configure as shown in the following screenshot −

它将弹出 Configure Warehouse 对话框。用户可以修改 Name 之外的所有详细信息。将 auto suspend time 从 5 分钟更新为 10 分钟。单击 Finish 按钮,如下面的屏幕截图所示。
It pop ups the Configure Warehouse dialog box. Users can modify all details other than Name. Update the auto suspend time from 5 minutes to 10 minutes. Click the Finish button as shown in the following screenshot.

当用户单击 Finish 按钮时,他们将能够在视图面板中看到更新的详细信息。
As the users clicks the Finish button, they will be able to see the updated details in the view panel.
View Warehouse
单击顶部功能区上的 Warehouses 按钮。它显示了仓库的视图面板,其中存在所有已创建的仓库。
Click the Warehouses button present at top ribbon. It displays the View panel of warehouses where all the created warehouses are present.
-
Use the Create button for creating a new warehouse.
-
Use the Configure button for altering/modifying an existing warehouse.
-
Use the Resume button to activate the selected warehouse, if it is in suspended mode.
以下截图演示了如何 Resume 处于 suspended 模式的仓库 −
The following screenshot demonstrates how you can Resume a warehouse which is in suspended mode −

单击 Resume 按钮后,将弹出对话框。在对话框中单击 Finish 按钮,如下图所示 −
After clicking the Resume button, its pops up a dialog box. Click on the Finish button there as shown in the following screenshot −

现在,用户可以看到 warehouse 是 started ,如下图所示 −
Now the user can see the warehouse is started as shown in the following screenshot −

同样,用户可以立即单击 Suspend 按钮 suspend 仓库。如果任何仓库处于 Started 模式,则启用此按钮。选择要暂停的 warehouse 并单击 Suspend 按钮。将弹出对话框,单击 Yes 暂停,否则单击否。
Similarly, user can suspend a warehouse immediately using the Suspend button. This button enables if any of your warehouses are in Started mode. Select the warehouse to suspend and click the Suspend button. It pops up a dialog box, click Yes to suspend, else No.
以下截图显示了 suspend 功能 −
The following screenshot displays the suspend functionality −

用户也可以删除仓库,方法是选择仓库并单击 Drop 按钮,如下图所示 −
User can delete a warehouse as well, by selecting a warehouse and by clicking the Drop button as shown in the following screenshot −

将弹出确认对话框。单击是删除,否则单击否。
It pops up a dialog box for confirmation. Click Yes for deletion, else No.
Working on Warehouses using Snowflake’s SQL Interface
现在,我们来了解如何使用 Snowflake 的 SQL 界面处理仓库。
Now let’s check how to work with warehouses using Snowflake’s SQL Interface.
Create Warehouse
登录 Snowflake 并导航到 Worksheets 。用户登录后,默认情况下会打开工作表;否则,单击顶部功能区中的工作表,如下图所示。
Login into Snowflake and navigate to Worksheets. By default, Worksheet is opened once the user logs in, else click the Worksheets present at the top ribbon as shown in the following screenshot.

使用以下查询创建仓库 TEST_WH −
Use the following query to create a warehouse TEST_WH −
CREATE WAREHOUSE "TEST_WH"
WITH WAREHOUSE_SIZE = 'SMALL'
AUTO_SUSPEND = 600
AUTO_RESUME = TRUE
MIN_CLUSTER_COUNT = 1
MAX_CLUSTER_COUNT = 2
SCALING_POLICY = 'STANDARD'
COMMENT = ' '
单击 Run 执行查询。结果将显示在 Results 面板中,说明已成功创建仓库“TEST_WH”。
Click Run to execute the query. Result will be displayed in Results panel as the warehouse "TEST_WH" was successfully created.
以下屏幕截图显示了使用 SQL 处理的输出 −
The following screenshot displays the output processed by using SQL −

Edit/Modify/Alter Warehouse
要更改/修改仓库,请使用以下查询并运行它 −
To alter/modify the warehouse, use the following query and run it −
ALTER WAREHOUSE "TEST_WH"
SET WAREHOUSE_SIZE = 'SMALL'
AUTO_SUSPEND = 1200
AUTO_RESUME = TRUE
MIN_CLUSTER_COUNT = 1
MAX_CLUSTER_COUNT = 1
SCALING_POLICY = 'STANDARD'
COMMENT = ' '
用户可以转到 View 面板并验证更新后的详细信息,如下所示 −
User can go to the View panel and verify the updated details as shown below −

View Warehouses
要查看所有列出的仓库,用户可以使用以下 SQL。它将显示所有列出仓库的详细信息。
To view all listed warehouses, user can use following SQL. It brings details of all listed warehouses.
SHOW WAREHOUSES
要暂停仓库,请使用以下 SQL −
To suspend a warehouse, use following SQL −
ALTER WAREHOUSE TEST_WH SUSPEND
要 resume 仓库,请使用以下 SQL −
To resume a warehouse, use following SQL −
ALTER WAREHOUSE "TEST_WH" RESUME If SUSPENDED
要 delete 仓库,请使用以下 SQL −
To delete a warehouse, use the following SQL −
DROP WAREHOUSE "TEST_WH"