COUNT SHARDING RULE

Description

The COUNT SHARDING RULE syntax is used to query the number of sharding rules for specified database.

Syntax

Grammar Railroad diagram

  1. CountShardingRule::=
  2. 'COUNT' 'SHARDING' 'RULE' ('FROM' databaseName)?
  3. databaseName ::=
  4. identifier

Supplement

  • When databaseName is not specified, the default is the currently used DATABASE. If DATABASE is not used, No database selected will be prompted.

Return value description

ColumnDescription
rule_namerule type
databasethe database to which the rule belongs
countthe number of the rule

Example

  • Query the number of sharding rules for specified database.
  1. COUNT SHARDING RULE FROM sharding_db;
  1. mysql> COUNT SHARDING RULE FROM sharding_db;
  2. +--------------------------+----------------+-------+
  3. | rule_name | database | count |
  4. +--------------------------+----------------+-------+
  5. | sharding_table | sharding_db | 2 |
  6. | sharding_table_reference | sharding_db | 2 |
  7. +--------------------------+----------------+-------+
  8. 2 rows in set (0.00 sec)
  • Query the number of sharding rules for current database.
  1. COUNT SHARDING RULE;
  1. mysql> COUNT SHARDING RULE;
  2. +--------------------------+----------------+-------+
  3. | rule_name | database | count |
  4. +--------------------------+----------------+-------+
  5. | sharding_table | sharding_db | 2 |
  6. | sharding_table_reference | sharding_db | 2 |
  7. +--------------------------+----------------+-------+
  8. 2 rows in set (0.00 sec)

Reserved word

COUNT, SHARDING, RULE, FROM