将 MySQL 列更改为 AUTO_INCREMENT [英] Alter a MySQL column to be AUTO_INCREMENT

查看:55
本文介绍了将 MySQL 列更改为 AUTO_INCREMENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改一个表以使其主键列 AUTO_INCREMENT 事后.我尝试了以下 SQL,但收到了语法错误通知.

ALTER TABLE 文档ALTER COLUMN document_id AUTO_INCREMENT

我做错了什么还是不可能?

<前>+--------------------+|版本() |+--------------------+|5.0.75-0ubuntu10.2 |+--------------------+

解决方案

ALTER TABLE document MODIFY COLUMN document_id INT auto_increment

I’m trying to modify a table to make its primary key column AUTO_INCREMENT after the fact. I have tried the following SQL, but got a syntax error notification.

ALTER TABLE document
ALTER COLUMN document_id AUTO_INCREMENT

Am I doing something wrong or is this not possible?

+--------------------+
| VERSION()          |
+--------------------+
| 5.0.75-0ubuntu10.2 |
+--------------------+

解决方案

ALTER TABLE document MODIFY COLUMN document_id INT auto_increment

这篇关于将 MySQL 列更改为 AUTO_INCREMENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆