【 使用环境 】生产环境
【 OB or 其他组件 】
【 使用版本 】5.7.25-OceanBase_CE-v4.3.0.1
【问题描述】需要将一张非分区表改为range一级分区
【表结构】
CREATE TABLE memberconsumptionorders_copy1
(
Id
int(11) NOT NULL AUTO_INCREMENT,
TenantId
int(11) DEFAULT NULL,
OrderCode
varchar(50) DEFAULT NULL,
ReceiptCode
varchar(50) DEFAULT NULL,
TerminalNo
longtext DEFAULT NULL,
CreatorTime
datetime(6) NOT NULL,
OrganizationId
char(36) NOT NULL,
OrganizationCode
longtext DEFAULT NULL,
OrganizationName
longtext DEFAULT NULL,
TransactionState
int(11) NOT NULL,
CasherId
char(36) NOT NULL,
CasherCode
longtext DEFAULT NULL,
CasherName
longtext DEFAULT NULL,
OrderAmount
decimal(65,30) NOT NULL,
PayAmount
decimal(65,30) NOT NULL,
DiscountsAmount
decimal(65,30) NOT NULL,
CRMAmount
decimal(65,30) NOT NULL,
MemberId
char(36) DEFAULT NULL,
MemberName
longtext DEFAULT NULL,
MemberCode
varchar(50) DEFAULT NULL,
MemberPhone
longtext DEFAULT NULL,
OrderSource
int(11) NOT NULL,
ThirdpartyOrderCode
longtext DEFAULT NULL,
ReturnOrderCode
longtext DEFAULT NULL,
SnNo
longtext DEFAULT NULL,
MerchantName
longtext DEFAULT NULL,
MerchantId
char(36) DEFAULT NULL,
MerchantCode
longtext DEFAULT NULL,
ConsumptionOrderSource
int(11) NOT NULL,
ThirdOrderTime
datetime(6) DEFAULT NULL,
OrderScore
decimal(65,30) NOT NULL,
PayScore
decimal(65,30) NOT NULL,
Freight
decimal(18,4) NOT NULL,
DepositOrderCode
longtext DEFAULT NULL,
DepositOrderId
int(11) DEFAULT NULL,
ArrearsState
int(11) NOT NULL,
ConsumptionSaleOrderId
int(11) DEFAULT NULL,
MarketingReturned
tinyint(1) NOT NULL DEFAULT ‘0’,
PRIMARY KEY (Id
, CreatorTime
),
KEY IX_MemberConsumptionOrders_CreatorTime
(CreatorTime
) BLOCK_SIZE 16384 LOCAL,
KEY IX_MemberConsumptionOrders_MemberId
(MemberId
) BLOCK_SIZE 16384 LOCAL,
KEY IX_MemberConsumptionOrders_OrderCode
(OrderCode
) BLOCK_SIZE 16384 LOCAL,
KEY IX_MemberConsumptionOrders_OrganizationId
(OrganizationId
) BLOCK_SIZE 16384 LOCAL,
KEY IX_MemberConsumptionOrders_ReceiptCode
(ReceiptCode
) BLOCK_SIZE 16384 LOCAL
) AUTO_INCREMENT = 3020744 AUTO_INCREMENT_MODE = ‘ORDER’ DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = ‘zstd_1.3.8’ REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
【执行分区语句】
ALTER TABLE memberconsumptionorders_copy1 PARTITION BY RANGE(UNIX_TIMESTAMP(CreatorTime))
(
PARTITION M1 VALUES LESS THAN(UNIX_TIMESTAMP(‘2023-01-01’)),
PARTITION M2 VALUES LESS THAN(UNIX_TIMESTAMP(‘2024-01-01’)),
PARTITION M3 VALUES LESS THAN(UNIX_TIMESTAMP(‘2025-01-01’))
);
【报错信息】
1486 - Constant or random or timezone-dependent expressions in (sub)partitioning function are not allowed