报错:
[HY000][3750] Unable to create or change a table without a primary key, when the system variable ‘sql_require_primary_key’ is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting.
出现场景:想要使用以下语句更改数据库的主键
alter table A
drop primary key;
alter table A
add primary key (id);
解决办法:把两条语句写成一条即可
alter table A
drop primary key,
add primary key (id);