分片策略命令sharding policy command

显示策略show policy

.show table [table_name] policy sharding

.show table * policy sharding

.show database [database_name] policy sharding

Show 策略显示数据库或表的分片策略。Show policy displays the sharding policy for the database or table. 如果给定的名称为“*”,它将显示给定实体类型(数据库或表)的所有策略。It shows all policies of the given entity type (database or table) if the given name is '*'.

输出Output

策略名称Policy name 实体名称Entity name 策略Policy 子实体Child entities 实体类型Entity type
ExtentsShardingPolicyExtentsShardingPolicy 数据库/表名称database / table name 表示策略的 json 格式字符串json format string that represents the policy 表列表(对于数据库)list of tables (for a database) 数据库/表database / table

更改策略alter policy

示例Examples

下面的示例返回实体更新后的盘区分片策略,并将数据库或表指定为限定名称作为其输出。The following examples return the updated extents sharding policy for the entity, with database or table specified as a qualified name, as their output.

在表级别显式设置策略的所有属性Setting all properties of the policy explicitly at table level

.alter table [table_name] policy sharding 
@'{ "MaxRowCount": 750000, "MaxExtentSizeInMb": 1024, "MaxOriginalSizeInMb": 2048}'

在数据库级别显式设置策略的所有属性Setting all properties of the policy explicitly at database level

.alter database [database_name] policy sharding
@'{ "MaxRowCount": 750000, "MaxExtentSizeInMb": 1024, "MaxOriginalSizeInMb": 2048}'

在数据库级别设置默认分片策略Setting the default sharding policy at database level

.alter database [database_name] policy sharding @'{}'

在数据库级别更改策略的单个属性Altering a single property of the policy at database level

所有其他属性保持不变。Keep all other properties as-is.

.alter-merge database [database_name] policy sharding
@'{ "MaxExtentSizeInMb": 1024}'

在表级别更改策略的单个属性Altering a single property of the policy at table level

所有其他属性保持不变Keep all other properties as-is

.alter-merge table [table_name] policy sharding
@'{ "MaxRowCount": 750000}'

删除策略delete policy

.delete table [table_name] policy sharding

.delete database [database_name] policy sharding

此命令删除给定实体的当前分片策略。The command deletes the current sharding policy for the given entity.