一、select
mysql> select * from test1 where a=2;+——+——+———+| a | b | c |+——+——+———+| 2 | 3 | record2 || 2 | 4 | record3 |+——+——+———+2 rows in set (0.00 sec)
二、insert/replace
字段必须包含 shardkey,否则会拒绝执行该 SQL,因为 proxy 不知道将该 SQL 发往哪个后端数据库:
mysql> insert into test1 (b,c) values(4,"record3");ERROR 810 (HY000): Proxy ERROR:sql is too complex,need to send to only noshard table. Shard table insert must has field specmysql> insert into test1 (a,c) values(4,"record3");Query OK, 1 row affected (0.01 sec)
三、delete/update
使用分表时,为安全考虑,执行该类 SQL 时,必须带有 where 条件,否则拒绝执行该 SQL 命令:
mysql> delete from test1;ERROR 810 (HY000): Proxy ERROR:sql is too complex,need to send to only noshard table. Shard table delete/update must have a where clausemysql> delete from test1 where a=1;Query OK, 1 row affected (0.01 sec)