| Foreword |
|
xiii | |
| Preface |
|
xix | |
|
|
|
|
|
|
3 | (4) |
|
The Value of MySQL and MariaDB |
|
|
3 | (1) |
|
|
|
4 | (1) |
|
Other Books and Other Publications |
|
|
4 | (3) |
|
2 Installing MySQL and MariaDB |
|
|
7 | (22) |
|
The Installation Packages |
|
|
7 | (1) |
|
|
|
8 | (1) |
|
|
|
9 | (1) |
|
|
|
10 | (1) |
|
|
|
11 | (13) |
|
Linux Binary Distributions |
|
|
12 | (1) |
|
|
|
13 | (3) |
|
|
|
16 | (3) |
|
FreeBSD and Sun Solaris Distributions |
|
|
19 | (2) |
|
|
|
21 | (3) |
|
|
|
24 | (5) |
|
|
|
24 | (1) |
|
Setting Initial Password for root |
|
|
25 | (1) |
|
More on Passwords and Removing Anonymous Users |
|
|
25 | (1) |
|
|
|
26 | (3) |
|
3 The Basics and the mysql Client |
|
|
29 | (16) |
|
|
|
29 | (1) |
|
|
|
30 | (3) |
|
Starting to Explore Databases |
|
|
33 | (7) |
|
|
|
34 | (2) |
|
Inserting and Manipulating Data |
|
|
36 | (3) |
|
|
|
39 | (1) |
|
|
|
40 | (1) |
|
|
|
41 | (4) |
|
Part II Database Structures |
|
|
|
4 Creating Databases and Tables |
|
|
45 | (14) |
|
|
|
46 | (1) |
|
|
|
47 | (4) |
|
|
|
51 | (1) |
|
More Perspectives on Tables |
|
|
52 | (4) |
|
|
|
56 | (1) |
|
|
|
56 | (3) |
|
|
|
59 | (32) |
|
Prudence When Altering Tables |
|
|
59 | (2) |
|
|
|
61 | (10) |
|
|
|
68 | (3) |
|
|
|
71 | (9) |
|
Setting a Column's Default Value |
|
|
71 | (2) |
|
Setting the Value of AUTO_INCREMENT |
|
|
73 | (1) |
|
Another Method to Alter and Create a Table |
|
|
74 | (3) |
|
|
|
77 | (2) |
|
|
|
79 | (1) |
|
|
|
80 | (5) |
|
|
|
85 | (1) |
|
|
|
85 | (6) |
|
Part III Basics of Handling Data |
|
|
|
|
|
91 | (28) |
|
|
|
91 | (2) |
|
|
|
93 | (11) |
|
The Table for Bird Orders |
|
|
94 | (1) |
|
The Table for Bird Families |
|
|
95 | (6) |
|
|
|
101 | (3) |
|
|
|
104 | (10) |
|
|
|
104 | (1) |
|
Inserting Data from Another Table |
|
|
104 | (2) |
|
A Digression: Setting the Right ID |
|
|
106 | (4) |
|
|
|
110 | (2) |
|
Priorities When Inserting Data |
|
|
112 | (2) |
|
|
|
114 | (1) |
|
|
|
115 | (4) |
|
|
|
119 | (18) |
|
|
|
120 | (1) |
|
|
|
120 | (1) |
|
|
|
121 | (3) |
|
|
|
124 | (1) |
|
|
|
124 | (3) |
|
|
|
127 | (5) |
|
Counting and Grouping Results |
|
|
132 | (2) |
|
|
|
134 | (1) |
|
|
|
134 | (3) |
|
8 Updating and Deleting Data |
|
|
137 | (16) |
|
|
|
137 | (12) |
|
|
|
138 | (4) |
|
|
|
142 | (1) |
|
Ordering to Make a Difference |
|
|
143 | (1) |
|
|
|
144 | (2) |
|
|
|
146 | (3) |
|
|
|
149 | (2) |
|
Deleting in Multiple Tables |
|
|
150 | (1) |
|
|
|
151 | (1) |
|
|
|
151 | (2) |
|
9 Joining and Subquerying Data |
|
|
153 | (26) |
|
|
|
153 | (3) |
|
|
|
156 | (10) |
|
|
|
157 | (5) |
|
|
|
162 | (2) |
|
Deleting Within Joined Tables |
|
|
164 | (2) |
|
|
|
166 | (7) |
|
|
|
167 | (2) |
|
|
|
169 | (1) |
|
|
|
170 | (2) |
|
|
|
172 | (1) |
|
Performance Considerations with Subqueries |
|
|
173 | (1) |
|
|
|
173 | (1) |
|
|
|
174 | (5) |
|
Part IV Built-in Functions |
|
|
|
|
|
179 | (24) |
|
|
|
180 | (5) |
|
|
|
180 | (2) |
|
|
|
182 | (1) |
|
Trimming and Padding Strings |
|
|
183 | (2) |
|
|
|
185 | (3) |
|
Searching Strings and Using Lengths |
|
|
188 | (8) |
|
Locating Text Within a String |
|
|
188 | (3) |
|
|
|
191 | (1) |
|
Comparing and Searching Strings |
|
|
192 | (2) |
|
Replacing and Inserting into Strings |
|
|
194 | (2) |
|
|
|
196 | (3) |
|
|
|
199 | (1) |
|
|
|
200 | (1) |
|
|
|
200 | (3) |
|
11 Date and Time Functions |
|
|
203 | (26) |
|
|
|
203 | (2) |
|
|
|
205 | (3) |
|
Extracting Date and Time Components |
|
|
208 | (4) |
|
Formatting Dates and Time |
|
|
212 | (2) |
|
Adjusting to Standards and Time Zones |
|
|
214 | (3) |
|
Adding and Subtracting Dates and Time |
|
|
217 | (5) |
|
Comparing Dates and Times |
|
|
222 | (4) |
|
|
|
226 | (1) |
|
|
|
226 | (3) |
|
12 Aggregate and Numeric Functions |
|
|
229 | (24) |
|
|
|
229 | (12) |
|
|
|
230 | (5) |
|
Calculating a Group of Values |
|
|
235 | (5) |
|
|
|
240 | (1) |
|
|
|
241 | (6) |
|
|
|
241 | (3) |
|
|
|
244 | (1) |
|
|
|
245 | (1) |
|
Eliminating Negative Numbers |
|
|
245 | (2) |
|
|
|
247 | (1) |
|
|
|
247 | (6) |
|
Part V Administration and Beyond |
|
|
|
13 User Accounts and Privileges |
|
|
253 | (26) |
|
|
|
253 | (3) |
|
Restricting the Access of User Accounts |
|
|
256 | (9) |
|
|
|
256 | (2) |
|
|
|
258 | (2) |
|
Database Components and Privileges |
|
|
260 | (5) |
|
Administrative User Accounts |
|
|
265 | (4) |
|
User Account for Making Backups |
|
|
265 | (1) |
|
User Account for Restoring Backups |
|
|
266 | (1) |
|
User Account for Bulk Importing |
|
|
267 | (1) |
|
User Account to Grant Privileges |
|
|
268 | (1) |
|
|
|
269 | (1) |
|
|
|
270 | (2) |
|
Changing Passwords and Names |
|
|
272 | (2) |
|
Setting a User Account Password |
|
|
272 | (1) |
|
|
|
273 | (1) |
|
|
|
274 | (2) |
|
|
|
276 | (1) |
|
|
|
276 | (3) |
|
14 Backing Up and Restoring Databases |
|
|
279 | (36) |
|
|
|
279 | (13) |
|
|
|
280 | (2) |
|
|
|
282 | (6) |
|
Backing Up Specific Databases |
|
|
288 | (1) |
|
|
|
289 | (1) |
|
Backing Up Specific Tables |
|
|
290 | (2) |
|
|
|
292 | (15) |
|
|
|
292 | (1) |
|
|
|
293 | (5) |
|
Restoring Only Rows or Columns |
|
|
298 | (2) |
|
Recovering from a Binary Log |
|
|
300 | (7) |
|
Developing a Backup Policy |
|
|
307 | (5) |
|
|
|
312 | (1) |
|
|
|
312 | (3) |
|
|
|
315 | (22) |
|
|
|
315 | (3) |
|
|
|
318 | (6) |
|
|
|
319 | (1) |
|
Checking the Accuracy of the Import |
|
|
320 | (3) |
|
|
|
323 | (1) |
|
|
|
324 | (3) |
|
|
|
324 | (2) |
|
|
|
326 | (1) |
|
More Field and Line Definitions |
|
|
327 | (3) |
|
Starting, Terminating, and Escaping |
|
|
328 | (1) |
|
Replacing Data Versus Ignoring Errors |
|
|
329 | (1) |
|
Importing from Outside MySQL |
|
|
330 | (3) |
|
|
|
331 | (1) |
|
|
|
331 | (1) |
|
Importing Without FILE Privileges |
|
|
332 | (1) |
|
|
|
333 | (2) |
|
|
|
335 | (1) |
|
|
|
335 | (2) |
|
16 Application Programming Interfaces |
|
|
337 | (32) |
|
Creating API User Accounts |
|
|
338 | (1) |
|
|
|
338 | (4) |
|
|
|
339 | (1) |
|
|
|
340 | (1) |
|
Complete Minimal C API Program |
|
|
341 | (1) |
|
Compiling with C Includes |
|
|
342 | (1) |
|
|
|
342 | (6) |
|
|
|
343 | (1) |
|
|
|
343 | (1) |
|
|
|
343 | (3) |
|
A Full Example with Perl DBI |
|
|
346 | (2) |
|
|
|
348 | (1) |
|
|
|
348 | (5) |
|
Installing and Configuring |
|
|
349 | (1) |
|
|
|
349 | (1) |
|
|
|
350 | (3) |
|
|
|
353 | (1) |
|
|
|
353 | (4) |
|
|
|
353 | (1) |
|
|
|
353 | (1) |
|
|
|
354 | (1) |
|
|
|
355 | (2) |
|
|
|
357 | (1) |
|
|
|
357 | (7) |
|
Installing and Preparing MySQL/Ruby |
|
|
357 | (2) |
|
|
|
359 | (1) |
|
|
|
360 | (1) |
|
Sample MySQL/Ruby Program |
|
|
361 | (3) |
|
|
|
364 | (1) |
|
|
|
364 | (2) |
|
|
|
366 | (1) |
|
|
|
366 | (3) |
| Index |
|
369 | |