Logo
SQL Translator

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,默认值为 false
  • SQL_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

输出说明

说明
typeSQL 翻译器类型
propsSQL 翻译器参数
use_original_sql_when_translating_failed翻译失败时是否使用原始 SQL
sql_translator_cacheSQL 翻译缓存配置

示例

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)