- 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 658:
SAVE TRANSACTION Select Update Begi
- Page 662:
Figure 11-5 Begin Transaction Delet
- Page 666:
In spite of all of these performanc
- Page 670:
Shared A shared lock essentially me
- Page 674:
of record locks, the DBMS may decid
- Page 678:
No updates, additions, or deletions
- Page 682:
International Board Manufacturer ha
- Page 686:
contention. You could wrap your new
- Page 690:
Summary Transactions ensure that us
- Page 696:
Chapter 12 328 SQL security is cent
- Page 700:
Chapter 12 Creating User IDs Figure
- Page 704:
Chapter 12 3. In the SQL window, ty
- Page 708:
Chapter 12 ❑ You can assign a dif
- Page 712:
Chapter 12 Privileges Privileges ar
- Page 716:
Chapter 12 338 You could then give
- Page 720:
Chapter 12 You might implement this
- Page 724:
Chapter 12 Another shortcut, using
- Page 728:
Chapter 12 As you can imagine, givi
- Page 732:
Chapter 12 The situation gets a lit
- Page 736:
Chapter 12 Summary Database securit
- Page 740:
Chapter 13 robust, fault-tolerant m
- Page 744:
Chapter 13 Gigahertz Networks or Co
- Page 748:
Chapter 13 Database Cache 354 In ad
- Page 752:
Chapter 13 Again, the shotgun appro
- Page 756:
Chapter 13 358 Figure 13-3 Leaf Ind
- Page 760:
Chapter 13 Try It Out Dropping Inde
- Page 764:
Chapter 13 64k Block 64k Block Figu
- Page 768:
Chapter 13 ❑ Inner joins look lik
- Page 774:
Chapter 1 Exercise 1 Solution A Exe
- Page 778:
Chapter 2 Exercise 1 Solution There
- Page 782:
Email, DateOfJoining ) VALUES ( 7,
- Page 786:
Chapter 3 Exercise 1 Solution First
- Page 790:
As well as joining the tables, you
- Page 794:
Figure A-2 Notice that Table1 is re
- Page 798:
Executing the query provides the fo
- Page 802:
Category COUNT(DVDPrice), SUM(DVDPr
- Page 806:
This is the final SQL and gives the
- Page 810:
The results from the query are as f
- Page 814:
Clearly this query hasn’t returne
- Page 818:
Chapter 12 Exercise 1 Solution EXEC
- Page 822:
B Setting Up and Using the Five Dat
- Page 826:
Next, you come to a screen that giv
- Page 830:
Leave the check box for “Configur
- Page 834:
For this book, the default option o
- Page 838:
Now click Next to continue. In the
- Page 842:
Click Finish, and congratulate your
- Page 846:
Figure B-22 Click Ignore to continu
- Page 850:
Figure B-26 Click the Add New Conne
- Page 854: Figure B-29 Click the triangle next
- Page 858: Installing and Using IBM DB2 A free
- Page 862: Figure B-34 The default option of T
- Page 866: Click Next to continue to the conta
- Page 870: The screen in Figure B-42 allows yo
- Page 874: Figure B-45 Figure B-46 Setting Up
- Page 878: Figure B-48 Setting Up and Using th
- Page 882: Figure B-50 You must reconnect to t
- Page 886: You can see that DB2 automatically
- Page 890: The box in the middle of the screen
- Page 894: If you select MyTable from the list
- Page 898: Installing and Using Microsoft SQL
- Page 902: Figure B-63 What you enter here is
- 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