Teradata-Performance SQL
Teradata-Performance SQL
Class Outline
CoffingDW education has been customized for every customer
for the past 20 years. Our classes can be taught either on site or
remotely via the internet.
Topics:
Basic SQL Functions
The WHERE Clause
Distinct Vs. Group By
The TOP Command
Review
HELP and SHOW
Aggregation Function
Join Functions
Date Functions
Format Functions
OLAP Functions
The Quantile Function
Temporary Tables
Sub-query Functions
Substrings and Positioning Functions
Interrogating the Data
View Functions
Macro Functions
Set Operators Functions
Creating Tables, Secondary Indexes, and Join Indexes
Data Manipulation Language (DML)
Stored Procedure Functions
Trigger Functions
Math Functions
Sample
Statistical Aggregate Functions
Explain
Collect Statistics
Hashing Functions
BTEQ – Batch Teradata Query
Top SQL Commands Cheat Sheet
Prerequisites: None
Course Outline:
Chapter 1 - Basic SQL Functions
Introduction
SELECT * (All Columns) in a Table
SELECT Specific Columns in a Table
Using the Best Form for Writing SQL
Commas in the Front or in the Back?
Place your Commas in front for better Debugging Capabilities
Sort the Data with the ORDER BY Keyword
ORDER BY Defaults to Ascending
Use the Name or the Number in your ORDER BY Statement
Two Examples of ORDER BY using Different Techniques
Changing the ORDER BY to Descending Order
NULL Values sort First in Ascending Mode (Default)
NULL Values sort Last in Descending Mode (DESC)
Major Sort vs. Minor Sorts
Multiple Sort Keys using Names vs. Numbers
Sorts are Alphabetical, NOT Logical
Using A CASE Statement to Sort Logically
How to ALIAS a Column Name
A Missing Comma can by Mistake become an Alias
The Title Command and Literal Data
Comments using Double Dashes are Single Line Comments
Comments for Multi-Lines
Comments for Multi-Lines as Double Dashes per Line
A Great Technique for Comments to Look for SQL Errors
TOP Command
TOP Command is brilliant when ORDER BY is used!
The TOP Command WITH TIES
How the TOP Command WITH TIES Decides
The TOP Command will NOT work with Certain Commands
Chapter 5 – Review
INSERT Syntax # 1
INSERT Example with Syntax 1
INSERT Syntax # 2
INSERT Example with Syntax 2
INSERT Example with Syntax 3
Using NULL for Default Values
INSERT/SELECT Command
INSERT/SELECT Example using All Columns (*)
INSERT/SELECT Example with Less Columns
INSERT/SELECT to Build a Data Mart
Fast Path INSERT/SELECT
NOT quite the Fast Path INSERT/SELECT
UNION for the Fast Path INSERT/SELECT
BTEQ for the Fast Path INSERT/SELECT
The UPDATE Command Basic Syntax
Two UPDATE Examples
Subquery UPDATE Command Syntax
Example of Subquery UPDATE Command
Join UPDATE Command Syntax
Example of an UPDATE Join Command
Fast Path UPDATE
The DELETE Command Basic Syntax
Two DELETE Examples to DELETE ALL Rows in a Table
A DELETE Example Deleting only Some of the Rows
Subquery and Join DELETE Command Syntax
Example of Subquery DELETE Command
Example of Join DELETE Command
Fast Path DELETE
Fast Path DELETE Example # 1
Fast Path DELETE Example # 2
Fast Path DELETE Example # 3
MERGE INTO
MERGE INTO Example that Matches
MERGE INTO Example that does NOT Match
OReplace
Chapter 25 - Sample
Chapter 27 - Explain
EXPLAIN Keywords
EXPLAIN Keywords Continued
Explain Example – Full Table Scan
Explain Example – Unique Primary Index (UPI)
Explain Example – Non-Unique Primary Index (NUPI)
Explain Example – Unique Secondary Index (USI)
Explain Example – Redistributed to All-AMPs
Explain Example – Row Hash Match Scan
Explain Example – Duplicated on All-AMPs
Explain Example –Low Confidence
Explain Example – High Confidence
Explain Example – Product Join
Explain Example – BMSMS
Explain Terminology for Partitioned Primary Index Tables
Explain Example – From a Single Partition
Explain Example – From N Partitions
Explain Example – Partitions and Current_Date