3.8 Hint

3.8.1 分库分表-Syntax

/* { ! | #}dble: {sql=SELECT select_expr  FROM  table_references  WHERE  where_condition

                 |shardingNode=shardingNode_name

                 |db_type={slave|master}}

*/   ordinary_sql

3.8.2 读写分离-Syntax

/* { ! | #}dble: {db_type={slave|master}}

                 |db_instance_url={ip:port}}

*/   ordinary_sql
/* master */  ordinary_sql
/* uproxy_dest: ip:port */  ordinary_sql

注意:

  • 在不影响sql语句完整性的前提下,/* master *//* uproxy_dest: ip:port */可放在sql语句的首尾和中间

3.8.3 举例

/*!dble:sql=select 1 from sbtest */ call p_show_time();
/*!dble:shardingNode=dn1*/ update sbtest set name = 'test';
/*!dble:db_type=master*/ select count(*) from sbtest;
/*!dble:db_instance_url=127.0.0.1:3307*/ select count(*) from sbtest;
/*#dble:sql=select 1 from sbtest */ call p_show_time();
/*#dble:shardingNode=dn1*/ update sbtest set name = 'test';
/*#dble:db_type=master*/ select count(*) from sbtest;
/*#dble:db_instance_url=127.0.0.1:3307*/ select count(*) from sbtest;
select /* master */ * from sbtest;
show processlist /* uproxy_dest: 127.0.0.1:3307 */

results matching ""

    No results matching ""