Structured Query Language/Standard Track Print - Wikibooks, open boo... https://en.wikibooks.org/w/index.php?title=Structured_Query_Language... Structured Query Language/Standard Track Print Introduction Contents 1 Introduction 2 It's a Translation and a Guide 3 What this Wikibook is not 4 How to proceed 5 Conventions 5.1 Historical Context 5.2 What makes up a Database Management System? 5.3 Classification of DBMS Design 6 The Theory 7 The Data Model 8 Some more Basics 9 History 10 Characteristics 11 Fundamentals 12 Turing completeness 13 Benefit of Standardization 14 Limits 15 The Standardization Process 16 Verification of Conformance to the Standard 17 Implementations 18 Create Table 18.1 Data Types 18.2 Constraints 18.3 Foreign Key 19 Alter Table 20 Drop Table 21 Select 21.1 Basic Syntax 21.2 Case 21.3 Grouping 21.4 Join 21.5 Subquery 21.6 Set operations 21.7 Rollup/Cube 21.8 Window functions 21.9 Recursions 22 Insert 23 Update 24 Merge 25 Delete 26 Truncate 27 Standard Track 28 More than a Spreadsheet 29 Conceive the Structure 30 Fasten Decisions 31 The Result 32 Back to Start 33 Store new Data with INSERT Command 34 Retrieve Data with SELECT Command 35 Modify Data with UPDATE Command 36 Remove data with DELETE Command 37 Summary 1 sur 121 27/01/2016 00:25 Structured Query Language/Standard Track Print - Wikibooks, open boo... https://en.wikibooks.org/w/index.php?title=Structured_Query_Language... 38 person 39 contact 40 hobby 41 person_hobby 42 Visualisation of the Structure 43 person 44 contact 45 hobby 46 person_hobby 47 Grow up 48 Projection 48.1 UNIQUE 48.2 Aliases for Columnnames 48.3 Functions 48.4 SELECT within SELECT 49 Table names 50 Restriction 50.1 Comparisons 50.2 Boolean logic 51 Grouping 52 Sorting 53 Combine the Language Elements 54 Further Information 55 Exercises 56 AUTOCOMMIT 57 COMMIT 58 ROLLBACK 59 Exercises 60 The Idea 61 The Basic Syntax 62 Four Join Types 62.1 Inner Join 62.2 Left (outer) Join 62.3 Right (outer) Join 62.4 Full (outer) Join 63 Cartesian Product 64 The n:m Situation 65 More Details 66 Exercises 67 Constitute Groups 67.1 Grouping over multiple columns 68 Inspect Groups 69 Focus on Desired Groups 70 The Overall Picture 71 Exercises 72 Extention of Boolean Logic 73 Retrieve the NULL Special Marker 74 Some Examples 75 Coalesce() and Similar Functions 76 Exercises 77 Aggregate functions 77.1 The NULL special marker 77.2 ALL vs. DISTINCT 77.3 Hint 78 Scalar functions 79 Exercises 80 UNION 81 INTERSECT 82 EXCEPT 83 Order By 84 Group By 85 Exercises 86 Two Examples 87 Syntax 2 sur 121 27/01/2016 00:25 Structured Query Language/Standard Track Print - Wikibooks, open boo... https://en.wikibooks.org/w/index.php?title=Structured_Query_Language... 88 Typical Use Cases 89 Exercises 90 Classification 91 Scalar Value Subquery 92 Row Subquery 93 Table Subquery 94 Another Example 95 Exercises 96 Create a View 97 Examples and Explanations 97.1 Example 1: Hide Columns 97.2 Example 2: Rename Columns 97.3 Example 3: Apply WHERE Condition 97.4 Example 4: Use Functions 97.5 Example 5: Join 98 Some more Hints 99 Write Access via Views 100 Clean up the Example Database 101 Exercises 102 Evaluate Values at Runtime 103 Evaluate Rows at Runtime 104 Clean up Your Database 105 Exercises 106 Evaluate Values at Runtime 107 Subqueries in WHERE Clause 108 Exercises 109 Description 110 Example 111 Use Case 112 Extentions 113 Caveat 114 Exercises 115 Example 116 Exercise 117 Example 118 An Analogy 119 Exercises 120 General Description 121 Column Definition 121.1 Data Type 121.2 Default Value 121.3 Identity Specification 121.4 Column Constraint 122 Table Constraint 122.1 Primary Key, UNIQUE and Foreign Key 122.2 NOT NULL and Simple Column Checks 122.3 General Column Checks 123 Column Constraints vs. Table Constraints 124 Clean Up 125 Exercises 126 Overview 127 Character 128 Binary 129 Exact Numeric 130 Approximate Numeric 131 Temporal 132 Boolean 133 XML 134 Domains 135 Clean Up 136 Exercises 137 Foreign Key vs. Join 138 Syntax 139 Example 3 sur 121 27/01/2016 00:25 Structured Query Language/Standard Track Print - Wikibooks, open boo... https://en.wikibooks.org/w/index.php?title=Structured_Query_Language... 140 n:m Relationship 141 ON DELETE / ON UPDATE 142 IMMEDIATE / DEFERRED 143 The Chicken-Egg Problem 144 DROP TABLE / TRUNCATE TABLE 145 Exercises 146 Columns 146.1 Add a Column 146.2 Alter the Characteristic of a Column 146.2.1 Change the Data Type 146.2.2 Change the DEFAULT Clause 146.2.3 Change the NOT NULL Clause 146.3 Drop a Column 147 Table Constraints 147.1 Add a Table Constraint 147.2 Alter a Table Constraint 147.3 Drop a Table Constraint 148 Exercises 149 Global Temporary Tables (GTT) 150 Local Temporary Tables (LTT) 151 Declared Local Temporary Tables (DLTT) 152 Implementation Hints 153 The Concept of Indexes 154 Basic Index 155 Multiple Columns 156 Functional Index 157 Unique Index 158 Drop an Index 159 Privileges 160 Object Types 161 Roles / Public 162 Grant Option 163 IN 164 ALL 165 ANY/SOME 166 EXISTS 167 Example Table 168 ROLLUP 169 CUBE 170 Syntax 171 Overall Description 172 Example Table 173 A First Query 174 Basic Window Functions 175 Determine Partition and Sequence 176 Determine the Frame 176.1 Terminology 176.2 ROWS 176.3 GROUPS 176.4 RANGE 176.5 Defaults 176.6 A Word of Caution 177 Exercises 178 Syntax 179 Example Table 180 Basic Queries 181 Notice the Level 182 Create Paths 183 Depth First / Breads First 184 Exercises 185 The Problem 186 Step 1: Evaluation of NULLs 186.1 Comparision Predicates, IS NULL Predicate 186.2 Other Predicates 4 sur 121 27/01/2016 00:25 Structured Query Language/Standard Track Print - Wikibooks, open boo... https://en.wikibooks.org/w/index.php?title=Structured_Query_Language... 186.3 Predefined Functions 186.4 Grouping 187 Step 2: Boolean Operations within 3VL 187.1 Inspection 187.2 NOT 187.3 AND, OR 188 Some Examples 189 Transaction Boundaries 189.1 Savepoints 190 Atomicity 191 Consistency 192 Isolation 192.1 Classification of Isolation Problems 192.2 Avoidance of Isolation Problems 193 Durability 194 Autocommit 195 References 196 Appendices 197 License 197.1 GNU Free Documentation License 198 0. PREAMBLE 199 1. APPLICABILITY AND DEFINITIONS 200 2. VERBATIM COPYING 201 3. COPYING IN QUANTITY 202 4. MODIFICATIONS 203 5. COMBINING DOCUMENTS 204 6. COLLECTIONS OF DOCUMENTS 205 7. AGGREGATION WITH INDEPENDENT WORKS 206 8. TRANSLATION 207 9. TERMINATION 208 10. FUTURE REVISIONS OF THIS LICENSE 209 11. RELICENSING 210 How to use this License for your documents It's a Translation and a Guide This Wikibook introduces the programming language SQL as defined by ISO/IEC. The standard — similar to most standard publications — is quite technical and neither easy to read nor understand. There is therefore a demand for a text document explaining the key features of the language. That is what this wikibook strives to do: present a readable, understandable introduction for everyone interested in the topic. Manuals and white papers by database vendors are mainly focused on technical aspects of their product. As they want to set themselves apart from each other, they tend to emphasize those aspects which go beyond the SQL standard and the products from other vendors. This is contrary to the wikibooks approach: we want to emphasize the common aspects. The main audience of this wikibook is, therefore, people who want to learn the language, either as a beginner or for someone with existing knowledge and some degree of experience looking for a recapitulation. What this Wikibook is not First of all, this wikibook is not a reference manual for the syntax of standard SQL or any of its implementations. Reference manuals usually consist of definitions and explanations for those definitions. By contrast, this wikibook tries to present concepts and basic commands through textual descriptions and examples. Of course some syntax will be demonstrated. On some pages there are additonal hints about slightly differences between the standard and special implementations. This wikibook is also not a complete tutorial. First, its focus is the standard and not any concrete implementation. When learning a computer language it is necessary to work with it and experience it personally. Hence, a concrete implementation is needed. And most of them differ more or less from the standard. Second, this wikibook is far away from reflecting the complete standard, e.g. the central part of the standard consists of about 18 MB text in more than 1,400 pages. But this wikibook can be used as a companion for learning about SQL. How to proceed 5 sur 121 27/01/2016 00:25 Structured Query Language/Standard Track Print - Wikibooks, open boo... https://en.wikibooks.org/w/index.php?title=Structured_Query_Language... For everyone new to SQL, it will be necessary to study the chapters and pages from beginning to end. For persons who have some experience with SQL or who are interested in a specific aspect, it is possible to navigate directly to any page. Knowledge about any other computer language is not necessary, but it will be helpful. This wikibook consists of descriptions, definitions, and examples. It should be read with care. Furthermore, it is absolutely necessary to personally do some experiments with data and data structures. Hence, access to a concrete database system where read-only and read-write tests can be done is necessary. For those tests, our example database or individually defined tables and data can be used.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages121 Page
-
File Size-