CREATE PLACEMENT POLICY

CREATE PLACEMENT POLICY 用于创建命名的放置策略,随后可以将该策略分配给表、分区或数据库。

语法图

CreatePolicyStmt
CREATEPLACEMENTPOLICYIfNotExistsPolicyNamePlacementOptionList
PolicyName
Identifier
PlacementOptionList
PlacementOptionPlacementOptionListPlacementOptionPlacementOptionList,PlacementOption
PlacementOption
CommonPlacementOptionSugarPlacementOptionAdvancedPlacementOption
CommonPlacementOption
FOLLOWERSEqOptLengthNum
SugarPlacementOption
PRIMARY_REGIONEqOptstringLitREGIONSEqOptstringLitSCHEDULEEqOptstringLit
AdvancedPlacementOption
LEARNERSEqOptLengthNumCONSTRAINTSEqOptstringLitLEADER_CONSTRAINTSEqOptstringLitFOLLOWER_CONSTRAINTSEqOptstringLitLEARNER_CONSTRAINTSEqOptstringLitSURVIVAL_PREFERENCESEqOptstringLit

示例

CREATE PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4; CREATE TABLE t1 (a INT) PLACEMENT POLICY=p1; SHOW CREATE PLACEMENT POLICY p1;
Query OK, 0 rows affected (0.08 sec) Query OK, 0 rows affected (0.10 sec) +--------+---------------------------------------------------------------------------------------------------+ | Policy | Create Policy | +--------+---------------------------------------------------------------------------------------------------+ | p1 | CREATE PLACEMENT POLICY `p1` PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4 | +--------+---------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)

MySQL 兼容性

该语句是 TiDB 对 MySQL 语法的扩展。

另请参阅