- 论坛徽章:
- 0
|
我试了下是可以的,版本是5.1.42
mysql [localhost] {msandbox} (test) > create table t_partition(
-> id int(5),
-> time timestamp,
-> name char(5)
-> )
-> partition by range (id) (
-> partition p0 values less than (3),
-> partition p1 values less than (6),
-> partition p2 values less than MAXVALUE
-> );
Query OK, 0 rows affected (0.06 sec)
mysql [localhost] {msandbox} (test) > select * from t_partition;
+------+---------------------+------+
| id | time | name |
+------+---------------------+------+
| 1 | 2010-02-05 15:38:39 | aa |
| 2 | 2010-02-05 15:38:39 | bb |
| 3 | 2010-02-05 15:38:39 | cc |
| 4 | 2010-02-05 15:38:39 | dd |
| 5 | 2010-02-05 15:38:39 | ee |
| 6 | 2010-02-05 15:38:39 | ff |
| 7 | 2010-02-05 15:38:39 | gg |
| 8 | 2010-02-05 15:38:39 | hh |
+------+---------------------+------+
8 rows in set (0.00 sec)
mysql [localhost] {msandbox} (test) > explain partitions select * from t_partition where id=1 and time< now();
+----+-------------+-------------+------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | t_partition | p0 | ALL | NULL | NULL | NULL | NULL | 8 | Using where |
+----+-------------+-------------+------------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
mysql [localhost] {msandbox} (test) > explain partitions select * from t_partition where time< now();
+----+-------------+-------------+------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | t_partition | p0,p1,p2 | ALL | NULL | NULL | NULL | NULL | 8 | Using where |
+----+-------------+-------------+------------+------+---------------+------+---------+------+------+-------------+ |
|