当前页面: 开发资料首页 → 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');
也可以