praise for the first edition of the definitive guide to mysql978-1-4302-0669-9/1.pdf · praise for...

17
Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most exhaustive books on the subject and provides every- thingfor a new user as well as complete reference coverage for an experienced user, programmer, or administrator. The Definitive Guide to MySQL, Second Edition is highly recommended for anyone interested in learning, administering, or program- ming MySQL." -Harold McFarland, The Midwest Book Review (www.midwestbookreview.com) Praise for the first edition of The Definitive Guide to MySQL: "There are a number of books written on the subject ofMySQL databases. I have had the opportunity to read some and have found many of them lacking and confusing. I happened to get a glimpse of a book simply called MySQL, it seemed quite inter- esting and as I was about to build a dynamically driven website for a client I felt I should get this book as the others I have seen were not up to the job. As I suspected from my chancery glimpse, it was what I needed. "MySQL by Michael Kofler is a comprehensive guide to MySQL. The book explains . how to install and configure MySQL on both Linux/UNIX and also on MS Windows NTI200019x environments. Kofler presents some of the issues one should consider when using MySQL. The books guides you through SQL programming and MySQL administration." -M. Williams, Kemputing (http://kemputing.net) "Whatever the secret formula that goes into Apress books, the result produced is clear, thorough, useful, powerful books that are easy to read, grasp, and apply. The titles are focused on explodingly popular computer topics. MySQL by Michael Kofler lives up to the high Apress standard." -International News Agency (www.inewsagency.com)

Upload: others

Post on 06-Nov-2019

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most exhaustive books on the subject and provides every­thingfor a new user as well as complete reference coverage for an experienced user, programmer, or administrator. The Definitive Guide to MySQL, Second Edition is highly recommended for anyone interested in learning, administering, or program­ming MySQL."

-Harold McFarland, The Midwest Book Review (www.midwestbookreview.com)

Praise for the first edition of The Definitive Guide to MySQL: "There are a number of books written on the subject ofMySQL databases. I have had the opportunity to read some and have found many of them lacking and confusing. I happened to get a glimpse of a book simply called MySQL, it seemed quite inter­esting and as I was about to build a dynamically driven website for a client I felt I should get this book as the others I have seen were not up to the job. As I suspected from my chancery glimpse, it was what I needed.

"MySQL by Michael Kofler is a comprehensive guide to MySQL. The book explains . how to install and configure MySQL on both Linux/UNIX and also on MS Windows NTI200019x environments. Kofler presents some of the issues one should consider when using MySQL. The books guides you through SQL programming and MySQL administration."

-M. Williams, Kemputing (http://kemputing.net)

"Whatever the secret formula that goes into Apress books, the result produced is clear, thorough, useful, powerful books that are easy to read, grasp, and apply. The titles are focused on explodingly popular computer topics. MySQL by Michael Kofler lives up to the high Apress standard."

-International News Agency (www.inewsagency.com)

Page 2: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

The Definitive Guide to MySQl

Second Edition

MICHAEL KOFLER Translated by DAVID KRAMER

APress Media, LLC

Page 3: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

The Definitive Guide to MySQL, Second Edition Copyright ©2004 by Michael KoflerOriginally published by Apress in 2004

All rights reserved. No part of this work may be reproduced or transmitted in any fonn or by any means, elecuonic or mechanical, including photocopying. recording. or by any infonnation storage or retrieval system, without the prior written pennission of the copyright owner and the publisher.

ISBN 978-1-59059-144-4 ISBN 978-1-4302-0669-9 (eBook) DOI 10.1007/978-1-4302-0669-9

Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

Translator, Editor, and Compositor: David Kramer

Editorial Board: Steve Anglin, Dan Appleman, Craig Berry, Gary Cornell, Tony Davis, Jason Gilmore, Steven Rycroft, Julian Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wray, John Zukowski

Assistant Publisher: Grace Wong

Production Manager: Kart Brooks

Proofreader: Elizabeth Berry

Cover Designer: Kurt Krames

Manufacturing Manager: Tom Debolski

In the United States: phone 1-800-SPRINGER, email orders~pringer-ny.cOln, or visit http://_.springer-ny.com. Outside the United States: fax +49 6221 345229, email orderstlspringer. de, or visit http: //_.springer .de.

For infonnation on translations, please contact Apress directly at 2560 Ninth Street, SUite 219, BerkeJey, CA 94710. Phone 510-549-5930, fax 510-549-5939, email info{lapress ,COlI, or visit http: //_ ... press .COlLt

The infonnation in this book is distributed on an ~as is» basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the infonnation contained in this work.

Page 4: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Contents at a Glance

About the Author xi

About the Translator xii

Preface xiii

I Introduction 1

1 What Is MySQU 3

2 The Test Environment 21

3 Introductory Example (An Opinion Poll) 67

4 User Interfaces 85

II Fundamentals 83

5 Database Design 121

6 An Introduction to SQL 177

7 SQLRecipes 199

8 InnoDB Tables and Transactions 239

9 Security 261

10 Administration and Server Configuration 305

III Programming 373

11 PUP: Fundamentals and Programming Techniques 375

12 PUP: Library Management 413

13 PUP: Discussion Forum 467

14 Perl 495

15 Java, JSP' JDBC 523

16 CandC++ 555

17 Visual Basic, C#, ODBC 577

IV Reference 639

18 SQL Reference 641

19 MySQLToois 703

20 API Reference 733

V Appendices 759

A Glossary 761

B MySQL4.1 767

C Example Files 781

D Bibliography 783

Index 785

ill

Page 5: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Contents

About the Author

About the Translator

Preface What Does This Book Offer? . What Is New in the Second Edition? What Does This Book Not Offer? Example Programs, Source Code Versions .. Notation ... Commands Abbreviations

I Introduction

1 WhatIsMySQU What Is a Database? . MySQL ....... . Features of MySQL Limitations ofMySQL . MySQL Version Numbers MySQL Licensing . . . Alternatives to MySQL . Summary .......

2 The Test Environment Wmdows or Unix/Linux? MySQL (Server Installation) . MySQL (Client Installation) Apache ... .

PHP .... . phpMyAdmin

Perl ...... Connector/ODBC Editors ......

Using MySQL with an ISP

xi

xii

xiii xiii xiv xv xv

xvi xvii

xviii xviii

1

3 4 6 7 9

11 14 18 19

21 22 23 37 38 46 53 55 62 63 64

v

Page 6: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Contents

vi

3 Introductory Example (An Opinion Poll) Overview ....... . Database Development . . . . . . . . . . The Questionnaire. . . . . . . . . . . . . Questionnaire Evaluation and Displaying Results Ideas for Improvements . . . . . . . . . . . . . .

II Fundamentals

4 User Interfaces Overview ........... . mysql ............. . WinMySQLadmin (Windows) . MySQL Control Center (Windows, Linux) phpMyAdmin (HTML) ......... .

5 Database Design Introduction . . . Database Theory MySQL Data Types Indexes ..... . MySQL Table Types Creating Databases, Tables, and Indexes Example mylibrary (Library) ..... Example myforum (Discussion Group) Example exceptions (Special Cases) .

6 An Introduction to SQL Introduction . . . . . . . Simple Queries (SELECT) Queries with Related Tables . Uniting Query Results . . . . Grouped Queries, Aggregate Functions . Altering Data (INSERT, UPDATE, and DELETE)

7 SQL Recipes Character Strings ... . . . . . . . . Date and Time . . . . . . . . . . . . . Variables and Conditionals (IF, CASE) Copying Data from One Table to Another. Pivot Tables . . . . . . . . . . SubSELECTs . . . . . . . . . . Ensuring the Integrity of Data. Tracking Down Duplicates .. Bringing a Table into Normal Form . Processing the First or Last n Records Selecting Random Records Full-Text Search . . . . . . . . . . . .

67 68 69 75 76 80

83

85 86 87 93 97

101

121 122 123 137 146 151 155 158 170 174

177 178 179 184 188 189 191

199 200 204 207 210 212 216 219 224 225 227 229 231

Page 7: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

8 InnoDB Tables and 1ransactlons Introduction . . . . . . . . . . . . First Experiments with InnoDB Tables 'Ii'ansactions . . . . . . . . . . . . . . Integrity'Rules (Foreign Key Constraints) .

9 Security Introduction . FirstAid ... The Internal Workings of the Access System Tools for Setting Access Privileges. . . . . Problems with Establishing a Connection . System Security . . . . . . . . . . . . . . .

10 Administration and Server Configuration Basic Administration Backups .............. . Database Migration . . . . . . . . . Importing and Exporting Text Files . International Customization, Character Sets . Logging ............ . Replication ............ . Maintenance ofMyISAM Tables . Administration ofInnoDB Tables . Server 1\ming . . . . . . . . ISP Database Administration

III Programming

11 PHP: Fundamentals and Programming Techniques Introduction . . . . . . . . . . . . . . . . . . . . . Establishing a Connection to the Database . . . . Executing SQL Commands . . . . . . . . . . SELECT Queries . . . . . . . . . . . . . . . . . . Changes to Data (INSERT, UPDATE, DELETE) . . Character Strings, BWBs, DATEs, SETs, ENUMs,

andNULL. . . . . . .. . .... Error Checking ....... . Storing and Displaying Images

12 PHP: UbraryManagement Introduction . . . . . . . . . . . . . . . . . . . Auxiliary Functions (mylibraryconnect.inc.php) Book Search (jind.php) ..... . . . . . . . . Simple Input of New Books (simpleinput.php) . Convenient Input of New Book Data (input. php) . Managing the Book Categories (categories.php) Ideas for Improvements and Extensions . . . . .

. . . . . ...... 239 240 244 245 255

261 262 267 274 290 296 301

305 306 310 316 320 331 335 342 353 357 365 369

373

375 376 378 383 385 390

391 403 404

413 414 414 416 430 433 455 465

Contents

vii

Page 8: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Contents

viii

13 PUP: Discussion Forum How to Run It . . . . . . Overview of the Program Code Registration (forumlogin. php) . Defining a New User (forumnewlogin. php) Display list of All Discussion Groups (forumlist. php) Message List of a Discussion Group (forumread. php) . Representation of Message Text (forummessage. php) Displaying a Thread (forumthread. php) . . . . . . . Contributing to a Discussion (forumwri te • php) . Leaving the Forum (forumlogout. php) Possibilities for Extension . . . . . . . . . . . .

14 Perl Programming Techniques . . . . . . . . . . . . . . . Example: Deleting Invalid Data Records (mylibrary) . CGI Example: Library Management (mylibrary)

15 Java, JSP' JDBC Introduction . . . . . . . . Programming Techniques . Java Server Pages OSP) ..

16 C and C++ The C Application Programming Interface Connector/C++ (MySQL++) . . ....

17 Visual Basic, C#, ODBC Fundamentals . . . . . . Access .......... Data Analysis with Excel. ADO Programming and Visual Basic/VBA MyVbQL (Visual Basic Programming Without ADO/ODBC) . ADO.NET (Visual Basic .NET, C#) . . . . . . . . .

Converter: Microsoft SQL Server -t MySQL . . . . . . . . .

IV Reference

18 SQL Reference Syntax ......... . Operators ....... . Variables and Constants . MySQL Data Types ... Command Overview (Thematic) . Command Reference (Alphabetical) Function Reference . . . . . . . . . .

467 468 471 473 475 477 478 484 486 487 492 492

495 496 512 514

523 524 528 548

555 556 567

577 578 584 590 592 612 616 635

639

641 642 647 651 653 655 657 692

Page 9: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

19 MySQL Tools Overview ................................... . Common Options and Configuration Files . . . . . . . . . . . . . . . . . . mysqld(Server) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . mysqld_safe(Server Start) .......................... . mysql_ install_ db(New Installation of mysql Database) . . . . . . . . . . . mysql_ fix _privilegesCUpdating the mysql Database) . . . . . . . . . . . . mysql_ fix _ extension 5 (Renaming MylSAM Files) ............. . mysql(SQL Command Interpreter) ..................... . mysqladmin(Administration) . . . . . . . . . . . . . . . . . . . . . . . . . . mysqldump(Backup/Export) . . . . . . . . . . . . . . . . . . . . . . . . . . mysqlimport(Text Import, Bulk Import) . . . . . . . . . . . . . . . . . . . . mysqlshow(Displaying Information) . . . . . . . . . . . . . . . . . . . . . . mysqlbug(Sending Error Notification) . . . . . . . . . . . . . . . . . . . . . myisarrichk(Repairing MylSAM Files) .................... . myisampack(Compressing MyISAM Files) . . . . . . . . . . . . . . . . . . .

20 API Reference PHPAPI ......... . PerlDBI ......... . JDBC (Connector/J) . . . . . . CAPI ............... .

V Appendices

A Glossary

B MySQL4.1

C Example Files

D Bibliography

Index

Contents

703 704 705 711 718 719 719 720 720 723 724 727 728 728 729 731

733 734 738 745 752

759

761

767

781

783

785

ix

Page 10: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

About the Author

MICHAEL KOFLER EARNED HIS PH.D. in computer science at Graz Technical University. He has written a number of successful computer books on topics such as Visual Basic, Linux, Mathematica, and Maple. Kofler is also the author of Definitive Guide to Excel VBA, Second Edition, published by Apress.

xi

Page 11: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

xii

About the Translator

DAVID KRAMER EARNED HIS PH.D. in mathematics at the University of Maryland, and his MA. in music at Smith College. For many years he worked in academia, first as a professor of mathematics and computer science, and later as a director of academic computing. Over the past eight years he has edited hundreds of books in mathematics and the sciences, and has translated a number of books in a variety of fields, including Definitive Guide to Excel VBA, by Michael Kofler; Enterprise JavaBeans 2.1, by Stefan Denninger and Ingo Peters; and Cryptography in C and C++, by Michael Welschenbach, all published by Apress. Other translations include The Game's Afoot! Game Theory in Myth and Paradox, by Alexander Mehlmann; the children's musical Red Riding! Red Riding!, by Ernst Ekker with music by Sergei Dreznin; In Quest of Tomorrow's Medicines, by Jiirgen Drews; and the novel To Err Is Divine, by Agota Bozai, which will be published by Counterpoint Press in April 2004.

Page 12: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Preface

MYSQL IS THE MOST WIDELY used database system in the Open Source sector. There are many reasons why this is so:

• MySQL is fast.

• MySQL is stable.

• MySQL is easy to learn.

• MySQL runs on popular operating systems (Wmdows, Linux, Mac OS X, various flavors of Unix).

• MySQL applications can be created in a great variety of programming languages (such as C, C++, CD, Java, Perl, PHp, Python, VB, and VB.NET).

• MySQL is extensively documented on the Internet, and there are many books on the subject available.

• MySQL is available for many applications free of charge (GPL license).

• Since the licensing restrictions of GPL are unacceptable for many commercial applications, there are reasonably priced commercial licenses and optional support contracts.

MySQL is on the verge of repeating in the database market the success achieved by Linux in the operating system sector. In combination with PHP or Perl, MySQL is prOviding the database system for more and more web sites. (A favorite combination is Linux + Apache + MySQL + Perl or PHP. Such systems are called "LAMP systems" for short.) MySQL is not just for small web sites; it is used by large firms with huge amounts of data, such as Yahoo!, Slashdot, and Google.

What Does This Book Offer?

This book provides a complete application- and example-oriented introduction to the database sys~m MySQL. No previous knowledge, either of SQL or database design, is assumed.

The introductory Part I of the book begins with an extensive introduction on installation under Wmdows and Linux. We also consider the installation of components that are used in combination with MySQL (Apache, PHP, phpMyAdmin, Perl, Connector/MyODBC). Building on this, our first example will show the basic use of MySQL and PHP.

Part II, "Fundamentals," provides a large amount of background material on the use of various user interfaces, on the database language SQL, on the proper design of databases, on the use of InnoDB tables, on the access system ofMySQL, and on many other topics on administration (such as backups, logging, and replication).

xiii

Page 13: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Preface

xiv

In Part III, "Programming," we emphasize the language PHP: Three chapters cover basic techniques of programming and show how to construct two extensive examples (bookkeeping, a discussion forum). Most of the PHP examples can be tried out live on my web site. We deal with other programming languages, too, with chapters devoted to Perl, Java, C/C++, and VB/VB.NET/C#.

We end the main text with a reference section (Part IV) that provides an overview of the SQL commands of MySQL, the commands and options of the administrative tools, and the functions of important programming interfaces (PHP, Perl, C, Java).

Finally, there are several appendices, comprising (A) a glossary of terms, (B) breaking news on the forthcoming MySQL version 4.1, (C) information on the example files for this book (available at www.apress.com) , and (D) a bibliography with suggestions for further reading.

In combination with the example databases and programs, this book should provide a good foundation for the development of your own database applications. In this I wish you much fun and success.

What Is New in the Second Edition?

Michael Kofler, August 2003 <[email protected]>

http://www.kofler.cc/mysql

There is much that is new. This book has been completely revised, from the first page to the last. (It took as long to produce this second edition as to write the first edition from scratch!) The following list indicates the most important changes:

• MySQL: The book now covers MySQL 4.0 and to some extent MySQL 4.1. These changes appear throughout the entire book, from installation to the reference section to the appendixes.

• User interface: This book describes the new user interface MySQL Control Center and the latest version of phpMyAdmin.

• SQL recipes: There is a new chapter in the introduction on SQL that provides answers to frequently asked SQL questions: How can I process the first/last n data records? How can duplicate records be located? How are subSELECT

commands formed in MySQL 4.0 and 4.11 How can a full-text search be accomplished efficiently?

• InnoDB tables, transactions, rules for integrity: A new chapter is devoted to the InnoDB table format. InnoDB tables enable the execution of transactions with row level locking and the protection of the integrity of relations between tables (foreign key constraints).

• Security, access rights: Chapter 9 deals with all the innovations dealing with access rights (MySQL privileges). A new section gives a number of practical tips on solving problems with establishing connections.

• Administration: Everything related to administration is contained in a single clearly structured chapter. New sections deal with the administration of InnoDB tables and server tuning (including Query Cache).

Page 14: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

• PUP: All PHP examples have been reworked in PHP 4.3. The HTML code generated from the PHP examples is now largely XHMTL compatible. The PHP text has been divided over four chapters and is now more clearly structured. In Chapter 11, on techniques ofPHP programming, we now also deal with storing images (file uploadl download).

• Java: A new chapter describes programming of Java and JSP applications on the basis of JDBC and Connector IJDBC.

• C/C++: A new chapter discusses the development of C and C++ programs.

• VB6: A new example program demonstrates the use of BWBs.

• VB.NET, C#: A new section in Chapter 17 deals with the development of ADO.NET applications with the programming languages VB.NET and C#.

• Reference: The three reference chapters have been thoroughly brought up to date and expanded with new sections (C functions, JDBC classes).

• MySQL 4.1: Appendix B brings together all known changes in MySQL 4.1: improved character set support (including Unicode), the use of subSELECTs, the management of geometric and geographic data (GIS), the use of precompiled commands (prepared statements), etc.

What Does This Book Not Offer?

Several chapters in this book deal with the programming of MySQL applications in a variety of programming languages, such as PHp, Perl, C, C++, Java, and Visual Basic. These chapters assume that the reader is familiar with the specific programming language. (There is simply no room in this book to offer an introduction to a number of programming languages.) In other words, you will profit from, say, the PHP chapter in this book only if you are already familiar with the programming language PHP.

Example Programs, Source Code

To the extent that we are dealing with web applications, almost all of the applications in this book can be tried out directly on my website (www.kofler.cc) . The source code for all the examples is available at www.apress.comin the downloads section.

In the longer program listings in this book you will find at the beginning of the example a comment line that specifies the file name appearing in the example files on the web site, for example,

<!-- php-programming/simp1einput.php --)

To save space, sometimes only the most interesting passages in the program code are printed.

Preface

xv

Page 15: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Pre/ace

xvi

Versions

The functionality of MySQL and of the programs, programming languages, and libraries placed in its environment changes with every new version-which sometimes appear weekly. The following overview indicates which versions I have worked with (explanations of the various names will appear at appropriate places in the book):

• Apache: Versions 1.3.n and 2.0.n.

• Connector/J: Version 3.0.6.

• Connector/ODBC (fonnerlyMyODBC): Version 3.51.06.

• gee: Version 3.2

• Java: Version 1.4.1 (Wmdows) and 1.3.1 (Linux).

• JSP: see Tomcat.

• Unux: MySQL and other programs were tested for this book under Linux and Wmdows. Under Linux, the distributions Red Hat 8.0 and 9.0 (beta 3) and SuSE 8.1 and 8.2 (beta 5) were used.

• MySQL: Version 4.0.14. In most of the example programs, however, compatibil­itywith MySQL 3.23.n was taken into account, since this version is still in use by many Internet service providers. On the other hand, the latest developments of MySQL 4.1 were tested with a development version (alpha version, from end of July 2003), as described in Appendix B.

• Connector/C++: Version 1. 7.9.

• Perl: Versions 5.6 and 5.8.

• PUP: Versions 4.2 and 4.3. As file identifier, the suffix * . php is generally used.

• pbpMyAdmin: Version 2.4.

• Tomcat: Version 4.0.4 (Java Servlet 2.2, Java Server 1.1).

• Visual Basic, VBA, ADO: Visual Basic programs were developed and tested with VB6 and VBA6 and ADO versions 2.1 and 2.7.

• Visual Basic .NET, C#, ADO.NET, ASRNET: All of these are based on Visual Studio .NET 2002 (.NET Framework 1.0).

• Windows: All tests under Wmdows were carried out with Wmdows 2000. In principle, everything should be valid for Wmdows NT 4, Wmdows XP, and future versions ofWmdows.

Page 16: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Notation

• SQL commands and functions, as well as methods, classes, and key words in SQL, C, Java, PRp, Perl, VB, etc., generally appear in italic (e.g., SELECT, mysqLquery). (Note, however, that when the background text is italic, as in the gray "Remark," "Tip," "Caution," and "Pointer" boxes and some section headings, such commands and functions will appear in a roman font; e.g., SELECT.)

• Unix/Linux user names also appear in italic (e.g., root, mysql).

• MENU COMMANDS USE CAPS AND SMALL CAPS (e.g., FILE I OPEN).

• Keyboard shortcuts use a monospace font (e.g., Shi ft+Delete).

• File and directory names also use the monospace font (e.g., /usrllocal or (: \Windows).

• Programs and programming commands are in the monospace font as well (e.g., mysql or cmd. exe).

• MySQL options and configuration parameters appear in regular roman type (e.g., default-charset).

• Program listings and command line input appear in a sans serif font.

SQL commands are generally written in UPPERCASE letters. This is not a syntactic necessity, but merely a convention. MySQL does not distinguish between uppercase and lowercase in interpreting SQL commands.

In specifying Wmdows directories, we will often not write out the absolute path, since it depends in any case on the particular installation. We observe the following conventions:

• \Windows \ means the Wmdows directory (e.g., c: \Windows or D: \WinNT 4).

• Programs \ means the directory under Wmdows for program installation (e.g., (:\Programs orD:\Program Files).

• Mysql \ means the MySQL installation directory (e.g., (: \Mysql or D: \Program Files \Mysql).

Preface

xvii

Page 17: Praise for the first edition of The Definitive Guide to MySQL978-1-4302-0669-9/1.pdf · Praise for The Definitive Guide to MySQL, Second Edition: "In short, it is one of the most

Preface

xviii

Commands

Many commands will be presented in this book. We will be moving back and forth between the Unix/Linux and Wmdows conventions. The following two commands are equivalent:

root# mysqladmin -u root -h localhost password xxx

> mysqladmin -u root -h localhost password xxx

In each case we have given the system prompt (root# for Unix/Linux and > for Wmdows). You type in only what follows the prompt (here in boldface type). Under Unix/Linux it is possible to divide long inputs over several lines. The lines are separated by means of the backslash symbol \. We shall often use this convention in this book. The follOwing command thus corresponds to the command above:

root# mysqladmin -u root -h localhost \ password xxx

In each case, xxx is to be replaced by the relevant text (in this example by your password). We have indicated that xxx is dummy text by the use of a slant font.

Abbreviations

I have attempted in this book to make as little use of abbreviations as possible. However, there are several abbreviations that will be used repeatedly without being introduced anew in each chapter:

ADO BLOB GPL HTML InnoDB

ISP JSP MySQL ODBC

PHP

RPM SQL URL

VB VBA

Active Data Objects (Microsoft database library) Binary Large Object (binary data block) GNU Public License (important license for Open Source software) HyperText Markup Language (format for describing web documents) Not an abbreviation, but the name of a company that has developed a special table format for MySQL (InnoDB tables) Internet Service Provider Java Server Pages The name of the company that developed the database system MySQL Open Database Connectivity (interface for database access, particularly popular under Wmdows) PHP Hypertext Preprocessor (a scripting programming language for HTML pages) Red Hat Packet Manager (a format for Linux software packages) Structured Query Language (database programming language) Uniform Resource Locator (Internet address of the form http://www.company.com/page.html) Visual Basic (programming language) Visual Basic for Applications (programming language within the Microsoft Office package)