Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword or section
Like this
3Activity

Table Of Contents

Book Editions
Quick Find
Index of Concepts
Introduction to SQL
Syntax Diagram Conventions
SQL Components
DB2 Objects
DB2 Data Types
Date/Time Arithmetic
DB2 Special Registers
Distinct Types
Fullselect, Subselect, & Common Table Expression
SELECT Statement
FETCH FIRST Clause
Working with Nulls
Quotes and Double-quotes
SQL Predicates
Basic Predicate
Quantified Predicate
BETWEEN Predicate
EXISTS Predicate
IN Predicate
LIKE Predicate
NULL Predicate
Special Character Usage
Precedence Rules
Processing Sequence
CAST Expression
VALUES Clause
CASE Expression
CASE Syntax Styles
Sample SQL
Miscellaneous SQL Statements
Cursor
CURSOR
Select Into
Prepare
Describe
Execute
Execute Immediate
Set Variable
Set DB2 Control Structures
Unit-of-Work Processing
Commit
Savepoint
Release Savepoint
Rollback
Data Manipulation Language
Insert
Update
Delete
Select DML Changes
Merge
Compound SQL
Introduction
Statement Delimiter
SQL Statement Usage
DECLARE Variables
FOR Statement
GET DIAGNOSTICS Statement
IF Statement
ITERATE Statement
LEAVE Statement
SIGNAL Statement
WHILE Statement
Other Usage
Trigger
Scalar Function
Table Function
Column Functions
Column Functions, Definitions
CORRELATION
COUNT
COUNT_BIG
COVARIANCE
GROUPING
REGRESSION
STDDEV
VAR or VARIANCE
OLAP Functions
OLAP Functions, Definitions
Ranking Functions
Row Numbering Function
CHAR
CLOB
COALESCE
CONCAT
COSH
DATE
DAYNAME
DAYOFWEEK
DAYOFWEEK_ISO
DAYOFYEAR
DAYS
DBCLOB
DBPARTITIONNUM
DBPARTITIONNUM (
DEC or DECIMAL
DEGREES
DEREF
DECRYPT_BIN and DECRYPT_CHAR
DIFFERENCE
DIGITS
DLCOMMENT
DLLINKTYPE
DLNEWCOPY
DLPREVIOUSCOPY
DLREPLACECONTENT
DLURLCOMPLETE
DLURLCOMPLETEONLY
DLURLCOMPLETEWRITE
DLURLPATH
DLURLPATHONLY
DLURLPATHWRITE
DLURLSCHEME
DLURLSERVER
DLVALUE
DOUBLE or DOUBLE_PRECISION
ENCRYPT
EVENT_MON_STATE
FLOAT
FLOOR
GENERATE_UNIQUE
GETHINT
GRAPHIC
HASHEDVALUE
HOUR
IDENTITY_VAL_LOCAL
INSERT
INT or INTEGER
JULIAN_DAY
LCASE or LOWER
LEFT
LENGTH
LN or LOG
LOCATE
LOG or LN
LOG10
LONG_VARCHAR
LONG_VARGRAPHIC
LOWER
LTRIM
MICROSECOND
MIDNIGHT_SECONDS
MINUTE
MONTH
MONTHNAME
MULTIPLY_ALT
NULLIF
PARTITION
POSSTR
POWER
QUARTER
RADIANS
RAISE_ERROR
RAND
REAL
REPEAT
REPLACE
RIGHT
ROUND
RTRIM
SECOND
SIGN
SINH
SMALLINT
SNAPSHOT Functions
SOUNDEX
SPACE
SQRT
STRIP
SUBSTR
TABLE
TABLE_NAME
TABLE_SCHEMA
TANH
TIME
TIMESTAMP
TIMESTAMP_FORMAT
TIMESTAMP_ISO
TIMESTAMPDIFF
TO_CHAR
TO_DATE
TRANSLATE
TRIM
TRUNC or TRUNCATE
TYPE_ID
TYPE_NAME
TYPE_SCHEMA
UCASE or UPPER
VALUE
VARCHAR
VARCHAR_FORMAT
VARGRAPHIC
VEBLOB_CP_LARGE
WEEK
WEEK_ISO
YEAR
"+" PLUS
"-" MINUS
"*" MULTIPLY
"/" DIVIDE
"||" CONCAT
User Defined Functions
Sourced Functions
Description
Examples
Table Functions
Useful User-Defined Functions
Julian Date Functions
Get Prior Date
Generating Numbers
Check Data Value Type
Order By, Group By, and Having
Order By
Notes
Order by Examples
Group By and Having
Rules and Restrictions
GROUP BY Flavors
GROUP BY Sample Data
Simple GROUP BY Statements
GROUPING SETS Statement
ROLLUP Statement
CUBE Statement
Complex Grouping Sets - Done Easy
Group By and Order By
Group By in Join
COUNT and No Rows
Joins
Why Joins Matter
Sample Views
Join Syntax
Query Processing Sequence
ON vs. WHERE
Join Types
Inner Join
Left Outer Join
Right Outer Join
Full Outer Joins
Cartesian Product
Join Notes
Using the COALESCE Function
Listing non-matching rows only
Join in SELECT Phrase
Predicates and Joins, a Lesson
Joins - Things to Remember
Complex Joins
Sub-Query
Sample Tables
Sub-query Flavours
Sub-query Syntax
Correlated vs. Uncorrelated Sub-Queries
Multi-Field Sub-Queries
Nested Sub-Queries
Usage Examples
True if NONE Match
True if ANY Match
True if TEN Match
True if ALL match
Union, Intersect, and Except
Syntax Diagram
Usage Notes
Union & Union All
Intersect & Intersect All
Except & Except All
Unions and Views
Materialized Query Tables
Syntax Options
Select Statement
Optimizer Options
Refresh Deferred Tables
Refresh Immediate Tables
Usage Notes and Restrictions
Multi-table Materialized Query Tables
Indexes on Materialized Query Tables
Organizing by Dimensions
Using Staging Tables
Identity Columns and Sequences
Identity Columns
Altering Identity Column Options
Gaps in Identity Column Values
IDENTITY_VAL_LOCAL Function
Sequences
Getting the Sequence Value
Multi-table Usage
Counting Deletes
Identity Columns vs. Sequences - a Comparison
Roll Your Own
Support Multi-row Inserts
Temporary Tables
Temporary Tables - in Statement
Common Table Expression
Full-Select
Declared Global Temporary Tables
Recursive SQL
Use Recursion To
When (Not) to Use Recursion
How Recursion Works
List Dependents of AAA
Notes & Restrictions
Sample Table DDL & DML
Introductory Recursion
List all Children #1
List all Children #2
List Distinct Children
Show Item Level
Select Certain Levels
Select Explicit Level
Trace a Path - Use Multiple Recursions
Extraneous Warning Message
Logical Hierarchy Flavours
Divergent Hierarchy
Convergent Hierarchy
Recursive Hierarchy
Balanced & Unbalanced Hierarchies
Data & Pointer Hierarchies
Halting Recursive Processing
Stop After "n" Levels
Stop When Loop Found
Keeping the Hierarchy Clean
Clean Hierarchies and Efficient Joins
Limited Update Solution
Before Row Triggers - Set Values
Before Row Trigger - Signal Error
After Row Triggers - Record Data States
After Statement Triggers - Record Changes
Examples of Usage
Protecting Your Data
Sample Application
Enforcement Tools
Distinct Data Types
Customer-Balance Table
US-Sales Table
Conclusion
Retaining a Record
Schema Design
Recording Changes
Multiple Versions of the World
Using SQL to Make SQL
Export Command
SQL to Make SQL
Running SQL Within SQL
Generate SQL within SQL
Make Query Column-Independent
Business Uses
Meta Data Dictionaries
DB2 SQL Functions
Function and Stored Procedure Used
Different Data Types
Java Functions
Tabular Functions
Transpose Function
Update Real Data using Meta-Data
Fun with SQL
Creating Sample Data
Data Generation
Make Reproducible Random Data
Make Random Data - Different Ranges
Make Random Data - Varying Distribution
Make Random Data - Different Flavours
Make Test Table & Data
Time-Series Processing
Find Overlapping Rows
Find Gaps in Time-Series
Show Each Day in Gap
Other Fun Things
Randomly Sample Data
Convert Character to Numeric
Multiple Counts from the Same Row
Normalize Denormalized Data
Denormalize Normalized Data
Transpose Numeric Data
Reversing Field Contents
Fibonacci Series
Business Day Calculation
Query Runs for "n" Seconds
Sort Character Field Contents
Calculating the Median
Converting HEX Data to Number
Quirks in SQL
Trouble with Timestamps
No Rows Match
Dumb Date Usage
RAND in Predicate
Date/Time Manipulation
Use of LIKE on VARCHAR
Comparing Weeks
DB2 Truncates, not Rounds
CASE Checks in Wrong Sequence
Division and Average
Date Output Order
Ambiguous Cursors
Multiple User Interactions
Floating Point Numbers
Legally Incorrect SQL
Appendix
DB2 Sample Tables
CATALOG
CL_SCHED
CUSTOMER
DEPARTMENT
EMP_PHOTO
EMP_RESUME
EMPLOYEE
EMPMDC
EMPPROJACT
IN_TRAY
INVENTORY
PRODUCT
PRODUCTSUPPLIER
PROJACT
PROJECT
PURCHASEORDER
SALES
STAFF
SUPPLIERS
Book Binding
Bibliography
IBM Sources
DB2 Manuals
Red Books
Online Tutorials
Other Sources
Books Published
Roger Sanders Books
DB2 Magazine
Index
0 of .
Results for:
No results containing your search query
P. 1
Db 2 Cookbook PDF

Db 2 Cookbook PDF

Ratings: (0)|Views: 39 |Likes:
Published by nur1euro

More info:

Published by: nur1euro on Nov 05, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/12/2013

pdf

text

original

You're Reading a Free Preview
Pages 9 to 107 are not shown in this preview.
You're Reading a Free Preview
Pages 121 to 305 are not shown in this preview.
You're Reading a Free Preview
Pages 314 to 375 are not shown in this preview.
You're Reading a Free Preview
Pages 384 to 445 are not shown in this preview.

Activity (3)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Jihane Naciri liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->