SQL_Translator #
语法 | 描述 | 类型 |
---|---|---|
ALTER SQL_TRANSLATOR RULE | 更新 SQL 翻译规则配置 | RAL |
SHOW SQL_TRANSLATOR RULE | 查询 SQL 翻译规则配置 | RAL |
1. 更新 SQL 翻译规则配置 #
alterSQLTranslatorRule
: ALTER SQL_TRANSLATOR RULE ( sqlTranslatorRuleDefinition )
;
sqlTranslatorRuleDefinition
: algorithmDefinition (, useOriginalSQLDefinition)? (, sqlTranslatorCacheDefinition)?
;
useOriginalSQLDefinition
: USE_ORIGINAL_SQL_WHEN_TRANSLATING_FAILED = useOriginalSQL
;
useOriginalSQL
: TRUE | FALSE
;
sqlTranslatorCacheDefinition
: SQL_TRANSLATOR_CACHE ( cacheOption )
;
cacheOption
: (INITIAL_CAPACITY = initialCapacity)? (,? MAXIMUM_SIZE = maximumSize)?
;
参数说明
USE_ORIGINAL_SQL_WHEN_TRANSLATING_FAILED
翻译失败时是否使用原始 SQL,默认值为 falseSQL_TRANSLATOR_CACHE
SQL 翻译缓存配置
示例
ALTER SQL_TRANSLATOR RULE (
TYPE(NAME="NATIVE"),
USE_ORIGINAL_SQL_WHEN_TRANSLATING_FAILED=TRUE,
SQL_TRANSLATOR_CACHE(INITIAL_CAPACITY=2000, MAXIMUM_SIZE=65535)
);
2. 查询 SQL 翻译规则配置 #
SHOW SQL_TRANSLATOR RULE
输出说明
列 | 说明 |
---|---|
type | SQL 翻译器类型 |
props | SQL 翻译器参数 |
use_original_sql_when_translating_failed | 翻译失败时是否使用原始 SQL |
sql_translator_cache | SQL 翻译缓存配置 |
示例
mysql> SHOW SQL_TRANSLATOR RULE;
+--------+-------+------------------------------------------+-------------------------------------------+
| type | props | use_original_sql_when_translating_failed | sql_translator_cache |
+--------+-------+------------------------------------------+-------------------------------------------+
| NATIVE | | true | initialCapacity: 2000, maximumSize: 65535 |
+--------+-------+------------------------------------------+-------------------------------------------+
1 row in set (0.02 sec)