This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER [database owner name] WITH CREATEROLE ENCRYTPED PASSWORD '[database owner's password]'; | |
CREATE DATABASE [database name] OWNER [database owner name]; | |
-- connect to [database name] | |
REVOKE CREATE ON SCHEMA public FROM PUBLIC; | |
REVOKE ALL ON DATABASE [database name] FROM PUBLIC; | |
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM PUBLIC; | |
-- log in as [database owner name] to [database name] db | |
CREATE SCHEMA [schema name]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This SQL file is for the Hands On Lab Guide for the 30-day free Snowflake trial account | |
// The numbers below correspond to the sections of the Lab Guide in which SQL is to be run in a Snowflake worksheet | |
// Modules 1 and 2 of the Lab Guide have no SQL to be run | |
// See the lab guide here - https://s3.amazonaws.com/snowflake-workshop-lab/InpersonZTS_LabGuide.pdf | |
//===================================== | |
// MODULE 1 | |
// Steps to Prepare Your Lab Environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Database: goprojects | |
-- DROP DATABASE goprojects; | |
CREATE DATABASE goprojects | |
WITH | |
OWNER = postgres | |
ENCODING = 'UTF8' | |
LC_COLLATE = 'Chinese (Simplified)_People''s Republic of China.936' | |
LC_CTYPE = 'Chinese (Simplified)_People''s Republic of China.936' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE test OWNER postgres; | |
# connect to db test and stay connected for rest of statements in this file. | |
\c test | |
# prevent unauthorized access | |
REVOKE ALL ON DATABASE test FROM PUBLIC; | |
REVOKE ALL ON SCHEMA public FROM PUBLIC; | |
# create "groups" (read: ROLES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |