mysql cookbook 2nd edition

990 1.9K 0
mysql  cookbook  2nd  edition

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info www.it-ebooks.info New to OSCON this year: OSCON Data The O’Reilly Open Source Convention Learn about open source technologies for gathering, storing, and analyzing data with practical techniques and tools you can immediately put to use at this rst-of-its-kind open source event. Register Now & Save 20% use discount code OS11DEBK July 25–27, 2011 Portland, OR oscon.com/data www.it-ebooks.info MySQL Cookbook www.it-ebooks.info www.it-ebooks.info SECOND EDITION MySQL Cookbook ™ Paul DuBois Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo www.it-ebooks.info www.it-ebooks.info MySQL Cookbook™, Second Edition by Paul DuBois Copyright © 2007, 2002 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/ institutional sales department: (800) 998-9938 or corporate@oreilly.com. Editors: Brian Jepson and Andy Oram Copy Editor: Mary Anne Weeks Mayo Production Editor: Adam Witwer Proofreader: Sada Preisch Indexer: Joe Wizda Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrators: Robert Romano and Jessamyn Read Printing History: October 2002: First Edition. November 2006: Second Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. MySQL Cookbook, the image of a green anole, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein. [C] www.it-ebooks.info www.it-ebooks.info Table of Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv 1. Using the mysql Client Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.0 Introduction 1 1.1 Setting Up a MySQL User Account 2 1.2 Creating a Database and a Sample Table 4 1.3 Starting and Stopping mysql 6 1.4 Specifying Connection Parameters Using Option Files 8 1.5 Protecting Option Files from Other Users 11 1.6 Mixing Command-Line and Option File Parameters 11 1.7 What to Do if mysql Cannot Be Found 12 1.8 Issuing SQL Statements 14 1.9 Canceling a Partially Entered Statement 15 1.10 Repeating and Editing SQL Statements 16 1.11 Using Auto-Completion for Database and Table Names 17 1.12 Telling mysql to Read Statements from a File 18 1.13 Telling mysql to Read Statements from Other Programs 21 1.14 Entering an SQL One-Liner 22 1.15 Using Copy and Paste as a mysql Input Source 23 1.16 Preventing Query Output from Scrolling off the Screen 23 1.17 Sending Query Output to a File or to a Program 25 1.18 Selecting Tabular or Tab-Delimited Query Output Format 26 1.19 Specifying Arbitrary Output Column Delimiters 27 1.20 Producing HTML or XML Output 29 1.21 Suppressing Column Headings in Query Output 31 1.22 Making Long Output Lines More Readable 31 1.23 Controlling mysql’s Verbosity Level 33 1.24 Logging Interactive mysql Sessions 33 1.25 Creating mysql Scripts from Previously Executed Statements 34 1.26 Using User-Defined Variables in SQL Statements 35 1.27 Numbering Query Output Lines 38 1.28 Using mysql as a Calculator 39 v www.it-ebooks.info [...]... the first edition library files and make a copy of each one: % % % % cp cp cp cp Cookbook. php Cookbook1 .php Cookbook_ Utils.php Cookbook_ Utils1.php Cookbook_ Webutils.php Cookbook_ Webutils1.php Cookbook_ Session.php Cookbook_ Session1.php 2 Find all PHP scripts that include the first edition library files, and change them to include the *1.php files instead For example, a script that includes Cookbook_ Utils.php... the code from scratch The book also can be useful for people who aren’t even using MySQL You might suppose that because this is a MySQL cookbook and not a PostgreSQL cookbook or an InterBase cookbook that it won’t apply to database systems other than MySQL To some extent that’s true, because some of the SQL constructs are MySQL- specific But many of the queries use standard SQL that is portable to many... specific only to Windows use the C:\> prompt: C:\> "C:\Program Files \MySQL\ MySQL Server 5.0\bin \mysql" SQL statements that are issued from within the mysql client program are shown with a mysql> prompt and terminated with a semicolon: mysql> SELECT * FROM my_table; For examples that show a query result as you would see it when using mysql, I sometimes truncate the output, using an ellipsis ( ) to indicate... MySQL for Apache Logging 812 819 822 826 831 835 837 20 Using MySQL- Based Web Session Management 845 20.0 20.1 20.2 20.3 20.4 Introduction Using MySQL- Based Sessions in Perl Applications Using MySQL- Based Storage in Ruby Applications Using MySQL- Based Storage with the PHP Session Manager Using MySQL for Session-Backing Store with Tomcat 845 849 854 858 869 A Obtaining MySQL. .. Note for First Edition Readers If you have the first edition of MySQL Cookbook, be warned that the PHP library files in the second edition have the same names as in the first edition, but are incompatible with them If you are using any PHP scripts that depend on the first edition library files, they will break if you install the second edition library files on top of them To prevent this from happening,... receiving the statement results from it One such client is the mysql program that is included in MySQL distributions When used interactively, mysql prompts you for a statement, sends it to the MySQL server for execution, and then displays the results This capability makes mysql useful in its own right, but it’s also a valuable tool to help you with your MySQL programming activities It’s often convenient to... in this book took place under MySQL 5.0 and 5.1 Because new features are added to MySQL on a regular basis, some examples will not work under older versions For example, MySQL 5.0 introduces views, triggers, and stored procedures and functions, and the INFORMATION_SCHEMA metadata database MySQL 5.1 introduces events On occasion, I point out workarounds that you can use in MySQL 4.1 to compensate for... Perl DBI 1.52, DBD: :mysql 3.0, Ruby DBI 0.1.1, PEAR DB 1.7.6, MySQLdb 1.2.0, and MySQL Connector/J 3.1 Perl DBI requires Perl 5.6 or higher, although it’s slated to require Perl 5.8 or higher beginning with DBI 1.51 Ruby DBI requires Ruby 1.8.0 or higher Most PHP scripts shown here will run under either PHP 4.1 or PHP 5 (I recommend PHP 5) MySQLdb requires Python 2.3.4 or higher MySQL Connector/J requires... languages used here MySQL APIs Used in This Book MySQL programming interfaces exist for many languages, including C, C++, Eiffel, Java, Pascal, Perl, PHP, Python, Ruby, Smalltalk, and Tcl Given this fact, writing a MySQL cookbook presents an author with something of a challenge Clearly, the book Preface | xxi should provide recipes for doing many interesting and useful things with MySQL, but which API... xiii Preface The MySQL database management system has gained a large following in recent years This has been true especially in the Linux and open source communities, but MySQL has an increasing foothold in the commercial sector as well MySQL is well liked for several reasons: it’s fast, and it’s easy to set up, use, and administer MySQL runs under many varieties of Unix and Windows, and MySQL- based programs . 25–27, 2011 Portland, OR oscon.com/data www.it-ebooks.info MySQL Cookbook ™ www.it-ebooks.info www.it-ebooks.info SECOND EDITION MySQL Cookbook ™ Paul DuBois Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo www.it-ebooks.info www.it-ebooks.info MySQL. History: October 2002: First Edition. November 2006: Second Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. MySQL Cookbook, the. Using MySQL- Based Storage in Ruby Applications 854 20.3 Using MySQL- Based Storage with the PHP Session Manager 858 20.4 Using MySQL for Session-Backing Store with Tomcat 869 A. Obtaining MySQL

Ngày đăng: 05/05/2014, 15:21

Từ khóa liên quan

Mục lục

  • MySQL Cookbook

  • MySQL Cookbook

  • Table of Contents

  • Preface

    • Who This Book Is For

    • What’s in This Book

    • MySQL APIs Used in This Book

    • Conventions Used in This Book

    • The MySQL Cookbook Companion Web Site

    • Version and Platform Notes

    • Upgrade Note for First Edition Readers

    • Additional Resources

    • Using Code Examples

    • Safari® Enabled

    • How to Contact Us

    • Acknowledgments

      • Second Edition

      • First Edition

      • Chapter 1. Using the mysql Client Program

        • 1.0  Introduction

        • 1.1  Setting Up a MySQL User Account

          • Problem

          • Solution

          • Discussion

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan