SlideShare a Scribd company logo
1 of 103
Download to read offline
MySQL Idiosyncrasies
that BITE
MySQL Idiosyncrasies That BITE - 2010.10
Title
Ronald Bradford
http://ronaldbradford.com
OTN LAD Tour 2010
South America
2010.10
Ronald Bradford
http://ronaldbradford.com
@RonaldBradford #OTN #LAOUC
MySQL Idiosyncrasies That BITE - 2010.10
Deļ¬nitions
idiosyncrasy
[id-ee-uh-sing-kruh-see, -sin-] ā€“noun,plural-sies.
A characteristic, habit, mannerism, or the
like, that is peculiar to ...
http://dictionary.com
MySQL Idiosyncrasies That BITE - 2010.10
About RDBMS - Oracle != MySQL
Product Age
Development philosophies
Target audience
Developer practices
Installed versions
MySQL Idiosyncrasies That BITE - 2010.10
Expected RDBMS Characteristics
Data Integrity
Transactions
ACID
Data Security
ANSI SQL
MySQL Idiosyncrasies That BITE - 2010.10
These RDBMS characteristics
are NOT enabled by default
in MySQL
WARNING !!!
(*)
MySQL Idiosyncrasies That BITE - 2010.10
MySQL Terminology
Storage Engines
MyISAM - Default
InnoDB - Default from MySQL 5.5
Transactions
Non Transactional Engine(s)
Transactional Engine(s)
MySQL Idiosyncrasies That BITE - 2010.10
1. Data Integrity
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity - Expected
CREATE TABLE orders (
qty TINYINT UNSIGNED NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET latin1;
INSERT INTO orders(qty) VALUES (0), (100), (255);
SELECT * FROM orders;
+-----+---------------------+
| qty | created |
+-----+---------------------+
| 0 | 2010-10-25 12:22:22 |
| 100 | 2010-10-25 12:22:22 |
| 255 | 2010-10-25 12:22:22 |
+-----+---------------------+
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity - Unexpected
mysql> INSERT INTO orders (qty) VALUES (-1), (9000);
mysql> SELECT * FROM orders;
+-----+---------------------+
| qty | created |
+-----+---------------------+
| 0 | 2010-10-25 12:22:22 |
| 100 | 2010-10-25 12:22:22 |
| 255 | 2010-10-25 12:22:22 |
| 0 | 2010-10-25 12:23:06 |
| 255 | 2010-10-25 12:23:06 |
+-----+---------------------+
//CREATE TABLE orders (
// qty TINYINT UNSIGNED NOT NULL,
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity - Unexpected
mysql> INSERT INTO orders (qty) VALUES (-1), (9000);
mysql> SELECT * FROM orders;
+-----+---------------------+
| qty | created |
+-----+---------------------+
| 0 | 2010-10-25 12:22:22 |
| 100 | 2010-10-25 12:22:22 |
| 255 | 2010-10-25 12:22:22 |
| 0 | 2010-10-25 12:23:06 |
| 255 | 2010-10-25 12:23:06 |
+-----+---------------------+
//CREATE TABLE orders (
// qty TINYINT UNSIGNED NOT NULL,
āœ˜
TINYINT is 1 byte.
UNSIGNED supports
values 0-255
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity - Warnings
mysql> INSERT INTO orders (qty) VALUES (-1), (9000);
Query OK, 2 rows affected, 2 warnings (0.05 sec)
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------+
| Warning | 1264 | Out of range value for column 'qty' at row 1 |
| Warning | 1264 | Out of range value for column 'qty' at row 2 |
+---------+------+----------------------------------------------+
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity - Unexpected (2)
mysql> INSERT INTO customers (name)
-> VALUES ('RONALD BRADFORD'),
-> ('FRANCISCO MUNOZ ALVAREZ');
mysql> SELECT * FROM customers;
+----------------------+
| name |
+----------------------+
| RONALD BRADFORD |
| FRANCISCO MUNOZ ALVA |
+----------------------+
2 rows in set (0.00 sec)
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity - Warnings (2)
INSERT INTO customers (name) VALUES ('RONALD BRADFORD'),
('FRANCISCO MUNOZ ALVAREZ');
Query OK, 2 rows affected, 1 warning (0.29 sec)
mysql> SHOW WARNINGS;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column 'name' at row 2 |
+---------+------+-------------------------------------------+
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity with Dates - Warnings
mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'd' at row 1 |
+---------+------+----------------------------------------+
mysql> SELECT * FROM sample_date;
+------------+
| d |
+------------+
| 0000-00-00 |
+------------+
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
SHOW WARNINGS
http://dev.mysql.com/doc/refman/5.1/en/show-warnings.html
MySQL Idiosyncrasies That BITE - 2010.10
Using SQL_MODE for Data Integrity
SQL_MODE =
STRICT_ALL_TABLES;
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
Recommended
Conļ¬guration
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity - Expected
mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES;
mysql> TRUNCATE TABLE sample_data;
mysql> INSERT INTO sample_data(i) VALUES (0), (100), (255);
mysql> INSERT INTO sample_data (i) VALUES (-1), (9000);
ERROR 1264 (22003): Out of range value for column 'i' at row 1
mysql> SELECT * FROM sample_data;
+-----+------+---------------------+
| i | c | t |
+-----+------+---------------------+
| 0 | NULL | 2010-06-06 14:39:48 |
| 100 | NULL | 2010-06-06 14:39:48 |
| 255 | NULL | 2010-06-06 14:39:48 |
+-----+------+---------------------+
3 rows in set (0.00 sec)
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity with Dates - Expected
mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES;
mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31');
ERROR 1292 (22007): Incorrect date value: '2010-02-31' for
column 'd' at row 1
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity with Dates - Unexpected
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-00');
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05');
mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00');
mysql> SELECT * FROM sample_date;
+------------+
| d |
+------------+
| 2010-00-00 |
| 2010-00-05 |
| 0000-00-00 |
+------------+
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Using SQL_MODE for Date Integrity
SQL_MODE =
STRICT_ALL_TABLES,
NO_ZERO_DATE,
NO_ZERO_IN_DATE;
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
Recommended
Conļ¬guration
MySQL Idiosyncrasies That BITE - 2010.10
Data Integrity with Dates - Expected
mysql> SET SESSION
SQL_MODE='STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE';
mysql> TRUNCATE TABLE sample_date;
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-00');
ERROR 1292 (22007): Incorrect date value: '2010-00-00' for column
'd' at row 1
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05');
ERROR 1292 (22007): Incorrect date value: '2010-00-05' for column
'd' at row 1
mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00');
ERROR 1292 (22007): Incorrect date value: '0000-00-00' for column
'd' at row 1
mysql> SELECT * FROM sample_date;
Empty set (0.00 sec)
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
2.Transactions
MySQL Idiosyncrasies That BITE - 2010.10
Transactions Example - Tables
DROP TABLE IF EXISTS parent;
CREATE TABLE parent (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
val VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (val)
) ENGINE=InnoDB DEFAULT CHARSET latin1;
DROP TABLE IF EXISTS child;
CREATE TABLE child (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id INT UNSIGNED NOT NULL,
created TIMESTAMP NOT NULL,
PRIMARY KEY (id),
INDEX (parent_id),
FOREIGN KEY (parent_id) REFERENCES parent(id)
) ENGINE=InnoDB DEFAULT CHARSET latin1;
MySQL Idiosyncrasies That BITE - 2010.10
Transactions Example - SQL
START TRANSACTION;
INSERT INTO parent(val) VALUES("a");
INSERT INTO child(parent_id,created)
VALUES(LAST_INSERT_ID(),NOW());
# Expecting an error with next SQL
INSERT INTO parent(val) VALUES("a");
ROLLBACK;
SELECT * FROM parent;
SELECT * FROM child;
MySQL Idiosyncrasies That BITE - 2010.10
Transactions Example - Expected
...
mysql> INSERT INTO parent (val) VALUES("a");
ERROR 1062 (23000): Duplicate entry 'a' for key 'val'
mysql> ROLLBACK;
mysql> SELECT * FROM parent;
Empty set (0.00 sec)
mysql> SELECT * FROM child;
Empty set (0.00 sec)
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
Transactions Example - Tables
DROP TABLE IF EXISTS parent;
CREATE TABLE parent (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
val VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (val)
) ENGINE=MyISAM DEFAULT CHARSET latin1;
DROP TABLE IF EXISTS child;
CREATE TABLE child (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id INT UNSIGNED NOT NULL,
created TIMESTAMP NOT NULL,
PRIMARY KEY (id),
INDEX (parent_id)
) ENGINE=MyISAM DEFAULT CHARSET latin1;
MyISAM is the current
default if not speciļ¬ed
MySQL Idiosyncrasies That BITE - 2010.10
Transactions Example - Unexpected
mysql> INSERT INTO parent (val) VALUES("a");
ERROR 1062 (23000): Duplicate entry 'a' for key 'val'
mysql> ROLLBACK;
mysql> SELECT * FROM parent;
+----+-----+
| id | val |
+----+-----+
| 1 | a |
+----+-----+
1 row in set (0.00 sec)
mysql> SELECT * FROM child;
+----+-----------+---------------------+
| id | parent_id | created |
+----+-----------+---------------------+
| 1 | 1 | 2010-06-03 13:53:38 |
+----+-----------+---------------------+
1 row in set (0.00 sec)
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Transactions Example - Unexpected (2)
mysql> ROLLBACK;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
+---------+-------+-------------------------------------
| Level | Code | Message
|
+---------+------+--------------------------------------
| Warning | 1196 | Some non-transactional changed tables
couldn't be rolled back |
+---------+------+--------------------------------------
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Transactions Solution
mysql> SET GLOBAL storage_engine=InnoDB;
# my.cnf
[mysqld]
default-storage-engine=InnoDB
# NOTE: Requires server restart
$ /etc/init.d/mysqld stop
$ /etc/init.d/mysqld start
http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine
Recommended
Conļ¬guration
MySQL Idiosyncrasies That BITE - 2010.10
Why use Non Transactional Tables?
No transaction overhead
Much faster
Less disk writes
Lower disk space requirements
Less memory requirements
http://dev.mysql.com/doc/refman/5.1/en/storage-engine-compare-transactions.html
MySQL Idiosyncrasies That BITE - 2010.10
3.Variable Scope
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Example
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> SHOW CREATE TABLE test1G
CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
MyISAM is the current
default if not speciļ¬ed
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Example (2)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | MyISAM |
+----------------+--------+
mysql> SET GLOBAL storage_engine='InnoDB';
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
Changing in
MySQL 5.5
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Example (3)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
mysql> DROP TABLE test1;
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> SHOW CREATE TABLE test1G
CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Example (4)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Example (4)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
mysql> SHOW SESSION VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | MyISAM |
+----------------+--------+
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Example (4)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
mysql> SHOW SESSION VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | MyISAM |
+----------------+--------+
MySQLVariables have
two scopes.
SESSION & GLOBAL
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Syntax
SHOW [GLOBAL | SESSION]VARIABLES;
SET [GLOBAL | SESSION] variable = value;
Default is GLOBAL since 5.0.2
http://dev.mysql.com/doc/refman/5.1/en/user-variables.html
http://dev.mysql.com/doc/refman/5.1/en/set-option.html
MySQL Idiosyncrasies That BITE - 2010.10
Variable Scope Precautions
Persistent connections (e.g. Java)
Replication SQL_THREAD
Be careful of existing
connections!
MySQL Idiosyncrasies That BITE - 2010.10
4. Storage Engines
MySQL Idiosyncrasies That BITE - 2010.10
Storage Engines Example - Creation
CREATE TABLE test1 (
id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;
SHOW CREATE TABLE test1G
*************************** 1. row *************
Table: test1
Create Table: CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Storage Engines Example - Creation
CREATE TABLE test1 (
id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;
SHOW CREATE TABLE test1G
*************************** 1. row *************
Table: test1
Create Table: CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
āœ˜
Even speciļ¬ed the
storage engine reverted
to the default
MySQL Idiosyncrasies That BITE - 2010.10
Storage Engines Example - Unexpected
CREATE TABLE test1 (
id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;
Query OK, 0 rows affected, 2 warnings (0.13 sec)
SHOW WARNINGS;
+---------+------+-----------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------+
| Warning | 1286 | Unknown table engine 'InnoDB' |
| Warning | 1266 | Using storage engine MyISAM for table 'test1' |
+---------+------+-----------------------------------------------+
2 rows in set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.10
Storage Engines Example - Cause
mysql> SHOW ENGINES;
+------------+---------+-------------------------+--------------+
| Engine | Support | Comment | Transactions |
+------------+---------+-------------------------+--------------+
| InnoDB | NO | Supports transaction... | NULL |
| MEMORY | YES | Hash based, stored i... | NO |
| MyISAM | DEFAULT | Default engine as ... | NO |
MySQL Idiosyncrasies That BITE - 2010.10
Storage Engines Example - Unexpected (2)
mysql> CREATE TABLE test1
id INT UNSIGNED NOT NULL
) ENGINE=InnDB DEFAULT CHARSET latin1;
Query OK, 0 rows affected, 2 warnings (0.11 sec)
mysql> SHOW WARNINGS;
+---------+------+-----------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------+
| Warning | 1286 | Unknown table engine 'InnDB' |
| Warning | 1266 | Using storage engine MyISAM for table 'test1' |
+---------+------+-----------------------------------------------+
āœ˜
Be careful of spelling
mistakes as well.
MySQL Idiosyncrasies That BITE - 2010.10
Using SQL_MODE for Storage Engines
SQL_MODE =
STRICT_ALL_TABLES,
NO_ZERO_DATE,
NO_ZERO_IN_DATE,
NO_ENGINE_SUBSTITUTION;
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
Recommended
Conļ¬guration
MySQL Idiosyncrasies That BITE - 2010.10
Storage Engines Example - Solution
SET SESSION SQL_MODE=NO_ENGINE_SUBSTITUTION;
DROP TABLE IF EXISTS test3;
CREATE TABLE test3 (
id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;
ERROR 1286 (42000): Unknown table engine 'InnoDB'
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
5.ACID
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity -
All or nothing
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Table
DROP TABLE IF EXISTS accounts;
CREATE TABLE accounts(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (username)
) ENGINE=MyISAM DEFAULT CHARSET latin1;
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Data
INSERT INTO accounts (username)
VALUES('jane'),('jo'),('joe'),('joel'),('jame'),
('jamel');
mysql> SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 1 | jane |
| 2 | jo |
| 3 | joe |
| 4 | joel |
| 5 | jame |
| 6 | jamel |
+----+----------+
6 rows in set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Unexpected
mysql> UPDATE accounts SET username=CONCAT(username,'l')
ERROR 1062 (23000): Duplicate entry 'joel' for key
'username'
mysql> SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 1 | janel |
| 2 | jol |
| 3 | joe |
| 4 | joel |
| 5 | jame |
| 6 | jamel |
+----+----------+
6 rows in set (0.01 sec)
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Unexpected (2)
mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 1 | janel |
| 2 | jol |
| 3 | joe |
| 4 | joel |
...
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Unexpected (2)
mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 1 | janel |
| 2 | jol |
| 3 | joe |
| 4 | joel |
...
āœ˜
Rollback has no effect
on non transactional
tables
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Transactional Table
CREATE TABLE accounts(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (username)
) ENGINE=InnoDB DEFAULT CHARSET latin1;
INSERT INTO accounts (username) VALUES('jane'),('jo')...
UPDATE accounts SET username=CONCAT(username,'l');
ERROR 1062 (23000): Duplicate entry 'joel' for key 'username'
SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 5 | jame |
| 6 | jamel |
| 1 | jane |
| 2 | jo |
| 3 | joe |
| 4 | joel |
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Transactional Table
CREATE TABLE accounts(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (username)
) ENGINE=InnoDB DEFAULT CHARSET latin1;
INSERT INTO accounts (username) VALUES('jane'),('jo')...
UPDATE accounts SET username=CONCAT(username,'l');
ERROR 1062 (23000): Duplicate entry 'joel' for key 'username'
SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 5 | jame |
| 6 | jamel |
| 1 | jane |
| 2 | jo |
| 3 | joe |
| 4 | joel |
āœ”
Data remains unchanged
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Transactional Table
mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 5 | jame |
| 6 | jamel |
| 1 | jane |
| 2 | jo |
| 3 | joe |
| 4 | joel |
+----+----------+
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Transactional Table
mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM accounts;
+----+----------+
| id | username |
+----+----------+
| 5 | jame |
| 6 | jamel |
| 1 | jane |
| 2 | jo |
| 3 | joe |
| 4 | joel |
+----+----------+
āœ˜
Data remains, INSERT
was not rolled back?
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - The culprit
mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | ON |
+---------------+-------+
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - The culprit
mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | ON |
+---------------+-------+
The default for
autocommit is ON.
Great care is needed to
change the default.
MySQL Idiosyncrasies That BITE - 2010.10
Atomicity - Recommendations
Always wrap SQL in transactions
START TRANSACTION | BEGIN [WORK]
COMMIT
Recommended
Practice
MySQL Idiosyncrasies That BITE - 2010.10
Isolation -
Transactions do not affect
other transactions
MySQL Idiosyncrasies That BITE - 2010.10
Transaction Isolation - Levels
READ-UNCOMMITTED
READ-COMMITTED
REPEATABLE-READ
SERIALIZABLE
http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html
http://ronaldbradford.com/blog/understanding-mysql-innodb-transaction-isolation-2009-09-24/
MySQL supports 4
isolation levels
MySQL Idiosyncrasies That BITE - 2010.10
Transaction Isolation - Default
The default is
REPEATABLE-READ
SET GLOBAL tx_isolation = 'READ-COMMITTED';
This is a mistake
http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/
MySQL Idiosyncrasies That BITE - 2010.10
Transaction Isolation - Default
The default is
REPEATABLE-READ
SET GLOBAL tx_isolation = 'READ-COMMITTED';
This is a mistake
http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/
Common mistake by
Oracle DBA's
supporting MySQL
MySQL Idiosyncrasies That BITE - 2010.10
Oracle READ COMMITTED
!=
MySQL READ-COMMITTED
MySQL Idiosyncrasies That BITE - 2010.10
Transaction Isolation - Binary Logging Errors
SET GLOBAL tx_isolation='READ-COMMITTED';
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test1 values (1,'x');
ERROR 1598 (HY000): Binary logging not possible.
Message: Transaction level 'READ-COMMITTED' in InnoDB is
not safe for binlog mode 'STATEMENT'
āœ˜
As of 5.1 this requires
further conļ¬guration
considerations
MySQL Idiosyncrasies That BITE - 2010.10
Durability -
No committed
transactions are lost
MySQL Idiosyncrasies That BITE - 2010.10
Data Safety
MyISAM writes/ļ¬‚ushes data every statement
Does not ļ¬‚ush indexes (*)
InnoDB can relax durability
ļ¬‚ush all transactions per second
innodb_flush_log_at_trx_commit
sync_binlog
innodb_support_xa
MySQL Idiosyncrasies That BITE - 2010.10
Auto Recovery
InnoDB has it
MyISAM does not - (*) Indexes
MYISAM-RECOVER=FORCE,BACKUP
REPAIR TABLE
myisamchk
MySQL Idiosyncrasies That BITE - 2010.10
Recovery Time
InnoDB is consistent
Redo Log ļ¬le size
Slow performance in Undo (*)
MyISAM grows with data volume
MySQL Idiosyncrasies That BITE - 2010.10
InnoDB Auto Recovery Example
InnoDB: Log scan progressed past the checkpoint lsn 0 188755039
100624 16:37:44 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 193997824
InnoDB: Doing recovery: scanned up to log sequence number 0 195151897
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 105565 row operations to undo
InnoDB: Trx id counter is 0 18688
100624 16:37:45 InnoDB: Starting an apply batch of log records to the
database...
InnoDB: Progress in percents: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19 ... 99
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 12051, file name ./binary-log.
000003
InnoDB: Starting in background the rollback of uncommitted transactions
...
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
MyISAM Repair needed Example
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/
descriptions' is marked as crashed and should be repaired
100126 22:44:35 [Warning] Checking table: './XXX/descriptions'
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/taggings'
is marked as crashed and should be repaired
100126 22:44:35 [Warning] Checking table: './XXX/taggings'
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/vehicle'
is marked as crashed and should be repaired
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
6. Data Security
MySQL Idiosyncrasies That BITE - 2010.10
User Privileges - Practices
CREATE USER goodguy@localhost IDENTIFIED BY 'sakila';
GRANT CREATE,SELECT,INSERT,UPDATE,DELETE ON odtug.* TO
goodguy@localhost;
CREATE USER superman@'%';
GRANT ALL ON *.* TO superman@'%';
Best Practice
Normal Practice
http://dev.mysql.com/doc/refman/5.1/en/create-user.html
http://dev.mysql.com/doc/refman/5.1/en/grant.html
āœ”
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
User Privileges - Normal Bad Practice
GRANT ALL ON *.* TO user@ā€™%ā€™
*.* gives you access to all tables in all schemas
@ā€™%ā€™ give you access from any external location
ALL gives you
ALTER,ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY
TABLES, CREATE USER, CREATEVIEW, DELETE, DROP, EVENT, EXECUTE, FILE,
INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, REPLICATION
CLIENT, REPLICATION SLAVE, SELECT, SHOW DATABASES, SHOWVIEW,
SHUTDOWN, SUPER,TRIGGER, UPDATE, USAGE
MySQL Idiosyncrasies That BITE - 2010.10
User Privileges - Why SUPER is bad
SUPER
Bypasses read_only
Bypasses init_connect
Can Disable binary logging
Change conļ¬guration dynamically
No reserved connection
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Read Only
$ mysql -ugoodguy -psakila odtug
mysql> insert into test1(id) values(1);
ERROR 1290 (HY000): The MySQL server is running with the
--read-only option so it cannot execute this statement āœ”
$ mysql -usuperman odtug
mysql> insert into test1(id) values(1);
Query OK, 1 row affected (0.01 sec)
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Read Only
$ mysql -ugoodguy -psakila odtug
mysql> insert into test1(id) values(1);
ERROR 1290 (HY000): The MySQL server is running with the
--read-only option so it cannot execute this statement āœ”
$ mysql -usuperman odtug
mysql> insert into test1(id) values(1);
Query OK, 1 row affected (0.01 sec)
āœ˜
Data inconsistency
now exists
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Init Connect
#my.cnf
[client]
init_connect=SET NAMES utf8
This specifies to use UTF8 for communication with client
and data
Common conļ¬guration
practice to support
UTF8
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Init Connect (2)
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Init Connect (2)
$ mysql -ugoodguy -psakila odtug
mysql> SHOW SESSION VARIABLES LIKE 'ch%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+----------+
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Init Connect (2)
$ mysql -usuperman odtug
mysql> SHOW SESSION VARIABLES LIKE
'character%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+----------+
$ mysql -ugoodguy -psakila odtug
mysql> SHOW SESSION VARIABLES LIKE 'ch%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+----------+
āœ” āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Init Connect (2)
$ mysql -usuperman odtug
mysql> SHOW SESSION VARIABLES LIKE
'character%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+----------+
$ mysql -ugoodguy -psakila odtug
mysql> SHOW SESSION VARIABLES LIKE 'ch%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+----------+
āœ” āœ˜
Data integrity can be
compromised
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Binary Log
mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+
| binary-log.000017 | 4488 | | |
+-------------------+----------+--------------+------------------+
mysql> DELETE FROM sales WHERE id=23;
mysql> SET SQL_LOG_BIN=0;
mysql> DELETE FROM sales WHERE id=80;
mysql> SET SQL_LOG_BIN=1;
mysql> DELETE FROM sales WHERE id=99;
mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| binary-log.000017 | 4580 | | |
+-------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and Binary Log (2)
# at 4488
#101025 12:57:24 server id 1 end_log_pos 4580 Query
thread_id=1 exec_time=0 error_code=0
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
DELETE FROM sales WHERE id=23
/*!*/;
# at 4580
#101025 13:01:26 server id 1 end_log_pos 4672 Query
thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1288018886/*!*/;
DELETE FROM sales WHERE id=99
/*!*/;
DELIMITER ;
āœ˜
Data auditability is now
compromised
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and reserved connection
$ mysql -uroot
mysql> show global variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 3 |
+-----------------+-------+
1 row in set (0.07 sec)
mysql> show global status like 'threads_connected';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_connected | 4 |
+-------------------+-------+
āœ”
When connected
correctly, 1 connection
is reserved for SUPER
MySQL Idiosyncrasies That BITE - 2010.10
SUPER and reserved connection - Unexpected
$ mysql -uroot
ERROR 1040 (HY000): Too many connections
mysql> SHOW PROCESSLIST;
+----+------+-----------+-------+---------+------+------------+---------------
| Id | User | Host | db | Command | Time | State | Info
+----+------+-----------+-------+---------+------+------------+---------------
| 13 | root | localhost | odtug | Query | 144 | User sleep | UPDATE test1 ...
| 14 | root | localhost | odtug | Query | 116 | Locked | select * from test1
| 15 | root | localhost | odtug | Query | 89 | Locked | select * from test1
āœ˜
When application
users all use SUPER,
administrator can't
diagnose problem
MySQL Idiosyncrasies That BITE - 2010.10
7. ANSI SQL
MySQL Idiosyncrasies That BITE - 2010.10
Group By Example
SELECT country, COUNT(*) AS color_count
FROM flags
GROUP BY country;
+-----------+-------------+
| country | color_count |
+-----------+-------------+
| Australia | 3 |
| Canada | 2 |
| Japan | 2 |
| Sweden | 2 |
| USA | 3 |
+-----------+-------------+
SELECT country, COUNT(*)
FROM flags;
+-----------+----------+
| country | COUNT(*) |
+-----------+----------+
| Australia | 12 |
+-----------+----------+
āœ”
āœ˜
MySQL Idiosyncrasies That BITE - 2010.10
Group By Example (2)
SET SESSION sql_mode=ONLY_FULL_GROUP_BY;
SELECT country, COUNT(*)
FROM flags;
ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...)
with no GROUP columns is illegal if there is no GROUP BY clause
http://ExpertPHPandMySQL.com Chapter 1 - Pg 31
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
Using SQL_MODE for ANSI SQL
SQL_MODE =
STRICT_ALL_TABLES,
NO_ZERO_DATE,
NO_ZERO_IN_DATE,
NO_ENGINE_SUBSTITUTION,
ONLY_FULL_GROUP_BY;
Recommended
Conļ¬guration
MySQL Idiosyncrasies That BITE - 2010.10
8. Case Sensitivity
MySQL Idiosyncrasies That BITE - 2010.10
Case Sensitivity String Comparison
SELECT 'OTN' = UPPER('otn');
+----------------------+
| 'OTN' = UPPER('otn') |
+----------------------+
| 1 |
+----------------------+
SELECT 'OTN' = 'OTN' AS same, 'OTN' = 'Otn' as initcap, 'OTN' = 'otn' as
lowercase, 'OTN' = 'otn' COLLATE latin1_general_cs AS different;
+------+---------+-----------+-----------+
| same | initcap | lowercase | different |
+------+---------+-----------+-----------+
| 1 | 1 | 1 | 0 |
+------+---------+-----------+-----------+
SELECT name, address, email
FROM customer
WHERE name = UPPER('bradford')
āœ˜This practice is
unnecessary as does not
utilize index if exists
MySQL Idiosyncrasies That BITE - 2010.10
Case Sensitivity Tables
# Server 1
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> INSERT INTO test1 VALUES(1);
mysql> INSERT INTO TEST1 VALUES(2);
# Server 2
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> INSERT INTO test1 VALUES(1);
mysql> INSERT INTO TEST1 VALUES(2);
ERROR 1146 (42S02): Table 'test.TEST1' doesn't exist
MySQL Idiosyncrasies That BITE - 2010.10
Case Sensitivity Tables (2) - Operating Speciļ¬c Settings
# Server 1 - Mac OS X / Windows Default
mysql> SHOW GLOBAL VARIABLES LIKE 'lower%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | ON |
| lower_case_table_names | 2 |
+------------------------+-------+
# Server 2 - Linux Default
mysql> SHOW GLOBAL VARIABLES LIKE 'lower%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 0 |
+------------------------+-------+
Be careful.This default
varies depending on
Operating System
MySQL Idiosyncrasies That BITE - 2010.10
Other Gotchas
MySQL Idiosyncrasies That BITE - 2010.10
Other features the BITE
Character Sets
Data/Client/Application/Web
Sub Queries
Rewrite as JOIN when possible
Views
No always efļ¬cient
Cascading Conļ¬guration Files
SQL_MODE's not to use
MySQL Idiosyncrasies That BITE - 2010.10
Conclusion
MySQL Idiosyncrasies That BITE - 2010.10
DON'T
ASSUME
MySQL Idiosyncrasies That BITE - 2010.10
Conclusion - SQL_MODE
SQL_MODE =
ALLOW_INVALID_DATES,ANSI_QUOTES, ERROR_FOR_DIVISION_ZERO,
HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER,
NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,
NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,
NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,
NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,
NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY (5.1.11),
PAD_CHAR_TO_FULL_LENGTH (5.1.20), PIPES_AS_CONCAT,
REAL_AS_FLOAT,STRICT_ALL_TABLES, STRICT_TRANS_TABLES
ANSI, DB2, MAXDB, MSSQL, MYSQL323, MYSQL40, ORACLE,
POSTGRESQL,TRADITIONAL
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
āœ”
MySQL Idiosyncrasies That BITE - 2010.10
Conclusion - SQL_MODE
SQL_MODE =
ALLOW_INVALID_DATES,ANSI_QUOTES, ERROR_FOR_DIVISION_ZERO,
HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER,
NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,
NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,
NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,
NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,
NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY (5.1.11),
PAD_CHAR_TO_FULL_LENGTH (5.1.20), PIPES_AS_CONCAT,
REAL_AS_FLOAT,STRICT_ALL_TABLES, STRICT_TRANS_TABLES
ANSI, DB2, MAXDB, MSSQL, MYSQL323, MYSQL40, ORACLE,
POSTGRESQL,TRADITIONAL
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
āœ”
āœ˜
?
MySQL Idiosyncrasies That BITE - 2010.10
RonaldBradford.com
MySQL4OracleDBA.com

More Related Content

What's hot

15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfzJoshua Thijssen
Ā 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erickokelloerick
Ā 
My sql statements by okello erick
My sql statements by okello erickMy sql statements by okello erick
My sql statements by okello erickokelloerick
Ā 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performanceoysteing
Ā 
MySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteMySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteRonald Bradford
Ā 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sqlMinhaj Kazi
Ā 
Lecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickLecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickokelloerick
Ā 
介ē» MySQL
介ē» MySQL介ē» MySQL
介ē» MySQLYUCHENG HU
Ā 
MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07Ronald Bradford
Ā 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesDamien Seguy
Ā 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQLEvan Weaver
Ā 
MySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreMySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreDave Stokes
Ā 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Traceoysteing
Ā 
Cat database
Cat databaseCat database
Cat databasetubbeles
Ā 
Lecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erickLecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erickokelloerick
Ā 
MySQL constraints
MySQL constraintsMySQL constraints
MySQL constraintsHarish Gyanani
Ā 

What's hot (18)

15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
Ā 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erick
Ā 
My sql statements by okello erick
My sql statements by okello erickMy sql statements by okello erick
My sql statements by okello erick
Ā 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
Ā 
MySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That BiteMySQL Idiosyncrasies That Bite
MySQL Idiosyncrasies That Bite
Ā 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
Ā 
Lecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickLecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erick
Ā 
介ē» MySQL
介ē» MySQL介ē» MySQL
介ē» MySQL
Ā 
MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07MySQL Idiosyncrasies That Bite 2010.07
MySQL Idiosyncrasies That Bite 2010.07
Ā 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queries
Ā 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQL
Ā 
MySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreMySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document Store
Ā 
Explain2
Explain2Explain2
Explain2
Ā 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
Ā 
Tugas praktikum smbd
Tugas praktikum smbdTugas praktikum smbd
Tugas praktikum smbd
Ā 
Cat database
Cat databaseCat database
Cat database
Ā 
Lecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erickLecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erick
Ā 
MySQL constraints
MySQL constraintsMySQL constraints
MySQL constraints
Ā 

Viewers also liked

Brandstreaming: an introduction
Brandstreaming: an introductionBrandstreaming: an introduction
Brandstreaming: an introductionJonny rosemont
Ā 
A Little Pumpkin Likes Reading Books
A Little Pumpkin Likes Reading BooksA Little Pumpkin Likes Reading Books
A Little Pumpkin Likes Reading BooksPEPY Empowering Youth
Ā 
2nd Easter A(2)
2nd Easter A(2)2nd Easter A(2)
2nd Easter A(2)Rey An Yatco
Ā 
B.j. mate i
B.j. mate iB.j. mate i
B.j. mate ipabloyasmin
Ā 
Chance challenge change Arise Roby
Chance challenge change   Arise RobyChance challenge change   Arise Roby
Chance challenge change Arise RobyArise Roby
Ā 
The Anatomy Of The Idea
The Anatomy Of The IdeaThe Anatomy Of The Idea
The Anatomy Of The IdeaRick van der Wal
Ā 
Blackwell Esteem AFSL
Blackwell Esteem AFSLBlackwell Esteem AFSL
Blackwell Esteem AFSLsamueltay77
Ā 
Where can tell me who I am?
Where can tell me who I am?Where can tell me who I am?
Where can tell me who I am?seltzoid
Ā 
Why scala - executive overview
Why scala - executive overviewWhy scala - executive overview
Why scala - executive overviewRazvan Cojocaru
Ā 
Parent meeting 2 add sub 2007
Parent meeting 2   add sub 2007Parent meeting 2   add sub 2007
Parent meeting 2 add sub 2007Shane
Ā 
ROR -Igal Assaf Paris sous la neige
ROR -Igal Assaf  Paris sous la neigeROR -Igal Assaf  Paris sous la neige
ROR -Igal Assaf Paris sous la neigeIgal Assaf
Ā 
Sainico & Warom - LED Catalog
Sainico & Warom - LED CatalogSainico & Warom - LED Catalog
Sainico & Warom - LED Catalogsainico
Ā 
Google Ground KiajĆ”nlĆ³
Google Ground KiajĆ”nlĆ³Google Ground KiajĆ”nlĆ³
Google Ground KiajĆ”nlĆ³pontrendezveny
Ā 
205180 cm with jde
205180 cm with jde205180 cm with jde
205180 cm with jdep6academy
Ā 
The new masters of management
The new masters of managementThe new masters of management
The new masters of managementrsoosaar
Ā 
Modul 5 kb 1
Modul 5   kb 1Modul 5   kb 1
Modul 5 kb 1pjj_kemenkes
Ā 

Viewers also liked (20)

Brandstreaming: an introduction
Brandstreaming: an introductionBrandstreaming: an introduction
Brandstreaming: an introduction
Ā 
A Little Pumpkin Likes Reading Books
A Little Pumpkin Likes Reading BooksA Little Pumpkin Likes Reading Books
A Little Pumpkin Likes Reading Books
Ā 
2nd Easter A(2)
2nd Easter A(2)2nd Easter A(2)
2nd Easter A(2)
Ā 
nullcon 2011 - Buffer UnderRun Exploits
nullcon 2011 - Buffer UnderRun Exploitsnullcon 2011 - Buffer UnderRun Exploits
nullcon 2011 - Buffer UnderRun Exploits
Ā 
B.j. mate i
B.j. mate iB.j. mate i
B.j. mate i
Ā 
Chance challenge change Arise Roby
Chance challenge change   Arise RobyChance challenge change   Arise Roby
Chance challenge change Arise Roby
Ā 
The Anatomy Of The Idea
The Anatomy Of The IdeaThe Anatomy Of The Idea
The Anatomy Of The Idea
Ā 
Blackwell Esteem AFSL
Blackwell Esteem AFSLBlackwell Esteem AFSL
Blackwell Esteem AFSL
Ā 
Where can tell me who I am?
Where can tell me who I am?Where can tell me who I am?
Where can tell me who I am?
Ā 
Why scala - executive overview
Why scala - executive overviewWhy scala - executive overview
Why scala - executive overview
Ā 
August 2012
August 2012August 2012
August 2012
Ā 
SGGSWU Prospectus 2016-17
SGGSWU Prospectus 2016-17SGGSWU Prospectus 2016-17
SGGSWU Prospectus 2016-17
Ā 
Parent meeting 2 add sub 2007
Parent meeting 2   add sub 2007Parent meeting 2   add sub 2007
Parent meeting 2 add sub 2007
Ā 
ROR -Igal Assaf Paris sous la neige
ROR -Igal Assaf  Paris sous la neigeROR -Igal Assaf  Paris sous la neige
ROR -Igal Assaf Paris sous la neige
Ā 
Gscm1
Gscm1Gscm1
Gscm1
Ā 
Sainico & Warom - LED Catalog
Sainico & Warom - LED CatalogSainico & Warom - LED Catalog
Sainico & Warom - LED Catalog
Ā 
Google Ground KiajĆ”nlĆ³
Google Ground KiajĆ”nlĆ³Google Ground KiajĆ”nlĆ³
Google Ground KiajĆ”nlĆ³
Ā 
205180 cm with jde
205180 cm with jde205180 cm with jde
205180 cm with jde
Ā 
The new masters of management
The new masters of managementThe new masters of management
The new masters of management
Ā 
Modul 5 kb 1
Modul 5   kb 1Modul 5   kb 1
Modul 5 kb 1
Ā 

Similar to My SQL Idiosyncrasies That Bite OTN

MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFRonald Bradford
Ā 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTNRonald Bradford
Ā 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenNETWAYS
Ā 
Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicSaewoong Lee
Ā 
Mysql56 replication
Mysql56 replicationMysql56 replication
Mysql56 replicationChris Makayal
Ā 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7Eduardo Legatti
Ā 
MySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourMySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourRonald Bradford
Ā 
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
 - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.phpssuserfa5723
Ā 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Mydbops
Ā 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
Ā 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
Ā 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQLJussi Pohjolainen
Ā 
Php forum2015 tomas_final
Php forum2015 tomas_finalPhp forum2015 tomas_final
Php forum2015 tomas_finalBertrand Matthelie
Ā 
Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015mushupl
Ā 
My sql regis_handsonlab
My sql regis_handsonlabMy sql regis_handsonlab
My sql regis_handsonlabsqlhjalp
Ā 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Tesora
Ā 

Similar to My SQL Idiosyncrasies That Bite OTN (20)

MySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SFMySQL Idiosyncrasies That Bite SF
MySQL Idiosyncrasies That Bite SF
Ā 
MySQL SQL Tutorial
MySQL SQL TutorialMySQL SQL Tutorial
MySQL SQL Tutorial
Ā 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTN
Ā 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
Ā 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
Ā 
Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_public
Ā 
Mysql56 replication
Mysql56 replicationMysql56 replication
Mysql56 replication
Ā 
Mysql basics1
Mysql basics1Mysql basics1
Mysql basics1
Ā 
Hanya contoh saja dari xampp
Hanya contoh saja dari xamppHanya contoh saja dari xampp
Hanya contoh saja dari xampp
Ā 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
Ā 
MySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourMySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD Tour
Ā 
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
 - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php - Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
- Php myadmin sql dump-- version 4.0.10.7-- httpwww.php
Ā 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
Ā 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Ā 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Ā 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQL
Ā 
Php forum2015 tomas_final
Php forum2015 tomas_finalPhp forum2015 tomas_final
Php forum2015 tomas_final
Ā 
Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015
Ā 
My sql regis_handsonlab
My sql regis_handsonlabMy sql regis_handsonlab
My sql regis_handsonlab
Ā 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Ā 

More from Ronald Bradford

Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Ronald Bradford
Ā 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsRonald Bradford
Ā 
The History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemThe History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemRonald Bradford
Ā 
Lessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS EnvironmentsLessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS EnvironmentsRonald Bradford
Ā 
Monitoring your technology stack with New Relic
Monitoring your technology stack with New RelicMonitoring your technology stack with New Relic
Monitoring your technology stack with New RelicRonald Bradford
Ā 
MySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNMySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNRonald Bradford
Ā 
Successful MySQL Scalability
Successful MySQL ScalabilitySuccessful MySQL Scalability
Successful MySQL ScalabilityRonald Bradford
Ā 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLRonald Bradford
Ā 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance ImprovementsRonald Bradford
Ā 
LIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBALIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBARonald Bradford
Ā 
IGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBAIGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBARonald Bradford
Ā 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case StudyRonald Bradford
Ā 
Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Ronald Bradford
Ā 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemRonald Bradford
Ā 
MySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementMySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementRonald Bradford
Ā 
Know Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionKnow Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionRonald Bradford
Ā 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersRonald Bradford
Ā 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle DevelopersRonald Bradford
Ā 
The Ideal Performance Architecture
The Ideal Performance ArchitectureThe Ideal Performance Architecture
The Ideal Performance ArchitectureRonald Bradford
Ā 

More from Ronald Bradford (20)

Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1
Ā 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery Essentials
Ā 
The History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemThe History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystem
Ā 
Lessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS EnvironmentsLessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS Environments
Ā 
Monitoring your technology stack with New Relic
Monitoring your technology stack with New RelicMonitoring your technology stack with New Relic
Monitoring your technology stack with New Relic
Ā 
MySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNMySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTN
Ā 
Successful MySQL Scalability
Successful MySQL ScalabilitySuccessful MySQL Scalability
Successful MySQL Scalability
Ā 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQL
Ā 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance Improvements
Ā 
LIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBALIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBA
Ā 
IGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBAIGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBA
Ā 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study
Ā 
Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010
Ā 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and Ecosystem
Ā 
SQL v No SQL
SQL v No SQLSQL v No SQL
SQL v No SQL
Ā 
MySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementMySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object Management
Ā 
Know Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionKnow Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express Edition
Ā 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and Developers
Ā 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle Developers
Ā 
The Ideal Performance Architecture
The Ideal Performance ArchitectureThe Ideal Performance Architecture
The Ideal Performance Architecture
Ā 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
Ā 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...gurkirankumar98700
Ā 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
Ā 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
Ā 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
Ā 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜RTylerCroy
Ā 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
Ā 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Ā 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Ā 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Ā 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Ā 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
Ā 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜
Ā 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Ā 

My SQL Idiosyncrasies That Bite OTN

  • 1. MySQL Idiosyncrasies that BITE MySQL Idiosyncrasies That BITE - 2010.10 Title Ronald Bradford http://ronaldbradford.com OTN LAD Tour 2010 South America 2010.10 Ronald Bradford http://ronaldbradford.com @RonaldBradford #OTN #LAOUC
  • 2. MySQL Idiosyncrasies That BITE - 2010.10 Deļ¬nitions idiosyncrasy [id-ee-uh-sing-kruh-see, -sin-] ā€“noun,plural-sies. A characteristic, habit, mannerism, or the like, that is peculiar to ... http://dictionary.com
  • 3. MySQL Idiosyncrasies That BITE - 2010.10 About RDBMS - Oracle != MySQL Product Age Development philosophies Target audience Developer practices Installed versions
  • 4. MySQL Idiosyncrasies That BITE - 2010.10 Expected RDBMS Characteristics Data Integrity Transactions ACID Data Security ANSI SQL
  • 5. MySQL Idiosyncrasies That BITE - 2010.10 These RDBMS characteristics are NOT enabled by default in MySQL WARNING !!! (*)
  • 6. MySQL Idiosyncrasies That BITE - 2010.10 MySQL Terminology Storage Engines MyISAM - Default InnoDB - Default from MySQL 5.5 Transactions Non Transactional Engine(s) Transactional Engine(s)
  • 7. MySQL Idiosyncrasies That BITE - 2010.10 1. Data Integrity
  • 8. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity - Expected CREATE TABLE orders ( qty TINYINT UNSIGNED NOT NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET latin1; INSERT INTO orders(qty) VALUES (0), (100), (255); SELECT * FROM orders; +-----+---------------------+ | qty | created | +-----+---------------------+ | 0 | 2010-10-25 12:22:22 | | 100 | 2010-10-25 12:22:22 | | 255 | 2010-10-25 12:22:22 | +-----+---------------------+ āœ”
  • 9. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity - Unexpected mysql> INSERT INTO orders (qty) VALUES (-1), (9000); mysql> SELECT * FROM orders; +-----+---------------------+ | qty | created | +-----+---------------------+ | 0 | 2010-10-25 12:22:22 | | 100 | 2010-10-25 12:22:22 | | 255 | 2010-10-25 12:22:22 | | 0 | 2010-10-25 12:23:06 | | 255 | 2010-10-25 12:23:06 | +-----+---------------------+ //CREATE TABLE orders ( // qty TINYINT UNSIGNED NOT NULL, āœ˜
  • 10. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity - Unexpected mysql> INSERT INTO orders (qty) VALUES (-1), (9000); mysql> SELECT * FROM orders; +-----+---------------------+ | qty | created | +-----+---------------------+ | 0 | 2010-10-25 12:22:22 | | 100 | 2010-10-25 12:22:22 | | 255 | 2010-10-25 12:22:22 | | 0 | 2010-10-25 12:23:06 | | 255 | 2010-10-25 12:23:06 | +-----+---------------------+ //CREATE TABLE orders ( // qty TINYINT UNSIGNED NOT NULL, āœ˜ TINYINT is 1 byte. UNSIGNED supports values 0-255
  • 11. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity - Warnings mysql> INSERT INTO orders (qty) VALUES (-1), (9000); Query OK, 2 rows affected, 2 warnings (0.05 sec) mysql> SHOW WARNINGS; +---------+------+----------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------+ | Warning | 1264 | Out of range value for column 'qty' at row 1 | | Warning | 1264 | Out of range value for column 'qty' at row 2 | +---------+------+----------------------------------------------+
  • 12. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity - Unexpected (2) mysql> INSERT INTO customers (name) -> VALUES ('RONALD BRADFORD'), -> ('FRANCISCO MUNOZ ALVAREZ'); mysql> SELECT * FROM customers; +----------------------+ | name | +----------------------+ | RONALD BRADFORD | | FRANCISCO MUNOZ ALVA | +----------------------+ 2 rows in set (0.00 sec) āœ˜
  • 13. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity - Warnings (2) INSERT INTO customers (name) VALUES ('RONALD BRADFORD'), ('FRANCISCO MUNOZ ALVAREZ'); Query OK, 2 rows affected, 1 warning (0.29 sec) mysql> SHOW WARNINGS; +---------+------+-------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------+ | Warning | 1265 | Data truncated for column 'name' at row 2 | +---------+------+-------------------------------------------+
  • 14. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity with Dates - Warnings mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31'); Query OK, 1 row affected, 1 warning (0.00 sec) mysql> SHOW WARNINGS; +---------+------+----------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------+ | Warning | 1265 | Data truncated for column 'd' at row 1 | +---------+------+----------------------------------------+ mysql> SELECT * FROM sample_date; +------------+ | d | +------------+ | 0000-00-00 | +------------+ āœ˜
  • 15. MySQL Idiosyncrasies That BITE - 2010.10 SHOW WARNINGS http://dev.mysql.com/doc/refman/5.1/en/show-warnings.html
  • 16. MySQL Idiosyncrasies That BITE - 2010.10 Using SQL_MODE for Data Integrity SQL_MODE = STRICT_ALL_TABLES; http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html Recommended Conļ¬guration
  • 17. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity - Expected mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES; mysql> TRUNCATE TABLE sample_data; mysql> INSERT INTO sample_data(i) VALUES (0), (100), (255); mysql> INSERT INTO sample_data (i) VALUES (-1), (9000); ERROR 1264 (22003): Out of range value for column 'i' at row 1 mysql> SELECT * FROM sample_data; +-----+------+---------------------+ | i | c | t | +-----+------+---------------------+ | 0 | NULL | 2010-06-06 14:39:48 | | 100 | NULL | 2010-06-06 14:39:48 | | 255 | NULL | 2010-06-06 14:39:48 | +-----+------+---------------------+ 3 rows in set (0.00 sec) āœ”
  • 18. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity with Dates - Expected mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES; mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31'); ERROR 1292 (22007): Incorrect date value: '2010-02-31' for column 'd' at row 1 āœ”
  • 19. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity with Dates - Unexpected mysql> INSERT INTO sample_date (d) VALUES ('2010-00-00'); mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05'); mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00'); mysql> SELECT * FROM sample_date; +------------+ | d | +------------+ | 2010-00-00 | | 2010-00-05 | | 0000-00-00 | +------------+ āœ˜
  • 20. MySQL Idiosyncrasies That BITE - 2010.10 Using SQL_MODE for Date Integrity SQL_MODE = STRICT_ALL_TABLES, NO_ZERO_DATE, NO_ZERO_IN_DATE; http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html Recommended Conļ¬guration
  • 21. MySQL Idiosyncrasies That BITE - 2010.10 Data Integrity with Dates - Expected mysql> SET SESSION SQL_MODE='STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE'; mysql> TRUNCATE TABLE sample_date; mysql> INSERT INTO sample_date (d) VALUES ('2010-00-00'); ERROR 1292 (22007): Incorrect date value: '2010-00-00' for column 'd' at row 1 mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05'); ERROR 1292 (22007): Incorrect date value: '2010-00-05' for column 'd' at row 1 mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00'); ERROR 1292 (22007): Incorrect date value: '0000-00-00' for column 'd' at row 1 mysql> SELECT * FROM sample_date; Empty set (0.00 sec) āœ”
  • 22. MySQL Idiosyncrasies That BITE - 2010.10 2.Transactions
  • 23. MySQL Idiosyncrasies That BITE - 2010.10 Transactions Example - Tables DROP TABLE IF EXISTS parent; CREATE TABLE parent ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, val VARCHAR(10) NOT NULL, PRIMARY KEY (id), UNIQUE KEY (val) ) ENGINE=InnoDB DEFAULT CHARSET latin1; DROP TABLE IF EXISTS child; CREATE TABLE child ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, parent_id INT UNSIGNED NOT NULL, created TIMESTAMP NOT NULL, PRIMARY KEY (id), INDEX (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ) ENGINE=InnoDB DEFAULT CHARSET latin1;
  • 24. MySQL Idiosyncrasies That BITE - 2010.10 Transactions Example - SQL START TRANSACTION; INSERT INTO parent(val) VALUES("a"); INSERT INTO child(parent_id,created) VALUES(LAST_INSERT_ID(),NOW()); # Expecting an error with next SQL INSERT INTO parent(val) VALUES("a"); ROLLBACK; SELECT * FROM parent; SELECT * FROM child;
  • 25. MySQL Idiosyncrasies That BITE - 2010.10 Transactions Example - Expected ... mysql> INSERT INTO parent (val) VALUES("a"); ERROR 1062 (23000): Duplicate entry 'a' for key 'val' mysql> ROLLBACK; mysql> SELECT * FROM parent; Empty set (0.00 sec) mysql> SELECT * FROM child; Empty set (0.00 sec) āœ”
  • 26. MySQL Idiosyncrasies That BITE - 2010.10 Transactions Example - Tables DROP TABLE IF EXISTS parent; CREATE TABLE parent ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, val VARCHAR(10) NOT NULL, PRIMARY KEY (id), UNIQUE KEY (val) ) ENGINE=MyISAM DEFAULT CHARSET latin1; DROP TABLE IF EXISTS child; CREATE TABLE child ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, parent_id INT UNSIGNED NOT NULL, created TIMESTAMP NOT NULL, PRIMARY KEY (id), INDEX (parent_id) ) ENGINE=MyISAM DEFAULT CHARSET latin1; MyISAM is the current default if not speciļ¬ed
  • 27. MySQL Idiosyncrasies That BITE - 2010.10 Transactions Example - Unexpected mysql> INSERT INTO parent (val) VALUES("a"); ERROR 1062 (23000): Duplicate entry 'a' for key 'val' mysql> ROLLBACK; mysql> SELECT * FROM parent; +----+-----+ | id | val | +----+-----+ | 1 | a | +----+-----+ 1 row in set (0.00 sec) mysql> SELECT * FROM child; +----+-----------+---------------------+ | id | parent_id | created | +----+-----------+---------------------+ | 1 | 1 | 2010-06-03 13:53:38 | +----+-----------+---------------------+ 1 row in set (0.00 sec) āœ˜
  • 28. MySQL Idiosyncrasies That BITE - 2010.10 Transactions Example - Unexpected (2) mysql> ROLLBACK; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> SHOW WARNINGS; +---------+-------+------------------------------------- | Level | Code | Message | +---------+------+-------------------------------------- | Warning | 1196 | Some non-transactional changed tables couldn't be rolled back | +---------+------+-------------------------------------- āœ˜
  • 29. MySQL Idiosyncrasies That BITE - 2010.10 Transactions Solution mysql> SET GLOBAL storage_engine=InnoDB; # my.cnf [mysqld] default-storage-engine=InnoDB # NOTE: Requires server restart $ /etc/init.d/mysqld stop $ /etc/init.d/mysqld start http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine Recommended Conļ¬guration
  • 30. MySQL Idiosyncrasies That BITE - 2010.10 Why use Non Transactional Tables? No transaction overhead Much faster Less disk writes Lower disk space requirements Less memory requirements http://dev.mysql.com/doc/refman/5.1/en/storage-engine-compare-transactions.html
  • 31. MySQL Idiosyncrasies That BITE - 2010.10 3.Variable Scope
  • 32. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Example mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> SHOW CREATE TABLE test1G CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 MyISAM is the current default if not speciļ¬ed
  • 33. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Example (2) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | MyISAM | +----------------+--------+ mysql> SET GLOBAL storage_engine='InnoDB'; mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ Changing in MySQL 5.5
  • 34. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Example (3) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ mysql> DROP TABLE test1; mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> SHOW CREATE TABLE test1G CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 āœ˜
  • 35. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Example (4) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+
  • 36. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Example (4) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ mysql> SHOW SESSION VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | MyISAM | +----------------+--------+
  • 37. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Example (4) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ mysql> SHOW SESSION VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | MyISAM | +----------------+--------+ MySQLVariables have two scopes. SESSION & GLOBAL
  • 38. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Syntax SHOW [GLOBAL | SESSION]VARIABLES; SET [GLOBAL | SESSION] variable = value; Default is GLOBAL since 5.0.2 http://dev.mysql.com/doc/refman/5.1/en/user-variables.html http://dev.mysql.com/doc/refman/5.1/en/set-option.html
  • 39. MySQL Idiosyncrasies That BITE - 2010.10 Variable Scope Precautions Persistent connections (e.g. Java) Replication SQL_THREAD Be careful of existing connections!
  • 40. MySQL Idiosyncrasies That BITE - 2010.10 4. Storage Engines
  • 41. MySQL Idiosyncrasies That BITE - 2010.10 Storage Engines Example - Creation CREATE TABLE test1 ( id INT UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET latin1; SHOW CREATE TABLE test1G *************************** 1. row ************* Table: test1 Create Table: CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 āœ˜
  • 42. MySQL Idiosyncrasies That BITE - 2010.10 Storage Engines Example - Creation CREATE TABLE test1 ( id INT UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET latin1; SHOW CREATE TABLE test1G *************************** 1. row ************* Table: test1 Create Table: CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 āœ˜ Even speciļ¬ed the storage engine reverted to the default
  • 43. MySQL Idiosyncrasies That BITE - 2010.10 Storage Engines Example - Unexpected CREATE TABLE test1 ( id INT UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET latin1; Query OK, 0 rows affected, 2 warnings (0.13 sec) SHOW WARNINGS; +---------+------+-----------------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------------+ | Warning | 1286 | Unknown table engine 'InnoDB' | | Warning | 1266 | Using storage engine MyISAM for table 'test1' | +---------+------+-----------------------------------------------+ 2 rows in set (0.00 sec)
  • 44. MySQL Idiosyncrasies That BITE - 2010.10 Storage Engines Example - Cause mysql> SHOW ENGINES; +------------+---------+-------------------------+--------------+ | Engine | Support | Comment | Transactions | +------------+---------+-------------------------+--------------+ | InnoDB | NO | Supports transaction... | NULL | | MEMORY | YES | Hash based, stored i... | NO | | MyISAM | DEFAULT | Default engine as ... | NO |
  • 45. MySQL Idiosyncrasies That BITE - 2010.10 Storage Engines Example - Unexpected (2) mysql> CREATE TABLE test1 id INT UNSIGNED NOT NULL ) ENGINE=InnDB DEFAULT CHARSET latin1; Query OK, 0 rows affected, 2 warnings (0.11 sec) mysql> SHOW WARNINGS; +---------+------+-----------------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------------+ | Warning | 1286 | Unknown table engine 'InnDB' | | Warning | 1266 | Using storage engine MyISAM for table 'test1' | +---------+------+-----------------------------------------------+ āœ˜ Be careful of spelling mistakes as well.
  • 46. MySQL Idiosyncrasies That BITE - 2010.10 Using SQL_MODE for Storage Engines SQL_MODE = STRICT_ALL_TABLES, NO_ZERO_DATE, NO_ZERO_IN_DATE, NO_ENGINE_SUBSTITUTION; http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html Recommended Conļ¬guration
  • 47. MySQL Idiosyncrasies That BITE - 2010.10 Storage Engines Example - Solution SET SESSION SQL_MODE=NO_ENGINE_SUBSTITUTION; DROP TABLE IF EXISTS test3; CREATE TABLE test3 ( id INT UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET latin1; ERROR 1286 (42000): Unknown table engine 'InnoDB' āœ”
  • 48. MySQL Idiosyncrasies That BITE - 2010.10 5.ACID
  • 49. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - All or nothing
  • 50. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Table DROP TABLE IF EXISTS accounts; CREATE TABLE accounts( id INT UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(10) NOT NULL, PRIMARY KEY (id), UNIQUE KEY (username) ) ENGINE=MyISAM DEFAULT CHARSET latin1;
  • 51. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Data INSERT INTO accounts (username) VALUES('jane'),('jo'),('joe'),('joel'),('jame'), ('jamel'); mysql> SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 1 | jane | | 2 | jo | | 3 | joe | | 4 | joel | | 5 | jame | | 6 | jamel | +----+----------+ 6 rows in set (0.00 sec)
  • 52. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Unexpected mysql> UPDATE accounts SET username=CONCAT(username,'l') ERROR 1062 (23000): Duplicate entry 'joel' for key 'username' mysql> SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 1 | janel | | 2 | jol | | 3 | joe | | 4 | joel | | 5 | jame | | 6 | jamel | +----+----------+ 6 rows in set (0.01 sec) āœ˜
  • 53. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Unexpected (2) mysql> ROLLBACK; Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 1 | janel | | 2 | jol | | 3 | joe | | 4 | joel | ... āœ˜
  • 54. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Unexpected (2) mysql> ROLLBACK; Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 1 | janel | | 2 | jol | | 3 | joe | | 4 | joel | ... āœ˜ Rollback has no effect on non transactional tables
  • 55. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Transactional Table CREATE TABLE accounts( id INT UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(10) NOT NULL, PRIMARY KEY (id), UNIQUE KEY (username) ) ENGINE=InnoDB DEFAULT CHARSET latin1; INSERT INTO accounts (username) VALUES('jane'),('jo')... UPDATE accounts SET username=CONCAT(username,'l'); ERROR 1062 (23000): Duplicate entry 'joel' for key 'username' SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 5 | jame | | 6 | jamel | | 1 | jane | | 2 | jo | | 3 | joe | | 4 | joel | āœ”
  • 56. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Transactional Table CREATE TABLE accounts( id INT UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(10) NOT NULL, PRIMARY KEY (id), UNIQUE KEY (username) ) ENGINE=InnoDB DEFAULT CHARSET latin1; INSERT INTO accounts (username) VALUES('jane'),('jo')... UPDATE accounts SET username=CONCAT(username,'l'); ERROR 1062 (23000): Duplicate entry 'joel' for key 'username' SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 5 | jame | | 6 | jamel | | 1 | jane | | 2 | jo | | 3 | joe | | 4 | joel | āœ” Data remains unchanged
  • 57. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Transactional Table mysql> ROLLBACK; Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 5 | jame | | 6 | jamel | | 1 | jane | | 2 | jo | | 3 | joe | | 4 | joel | +----+----------+ āœ˜
  • 58. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Transactional Table mysql> ROLLBACK; Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM accounts; +----+----------+ | id | username | +----+----------+ | 5 | jame | | 6 | jamel | | 1 | jane | | 2 | jo | | 3 | joe | | 4 | joel | +----+----------+ āœ˜ Data remains, INSERT was not rolled back?
  • 59. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - The culprit mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | autocommit | ON | +---------------+-------+
  • 60. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - The culprit mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | autocommit | ON | +---------------+-------+ The default for autocommit is ON. Great care is needed to change the default.
  • 61. MySQL Idiosyncrasies That BITE - 2010.10 Atomicity - Recommendations Always wrap SQL in transactions START TRANSACTION | BEGIN [WORK] COMMIT Recommended Practice
  • 62. MySQL Idiosyncrasies That BITE - 2010.10 Isolation - Transactions do not affect other transactions
  • 63. MySQL Idiosyncrasies That BITE - 2010.10 Transaction Isolation - Levels READ-UNCOMMITTED READ-COMMITTED REPEATABLE-READ SERIALIZABLE http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html http://ronaldbradford.com/blog/understanding-mysql-innodb-transaction-isolation-2009-09-24/ MySQL supports 4 isolation levels
  • 64. MySQL Idiosyncrasies That BITE - 2010.10 Transaction Isolation - Default The default is REPEATABLE-READ SET GLOBAL tx_isolation = 'READ-COMMITTED'; This is a mistake http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/
  • 65. MySQL Idiosyncrasies That BITE - 2010.10 Transaction Isolation - Default The default is REPEATABLE-READ SET GLOBAL tx_isolation = 'READ-COMMITTED'; This is a mistake http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/ Common mistake by Oracle DBA's supporting MySQL
  • 66. MySQL Idiosyncrasies That BITE - 2010.10 Oracle READ COMMITTED != MySQL READ-COMMITTED
  • 67. MySQL Idiosyncrasies That BITE - 2010.10 Transaction Isolation - Binary Logging Errors SET GLOBAL tx_isolation='READ-COMMITTED'; Query OK, 0 rows affected (0.00 sec) mysql> insert into test1 values (1,'x'); ERROR 1598 (HY000): Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' āœ˜ As of 5.1 this requires further conļ¬guration considerations
  • 68. MySQL Idiosyncrasies That BITE - 2010.10 Durability - No committed transactions are lost
  • 69. MySQL Idiosyncrasies That BITE - 2010.10 Data Safety MyISAM writes/ļ¬‚ushes data every statement Does not ļ¬‚ush indexes (*) InnoDB can relax durability ļ¬‚ush all transactions per second innodb_flush_log_at_trx_commit sync_binlog innodb_support_xa
  • 70. MySQL Idiosyncrasies That BITE - 2010.10 Auto Recovery InnoDB has it MyISAM does not - (*) Indexes MYISAM-RECOVER=FORCE,BACKUP REPAIR TABLE myisamchk
  • 71. MySQL Idiosyncrasies That BITE - 2010.10 Recovery Time InnoDB is consistent Redo Log ļ¬le size Slow performance in Undo (*) MyISAM grows with data volume
  • 72. MySQL Idiosyncrasies That BITE - 2010.10 InnoDB Auto Recovery Example InnoDB: Log scan progressed past the checkpoint lsn 0 188755039 100624 16:37:44 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Doing recovery: scanned up to log sequence number 0 193997824 InnoDB: Doing recovery: scanned up to log sequence number 0 195151897 InnoDB: 1 transaction(s) which must be rolled back or cleaned up InnoDB: in total 105565 row operations to undo InnoDB: Trx id counter is 0 18688 100624 16:37:45 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... 99 InnoDB: Apply batch completed InnoDB: Last MySQL binlog file position 0 12051, file name ./binary-log. 000003 InnoDB: Starting in background the rollback of uncommitted transactions ... āœ”
  • 73. MySQL Idiosyncrasies That BITE - 2010.10 MyISAM Repair needed Example 100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/ descriptions' is marked as crashed and should be repaired 100126 22:44:35 [Warning] Checking table: './XXX/descriptions' 100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/taggings' is marked as crashed and should be repaired 100126 22:44:35 [Warning] Checking table: './XXX/taggings' 100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/vehicle' is marked as crashed and should be repaired āœ˜
  • 74. MySQL Idiosyncrasies That BITE - 2010.10 6. Data Security
  • 75. MySQL Idiosyncrasies That BITE - 2010.10 User Privileges - Practices CREATE USER goodguy@localhost IDENTIFIED BY 'sakila'; GRANT CREATE,SELECT,INSERT,UPDATE,DELETE ON odtug.* TO goodguy@localhost; CREATE USER superman@'%'; GRANT ALL ON *.* TO superman@'%'; Best Practice Normal Practice http://dev.mysql.com/doc/refman/5.1/en/create-user.html http://dev.mysql.com/doc/refman/5.1/en/grant.html āœ” āœ˜
  • 76. MySQL Idiosyncrasies That BITE - 2010.10 User Privileges - Normal Bad Practice GRANT ALL ON *.* TO user@ā€™%ā€™ *.* gives you access to all tables in all schemas @ā€™%ā€™ give you access from any external location ALL gives you ALTER,ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE USER, CREATEVIEW, DELETE, DROP, EVENT, EXECUTE, FILE, INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SELECT, SHOW DATABASES, SHOWVIEW, SHUTDOWN, SUPER,TRIGGER, UPDATE, USAGE
  • 77. MySQL Idiosyncrasies That BITE - 2010.10 User Privileges - Why SUPER is bad SUPER Bypasses read_only Bypasses init_connect Can Disable binary logging Change conļ¬guration dynamically No reserved connection
  • 78. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Read Only $ mysql -ugoodguy -psakila odtug mysql> insert into test1(id) values(1); ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement āœ” $ mysql -usuperman odtug mysql> insert into test1(id) values(1); Query OK, 1 row affected (0.01 sec) āœ˜
  • 79. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Read Only $ mysql -ugoodguy -psakila odtug mysql> insert into test1(id) values(1); ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement āœ” $ mysql -usuperman odtug mysql> insert into test1(id) values(1); Query OK, 1 row affected (0.01 sec) āœ˜ Data inconsistency now exists
  • 80. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Init Connect #my.cnf [client] init_connect=SET NAMES utf8 This specifies to use UTF8 for communication with client and data Common conļ¬guration practice to support UTF8
  • 81. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Init Connect (2)
  • 82. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Init Connect (2) $ mysql -ugoodguy -psakila odtug mysql> SHOW SESSION VARIABLES LIKE 'ch%'; +--------------------------+----------+ | Variable_name | Value | +--------------------------+----------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+----------+ āœ”
  • 83. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Init Connect (2) $ mysql -usuperman odtug mysql> SHOW SESSION VARIABLES LIKE 'character%'; +--------------------------+----------+ | Variable_name | Value | +--------------------------+----------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+----------+ $ mysql -ugoodguy -psakila odtug mysql> SHOW SESSION VARIABLES LIKE 'ch%'; +--------------------------+----------+ | Variable_name | Value | +--------------------------+----------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+----------+ āœ” āœ˜
  • 84. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Init Connect (2) $ mysql -usuperman odtug mysql> SHOW SESSION VARIABLES LIKE 'character%'; +--------------------------+----------+ | Variable_name | Value | +--------------------------+----------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+----------+ $ mysql -ugoodguy -psakila odtug mysql> SHOW SESSION VARIABLES LIKE 'ch%'; +--------------------------+----------+ | Variable_name | Value | +--------------------------+----------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+----------+ āœ” āœ˜ Data integrity can be compromised
  • 85. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Binary Log mysql> SHOW MASTER STATUS; +-------------------+----------+--------------+------------------+ | binary-log.000017 | 4488 | | | +-------------------+----------+--------------+------------------+ mysql> DELETE FROM sales WHERE id=23; mysql> SET SQL_LOG_BIN=0; mysql> DELETE FROM sales WHERE id=80; mysql> SET SQL_LOG_BIN=1; mysql> DELETE FROM sales WHERE id=99; mysql> SHOW MASTER STATUS; +-------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +-------------------+----------+--------------+------------------+ | binary-log.000017 | 4580 | | | +-------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
  • 86. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and Binary Log (2) # at 4488 #101025 12:57:24 server id 1 end_log_pos 4580 Query thread_id=1 exec_time=0 error_code=0 SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; DELETE FROM sales WHERE id=23 /*!*/; # at 4580 #101025 13:01:26 server id 1 end_log_pos 4672 Query thread_id=1 exec_time=0 error_code=0 SET TIMESTAMP=1288018886/*!*/; DELETE FROM sales WHERE id=99 /*!*/; DELIMITER ; āœ˜ Data auditability is now compromised
  • 87. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and reserved connection $ mysql -uroot mysql> show global variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 3 | +-----------------+-------+ 1 row in set (0.07 sec) mysql> show global status like 'threads_connected'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 4 | +-------------------+-------+ āœ” When connected correctly, 1 connection is reserved for SUPER
  • 88. MySQL Idiosyncrasies That BITE - 2010.10 SUPER and reserved connection - Unexpected $ mysql -uroot ERROR 1040 (HY000): Too many connections mysql> SHOW PROCESSLIST; +----+------+-----------+-------+---------+------+------------+--------------- | Id | User | Host | db | Command | Time | State | Info +----+------+-----------+-------+---------+------+------------+--------------- | 13 | root | localhost | odtug | Query | 144 | User sleep | UPDATE test1 ... | 14 | root | localhost | odtug | Query | 116 | Locked | select * from test1 | 15 | root | localhost | odtug | Query | 89 | Locked | select * from test1 āœ˜ When application users all use SUPER, administrator can't diagnose problem
  • 89. MySQL Idiosyncrasies That BITE - 2010.10 7. ANSI SQL
  • 90. MySQL Idiosyncrasies That BITE - 2010.10 Group By Example SELECT country, COUNT(*) AS color_count FROM flags GROUP BY country; +-----------+-------------+ | country | color_count | +-----------+-------------+ | Australia | 3 | | Canada | 2 | | Japan | 2 | | Sweden | 2 | | USA | 3 | +-----------+-------------+ SELECT country, COUNT(*) FROM flags; +-----------+----------+ | country | COUNT(*) | +-----------+----------+ | Australia | 12 | +-----------+----------+ āœ” āœ˜
  • 91. MySQL Idiosyncrasies That BITE - 2010.10 Group By Example (2) SET SESSION sql_mode=ONLY_FULL_GROUP_BY; SELECT country, COUNT(*) FROM flags; ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause http://ExpertPHPandMySQL.com Chapter 1 - Pg 31 āœ”
  • 92. MySQL Idiosyncrasies That BITE - 2010.10 Using SQL_MODE for ANSI SQL SQL_MODE = STRICT_ALL_TABLES, NO_ZERO_DATE, NO_ZERO_IN_DATE, NO_ENGINE_SUBSTITUTION, ONLY_FULL_GROUP_BY; Recommended Conļ¬guration
  • 93. MySQL Idiosyncrasies That BITE - 2010.10 8. Case Sensitivity
  • 94. MySQL Idiosyncrasies That BITE - 2010.10 Case Sensitivity String Comparison SELECT 'OTN' = UPPER('otn'); +----------------------+ | 'OTN' = UPPER('otn') | +----------------------+ | 1 | +----------------------+ SELECT 'OTN' = 'OTN' AS same, 'OTN' = 'Otn' as initcap, 'OTN' = 'otn' as lowercase, 'OTN' = 'otn' COLLATE latin1_general_cs AS different; +------+---------+-----------+-----------+ | same | initcap | lowercase | different | +------+---------+-----------+-----------+ | 1 | 1 | 1 | 0 | +------+---------+-----------+-----------+ SELECT name, address, email FROM customer WHERE name = UPPER('bradford') āœ˜This practice is unnecessary as does not utilize index if exists
  • 95. MySQL Idiosyncrasies That BITE - 2010.10 Case Sensitivity Tables # Server 1 mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> INSERT INTO test1 VALUES(1); mysql> INSERT INTO TEST1 VALUES(2); # Server 2 mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> INSERT INTO test1 VALUES(1); mysql> INSERT INTO TEST1 VALUES(2); ERROR 1146 (42S02): Table 'test.TEST1' doesn't exist
  • 96. MySQL Idiosyncrasies That BITE - 2010.10 Case Sensitivity Tables (2) - Operating Speciļ¬c Settings # Server 1 - Mac OS X / Windows Default mysql> SHOW GLOBAL VARIABLES LIKE 'lower%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_file_system | ON | | lower_case_table_names | 2 | +------------------------+-------+ # Server 2 - Linux Default mysql> SHOW GLOBAL VARIABLES LIKE 'lower%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_file_system | OFF | | lower_case_table_names | 0 | +------------------------+-------+ Be careful.This default varies depending on Operating System
  • 97. MySQL Idiosyncrasies That BITE - 2010.10 Other Gotchas
  • 98. MySQL Idiosyncrasies That BITE - 2010.10 Other features the BITE Character Sets Data/Client/Application/Web Sub Queries Rewrite as JOIN when possible Views No always efļ¬cient Cascading Conļ¬guration Files SQL_MODE's not to use
  • 99. MySQL Idiosyncrasies That BITE - 2010.10 Conclusion
  • 100. MySQL Idiosyncrasies That BITE - 2010.10 DON'T ASSUME
  • 101. MySQL Idiosyncrasies That BITE - 2010.10 Conclusion - SQL_MODE SQL_MODE = ALLOW_INVALID_DATES,ANSI_QUOTES, ERROR_FOR_DIVISION_ZERO, HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER, NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES, NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION, NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS, NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE, NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY (5.1.11), PAD_CHAR_TO_FULL_LENGTH (5.1.20), PIPES_AS_CONCAT, REAL_AS_FLOAT,STRICT_ALL_TABLES, STRICT_TRANS_TABLES ANSI, DB2, MAXDB, MSSQL, MYSQL323, MYSQL40, ORACLE, POSTGRESQL,TRADITIONAL http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html āœ”
  • 102. MySQL Idiosyncrasies That BITE - 2010.10 Conclusion - SQL_MODE SQL_MODE = ALLOW_INVALID_DATES,ANSI_QUOTES, ERROR_FOR_DIVISION_ZERO, HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER, NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES, NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION, NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS, NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE, NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY (5.1.11), PAD_CHAR_TO_FULL_LENGTH (5.1.20), PIPES_AS_CONCAT, REAL_AS_FLOAT,STRICT_ALL_TABLES, STRICT_TRANS_TABLES ANSI, DB2, MAXDB, MSSQL, MYSQL323, MYSQL40, ORACLE, POSTGRESQL,TRADITIONAL http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html āœ” āœ˜ ?
  • 103. MySQL Idiosyncrasies That BITE - 2010.10 RonaldBradford.com MySQL4OracleDBA.com