Db2 Coding - SQL Coding Tips and Techniques - Expert Videos
Duration
60 minutes
Overview
These expert videos provide some tips and techniques for coding efficient SQL statements in your Db2 applications. You will discover several different ways to avoid writing code, for example by using existing Functions and Db2 Utilities, and see how reusable Db2 code in the form of stored procedures and triggers, can be created. You will also look at the use of dynamic and static SQL and when each should be used, and how to use set operations in Db2 to combine data from multiple queries in different ways and for different use cases. Finally, you will be introduced to general tips and techniques for writing SQL statements.
Audience
This is aimed at individuals whose job role is to analyze and improve the performance of their Db2 database programs.
Prerequisites
Successful completion of the Interskill, Db2 Coding - Understanding and Reviewing Db2 Access Paths - Expert Videos, or equivalent knowledge.
Objectives
After completing this course, the student should be able to:
- Identify Existing Code That Can be Reused
- Describe When Static and Dynamic SQL Code Should be Used
- Describe SQL Statements and Clauses That Can be Used to Improve Your SQL Code
Course Content
Avoid Writing Code
Using Existing Code
Using the MERGE Statement
SELECT from INSERT, UPDATE, and MERGE
Scalar Functions
Date and Time Functions
Aggregate Functions
LOAD and UNLOAD Db2 Utilities
Reusable Db2 Code
Db2 Stored Procedures
Scenarios Where Db2 Stored Procedures are Useful
Db2 Triggers
Dynamic and Static SQL
Static SQL
Dynamic SQL
Considerations When Using Static and Dynamic SQL
SQL Guidelines
Testing Your Code
Limiting Data that is Returned
Optimize a Query
FETCH FIRST
EXISTS Clause
Finding Duplicates
No Operation expression
Set Operations
UNION Operation
INTERSECT Operation
EXCEPT Operation
Using the ALL Clause