ERROR 1105 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function

ERROR 1105 (HY000): A PRIMARY KEY must include all columns in the table‘s partitioning function

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));

ERROR 1105 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function

时间: 2024-12-26 00:00:40

ERROR 1105 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function的相关文章

1503 - A PRIMARY KEY must include all columns in the table's partitioning function

1503 - A PRIMARY KEY must include all columns in the table's partitioning function 错误的原因:表的主键字段必须包含分区字段.为什么? 举例来说,Id为auto_increment primary key,按日期分区.考虑下面的场景,插入一条Id为100的记录,mysql根据日期,当然知道插入到那个分区中,但是要检查所有的分区中是否已经包含Id为100的记录,显然效率很低.如果不检查所有的分区,只检查当前插入的分区

Atlas:ERROR 1105 (HY000): #07000Proxy Warning - IP Forbidden

1:遇到一个奇怪的问题 Atlas的管理接口正常 添加一个client之后save config mysql -uroot -p -P1234 -h127.0.0.1 报错了:ERROR 1105 (HY000): #07000Proxy Warning - IP Forbidden 2:查看配置文件 cat test.cnf client-ips=192.168.91.1301, 其中一个IP误添加出错了. 3:注释掉错误IP重新登录即可 [[email protected] bin]# ./

Error Code: 1068. Multiple primary key defined

1.错误描述 10:10:38 alter table user add num int(8) primary key first Error Code: 1068. Multiple primary key defined 0.000 sec 2.错误原因 这个错误的原因是定义了两个主键,导致出错 3.解决办法 alter table user add num int(8) primary key first; 去掉"primary key"

SQL PRIMARY KEY 约束\SQL FOREIGN KEY 约束\SQL CHECK 约束

SQL PRIMARY KEY 约束 PRIMARY KEY 约束唯一标识数据库表中的每条记录. 主键必须包含唯一的值. 主键列不能包含 NULL 值. 每个表都应该有一个主键,并且每个表只能有一个主键. SQL PRIMARY KEY Constraint on CREATE TABLE 下面的 SQL 在 "Persons" 表创建时在 "Id_P" 列创建 PRIMARY KEY 约束: MySQL: CREATE TABLE Persons ( Id_P i

FOREIGN KEY 外键约束; UNIQUE和PRIMARY KEY 主键约束、CREATE INDEX建立索引的使用

1)foreign key 是个约束,意思是说如果你给A字段设置了外键约束,以后你要往A字段插入数据,这个数据一定是要在foreign key 后面跟的那个字段中存在的值.这个的意义就是约束了数据的完整性,不会插入错误的数据. 修改添加t_topic外键约束: ALTER TABLE t_topic ADD CONSTRAINT fk_userTopics FOREIGN KEY (user_id) REFERENCES t_users(id) 删除表t_topic外键: ALTER TABLE

主键约束 primary key

主键的作用: 可以唯一标识 一条数据,每张表里面只能有一个主键,.主键特性: 非空且唯一.当表里没有主键的时,第一个出现的非空且为唯一的列,被当成主键. 例子:create table tb3(     id int primary key,    name varchar(20) not null); 唯一标识 一条数据 #删除主键约束mysql -> alter table tb3           -> drop primary key #添加主键约束mysql> alter t

mysql执行带外键的sql文件时出现mysql ERROR 1215 (HY000): Cannot add foreign key constraint的解决

ERROR 1215 (HY000): Cannot add foreign key constraint 最近在建表时遇到了这个错误,然后找了下找到了解决办法,记录下: 本来是要建两张表: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 create table department( id int, name varchar(20) ); create table employee( id int primary key auto_increment, name varch

mysql ERROR 126 (HY000): Incorrect key file for table '/tmp/#sql_1d87_0.MYI'; try to repair it

[[email protected] ~]# df -h 查看是否空间不足 在查看mysql数据目录情况 mysql> show variables like '%dir%'; +-----------------------------------------+------------------------------------+ | Variable_name                           | Value                              |

Discuz升级 Database Error : pre_common_syscache ADD PRIMARY KEY (cname)【解决办法】

错误码: 1068Multiple primary key defined Execution Time : 00:00:00:000Transfer Time : 00:00:00:000Total Time : 00:00:00:000 解决办法:DROP TABLE IF EXISTS pre_common_syscache;CREATE TABLE pre_common_syscache ( cname varchar(32) NOT NULL, ctype tinyint(3) uns