分区策略命令partitioning policy command

此处详细介绍了数据分区策略。The data partitioning policy is detailed here.

显示策略show policy

.show table [table_name] policy partitioning

.show 命令显示应用于表的分区策略。The .show command displays the partitioning policy that is applied on the table.

输出Output

策略名称Policy name 实体名称Entity name 策略Policy 子实体Child entities 实体类型Entity type
DataPartitioningDataPartitioning 表名称Table name 策略对象的 JSON 序列化JSON serialization of the policy object Nullnull Table

alter 和 alter-merge policyalter and alter-merge policy

.alter table [table_name] policy partitioning @'policy object, serialized as JSON'

.alter-merge table [table_name] policy partitioning @'partial policy object, serialized as JSON'

.alter 命令允许更改应用于表的分区策略。The .alter command allows changing the partitioning policy that is applied on the table.

此命令需要 DatabaseAdmin 权限。The command requires DatabaseAdmin permissions.

对策略的更改可能最多需要 1 小时才能生效。Changes to the policy could take up to 1 hour to take effect.

示例Examples

使用哈希分区键设置策略Setting a policy with a hash partition key

.alter table [table_name] policy partitioning @'{'
  '"PartitionKeys": ['
    '{'
      '"ColumnName": "my_string_column",'
      '"Kind": "Hash",'
      '"Properties": {'
        '"Function": "XxHash64",'
        '"MaxPartitionCount": 256,'
      '}'
    '}'
  ']'
'}'

使用统一范围日期/时间分区键设置策略Setting a policy with a uniform range datetime partition key

.alter table [table_name] policy partitioning @'{'
  '"PartitionKeys": ['
    '{'
      '"ColumnName": "my_datetime_column",'
      '"Kind": "UniformRange",'
      '"Properties": {'
        '"Reference": "1970-01-01T00:00:00",'
        '"RangeSize": "1.00:00:00"'
      '}'
    '}'
  ']'
'}'

使用两种分区键设置策略Setting a policy with both kinds of partition keys

.alter table [table_name] policy partitioning @'{'
  '"PartitionKeys": ['
    '{'
      '"ColumnName": "my_string_column",'
      '"Kind": "Hash",'
      '"Properties": {'
        '"Function": "XxHash64",'
        '"MaxPartitionCount": 256,'
      '}'
    '},'
    '{'
      '"ColumnName": "my_datetime_column",'
      '"Kind": "UniformRange",'
      '"Properties": {'
        '"Reference": "1970-01-01T00:00:00",'
        '"RangeSize": "1.00:00:00"'
      '}'
    '}'
  ']'
'}'

在表级别显式设置策略的特定属性Setting a specific property of the policy explicitly at table level

要将策略的 EffectiveDateTime 设置为其他值,请使用以下命令:To set the EffectiveDateTime of the policy to a different value, use the following command:

.alter-merge table [table_name] policy partitioning @'{"EffectiveDateTime":"2020-01-01"}'

删除策略delete policy

.delete table [table_name] policy partitioning

.delete 命令删除给定表的分区策略。The .delete command deletes the partitioning policy of the given table.