SHOW PLACEMENT

警告:

Placement Rules in SQL 是 TiDB 在 v5.3.0 中引入的实验特性,其语法在 GA 前可能会发生变化,还可能存在 bug。如果你知晓潜在的风险,可通过执行 SET GLOBAL tidb_enable_alter_placement = 1; 来开启该实验特性。

SHOW PLACEMENT 汇总了直接放置 (direct placement) 和放置策略 (placement policy) 中的所有放置选项,并以规范的形式呈现这些选项信息。

语法图

  1. ShowStmt ::=
  2. "PLACEMENT"

示例

  1. CREATE PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4;
  2. CREATE TABLE t1 (a INT) PLACEMENT POLICY=p1;
  3. CREATE TABLE t2 (a INT) PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4;
  4. SHOW PLACEMENT;
  1. Query OK, 0 rows affected (0.01 sec)
  2. Query OK, 0 rows affected (0.00 sec)
  3. Query OK, 0 rows affected (0.00 sec)
  4. +---------------+----------------------------------------------------------------------+------------------+
  5. | Target | Placement | Scheduling_State |
  6. +---------------+----------------------------------------------------------------------+------------------+
  7. | POLICY p1 | PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4 | NULL |
  8. | DATABASE test | PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4 | INPROGRESS |
  9. | TABLE test.t1 | PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4 | INPROGRESS |
  10. | TABLE test.t2 | PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4 | INPROGRESS |
  11. +---------------+----------------------------------------------------------------------+------------------+
  12. 4 rows in set (0.00 sec)

MySQL 兼容性

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

另请参阅