mysql中,已经建立的列添加 auto-increment
来源:互联网 发布:网络用语然是什么意思 编辑:程序博客网 时间:2024/05/17 04:04
已经建立的表test:
create table test
(
id int ,
age int not null
);
需求:给id列添加auto-increment
要给id添加auto-increment就得满足:id必须为主键,因为mysql表中,只有一个列能为auto-increment,而且这个列必须是主键。所以,先给id添加主键,然后再添加auto-increment,如下:
alter table test change id id int primary key; 添加主键
alter table test change id id int auto-increment; 添加auto-increment
接下来测试:
insert into test(age) values(22);
insert into test(age) values(33);
结果显示正确!
- mysql中,已经建立的列添加 auto-increment
- MySQL中设置Auto Increment的值
- Mysql中auto increment的基本特性
- 自增列(auto-increment)是如何在 InnoDB 中工作的
- mysql auto increment特性说明
- sql中AUTO INCREMENT 字段
- Mysql错误:Failed to read auto-increment value from storage engine Query的解决方法
- Failed to read auto-increment value from storage engine 诡异的mysql自增无效问题
- MYSQL-Failed to read auto-increment value from storage engine
- AUTO INCREMENT Reset
- SQL AUTO INCREMENT 字段
- SQL AUTO INCREMENT 字段
- SQL AUTO INCREMENT 字段
- SQL AUTO INCREMENT 字段
- python auto-increment
- oracle auto increment
- SQL AUTO INCREMENT 字段
- SQL AUTO INCREMENT
- C#运算符
- Ubuntu下搭建WebDAV服务器
- GitHub 上删除文件
- 二叉树的前序中序线索化及对对应线索二叉树的遍历
- C++,继承、虚函数解惑!
- mysql中,已经建立的列添加 auto-increment
- Unity3d 中的单例模式
- UVa:10382 Watering Grass
- (收藏)行人检测(Pedestrian Detection)资源
- Mysql数据库应用中简单的封装
- 代码检查错误列表总结
- python学习六:异常处理、map/reduce/filter内置函数、python集合(set)类型、元组转列表
- Maximum Subarray
- 线程