ALTER PLACEMENT POLICY
ALTER PLACEMENT POLICY
is used to modify existing placement policies that have previously been created. All the tables and partitions which use the placement policy will automatically be updated.
ALTER PLACEMENT POLICY
replaces the previous policy with the new definition. It does not merge the old policy with the new one. In the following example, FOLLOWERS=4
is lost when the ALTER PLACEMENT POLICY
is executed:
CREATE PLACEMENT POLICY p1 FOLLOWERS=4;
ALTER PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1";
Synopsis
- AlterPolicyStmt
- PolicyName
- PlacementOptionList
- PlacementOption
- CommonPlacementOption
- SugarPlacementOption
- AdvancedPlacementOption
AlterPolicyStmt ::=
"ALTER" "PLACEMENT" "POLICY" IfExists PolicyName PlacementOptionList
PolicyName ::=
Identifier
PlacementOptionList ::=
PlacementOption
| PlacementOptionList PlacementOption
| PlacementOptionList ',' PlacementOption
PlacementOption ::=
CommonPlacementOption
| SugarPlacementOption
| AdvancedPlacementOption
CommonPlacementOption ::=
"FOLLOWERS" EqOpt LengthNum
SugarPlacementOption ::=
"PRIMARY_REGION" EqOpt stringLit
| "REGIONS" EqOpt stringLit
| "SCHEDULE" EqOpt stringLit
AdvancedPlacementOption ::=
"LEARNERS" EqOpt LengthNum
| "CONSTRAINTS" EqOpt stringLit
| "LEADER_CONSTRAINTS" EqOpt stringLit
| "FOLLOWER_CONSTRAINTS" EqOpt stringLit
| "LEARNER_CONSTRAINTS" EqOpt stringLit
Examples
CREATE PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1";
CREATE TABLE t1 (i INT) PLACEMENT POLICY=p1; -- Assign policy p1 to table t1
ALTER PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1,us-west-2" FOLLOWERS=4; -- The rules of t1 will be updated automatically.
SHOW CREATE PLACEMENT POLICY p1\G;
Query OK, 0 rows affected (0.08 sec)
Query OK, 0 rows affected (0.10 sec)
***************************[ 1. row ]***************************
Policy | p1
Create Policy | CREATE PLACEMENT POLICY `p1` PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1,us-west-2" FOLLOWERS=4
1 row in set (0.00 sec)
MySQL compatibility
This statement is a TiDB extension to MySQL syntax.