ERROR 1105 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function
MySQL里面主键及唯一索引都需要包含分区键,否则均会报错
CREATE TABLE `sample` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', `trade_no` varchar(32) NOT NULL COMMENT 'xxx', `trade_type` varchar(32) DEFAULT NULL COMMENT 'xxx', `sub_trade_type` varchar(32) DEFAULT NULL COMMENT 'xxx', `request_no` varchar(64) NOT NULL COMMENT 'xxx', `request_date` date not null DEFAULT '2000-01-01' COMMENT 'xxx', `product_code` varchar(32) DEFAULT NULL COMMENT 'xxx', `trade_channel` varchar(16) DEFAULT NULL COMMENT 'xxx', `trade_status` varchar(32) NOT NULL COMMENT 'xxx', `revoke_flag` varchar(8) DEFAULT NULL COMMENT 'xxx', `cancel_flag` varchar(8) DEFAULT NULL COMMENT 'xxx', `original_trade_no` varchar(32) DEFAULT NULL COMMENT 'xxx', `trade_finished_date` date DEFAULT NULL COMMENT 'xxx', `pay_finish_date` date DEFAULT NULL COMMENT 'xxx', `ccy` varchar(3) NOT NULL COMMENT 'xxx', `trade_amt` bigint(16) NOT NULL COMMENT 'xxx', `discount_amt` bigint(16) DEFAULT NULL COMMENT 'xxx', `discount_info` varchar(256) DEFAULT NULL COMMENT 'xxx', `pay_amt` bigint(16) DEFAULT NULL COMMENT 'xxx', `billing_contract_no` bigint(20) not null DEFAULT 0 COMMENT 'xxx', `billing_login_name` varchar(32) DEFAULT NULL COMMENT 'xxx', `transfer_contract_no` varchar(16) DEFAULT NULL COMMENT 'xxx', `transfer_login_name` varchar(32) DEFAULT NULL COMMENT 'xxx', `transfer_flag` varchar(16) DEFAULT NULL COMMENT 'xxx', `merchant_no` varchar(32) DEFAULT NULL COMMENT 'xxx', `merchant_trade_no` varchar(32) DEFAULT NULL COMMENT 'xxx', `merchant_name` varchar(256) DEFAULT NULL COMMENT 'xxx', `goods_info` varchar(32) DEFAULT NULL COMMENT 'xxx', `memo` varchar(256) DEFAULT NULL COMMENT 'xxx', `created_at` date NOT NULL COMMENT 'xxx', `created_by` varchar(32) NOT NULL COMMENT 'xxx', `updated_at` date NOT NULL COMMENT 'xxx', `updated_by` varchar(32) NOT NULL COMMENT 'xxx', PRIMARY KEY (id,request_date) ) ENGINE=InnoDB AUTO_INCREMENT=5731 DEFAULT CHARSET=utf8 COMMENT='xxx' partition by range (year(request_date)*100+month(request_date)) ( partition p201604 values less than (201604), partition p201605 values less than (201605), partition p201606 values less than (201606), partition p201607 values less than (201607), partition p201608 values less than (201608), partition p201609 values less than (201609), partition p201610 values less than (201610), partition p201611 values less than (201611), partition p201612 values less than (201612), partition p201701 values less than (201701), partition p201702 values less than (201702), partition p201703 values less than (201703), partition p201704 values less than (201704), partition p201705 values less than (201705), partition p201706 values less than (201706), partition p201707 values less than (201707), partition p201708 values less than (201708), partition p201709 values less than (201709), partition p201710 values less than (201710), partition p201711 values less than (201711), partition p201712 values less than (201712), partition p201801 values less than (201801), partition p201802 values less than (201802), partition p201803 values less than (201803), partition p201804 values less than (201804), partition p201805 values less than (201805), partition p201806 values less than (201806), partition p201807 values less than (201807), partition p201808 values less than (201808), partition p201809 values less than (201809), partition p201810 values less than (201810), partition p201811 values less than (201811), partition p201812 values less than (201812));