Beruflich Dokumente
Kultur Dokumente
TABLE OF CONTENTS
1. Objective...................................................................................................................................... 1
2. Introduction................................................................................................................................. 1
2.1 What is MySQL?............................................................................................................ 1
2.2 Features of MySQL........................................................................................................ 2
3. Creating and using database.................................................................................................... 3
3.1 Creating and selecting database................................................................................. 3
3.2 Creating a table............................................................................................................. 4
3.3 Retrieving information from table............................................................................... 4
4. Common Queries....................................................................................................................... 5
4.1 Maximum value for a column........................................................................................ 5
4.2 Row holding the maximum of a certain column......................................................... 5
4.3 Maximum of column per group.................................................................................... 5
4.4 Rows holding the group-wise maximum of a certain column... ................................ 6
4.5 User-defined variables.................................................................................................... 7
4.6 Using auto increment..................................................................................................... 7
5. Optimizing SQL statements........................................................................................................ 9
5.1 Optimizing select statement........................................................................................... 9
5.2 Optimizing DML statements........................................................................................... 10
6. Optimization and indexes............................................................................................................ 12
6.1 Primary keys..................................................................................................................... 12
6.2 Foreign keys..................................................................................................................... 12
7. Optimizing database structure.................................................................................................... 13
7.1 Optimizing data size........................................................................................................ 13
7.2 Optimizing MySQL data types.......................................................................................... 13
7.3 Optimizing database structure....................................................................................... 14
8. Data types....................................................................................................... ............................ 15
8.1 Data type overview........................................................................................................ 15
8.2 Numeric type overview................................................................................................ 15
8.3 Integer, int, smallint, tinyint, mediumint, bigint.......................................................... 16
8.4 Date and time type overview......................................................................................... 17
8.5 The date, datetime, and timestamp types........................................................... ........ 18
8.6 Time type, year type...................................................................................................... 18
8.7 String type overview..................................................................................................... 19
8.8 The char and varchar types......................................................................................... 20
8.9 The enum type............................................................................................................... 20
8.10 The set type.................................................................................................................. 20
9. Data type storage requirements.............................................................................................. 22
10. Functions and operators.......................................................................................................... 25
10.1 Function and operator reference................................................................................ 25
CORPORATE TRAINING BOOK – MYSQL