blob: b1a325c0ccc8366fea94d59472e64adc82f5fd7d [file] [log] [blame]
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Dist SQL on ShardingSphere</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/dist-sql/</link>
<description>Recent content in Dist SQL on ShardingSphere</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<atom:link href="https://shardingsphere.apache.org/document/current/cn/features/dist-sql/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>RDL</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/dist-sql/rdl/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/dist-sql/rdl/</guid>
<description>定义 RDL(Resource &amp;amp; Rule Definition Language)用于定义数据源资源、创建规则等。
RDL 主要包括以下 SQL 内容:
Create DATASOURCES,用于注入数据源信息。 // SQL CREATE DATASOURCES ( ds_key=host_name:host_port:db_name:user_name:pwd [, ds_key=host_name:host_port:db_name:user_name:pwd, ...] ) // Example CREATE datasources ( ds0=127.0.0.1:3306:demo_ds_0:root:pwd, ds1=127.0.0.1:3306:demo_ds_1:root:pwd) CREATE SHARDING RULE,用于配置分片规则。 // SQL CREATE SHARDING RULE ( sharding_table_name=sharding_algorithm(algorithm_property[, algothrim_property]) [, sharding_table_name=sharding_algorithm_type(algorithm_property[, algothrim_property]), ...] ) sharding_algorithm_type: {MOD | HASH_MODE} mod_algorithm_properties: sharding_column,shards_amount mod_hash_algorithm_properties: sharding_column,shards_amount // Example CREATE SHARDING RULE ( t_order=hash_mod(order_id, 4), t_item=mod(item_id, 2) ) 使用实战 前置工作 启动MySQL服务 创建MySQL数据库(参考ShardingProxy数据源配置规则) 为ShardingProxy创建一个拥有创建权限的角色或者用户 启动Zookeeper服务 (为了持久化配置) 启动ShardingProxy 添加 governance 和 authentication 配置参数到 server.</description>
</item>
<item>
<title>RQL</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/dist-sql/rql/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/dist-sql/rql/</guid>
<description>定义 RDL(Resource &amp;amp; Rule Query Language)用于查询已有的数据源资源和规则。
TODO</description>
</item>
<item>
<title>SCTL</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/dist-sql/sctl/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/dist-sql/sctl/</guid>
<description>定义 SCTL (ShardingSphere Control Language) 为 Apache ShardingSphere 的控制语言,负责Hint、事务类型切换、分片执行计划查询等增量功能的操作。
使用实战 语句 说明 sctl:set transaction_type=XX 修改当前连接的事务类型, 支持LOCAL,XA,BASE。例:sctl:set transaction_type=XA sctl:show transaction_type 查询当前连接的事务类型 sctl:show cached_connections 查询当前连接中缓存的物理数据库连接个数 sctl:explain SQL 查看逻辑 SQL 的执行计划,例:sctl:explain select * from t_order; sctl:hint set PRIMARY_ONLY=true 针对当前连接,是否将数据库操作强制路由到主库 sctl:hint set DatabaseShardingValue=yy 针对当前连接,设置 hint 仅对数据库分片有效,并添加分片值,yy:数据库分片值 sctl:hint addDatabaseShardingValue xx=yy 针对当前连接,为表 xx 添加分片值 yy,xx:逻辑表名称,yy:数据库分片值 sctl:hint addTableShardingValue xx=yy 针对当前连接,为表 xx 添加分片值 yy,xx:逻辑表名称,yy:表分片值 sctl:hint clear 针对当前连接,清除 hint 所有设置 sctl:hint show status 针对当前连接,查询 hint 状态,primary_only:true/false,sharding_type:databases_only/databases_tables sctl:hint show table status 针对当前连接,查询逻辑表的 hint 分片值 注意事项 ShardingSphere-Proxy 默认不支持 hint,如需支持,请在 conf/server.</description>
</item>
</channel>
</rss>