PLACEMENT_POLICIES

The PLACEMENT_POLICIES table provides information on all placement policies. For details, refer to Placement Rules in SQL.

PLACEMENT_POLICIES - 图1

Note

This table is not available on TiDB Serverless clusters.

  1. USE information_schema;
  2. DESC placement_policies;
  1. +----------------------+---------------+------+-----+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +----------------------+---------------+------+-----+---------+-------+
  4. | POLICY_ID | bigint(64) | NO | | <null> | |
  5. | CATALOG_NAME | varchar(512) | NO | | <null> | |
  6. | POLICY_NAME | varchar(64) | NO | | <null> | |
  7. | PRIMARY_REGION | varchar(1024) | YES | | <null> | |
  8. | REGIONS | varchar(1024) | YES | | <null> | |
  9. | CONSTRAINTS | varchar(1024) | YES | | <null> | |
  10. | LEADER_CONSTRAINTS | varchar(1024) | YES | | <null> | |
  11. | FOLLOWER_CONSTRAINTS | varchar(1024) | YES | | <null> | |
  12. | LEARNER_CONSTRAINTS | varchar(1024) | YES | | <null> | |
  13. | SCHEDULE | varchar(20) | YES | | <null> | |
  14. | FOLLOWERS | bigint(64) | YES | | <null> | |
  15. | LEARNERS | bigint(64) | YES | | <null> | |
  16. +----------------------+---------------+------+-----+---------+-------+
  17. 12 rows in set (0.00 sec)

Examples

The PLACEMENT_POLICIES table only shows all placement policies. To view the canonical version of placement rules (including all placement policies and objects assigned placement policies), use the statement SHOW PLACEMENT instead:

  1. CREATE TABLE t1 (a INT);
  2. CREATE PLACEMENT POLICY p1 primary_region="us-east-1" regions="us-east-1";
  3. CREATE TABLE t3 (a INT) PLACEMENT POLICY=p1;
  4. SHOW PLACEMENT; -- Shows all information, including table t3.
  5. SELECT * FROM information_schema.placement_policies; -- Only shows placement policies, excluding t3.
  1. Query OK, 0 rows affected (0.09 sec)
  2. Query OK, 0 rows affected (0.11 sec)
  3. Query OK, 0 rows affected (0.08 sec)
  4. +---------------+------------------------------------------------+------------------+
  5. | Target | Placement | Scheduling_State |
  6. +---------------+------------------------------------------------+------------------+
  7. | POLICY p1 | PRIMARY_REGION="us-east-1" REGIONS="us-east-1" | NULL |
  8. | TABLE test.t3 | PRIMARY_REGION="us-east-1" REGIONS="us-east-1" | PENDING |
  9. +---------------+------------------------------------------------+------------------+
  10. 2 rows in set (0.00 sec)
  11. +-----------+--------------+-------------+----------------+-----------+-------------+--------------------+----------------------+---------------------+----------+-----------+----------+
  12. | POLICY_ID | CATALOG_NAME | POLICY_NAME | PRIMARY_REGION | REGIONS | CONSTRAINTS | LEADER_CONSTRAINTS | FOLLOWER_CONSTRAINTS | LEARNER_CONSTRAINTS | SCHEDULE | FOLLOWERS | LEARNERS |
  13. +-----------+--------------+-------------+----------------+-----------+-------------+--------------------+----------------------+---------------------+----------+-----------+----------+
  14. | 1 | def | p1 | us-east-1 | us-east-1 | | | | | | 2 | 0 |
  15. +-----------+--------------+-------------+----------------+-----------+-------------+--------------------+----------------------+---------------------+----------+-----------+----------+
  16. 1 rows in set (0.00 sec)