Error when use auto_increment in MySQL
I meet some errors when using auto_increment
in MySQL.
code is here:
user_id bigint(20) unsigned not null auto_increment=1000
but when I try
user_id bigint(20) unsigned not null au开发者_如何学编程to_increment
it works. why?
This should work:
create table test1 (
id int unsigned not null auto_increment,
primary key (id)
)auto_increment=100;
Are you trying to seed the auto increment number?
If so, the syntax is part of the CREATE|ALTER TABLE
command.
See http://dev.mysql.com/doc/refman/5.5/en/example-auto-increment.html
This happens because auto increment is set for the table and not a particular column.
So to start from 1000,
Create a table column with just auto_increment
And then alter the table using
ALTER TABLE your_table_name AUTO_INCREMENT=1000;
auto increment of mysql is only +1 value.
look at this http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
精彩评论