0% found this document useful (0 votes)
23 views

Inserting - . - . - . - . - . - . - . - . - . - . - . - . - 49

This document outlines topics related to SQL querying and table design. It discusses creating and using temporary tables, normalizing tables into first through fifth normal forms, and various SQL statements like SELECT, INSERT, and JOIN. The document is divided into chapters that cover table creation, data insertion, selecting data, and optimization techniques like normalization.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Inserting - . - . - . - . - . - . - . - . - . - . - . - . - 49

This document outlines topics related to SQL querying and table design. It discusses creating and using temporary tables, normalizing tables into first through fifth normal forms, and various SQL statements like SELECT, INSERT, and JOIN. The document is divided into chapters that cover table creation, data insertion, selecting data, and optimization techniques like normalization.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Contents

1.14.4 CREATE EXISTING TABLE . . . . . . . . . . . . . . . . . . . . . 33


1.15 Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
1.15.1 Global Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . 36
1.15.2 Local Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . 37
1.15.2.1 CREATE TABLE #table_name . . . . . . . . . . . . . . . . 37
1.15.2.2 DECLARE LOCAL TEMPORARY TABLE . . . . . . . . . 38
1.15.2.3 SELECT INTO #table_name . . . . . . . . . . . . . . . . . 40
1.16 Normalized Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
1.16.1 First Normal Form . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
1.16.2 Second Normal Form . . . . . . . . . . . . . . . . . . . . . . . . . 42
1.16.3 Third Normal Form . . . . . . . . . . . . . . . . . . . . . . . . . . 43
1.16.4 Boyce-Codd Normal Form. . . . . . . . . . . . . . . . . . . . . . . 44
1.16.5 Fourth Normal Form . . . . . . . . . . . . . . . . . . . . . . . . . . 45
1.16.6 Fifth Normal Form . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
1.17 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Chapter 2 Inserting . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.2 INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
2.2.1 INSERT All Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.2.2 INSERT Named Values . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.2.3 INSERT Select All Columns . . . . . . . . . . . . . . . . . . . . . . 53
2.2.4 INSERT Select Column List . . . . . . . . . . . . . . . . . . . . . . 54
2.2.5 INSERT Select With Auto Name . . . . . . . . . . . . . . . . . . . . 55
2.3 LOAD TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.4 ISQL INPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.5 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Chapter 3 Selecting . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.2 Logical Execution of a SELECT. . . . . . . . . . . . . . . . . . . . . . . . 70
3.3 FROM Clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.4 JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.4.1 CROSS JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.4.2 INNER JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.4.3 LEFT OUTER JOIN. . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.4.4 RIGHT OUTER JOIN. . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.4.5 FULL OUTER JOIN . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.5 Derived Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.6 Multi-Table Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.7 SELECT FROM Procedure Call . . . . . . . . . . . . . . . . . . . . . . . . 96
3.8 LATERAL Procedure Call . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.9 SELECT List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
3.10 Expressions and Operators . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.10.1 IF and CASE Expressions . . . . . . . . . . . . . . . . . . . . . . 105
3.11 Top 15 Scalar Built-in Functions . . . . . . . . . . . . . . . . . . . . . . 107
3.12 Boolean Expressions and the WHERE Clause . . . . . . . . . . . . . . . 113
3.12.1 Comparison Predicates . . . . . . . . . . . . . . . . . . . . . . . . 116

iv

You might also like