Partitionierung in MySQL 5.1 kommt nur mit Integer-Spalten zurecht (Quelle). Auf Nicht-Integer-Spalten sind nur wenige Partitionsfunktionen anwendbar. Zum Beispiel:
CREATE TABLE ti (id INT, amount DECIMAL(7,2), tr_date DATE) ENGINE=INNODB PARTITION BY HASH( MONTH(tr_date) ) PARTITIONS 6;Key-Partitionierung funktioniert in 5.1 ebenfalls, sofern der Primärschlüssel alle Spalten der Partitionsfunktion enthält:
CREATE TABLE k1 ( id CHAR(3) NOT NULL PRIMARY KEY, value int ) PARTITION BY KEY(id) PARTITIONS 10;Ab MySQL 5.5 stehen mit Range Columns und List Columns Partitionierungen für viele Datentypen inklusive Zeichenketten zur Verfügung.
List Columns Beispiel:
CREATE TABLE expenses ( expense_date DATE NOT NULL, category VARCHAR(30), amount DECIMAL (10,3) ); ALTER TABLE expenses PARTITION BY LIST COLUMNS (category) ( PARTITION p01 VALUES IN ('lodging', 'food'), PARTITION p02 VALUES IN ('flights', 'ground transportation'), PARTITION p03 VALUES IN ('leisure', 'customer entertainment'), PARTITION p04 VALUES IN ('communications'), PARTITION p05 VALUES IN ('fees') );Range Columns Beispiel:
CREATE TABLE range_test ( code CHAR(3), value INT ) PARTITION BY RANGE COLUMNS(code) ( PARTITION p0 VALUES LESS THAN ('MMM'), PARTITION p1 VALUES LESS THAN ('ZZZ') );Weiterführend:
- MySQL 5.1 Reference Manual :: Key partitioning
- A deep look at MySQL 5.5 partitioning enhancements
- MySQL 5.5 Reference Manual :: Range columns partitioning
- MySQL 5.5 Reference Manual :: List columns partitioning