25. RANGE COLUMNS
パーティショニング例 1
create table t1 (
id int unsigned not null auto_increment,
year_ smallint not null,
month_ tinyint unsigned not null,
primary key(id,year_,month_)
) partition by range columns (year_,month_) (
partition p1 values less than (2000, 4),
partition p2 values less than (2001, 8),
partition p3 values less than (2004, 11),
partition p4 values less than (2008, 2),
partition p5 values less than (2010, 3),
partition p6 values less than (2011, 4),
partition p7 values less than (maxvalue,
maxvalue)
);
26. EXPLAIN - RANGE COLUMNS
mysql> explain partitions
-> select * from t1
-> where year_ = 2008G
*************************** 1. row
***************************
id: 1
select_type: SIMPLE
table: t1
partitions: p4,p5
type: index
possible_keys: NULL
key: PRIMARY
key_len: 7
ref: NULL
rows: 8193
Extra: Using where; Using index
1 row in set (0.00 sec)
27. RANGE COLUMNS
パーティショニング例 2
create table t2 (
id int unsigned not null auto_increment,
mydate date not null,
primary key(id,mydate)
) partition by range columns (mydate) (
partition p1 values less than ('2000-04-01'),
partition p2 values less than ('2001-08-01'),
partition p3 values less than ('2004-11-01'),
partition p4 values less than ('2008-01-01'),
partition p5 values less than ('2010-03-01'),
partition p6 values less than ('2011-04-01'),
partition p7 values less than (maxvalue)
);
28. LIST COLUMNS
パーティショニング例
create table t3 (
id int unsigned not null auto_increment,
gender char(10),
flag tinyint unsigned not null,
primary key (id, gender, flag)
) partition by list columns (gender, flag) (
partition p1 values in (('male', 0)),
partition p2 values in (('female', 0)),
partition p3 values in (('male', 1)),
partition p4 values in (('female', 1)),
partition p5 values in (('unknown', 0),
('unknown',1))
);
36. SIGNAL
●
ストアドルーチン内で自発的にエラーを発生させる。
delimiter //
create trigger t4_bi before insert on t4
for each row begin
if NEW.a >= 100 then
signal SQLSTATE VALUE '42000'
set MESSAGE_TEXT =
'The column `a` value should be less than 100.';
end if;
end;//
delimiter ;
37. RESIGNAL
●
HANDLER 内で SIGNAL を再度発生させる。
DROP TABLE IF EXISTS xx;
delimiter //
CREATE PROCEDURE p ()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SET @error_count = @error_count + 1;
IF @a = 0 THEN RESIGNAL; END IF;
END;
DROP TABLE xx;
END//
delimiter ;
SET @error_count = 0;
SET @a = 0;
CALL p();
42. 起きるんです。。。
バックアップ不具合
OS のエラー
Table is full Out Of Memory
MySQL Enterprise Monitor
接続エラー
テーブルコラプション
リストア出来ない デッドロック
レプリケーション停止
文字化け
サーバが起動しない
性能劣化 スレーブの遅延
起動に時間がかかる
クラッシュ クエリの実行結果がおかしい
ログインできない Too many connections
データロスト SQL インジェクション