Module – 2
CONNECTING TO SNOWFLAKE CLOUD
[Link] for virtual warehouse
(1) [Link]
(2) show warehouses;
(3) alter warehouse compute_wh suspend;
(4) alter warehouse compute_wh resume;
(5) use warehouse compute_wh;
(6) create warehouse snowflake_training;
(7) create warehouse my_wh WAREHOUSE_SIZE = MEDIUM;
WAREHOUSE_SIZE = XSMALL | SMALL | MEDIUM | LARGE | XLARGE |
XXLARGE | XXXLARGE | X4LARGE
(8) alter warehouse compute_wh abort all queries;
(9) alter warehouse snowflake_training resume if suspended;
(10) alter warehouse compute_wh rename to compute_wh1;
[Link] Database
(11) [Link]
(12) create database aeei;
(13) create or replace database aeei;
(14) show databases like 'a%';
(15) use database demo_db;
(16) alter database if exists aeei rename to aeei1;
[Link] Schema
(17) [Link]
(18) Create or replace schema employees;
(19) create schema if not exists department;
(20) drop schema if exists department;
(21) show schemas like 'e%';
(22) use schema public;
(23) use schema information_schema;
(24) alter schema if exists employees rename to emp;
[Link] Tables
(25) [Link]
(26) CREATE TABLE … AS SELECT (creates a populated table; also
referred to as CTAS)
(27) CREATE TABLE … LIKE (creates an empty copy of an existing table)
(28) CREATE TABLE … CLONE (creates a clone of an existing table)
(29) create table employee (emp_id number, name varchar(20), contact
number);
[Link] View
(30) [Link]
(31) create view v1 (x, x_times_2) as select x, x * 2 from table1;
(32) create view customer_v as select * from
"SNOWFLAKE_SAMPLE_DATA"."TPCH_SF001"."CUSTOMER";
(33) select * from customer_v;
(34) create or replace force view ...
(35) Create a view in the current schema, with a comment, that selects all
the rows from a table:
create view myview comment='Test view' as select col1, col2 from
mytable;
(36) Show views;
(37) create or replace table employees (title varchar, employee_id integer,
manager_id integer);
(38) insert into employees (title, employee_id, manager_id) values
('President', 1, null), -- The President has no manager.
('Vice President Engineering', 10, 1),('Programmer', 100, 10),
('QA Engineer', 101, 10),('Vice President HR', 20, 1),('Health
Insurance Analyst', 200, 20);