Sign InTry Free

CREATE PLACEMENT POLICY

CREATE PLACEMENT POLICY is used to create a named placement policy that can later be assigned to tables, partitions, or database schemas.

Synopsis

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

Examples

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 compatibility

This statement is a TiDB extension to MySQL syntax.

See also

Download PDFRequest docs changes
Was this page helpful?
Open Source Ecosystem
TiDB
TiKV
TiSpark
Chaos Mesh
© 2022 PingCAP. All Rights Reserved.