SnowFlake University - Code Flashcards
What symbol would look for characters in each cell, regardles sof where they are (beginning, ending or in middle of a cell)?
But % before and after the characters you are looking for.
EX:
SELECT R_REASON_DESC
FROM “SNOWFLAKE_SAMPLE_DATA”.”TPCDS_SF100TCL”.”REASON”
WHERE R_REASON_DESC LIKE ‘%it%’;
What is the syntax of REPLACE function? and define each of the parameters.
REPLACE(subject, pattern [,replacement])
Subject - where to look
Pattern - What to look for
Replacement - what to replace it with (optional)
What to use to assign a name to a column?
AS
Not permanent
Replace function change the table permanently?
No
What to use to permanently change a table?
UPDATE and SET functions
Syntax of the UPDATE and SET functions:
UPDATE
SET column = REPLACE(subject, pattern [,replacement])
What to put in front of a comment?
// or –
What are the two ways of CONCATENATION
CONCAT function - linking only two values at a time
DOUBLE-PIPE - using a double-pipe symbol
Syntax of CONCAT function:
CONCAT(pattern, subject)
Nest a CONCAT function to…
concate mare than two values.
Basically one inside another
Double-pipe syntax:
pattern || subject || pattern
VARCHAR mean:
Alphanumeric data
How to define a CET
with a WITH clause
What does a CET clause do?
Precedes the body of the SELECT statement, and defines one or more CTEs the can be used later in the statement.
What does SELECT as a statement do?
It queries the database and retrieves a set of rows (most used statement)
What does SELECT as a clause do?
it defines the set of columns returned by a query
What does the COPY INTO command do?
Like LIST command, it is not actually SQL, and it is used to move data from an External Stage file into a Snowflake table
What database objects need to be defined to use a COPY INTO command?
- A table
- A stage
- File Format - structure of the file we want to load
- Identify the file you want to upload
What is the LIST command used for?
It is used to explore the data within a stage
To select files by directory, and down into any number of sub-directory levels, when using the LIST command, you can…
simply add the path
ex. LIST @MY_S3_BUCKET/load/d..
Is the LIST command SQL?
No
It is a lot more like a LINUX directory command
What does this symbol mean:
::
Data type conversion
ex:
select ‘2016-12-25’::date as christmas