Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 1.068 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
1.068
Dung lượng
4 MB
Nội dung
MySQL Cookbook By Paul DuBois Publisher : O'Reilly Pub Date : October 2002 ISBN : 0-596-00145-2 Pages : 1022 MySQL Cookbook provides a unique problem-and-solution format that offers practical examples for everyday programming dilemmas For every problem addressed in the book, there's a worked-out solution or "recipe" short, focused pieces of code that you can insert directly into your applications More than a collection of cut-and-paste code, this book explanation how and why the code works, so you can learn to adapt the techniques to similar situations Copyright Preface MySQL APIs Used in This Book Who This Book Is For What's in This Book Platform Notes Conventions Used in This Book The Companion Web Site Comments and Questions Additional Resources Acknowledgments Chapter Using the mysql Client Program Section 1.1 Introduction Section 1.2 Setting Up a MySQL User Account Section 1.3 Creating a Database and a Sample Table Section 1.4 Starting and Terminating mysql Section 1.5 Specifying Connection Parameters by Using Option Files Section 1.6 Protecting Option Files Section 1.7 Mixing Command-Line and Option File Parameters Section 1.8 What to Do if mysql Cannot Be Found Section 1.9 Setting Environment Variables Section 1.10 Issuing Queries Section 1.11 Selecting a Database Section 1.12 Canceling a Partially Entered Query Section 1.13 Repeating and Editing Queries Section 1.14 Using Auto-Completion for Database and Table Names Section 1.15 Using SQL Variables in Queries Section 1.16 Telling mysql to Read Queries from a File Section 1.17 Telling mysql to Read Queries from Other Programs Section 1.18 Specifying Queries on the Command Line Section 1.19 Using Copy and Paste as a mysql Input Source Section 1.20 Preventing Query Output from Scrolling off the Screen Section 1.21 Sending Query Output to a File or to a Program Section 1.22 Selecting Tabular or Tab-Delimited Query Output Format Section 1.23 Specifying Arbitrary Output Column Delimiters Section 1.24 Producing HTML Output Section 1.25 Producing XML Output Section 1.26 Suppressing Column Headings in Query Output Section 1.27 Numbering Query Output Lines Section 1.28 Making Long Output Lines More Readable Section 1.29 Controlling mysql's Verbosity Level Section 1.30 Logging Interactive mysql Sessions Section 1.31 Creating mysql Scripts from Previously Executed Queries Section 1.32 Using mysql as a Calculator Section 1.33 Using mysql in Shell Scripts Chapter Writing MySQL-Based Programs Section 2.1 Introduction Section 2.2 Connecting to the MySQL Server, Selecting a Database, and Disconnecting Section 2.3 Checking for Errors Section 2.4 Writing Library Files Section 2.5 Issuing Queries and Retrieving Results Section 2.6 Moving Around Within a Result Set Section 2.7 Using Prepared Statements and Placeholders in Queries Section 2.8 Including Special Characters and NULL Values in Queries Section 2.9 Handling NULL Values in Result Sets Section 2.10 Writing an Object-Oriented MySQL Interface for PHP Section 2.11 Ways of Obtaining Connection Parameters Section 2.12 Conclusion and Words of Advice Chapter Record Selection Techniques Section 3.1 Introduction Section 3.2 Specifying Which Columns to Display Section 3.3 Avoiding Output Column Order Problems When Writing Programs Section 3.4 Giving Names to Output Columns Section 3.5 Using Column Aliases to Make Programs Easier to Write Section 3.6 Combining Columns to Construct Composite Values Section 3.7 Specifying Which Rows to Select Section 3.8 WHERE Clauses and Column Aliases Section 3.9 Displaying Comparisons to Find Out How Something Works Section 3.10 Reversing or Negating Query Conditions Section 3.11 Removing Duplicate Rows Section 3.12 Working with NULL Values Section 3.13 Negating a Condition on a Column That Contains NULL Values Section 3.14 Writing Comparisons Involving NULL in Programs Section 3.15 Mapping NULL Values to Other Values for Display Section 3.16 Sorting a Result Set Section 3.17 Selecting Records from the Beginning or End of a Result Set Section 3.18 Pulling a Section from the Middle of a Result Set Section 3.19 Choosing Appropriate LIMIT Values Section 3.20 Calculating LIMIT Values from Expressions Section 3.21 What to Do When LIMIT Requires the "Wrong" Sort Order Section 3.22 Selecting a Result Set into an Existing Table Section 3.23 Creating a Destination Table on the Fly from a Result Set Section 3.24 Moving Records Between Tables Safely Section 3.25 Creating Temporary Tables Section 3.26 Cloning a Table Exactly Section 3.27 Generating Unique Table Names Chapter Working with Strings Section 4.1 Introduction Section 4.2 Writing Strings That Include Quotes or Special Characters Section 4.3 Preserving Trailing Spaces in String Columns Section 4.4 Testing String Equality or Relative Ordering Section 4.5 Decomposing or Combining Strings Section 4.6 Checking Whether a String Contains a Substring Section 4.7 Pattern Matching with SQL Patterns Section 4.8 Pattern Matching with Regular Expressions Section 4.9 Matching Pattern Metacharacters Literally Section 4.10 Controlling Case Sensitivity in String Comparisons Section 4.11 Controlling Case Sensitivity in Pattern Matching Section 4.12 Using FULLTEXT Searches Section 4.13 Using a FULLTEXT Search with Short Words Section 4.14 Requiring or Excluding FULLTEXT Search Words Section 4.15 Performing Phrase Searches with a FULLTEXT Index Chapter Working with Dates and Times Section 5.1 Introduction Section 5.2 Changing MySQL's Date Format Section 5.3 Telling MySQL How to Display Dates or Times Section 5.4 Determining the Current Date or Time Section 5.5 Decomposing Dates and Times Using Formatting Functions Section 5.6 Decomposing Dates or Times Using Component-Extraction Functions Section 5.7 Decomposing Dates or Times Using String Functions Section 5.8 Synthesizing Dates or Times Using Formatting Functions Section 5.9 Synthesizing Dates or Times Using Component-Extraction Functions Section 5.10 Combining a Date and a Time into a Date-and-Time Value Section 5.11 Converting Between Times and Seconds Section 5.12 Converting Between Dates and Days Section 5.13 Converting Between Date-and-Time Values and Seconds Section 5.14 Adding a Temporal Interval to a Time Section 5.15 Calculating Intervals Between Times Section 5.16 Breaking Down Time Intervals into Components Section 5.17 Adding a Temporal Interval to a Date Section 5.18 Calculating Intervals Between Dates Section 5.19 Canonizing Not-Quite-ISO Date Strings Section 5.20 Calculating Ages Section 5.21 Shifting Dates by a Known Amount Section 5.22 Finding First and Last Days of Months Section 5.23 Finding the Length of a Month Section 5.24 Calculating One Date from Another by Substring Replacement Section 5.25 Finding the Day of the Week for a Date Section 5.26 Finding Dates for Days of the Current Week Section 5.27 Finding Dates for Weekdays of Other Weeks Section 5.28 Performing Leap Year Calculations Section 5.29 Treating Dates or Times as Numbers Section 5.30 Forcing MySQL to Treat Strings as Temporal Values Section 5.31 Selecting Records Based on Their Temporal Characteristics Section 5.32 Using TIMESTAMP Values Section 5.33 Recording a Row's Last Modification Time Section 5.34 Recording a Row's Creation Time Section 5.35 Performing Calculations with TIMESTAMP Values Section 5.36 Displaying TIMESTAMP Values in Readable Form Chapter Sorting Query Results Section 6.1 Introduction Section 6.2 Using ORDER BY to Sort Query Results Section 6.3 Sorting Subsets of a Table Section 6.4 Sorting Expression Results Section 6.5 Displaying One Set of Values While Sorting by Another Section 6.6 Sorting and NULL Values Section 6.7 Controlling Case Sensitivity of String Sorts Section 6.8 Date-Based Sorting Section 6.9 Sorting by Calendar Day Section 6.10 Sorting by Day of Week Section 6.11 Sorting by Time of Day Section 6.12 Sorting Using Substrings of Column Values Section 6.13 Sorting by Fixed-Length Substrings Section 6.14 Sorting by Variable-Length Substrings Section 6.15 Sorting Hostnames in Domain Order Section 6.16 Sorting Dotted-Quad IP Values in Numeric Order Section 6.17 Floating Specific Values to the Head or Tail of the Sort Order Section 6.18 Sorting in User-Defined Orders Section 6.19 Sorting ENUM Values Chapter Generating Summaries Section 7.1 Introduction Section 7.2 Summarizing with COUNT( ) Section 7.3 Summarizing with MIN( ) and MAX( ) Section 7.4 Summarizing with SUM( ) and AVG( ) Section 7.5 Using DISTINCT to Eliminate Duplicates Section 7.6 Finding Values Associated with Minimum and Maximum Values Section 7.7 Controlling String Case Sensitivity for MIN( ) and MAX( ) Section 7.8 Dividing a Summary into Subgroups Section 7.9 Summaries and NULL Values Section 7.10 Selecting Only Groups with Certain Characteristics Section 7.11 Determining Whether Values are Unique Section 7.12 Grouping by Expression Results Section 7.13 Categorizing Non-Categorical Data Section 7.14 Controlling Summary Display Order Section 7.15 Finding Smallest or Largest Summary Values Section 7.16 Date-Based Summaries Section 7.17 Working with Per-Group and Overall Summary Values Simultaneously Section 7.18 Generating a Report That Includes a Summary and a List Chapter Modifying Tables with ALTER TABLE Section 8.1 Introduction Section 8.2 Dropping, Adding, or Repositioning a Column Section 8.3 Changing a Column Definition or Name Section 8.4 The Effect of ALTER TABLE on Null and Default Value Attributes Section 8.5 Changing a Column's Default Value Section 8.6 Changing a Table Type Section 8.7 Renaming a Table Section 8.8 Adding or Dropping Indexes Section 8.9 Eliminating Duplicates by Adding an Index Section 8.10 Using ALTER TABLE to Normalize a Table Chapter Obtaining and Using Metadata Section 9.1 Introduction Section 9.2 Obtaining the Number of Rows Affected by a Query Section 9.3 Obtaining Result Set Metadata Section 9.4 Determining Presence or Absence of a Result Set Section 9.5 Formatting Query Results for Display Section 9.6 Getting Table Structure Information Section 9.7 Getting ENUM and SET Column Information Section 9.8 Database-Independent Methods of Obtaining Table Information Section 9.9 Applying Table Structure Information Section 9.10 Listing Tables and Databases Section 9.11 Testing Whether a Table Exists Section 9.12 Testing Whether a Database Exists Section 9.13 Getting Server Metadata Section 9.14 Writing Applications That Adapt to the MySQL Server Version Section 9.15 Determining the Current Database Section 9.16 Determining the Current MySQL User Section 9.17 Monitoring the MySQL Server Section 9.18 Determining Which Table Types the Server Supports Chapter 10 Importing and Exporting Data Section 10.1 Introduction Section 10.2 Importing Data with LOAD DATA and mysqlimport Section 10.3 Specifying the Datafile Location Section 10.4 Specifying the Datafile Format Section 10.5 Dealing with Quotes and Special Characters Section 10.6 Importing CSV Files Section 10.7 Reading Files from Different Operating Systems Section 10.8 Handling Duplicate Index Values Section 10.9 Getting LOAD DATA to Cough Up More Information Section 10.10 Don't Assume LOAD DATA Knows More than It Does Section 10.11 Skipping Datafile Lines Section 10.12 Specifying Input Column Order Section 10.13 Skipping Datafile Columns Section 10.14 Exporting Query Results from MySQL Section 10.15 Exporting Tables as Raw Data Section 10.16 Exporting Table Contents or Definitions in SQL Format Section 10.17 Copying Tables or Databases to Another Server Section 10.18 Writing Your Own Export Programs Section 10.19 Converting Datafiles from One Format to Another Section 10.20 Extracting and Rearranging Datafile Columns Section 10.21 Validating and Transforming Data Section 10.22 Validation by Direct Comparison Section 10.23 Validation by Pattern Matching Section 10.24 Using Patterns to Match Broad Content Types Section 10.25 Using Patterns to Match Numeric Values Section 10.26 Using Patterns to Match Dates or Times Section 10.27 Using Patterns to Match Email Addresses and URLs Section 10.28 Validation Using Table Metadata Section 10.29 Validation Using a Lookup Table Section 10.30 Converting Two-Digit Year Values to Four-Digit Form Section 10.31 Performing Validity Checking on Date or Time Subparts Section 10.32 Writing Date-Processing Utilities Section 10.33 Using Dates with Missing Components Section 10.34 Performing Date Conversion Using SQL Section 10.35 Using Temporary Tables for Data Transformation Section 10.36 Dealing with NULL Values Section 10.37 Guessing Table Structure from a Datafile Section 10.38 A LOAD DATA Diagnostic Utility Section 10.39 Exchanging Data Between MySQL and Microsoft Access Section 10.40 Exchanging Data Between MySQL and Microsoft Excel Section 10.41 Exchanging Data Between MySQL and FileMaker Pro Section 10.42 Exporting Query Results as XML Section 10.43 Importing XML into MySQL Section 10.44 Epilog Chapter 11 Generating and Using Sequences Section 11.1 Introduction Section 11.2 Using AUTO_INCREMENT To Set Up a Sequence Column Section 11.3 Generating Sequence Values Section 11.4 Choosing the Type for a Sequence Column Section 11.5 The Effect of Record Deletions on Sequence Generation Section 11.6 Retrieving Sequence Values Section 11.7 Determining Whether to Resequence a Column Section 11.8 Extending the Range of a Sequence Column Section 11.9 Renumbering an Existing Sequence Section 11.10 Reusing Values at the Top of a Sequence Section 11.11 Ensuring That Rows Are Renumbered in a Particular Order Section 11.12 Starting a Sequence at a Particular Value Section 11.13 Sequencing an Unsequenced Table Section 11.14 Using an AUTO_INCREMENT Column to Create Multiple Sequences Section 11.15 Managing Multiple SimultaneousAUTO_INCREMENT Values Section 11.16 Using AUTO_INCREMENT Valuesto Relate Tables Section 11.17 Using Single-Row Sequence Generators Section 11.18 Generating Repeating Sequences Section 11.19 Numbering Query Output Rows Sequentially Chapter 12 Using Multiple Tables Section 12.1 Introduction Section 12.2 Combining Rows in One Table with Rows in Another Section 12.3 Performing a Join Between Tables in Different Databases Section 12.4 Referring to Join Output Column Names in Programs Section 12.5 Finding Rows in One Table That Match Rows in Another Section 12.6 Finding Rows with No Match in Another Table Section 12.7 Finding Rows Containing Per-Group Minimum or Maximum Values Section 12.8 Computing Team Standings Section 12.9 Producing Master-Detail Lists and Summaries Section 12.10 Using a Join to Fill in Holes in a List Section 12.11 Enumerating a Many-to-Many Relationship Section 12.12 Comparing a Table to Itself Section 12.13 Calculating Differences Between Successive Rows Section 12.14 Finding Cumulative Sums and Running Averages Section 12.15 Using a Join to Control Query Output Order Section 12.16 Converting Subselects to Join Operations Section 12.17 Selecting Records in Parallel from Multiple Tables Section 12.18 Inserting Records in One Table That Include Values from Another Section 12.19 Updating One Table Based on Values in Another Section 12.20 Using a Join to Create a Lookup Table from Descriptive Labels Section 12.21 Deleting Related Rows in Multiple Tables Section 12.22 Identifying and Removing Unattached Records Section 12.23 Using Different MySQL Servers Simultaneously Chapter 13 Statistical Techniques Section 13.1 Introduction Section 13.2 Calculating Descriptive Statistics Section 13.3 Per-Group Descriptive Statistics Section 13.4 Generating Frequency Distributions Section 13.5 Counting Missing Values Section 13.6 Calculating Linear Regressions or Correlation Coefficients Section 13.7 Generating Random Numbers Section 13.8 Randomizing a Set of Rows Section 13.9 Selecting Random Items from a Set of Rows Section 13.10 Assigning Ranks Chapter 14 Handling Duplicates Section 14.1 Introduction Section 14.2 Preventing Duplicates from Occurring in a Table Section 14.3 Dealing with Duplicates at Record-Creation Time Section 14.4 Counting and Identifying Duplicates Section 14.5 Eliminating Duplicates from a Query Result Section 14.6 Eliminating Duplicates from a Self-Join Result Section 14.7 Eliminating Duplicates from a Table Chapter 15 Performing Transactions Section 15.1 Introduction Section 15.2 Verifying Transaction Support Requirements Section 15.3 Performing Transactions Using SQL Section 15.4 Performing Transactions from Within Programs Section 15.5 Using Transactions in Perl Programs Section 15.6 Using Transactions in PHP Programs Section 15.7 Using Transactions in Python Programs Section 15.8 Using Transactions in Java Programs Section 15.9 Using Alternatives to Transactions Chapter 16 Introduction to MySQL on the Web Section 16.1 Introduction referential integrity and foreign keys Regexp class library REGEXP operator register_globals directive (PHP) register_globals setting (PHP) regression line regular expressions POSIX character class support SQL pattern matching, compared to wildcards REHASH related table updates deleting unrelated records using programs using mysql via table replacement using joins using LEFT JOINs related tables unattached records, finding and removing related-table updates lookup tables, creating with relative frequency distributions relative pathnames RENAME TABLE statement repetition, measuring in a set of values REPLACE query rows, finding the number affected REPLACE statement duplicates, preventing with for serving image files on web pages require and require_once statement, PHP resequencing 2nd [See also sequences]3rd [See also AUTO_INCREMENT columns] of AUTO_INCREMENT columns advisability ordering, control of result sets iteration through movement within presence or absence, determining rewinding results sorting [See sorting operations] ResultSetMetaData object (Java) retrieving from reusing code rewinding result sets RIGHT JOINs RIGHT( ) ROLLBACK statement rotating tables rowcount attribute (Python) rows [See also records] combining rows from two tables [See joins] deleting related rows in multiple tables by replacing tables cascaded deletes mysql, using programmatic deletion duplicates [See duplicate records] ID values, joining to descriptive information in another table inserting records in a table that include values from another matching in separate tables per group minimum or maximum values, finding random selection from a set randomizing selecting in parallel from multiple tables unattached records, finding and removing rpm (RedHat Package Manager) running averages, calculation using self-joins S -s option ( silent) script program ScriptAlias directive 2nd scrolling lists multiple pick scrolling_list( ) (Perl) SDK (Java Software Development Kit) Tomcat servers and search interfaces, implementing search_state.pl SEC_TO_TIME( ) 2nd 3rd 4th SECOND( ) 2nd seconds values, conversion to date-and-time to time security encapsulation, advantages of library files and option files scripts in the document tree, risks sed delimiters, selection using SELECT statement columns, displaying with column name aliases SELECT DATABASE( ) SELECT DISTINCT statement SELECT É INTO OUTFILE statement FILE privilege, requirement for SELECT statement 2nd calculations, using for columns, displaying output order, control ling eliminating duplicate rows identifying unattached records for deletion Perl placeholders for selection criteria, testing uses for WHERE clauses aliases and input columns finding NULL values negation operators NULLs, query conditions that miss SELECT USER( ) SELECT VERSION( ) customizing applications and SELECT WHERE query metadata, getting with portability across DBMSs selectall_arrayref( ) (Perl) for obtaining metadata placeholders, using with selectall_hashref( ) (Perl) for obtaining metadata selectcol_arrayref( ) (Perl) selectrow_array( ) (Perl) placeholders, using with selectrow_arrayref( ) (Perl) selectrow_hashref( ) (Perl) self-joins aliases and cumulative sums, finding duplicates, eliminating from excluding the reference value from results LEFT JOIN self-joins without reference values running averages, finding successive rows, calculating differences between seqence columns, need for table aliases and types of questions requiring semicolon (;) 2nd sequences event counts, using for extending sequence range generating lack of portability multiple sequences in one table, creating record deletions, impact on repeating sequences (cycles), generating resequencing, advisability retrieving values for reusing values at the top server-side retrieval compared to client-side methods starting value, setting using as counters server-side storage servers [See also mysqld]2nd databases on, listing metadata, getting Java, using raw protocol table types, determining support for user accounts, creating servers (MySQL) monitoring impact of monitoring sess_track.jsp sess_track.php sess_track.pl session hash element names session identifiers session IDs session management client-side vs server-side storage security aspects common tasks Perl, using server-side, database-backed session-based scripts session_set_save_handler( ) (PHP) 2nd sessions logging terminating SET calculations, using for SET column type renaming, column definition issues SET columns column definitions, adding comparing in self-joins definitions, obtaining hashes, for testing legality of data input values, validating 2nd member lists, obtaining SET values stings, treatment as sh PATH environment variable, setting shell scripting shell scripts Unix, writing in Windows, writing in shell scripts, invocation of mysql in SHOW COLUMNS queries ENUM columns, validation of input with query results SET columns, validation of input with query results SHOW COLUMNS statement default values displayed, interpreting ENUM column information, using to get SET column information, using to get table structure information, getting APIs, using table structure information, getting with SHOW CREATE TABLE statement 2nd 3rd checking available table types using table structure information, getting with SHOW DATABASES query complete listing of databases, obtaining with interpreting SHOW DATABASES statement testing for existence of a database, using for SHOW INDEX statement SHOW STATUS statement MySQL servers, monitoring using SHOW TABLE STATUS statement 2nd SHOW TABLES queries interpreting SHOW TABLES query complete listing of tables, obtaining with SHOW TABLES statement Java, issuing programatically using SHOW VARIABLES statement determining a serverÕs supported table types MySQL servers, monitoring using signed integers, pattern for matching silent option SimpleServlet class single page navigation indexes, generating from database content single strings, representing as single-pick form elements creating from database content types single-pick list elements functions and arguments functions, constructing for value lists and label hashes single-row sequence generators item tracking using skip-column-names (MySQL 3.22.20) | (program indicator, Apache) somedata.csv problem solution sorting aliasing of expressions APIs, using ascending order by calendar day column aliases, using columns, positional references for on dates or times by day of week mapping first day from Sunday to Monday DAYOFYEAR( ), problems using default sort direction descending order 2nd displaying as strings values sorted as numbers expression results, using lexical vs numerical order MIN( ), MAX( ), and case sensitivity multiple column sorts mixed-order sorting NULL values and of result sets on single-columns string sorts and case sensitivity on table subsets by time of day on unselected values sorting operations SOURCE 2nd source loops special characters database, table, and column names encoding in web output APIs, using encoding interactions HTML special characters URL special characters in strings including in queries Spreadsheet::ParseExcel::Simple module Spreadsheet::WriteExcel::FromDB module Spreadsheet::WriteExcel::Simple module SQL date conversion using pattern matching vs FULLTEXT searching NULL values and regular expressions, contrasted with reformatting of data in temporary tables statements variables calculation results, storing in non MySQL database engines, and for numbering query output lines sql_quote( ) (PHP MySQL_Access class) ssh, using for dumps between servers standard deviation calculation using aggregate functions uses start_form( ) (Perl) start_multipart_form( ) (Perl) startup files state_pager1.pl 2nd state_pager2.pl statement recall utility Windows systems statement terminator, mysql statement terminators APIs and statements types of 2nd statistical techniques aggregate functions in the calculation of statistical data calculating descriptive statistics correlation coefficients, calculating counting missing values (NULLs) frequency distributions, generating uses for linear regressions, calculating median, calculating mode, calculating per-group descriptive statistics, calculating random number generation randomizing a set of rows assigning ranks selecting randomly from a set of rows STATUS STATUS command STD( ) STDDEV( ) store_image.pl 2nd image storage configuration for database or filesystem STRCMP( ) string functions extraction of date and time values using string( ) (Perl) strings calculating one date from another using substring replacement case sensitivity MIN( ) and MAX( ) case sensitivity in comparisons, controlling case sensitivity, managing in comparisons combining in larger strings equality, testing for forcing interpretation as temporal values numbers, conversion to pattern matching [See pattern matching] relative ordering string types substrings, extraction substrings, matching to trailing spaces, preserving strip_slash_helper( ) (PHP) subselect queries converting to join operations SUBSTRING( ) SUBSTRING_INDEX( ) SUBSTRING_INDEX( ), for breaking apart strings at delimiters substrings, extraction from strings suEXEC mechanism SUM( ) strings, inapplicability to summaries averages calculations, using APIs for computed summaries COUNT( ) counting summaries date-based distinct values, categorizing determining whether values are unique display order, controlling getting distinct values without DISTINCT duplicates, detecting with 2nd duplicates, eliminating from expression results, grouping by finding smallest or largest values multiple sets of values, handling finding values associated with minimum and maximum values using joins MAX-CONCAT trick two-query approach grouping data by ranges HAVING clauses COUNT( ), using with joins, producing with LEFT JOINs and reference tables, creating with LIMIT clauses and master-detail summaries, producing MIN( ) and MAX( ) missing values, incorporating on non-categorical data NULL values and of per-group and overall summary values ranges, defining repetition, measuring in value sets reports, generating selection, groups with certain characteristics subgroups, dividing into sums techniques time-based distinct values, categorizing types of using temporary tables and joins sys.argv (Python) sys.path variable T Tab key, autocompletion using tab-delimited file format tab-delimited, linefeed-terminated format table option table types evaluating tables for type tables adding indexes aliasing of names ALTER TABLE [See ALTER TABLE statement] AUTO_INCREMENT columns, dropping to resequence AUTO_INCREMENT columns, including click to sort headings for query results columns adding dropping moving columns, displaying combining rows from two tables [See joins] conversion to transaction supporting types copying to another server creating creating two tables from one new indexes, adding databases, listing all the tables in deleting related rows in multiple tables by replacing tables cascaded deletes mysql, using programmatic deletion design saving data storage space dropping indexes duplicates, eliminating exporting as raw data fully qualified table references getting table structure information HTML, structure in information, database-independent methods of obtaining joining a table to itself joining from more than one database matching rows from or more metadata, getting methodology, choosing moving records between with multiple sequences, creating normalizing redesigning related table updates [See related table updates] renaming session records table creating SQL format, exporting in structure information, getting with result set metadata table names, specifying in queries table structure information uses for temporary tables TEMPORARY tables, creating temporary tables, using for data transformation testing for existence types types, determining server support for unique names for, generating using multiple web scripting query results as aliasing column names borderless empty table cells fix display, managing visual appearance XML, importing into MySQL tag libraries taglib directives 2nd entries TCP/IP connections to local host tcsh, PATH environment variable, setting team standings, computing tee files for reuse of queries tee option temporal values addition of zero for conversion to numbers current time, determining default values, enabling interpreting strings as TEMPORARY tables 2nd temporary tables using for data tranformation TERMINATED BY subclause terminator characters test harness programs test harness scripts, PHP Text::CSV_XS module, accessing documentation TIME column type values, allowable ranges time intervals, decomposing Python, using time of day, sorting by time values [See also temporal values] addition of combining with date values time zone discrepancies in time conversions time-formatting sequences time-related functions time_components( ) (Python) TIME_FORMAT( ) 2nd 3rd using for portions of times TIME_TO_SEC( ) 2nd 3rd 4th times adding temporal intervals to calculating intervals between comparisons conversion to seconds decomposing component-extraction functions, using formatting functions, using string functions, using numbers, treating as synthesizing component-extraction functions, using formatting functions, using time zone adjustments validity checking on subparts validity checking on values TIMESTAMP columns 2nd 3rd calculations on values vs DATETIME for recording record modification time for permanent record creation time, using format of values potential impacts of moving recording creation or modification time of records records, recording modification time values, reformatting for display TIMESTAMP values cgrouping in manageable categories timestamps, safeguarding table data with TINYINT, range of TLD files TLDs (Tag Library Descriptors) TO_DAYS( ) 2nd 3rd 4th to_excel.pl to_null.pl Tomcat built-in session management capabilities dependencies directory structure 2nd applications classes configuration and control operational directories environment variables installing JDBC driver directory location JDBC drivers and JDBC drivers, installing JSPs and Manager application mcb sample application, installation restarting applications without restarting the server servlet and JSP session interface session management Java methods MySQL, saving records in session management with MySQL server configuration files, changing session expiration session tables, creating tracking starting and stopping Linux Windows version WAR (web archive) files web scripts directory location web scripts, running on web site WEB-INF directory webapps directory XML and Tomcat server track_vars configuration setting (PHP) track_vars directive (PHP) trailing spaces, preserving transactions alternatives to, in nonsupporting environments atomic operations as alternative to BEGIN statement canceling with ROLLBACK statement Java programs, using in MySQL, supporting versions performing in programs server concurrency server integrity SQL, performing with table type availability, checking tables, transactional types, specifying transaction-safe table handlers, installing on server verifying server support of SHOW VARIABLES statement, checking with triple-equals operator (===) 2nd TRUNCATE( ) try blocks (Python) TYPE clauses U unattached records deleting via mysql programmatic deletion identifying undef (Perl) undefined values, testing for in Perl UNIONs column selection constraints for selecting records in parallel from multiple tables parentheses, for sorting select results simulating with temporary tables UNIQUE indexes 2nd 3rd AUTO_INCREMENT columns and declaring NULL values and NULLs and 2nd Unix cut utility file line terminators JDBC drivers, installing loading image files to MySQL od program path, indicating shell scripts, writing Unix epoch user-specific option files web scripts, path to language processor, indicating UNIX_TIMESTAMP( ) 2nd intervals, determination using UNLOCK statement unmarked lists, web scripting query results as [See also lists]2nd unordered lists, web scripting query results as [See also lists]2nd unsigned integers, pattern for matching UNSIGNED typing, AUTO_INCREMENT columns UPDATE query rows, finding the number affected update_related.pl UPPER( ) 2nd url( ) (Perl) urlencode( ) (PHP) urllib.quote( ) (Python) URLs (uniform resource locators) encoding of special characters pattern matching for web script locations, indicating via USE use DBI (Perl) user accounts (MySQL) creating login accounts, contrasted with USER( ) user-defined storage module, setting for PHP sessions users finding out whoÕs connected logging UWIN (Unix for Windows) V validation of data dates and times, checking of subparts ENUM columns, input values for lookup tables, using Java Perl PHP pattern matching for SET columns, for table metadata, using VARCHAR columns, conversions to CHAR types variable checking (Perl) variable substitution variance, calculation using standard deviation verbose option verbosity of output, setting vertical option vertical output format virtual servers associating log records with W -w option (Perl) WAR (web archive) files unpacking manually wasNull( ) (Java) web application structure web forms [See forms] web pages access counting displaying query results in as email addresses as hyperlinks as lists as navigation indexes as paragraph text as tables record fetching and HTML generation hit logging mapping column types to elements serving query results for download forcing client download web scripting extensions web scripts Apache servers, running on compared to HTML directory location Tomcat servers directory locations for, Apache servers filename extension, for processor type identification forms behaviors database records, loading to with file upload fields input, collecting multiple-pick elements, creating from database content queries, constructing from input single-pick elements, creating from database content validating input HTML and XHTML output images, storage using in Perl Apache servers in PHP Apache servers in Python Apache servers input processing file uploads MySQL, using for search interfaces, implementing query results paragraph text, displaying as server configuration for self-enabled or external script execution source HTML, viewing testing Tomcat servers, running on vs command-line scripts web page generation using web servers privileges and permissions sharing, risks of software, obtaining WEB-INF directory WEB-INF subdirectory web.xml file webapps directory WEEKDAY( ) 2nd WHERE clauses 2nd aggregate functions, incompatibility COUNT( ), using with data and comparison operators, use in efficient queries excluding reference values in self-joins group selection and joins and LEFT JOINs and matching rows in separate tables wildcards (pattern matching) Windows DOS command-line environment, limitations executing programs in file line terminators filename extensions JCBC drivers, installing library files specifying location loading image file to MySQL PATH environment variable, setting shell scripting statement recall capabilities Tomcat server, starting and stopping user-specific option files web scripts, path to language processor, indicating X XHTML HTML, compared to XML MySQL, importing into query results, exportation as Tomcat servers and xml option (MySQL 4.0) XML::XPath module xml_to_mysql.pl Y yank_col.pl YEAR( ) 2nd 3rd year-length calculations and leap years Z zero, addition to temporal string values Zip and Zip+4 postal codes, pattern for matching ... of the statements, skip ahead to Recipe 1.16 mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> mysql> USE cookbook; CREATE TABLE limbs (thing VARCHAR(20),... 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 databases other than MySQL To some extent... named cookbook The arguments to mysql include -h localhost to connect to the MySQL server running on the local host, -p to tell mysql to prompt for a password, and -u root to connect as the MySQL