如何将AUTO_INCREMENT添加到现有列? [英] How to add AUTO_INCREMENT to an existing column?

查看:80
本文介绍了如何将AUTO_INCREMENT添加到现有列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将auto_increment添加到MySQL表的现有列中?

How do I add auto_increment to an existing column of a MySQL table?

推荐答案

我想您要按照

I think you want to MODIFY the column as described for the ALTER TABLE command. It might be something like this:

ALTER TABLE users MODIFY id INTEGER NOT NULL AUTO_INCREMENT;

在运行以上命令之前,请确保id列具有主索引.

Before running above ensure that id column has a Primary index.

这篇关于如何将AUTO_INCREMENT添加到现有列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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