datagrip 数据库切换主键的问题
问题:
在使用 datagrip 建立好了一张表 t_product 表,设置的主键是 id 自增,建立好后我想切换主键成 product_id,于是我重新编辑这张表,做了如下的一连串操作:
- 切换主键索引为 product_id
- 切换唯一索引为 product_id
- 删除 id 字段
- 最后保存提示错误:
[42000][1075] Incorrect table definition; there can be only one auto column and it must be defined as a key.
不知道为什么会这样?
补充:
如果我分两步走就可以成功
但是如果执行如下操作:
- 切换主键索引为 product_id
- 切换唯一索引为 product_id
- 不删除 id 保存成功
然后再进行第二次编辑:
- 删除 id 字段
- 就可以保存成功