RAL (Resource & Rule Administration Language) responsible for hint, circuit breaker, configuration import and export, scaling control and other management functions.

Hint

StatementFunctionExample
SET READWRITE_SPLITTING HINT SOURCE = [auto / write]For current connection, set readwrite splitting routing strategy (automatic or forced to write data source)SET READWRITE_SPLITTINGHINT SOURCE = write
SET SHARDING HINT DATABASE_VALUE = yyFor current connection, set sharding value for database sharding only, yy: sharding valueSET SHARDING HINT DATABASE_VALUE = 100
ADD SHARDING HINT DATABASE_VALUE xx = yyFor current connection, add sharding value for table, xx: logic table, yy: database sharding valueADD SHARDING HINT DATABASE_VALUE t_order = 100
ADD SHARDING HINT TABLE_VALUE xx = yyFor current connection, add sharding value for table, xx: logic table, yy: table sharding valueADD SHARDING HINT TABLE_VALUE t_order = 100
CLEAR HINTFor current connection, clear all hint settingsCLEAR HINT
CLEAR [SHARDING HINT / READWRITE_SPLITTING HINT]For current connection, clear hint settings of sharding or readwrite splittingCLEAR READWRITE_SPLITTING HINT
SHOW [SHARDING / READWRITE_SPLITTING] HINT STATUSFor current connection, query hint settings of sharding or readwrite splittingSHOW READWRITE_SPLITTING HINT STATUS

Migration

StatementFunctionExample
MIGRATE TABLE ds.schema.table INTO tableMigrate table from source to targetMIGRATE TABLE ds_0.public.t_order INTO t_order
SHOW MIGRATION LISTQuery running listSHOW MIGRATION LIST
SHOW MIGRATION STATUS jobIdQuery migration statusSHOW MIGRATION STATUS 1234
STOP MIGRATION jobIdStop migrationSTOP MIGRATION 1234
START MIGRATION jobIdStart stopped migrationSTART MIGRATION 1234
ROLLBACK MIGRATION jobIdRollback migrationROLLBACK MIGRATION 1234
COMMIT MIGRATION jobIdCommit migrationCOMMIT MIGRATION 1234
CHECK MIGRATION jobIdData consistency checkCHECK MIGRATION 1234
SHOW MIGRATION CHECK ALGORITHMSShow available consistency check algorithmsSHOW MIGRATION CHECK ALGORITHMS
CHECK MIGRATION jobId (by type(name=algorithmTypeName)?Data consistency check with defined algorithmCHECK MIGRATION 1234 by type(name=”DATA_MATCH”)

Circuit Breaker

StatementFunctionExample
[ENABLE / DISABLE] READWRITE_SPLITTING (READ)? resourceName [FROM databaseName]Enable or disable read data sourceENABLE READWRITE_SPLITTING READ resource_0
[ENABLE / DISABLE] INSTANCE instanceIdEnable or disable proxy instanceDISABLE INSTANCE instance_1
SHOW INSTANCE LISTQuery proxy instance informationSHOW INSTANCE LIST
SHOW READWRITE_SPLITTING (READ)? resourceName [FROM databaseName]Query all read resources statusSHOW READWRITE_SPLITTING READ RESOURCES

Global Rule

StatementFunctionExample
SHOW AUTHORITY RULEQuery authority rule configurationSHOW AUTHORITY RULE
SHOW TRANSACTION RULEQuery transaction rule configurationSHOW TRANSACTION RULE
SHOW SQL_PARSER RULEQuery SQL parser rule configurationSHOW SQL_PARSER RULE
ALTER TRANSACTION RULE(DEFAULT=xx,TYPE(NAME=xxx, PROPERTIES(key1=value1,key2=value2…)))Alter transaction rule configuration, DEFAULT: default transaction type, support LOCAL, XA, BASE; NAME: name of transaction manager, support Atomikos, Narayana and BitronixALTER TRANSACTION RULE(DEFAULT=”XA”,TYPE(NAME=”Narayana”, PROPERTIES(“databaseName”=”jbossts”,“host”=”127.0.0.1”)))
ALTER SQL_PARSER RULE SQL_COMMENT_PARSE_ENABLE=xx, PARSE_TREE_CACHE(INITIAL_CAPACITY=xx, MAXIMUM_SIZE=xx, CONCURRENCY_LEVEL=xx), SQL_STATEMENT_CACHE(INITIAL_CAPACITY=xxx, MAXIMUM_SIZE=xxx, CONCURRENCY_LEVEL=xxx)Alter SQL parser rule configuration, SQL_COMMENT_PARSE_ENABLE: whether to parse the SQL comment, PARSE_TREE_CACHE: local cache configuration of syntax tree, SQL_STATEMENT_CACHE: local cache of SQL statementALTER SQL_PARSER RULE SQL_COMMENT_PARSE_ENABLE=false, PARSE_TREE_CACHE(INITIAL_CAPACITY=10, MAXIMUM_SIZE=11, CONCURRENCY_LEVEL=1), SQL_STATEMENT_CACHE(INITIAL_CAPACITY=11, MAXIMUM_SIZE=11, CONCURRENCY_LEVEL=100)

Other

StatementFunctionExample
SHOW INSTANCE INFOQuery the instance information of the proxySHOW INSTANCE INFO
SHOW MODE INFOQuery the mode configuration of the proxySHOW MODE INFO
SET VARIABLE proxy_property_name = xxproxy_property_name is one of properties configuration of proxy, name is split by underscoreSET VARIABLE sql_show = true
SET VARIABLE transaction_type = xxModify transaction_type of the current connection, supports LOCAL, XA, BASESET VARIABLE transaction_type = “XA”
SET VARIABLE agent_plugins_enabled = [TRUE / FALSE]Set whether the agent plugins are enabled, the default value is falseSET VARIABLE agent_plugins_enabled = TRUE
SHOW ALL VARIABLESQuery proxy all properties configurationSHOW ALL VARIABLES
SHOW VARIABLE variable_nameQuery proxy variable, name is split by underscoreSHOW VARIABLE sql_show
REFRESH TABLE METADATARefresh the metadata of all tablesREFRESH TABLE METADATA
REFRESH TABLE METADATA tableNameRefresh the metadata of the specified tableREFRESH TABLE METADATA t_order
REFRESH TABLE METADATA tableName FROM RESOURCE resourceNameRefresh the tables’ metadata in the specified data sourceREFRESH TABLE METADATA t_order FROM RESOURCE ds_1
REFRESH TABLE METADATA FROM RESOURCE resourceName SCHEMA schemaNameRefresh the tables’ metadata in a schema of a specified data source. If there are no tables in the schema, the schema will be deleted.REFRESH TABLE METADATA FROM RESOURCE ds_1 SCHEMA db_schema
SHOW TABLE METADATA tableName [, tableName] …Query table metadataSHOW TABLE METADATA t_order
EXPORT DATABASE CONFIG [FROM database_name] [, file=”file_path”]Export resources and rule configurations to YAML formatEXPORT DATABASE CONFIG FROM readwrite_splitting_db
IMPORT DATABASE CONFIG FILE=”file_path”Import resources and rule configuration from YAML, only supports import into an empty databaseIMPORT DATABASE CONFIG FILE = “/xxx/config-sharding.yaml”
SHOW RULES USED RESOURCE resourceName [from database]Query the rules for using the specified resource in databaseSHOW RULES USED RESOURCE ds_0 FROM databaseName

Notice

ShardingSphere-Proxy does not support hint by default, to support it, set proxy-hint-enabled to true in conf/server.yaml.