mysql建立自增字段

记住这个auto_increment关键字!

例子:

create table users(
userid int not null auto_increment,
username varchar(20),
passwd varchar(20),
email varchar(30),
grade int,
primary key(userid)
)
auto_increment=100;

auto_increment=100;这句是把userid的开始值设为100。

插入的时候,可以这么写

insert into users(username,passwd,email,grade) values
('qq','qq','[email protected]',1);

不可以这么写(他真报错呀<Column count doesn't match value count at row 1>)
insert into users values
('qq','qq','[email protected]',1);

你可能感兴趣的:(mysql,qq)