USE WAREHOUSE

Specifies the active/current virtual warehouse for the session. You must specify a warehouse for a session, and the warehouse must be running before you can execute queries and DML statements in the session.

To view the current warehouse for a session, call the CURRENT_WAREHOUSE context function.

See also:

ALTER WAREHOUSE , CREATE WAREHOUSE , SHOW WAREHOUSES

Syntax

USE WAREHOUSE <name>
Copy

Parameters

name

Specifies the identifier for the warehouse to use for the session. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.

Examples

The following example specifies the warehouse where the current session performs its work:

USE WAREHOUSE mywarehouse;
Copy

The following example changes from one warehouse to another, then back to the original warehouse. The name of the original warehouse is stored in a variable. Run the following commands:

SELECT CURRENT_WAREHOUSE();
SET original_warehouse = (SELECT CURRENT_WAREHOUSE());
USE WAREHOUSE warehouse_two;
SELECT CURRENT_WAREHOUSE();
USE WAREHOUSE IDENTIFIER($original_warehouse);
SELECT CURRENT_WAREHOUSE();
Copy

The output for these commands shows how the current warehouse value changes:

>SELECT CURRENT_WAREHOUSE();
+---------------------+
| WAREHOUSE_ONE       |
+---------------------+

>SET original_warehouse = (SELECT CURRENT_WAREHOUSE());

>USE WAREHOUSE warehouse_two;
>SELECT CURRENT_WAREHOUSE();
+---------------------+
| WAREHOUSE_TWO       |
+---------------------+

>USE WAREHOUSE IDENTIFIER($original_warehouse);
>SELECT CURRENT_WAREHOUSE();
+---------------------+
| WAREHOUSE_ONE       |
+---------------------+
Language: English