站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题MYSQL里的auto_increment如何设置和insert使用呢?没分了:(

MYSQL里的auto_increment如何设置和insert使用呢?没分了:(

摘要: MYSQL里的auto_increment如何设置和insert使用呢?没分了:(


create table test(
id int not null auto_increment ,
name varchar(20),
primary key (id)
);

我现在想insert一条数据,如何使用这个id字段让它自动增加呢?



报这个错:
[mysql] 错误 1062: Duplicate entry '0' for key 1

大家帮帮忙了


这个问题是不是很麻烦不好解决?

大家给电代码看看也好啊


你插入时候别管id,就插后面的字段,他会自己增加的


我是这样试了,但是不行,总是报错,[mysql] 错误 1062: Duplicate entry '0' for key 1

我的MYSQL版本是5.0的 该不会和这个有关系吧?


o


dropt table test;
create table test(
id int unsigned not null auto_increment,
name varchar(20),
primary key (id)
);

insert into test values(0,'bccb');
select * from test;


insert into test values(null,'bccb');
也可以


↑返回目录
前一篇: 动态生成的shtml,编码为什么默认是西欧??????? 十万火急,解决者满分!!!!!!!!
后一篇: 如何实现在线视频录制(包括声音)?像网友(www.wangyou.com)网站那样的效果,浏览器访问页面,在页面中实现在线视频录制的效果。