
Contents
About 1 ...................................................................................................................................................................................
Chapter 1: Getting started with MySQL 2 .............................................................................................................
Section 1.1: Getting Started 2 ...........................................................................................................................................
Section 1.2: Information Schema Examples 6 ................................................................................................................
Chapter 2: Data Types 7 ...............................................................................................................................................
Section 2.1: CHAR(n) 7 ......................................................................................................................................................
Section 2.2: DATE, DATETIME, TIMESTAMP, YEAR, and TIME 7 ...................................................................................
Section 2.3: VARCHAR(255) -- or not 8 ..........................................................................................................................
Section 2.4: INT as AUTO_INCREMENT 8 ......................................................................................................................
Section 2.5: Others 8 ........................................................................................................................................................
Section 2.6: Implicit / automatic casting 9 .....................................................................................................................
Section 2.7: Introduction (numeric) 9 .............................................................................................................................
Section 2.8: Integer Types 10 ..........................................................................................................................................
Section 2.9: Fixed Point Types 10 ...................................................................................................................................
Section 2.10: Floating Point Types 10 .............................................................................................................................
Section 2.11: Bit Value Type 11 ........................................................................................................................................
Chapter 3: SELECT 12 ......................................................................................................................................................
Section 3.1: SELECT with DISTINCT 12 ............................................................................................................................
Section 3.2: SELECT all columns (*) 12 ...........................................................................................................................
Section 3.3: SELECT by column name 13 .......................................................................................................................
Section 3.4: SELECT with LIKE (%) 13 .............................................................................................................................
Section 3.5: SELECT with CASE or IF 15 ..........................................................................................................................
Section 3.6: SELECT with Alias (AS) 15 ...........................................................................................................................
Section 3.7: SELECT with a LIMIT clause 16 ...................................................................................................................
Section 3.8: SELECT with BETWEEN 16 ..........................................................................................................................
Section 3.9: SELECT with WHERE 18 ...............................................................................................................................
Section 3.10: SELECT with LIKE(_) 18 .............................................................................................................................
Section 3.11: SELECT with date range 19 ........................................................................................................................
Chapter 4: Backticks 20 .................................................................................................................................................
Section 4.1: Backticks usage 20 .......................................................................................................................................
Chapter 5: NULL 21 ..........................................................................................................................................................
Section 5.1: Uses for NULL 21 ..........................................................................................................................................
Section 5.2: Testing NULLs 21 .........................................................................................................................................
Chapter 6: Limit and Oset 22 ...................................................................................................................................
Section 6.1: Limit and Oset relationship 22 ..................................................................................................................
Chapter 7: Creating databases 24 ...........................................................................................................................
Section 7.1: Create database, users, and grants 24 ......................................................................................................
Section 7.2: Creating and Selecting a Database 26 ......................................................................................................
Section 7.3: MyDatabase 26 ............................................................................................................................................
Section 7.4: System Databases 27 ..................................................................................................................................
Chapter 8: Using Variables 28 ....................................................................................................................................
Section 8.1: Setting Variables 28 .....................................................................................................................................
Section 8.2: Row Number and Group By using variables in Select Statement 28 .....................................................
Chapter 9: Comment Mysql 31 ...................................................................................................................................
Section 9.1: Adding comments 31 ...................................................................................................................................
Section 9.2: Commenting table definitions 31 ...............................................................................................................
评论