- Page 2:
Beginning SQL Paul Wilton and John
- Page 10:
Beginning SQL Paul Wilton and John
- Page 14:
About the Authors Paul Wilton After
- Page 18:
Paul Wilton: With lots of love to m
- Page 24:
Contents x Selecting Correct Data T
- Page 28:
Contents xii Re-examining NULL 180
- Page 32:
Contents Chapter 11: Transactions 3
- Page 36:
Contents xvi How Do You Do It? 357
- Page 42:
Introduction Data, data, data! Data
- Page 46:
By the time you’ve completed Chap
- Page 50:
Once you download the code, just de
- Page 54:
1 Introduction to SQL A nice, gentl
- Page 58:
Figure 1-1 Why and When to Use a Da
- Page 62:
Databases are great at dealing with
- Page 66:
The SQL language is actually fairly
- Page 70:
you wish, and the database system d
- Page 74:
A keyword is a word that has some m
- Page 78:
Introduction to SQL A perfectly val
- Page 82:
Data Type Description Storage Used
- Page 86:
The char and varchar data types use
- Page 90:
Most RDBMSs handle the most common
- Page 94:
To add a new column, use the basic
- Page 98:
Now that you know what you want to
- Page 102:
❑ Meeting date 2 ❑ Location 2
- Page 106:
Generally speaking, picking a data
- Page 110:
example, the MemberId field links t
- Page 114:
Depending on which RDBMS you’re u
- Page 118:
The FilmCategory table is very smal
- Page 122:
2 Entering Information The last cha
- Page 126:
like this: INSERT INTO Category VAL
- Page 130:
Inserting Data into the Case Study
- Page 134:
The WHERE Clause So far you’ve se
- Page 138:
Try It Out Using Logical Operators
- Page 142:
Exercises 1. Three new members have
- Page 148:
Chapter 3 54 MemberId FirstName 1 K
- Page 152:
Chapter 3 The results are as follow
- Page 156:
Chapter 3 The results to this query
- Page 160:
Chapter 3 FavCategory (CategoryId,
- Page 164:
Chapter 3 Logical Operators and Ope
- Page 168:
Chapter 3 The statement returns the
- Page 172:
Chapter 3 NOT Operator Examples thu
- Page 176:
Chapter 3 2. Using the following SQ
- Page 180:
Chapter 3 When you execute the quer
- Page 184:
Chapter 3 Now that you’re acquain
- Page 188:
Chapter 3 It’s as simple as that!
- Page 192:
Chapter 3 76 YearReleased 1947 1967
- Page 196:
Chapter 3 78 FilmName Rating Gone w
- Page 200:
Chapter 3 2. Add a WHERE clause to
- Page 204:
Chapter 3 Executing this SQL provid
- Page 208:
Chapter 3 84 FullName First name is
- Page 212:
Chapter 3 86 FullName First name is
- Page 216:
Chapter 3 Even though DateOfBirth i
- Page 220:
Chapter 3 Member Name The member is
- Page 224:
Chapter 3 92 The preceding SQL prod
- Page 228:
Chapter 3 94 ❑ Category ❑ FavCa
- Page 232:
Chapter 3 96 You’re one step furt
- Page 236:
Chapter 3 98 FirstName LastName Cat
- Page 240:
Chapter 3 This time, you achieve mo
- Page 244:
Chapter 3 SQL Is Set-Based 102 You
- Page 248:
Chapter 3 104 Category MemberId Thr
- Page 252:
Chapter 3 106 You should see the fo
- Page 256:
Chapter 3 The overlapping portions
- Page 260:
Chapter 3 110 More than one conditi
- Page 264:
Chapter 3 112 Next, link the Member
- Page 268:
Chapter 3 114 FirstName LastName Da
- Page 272:
Chapter 3 ❑ The slightly tricky t
- Page 276:
Chapter 4 normalization can make da
- Page 280:
Chapter 4 120 Field Name Data Type
- Page 284:
Chapter 4 122 The Street, City, and
- Page 288:
Chapter 4 MySQL versions prior to 5
- Page 292:
Chapter 4 126 Except for IBM’s DB
- Page 296:
Chapter 4 128 You can add more than
- Page 300:
Chapter 4 Try It Out Adding a CHECK
- Page 304:
Chapter 4 Obviously, if the table i
- Page 308:
Chapter 4 134 Drop the MoreHolidayB
- Page 312:
Chapter 4 136 If you want to return
- Page 316:
Chapter 4 If you’re using IBM DB2
- Page 320:
Chapter 4 140 index helps speed up
- Page 324:
Chapter 4 142 The results you get m
- Page 328:
Chapter 4 144 The results of the qu
- Page 332:
Chapter 4 146 Remember, IBM DB2 doe
- Page 336:
Chapter 4 148 UPDATE Films SET Film
- Page 340:
Chapter 4 150 Finally, you do the s
- Page 344:
Chapter 4 152 SELECT * FROM MemberD
- Page 348:
Chapter 4 ❑ Choose meaningful nam
- Page 354:
5 Manipulating Data In Chapter 3, y
- Page 358:
The results of this query are as fo
- Page 362:
You can raise a number to any power
- Page 366:
To demonstrate the sort of results
- Page 370:
The CEILING() Function The CEILING(
- Page 374:
ased on the digits after the decima
- Page 378:
The SUBSTRING() function works at t
- Page 382:
LastName UPPER(LastName) LOWER(Last
- Page 386:
The LENGTH() function takes just on
- Page 390:
LastName LOWER(SUBSTRING(LastName,1
- Page 394:
FirstName DIFFERENCE(FirstName, ‘
- Page 398:
Converting Different Data Types Thi
- Page 402:
CREATE Table MyTable(FirstColumn in
- Page 406:
The COALESCE() Function The COALESC
- Page 410:
Ideally, this first argument is the
- Page 414:
LocationId Street City State 1 Main
- Page 418:
6 Grouping and Aggregating Data So
- Page 422:
Running the query, complete with a
- Page 426:
MemberId Street City State 11 Newis
- Page 430:
Executing the SQL returns seven dis
- Page 434:
For example, the following code add
- Page 438:
Running the query gives the answer
- Page 442:
SELECT MAX(LastName), MIN(LastName)
- Page 446:
immediately after the GROUP BY stat
- Page 450:
Executing the final SQL provides th
- Page 456:
Chapter 7 The INNER JOIN links the
- Page 460:
Chapter 7 FilmName FirstName LastNa
- Page 464:
Chapter 7 212 As mentioned, that wo
- Page 468:
Chapter 7 Category Street Romance T
- Page 472:
Chapter 7 216 MD1.First MD1.Last MD
- Page 476:
Chapter 7 SELECT MD1.MemberId, MD1.
- Page 480:
Chapter 7 220 SELECT Category, Film
- Page 484:
Chapter 7 222 Location.Street Membe
- Page 488:
Chapter 7 224 Category MemberId War
- Page 492:
Chapter 7 Look at the results that
- Page 496:
Chapter 7 228 The Maltese Poodle 8
- Page 500:
Chapter 7 230 9 10 11 12 13 14 15 1
- Page 504:
Chapter 7 232 On Golden Puddle 1967
- Page 510:
8 Queries within Queries This chapt
- Page 514:
There are no films with a value in
- Page 518:
The error wording depends on the da
- Page 522:
Now execute the query. You receive
- Page 526:
The query provides the following re
- Page 530:
If you execute this query, you can
- Page 534:
To obtain the same results as you w
- Page 538:
MemberId 1 10 14 6 5 8 7 11 15 4 13
- Page 542:
Now NOT EXISTS returns true, and as
- Page 546:
This is the same as the query just
- Page 550:
clause specifying that the film’s
- Page 554:
4. Next, quickly double-check a few
- Page 558:
Now that you’ve confirmed that th
- Page 562:
Summary Queries within Queries This
- Page 568:
Chapter 9 264 Figure 9-1 The SQL ne
- Page 572:
Chapter 9 266 INSERT INTO OrderItem
- Page 576:
Chapter 9 268 VALUES (5,7, 2,’200
- Page 580:
Chapter 9 Now that you’ve added t
- Page 584:
Chapter 9 272 FirstName LastName Mo
- Page 588:
Chapter 9 274 DVDPrice column is in
- Page 592:
Chapter 9 SalesPersonId FirstName L
- Page 596:
Chapter 9 278 SalesPersonId MemberI
- Page 600:
Chapter 9 280 SalesPersonId MemberI
- Page 604:
Chapter 9 282 MemberDetails.FirstNa
- Page 608: Chapter 9 284 The query would work
- Page 612: Chapter 9 Exercises 286 Assume that
- Page 616: Chapter 10 Now that you know what v
- Page 620: Chapter 10 Types of Views Given tha
- Page 624: Chapter 10 Perhaps you need to view
- Page 628: Chapter 10 Figure 10-7 Summary view
- Page 632: Chapter 10 296 This statement gives
- Page 636: Chapter 10 The CHECK OPTION plays a
- Page 642: 11 Transactions When you move out o
- Page 646: Example Data This section creates e
- Page 650: 3. Build a record in the Rentals ta
- Page 654: The other statement that the ANSI S
- Page 660: Chapter 11 ROLLBACK TRANSACTION 310
- Page 664: Chapter 11 Transaction Logs 312 How
- Page 668: Chapter 11 Database There are perfe
- Page 672: Chapter 11 In order to find and fix
- Page 676: Chapter 11 When discussing locking,
- Page 680: Chapter 11 Usually, the default iso
- Page 684: Chapter 11 From Sue’s perspective
- Page 688: Chapter 11 5. At this point, you ne
- Page 694: 12 SQL Security In today’s world,
- Page 698: Setting up security begins with cre
- Page 702: ALTER USER username options ALTER U
- Page 706: In Figure 12-3, three different gro
- Page 710:
How It Works After you run this sta
- Page 714:
check constraints can be used in a
- Page 718:
You could then give SELECT privileg
- Page 722:
Limitations on Views Views are by t
- Page 726:
GRANT SELECT (NAME, SSN, SALARY) ON
- Page 730:
Betsey also grants privileges to Ji
- Page 734:
The CASCADE option tells the DBMS t
- Page 738:
13 Database Tuning SQL is a languag
- Page 742:
Perhaps this doesn’t sound remote
- Page 746:
When an application asks for data f
- Page 750:
The point of all the discussion of
- Page 754:
How Do You Do It? And herein lies t
- Page 758:
The slots are often implemented as
- Page 762:
On the other hand, an index on a tr
- Page 766:
Tuning Tips The following list cont
- Page 770:
Database Tuning Exercises 1. Create
- Page 776:
Appendix A Exercise 2 Solution 368
- Page 780:
Appendix A ( 8, ‘Jack’, ‘John
- Page 784:
Appendix A ZipCode, Email, DateOfJo
- Page 788:
Appendix A Exercise 3 Solution Firs
- Page 792:
Appendix A 376 Figure A-1 ISBN is a
- Page 796:
Appendix A Chapter 5 Exercise 1 Sol
- Page 800:
Appendix A 380 You might receive sl
- Page 804:
Appendix A 382 You should use the f
- Page 808:
Appendix A Your answer may differ,
- Page 812:
Appendix A WHERE (SELECT COUNT(*) f
- Page 816:
Appendix A Exercise 2 Solution CREA
- Page 820:
Appendix A Chapter 13 Exercise 1 So
- Page 824:
Appendix B 392 Click the database i
- Page 828:
Appendix B 394 Click Install to beg
- Page 832:
Appendix B 396 Select the Detailed
- Page 836:
Appendix B 398 Leave it at the defa
- Page 840:
Appendix B 400 Having entered your
- Page 844:
Appendix B 402 Figure B-20 The inst
- Page 848:
Appendix B 404 At the very top of t
- Page 852:
Appendix B 406 Having done that, ma
- Page 856:
Appendix B 408 Figure B-30 MyTable
- Page 860:
Appendix B 410 Figure B-32 Click Ne
- Page 864:
Appendix B 412 Click Next to contin
- Page 868:
Appendix B 414 Click OK to clear th
- Page 872:
Appendix B If you’re ready and ha
- Page 876:
Appendix B 418 You can also enter a
- Page 880:
Appendix B 420 Figure B-49 The Film
- Page 884:
Appendix B 422 Now you need to inse
- Page 888:
Appendix B 424 In Access it’s not
- Page 892:
Appendix B 426 Figure B-56 You need
- Page 896:
Appendix B 428 Then click the Run i
- Page 900:
Appendix B 430 The next screen (see
- Page 904:
Appendix B 432 On the next screen,
- Page 908:
Appendix B 434 Click Next to procee
- Page 912:
Appendix B 436 Figure B-72 The huge
- Page 916:
Appendix B 438 Figure B-74 Notice t
- Page 920:
Appendix B 440 Figure B-76 The Obje
- Page 924:
Appendix B 442 Figure B-78 Chapter
- Page 928:
Appendix B You don’t need MyTable
- Page 932:
Appendix B 446 Figure B-82 To begin
- Page 936:
Appendix B Using Oracle’s SQL*Plu
- Page 940:
Appendix B 450 Figure B-87 Another
- Page 944:
Appendix C Category Table The follo
- Page 948:
Appendix C 454 ( 3, ‘Sandra’,
- Page 952:
Appendix C 456 ZipCode, Email, Date
- Page 956:
Appendix C DateOfJoining ) VALUES (
- Page 960:
Appendix C 460 VALUES ( 1, 3 ); INS
- Page 964:
Appendix C VALUES ( 5, 3 ); INSERT
- Page 968:
Appendix C 464 3 ); INSERT INTO Fil
- Page 972:
Appendix C 5, 6 ); INSERT INTO Film
- Page 976:
Appendix C 468 5 ); INSERT INTO Att
- Page 980:
Appendix C Oracle 470 To save some
- Page 984:
Appendix C 472 LocationId, MeetingD
- Page 990:
Symbols + (addition operator), 82,
- Page 994:
BEGIN TRANSACTION statement, 306, 3
- Page 998:
SERIALIZABLE statement, 318 SET TRA
- Page 1002:
data types brackets, 25 categories,
- Page 1006:
Oracle concatenation, 85-88 configu
- Page 1010:
error messages debugging, 26 subque
- Page 1014:
concatenation, 85-88 data type comp
- Page 1018:
primary keys database creation exam
- Page 1022:
concurrent connection selection, 39
- Page 1026:
passwords group access, 333 IBM ins
- Page 1030:
ROLLBACK statement, 307-308 ROLLBAC
- Page 1034:
REPEATABLE READ, 319 REVOKE, 344-34
- Page 1038:
telephone numbers, data type select
- Page 1042:
historical, data selection, 90-94 N