multiple auto_incremented field

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

multiple auto_incremented field

Post by neel_basu »

I just wanna make it Sure if more than one auto_increment field can be created or not as far I know the Answer Is no . Nut I Wanna make sur about it
Plase Anwer

EDIT : OOPS Sorry Spelling mistake
Last edited by neel_basu on Thu Jan 25, 2007 3:49 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Spell check.

Why not try it and find out?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

feyd wrote:Spell check.

Why not try it and find out?
Ya I've Tried It.
It Shows
mysql_error() wrote:Incorrect table definition; there can be only one auto column and it must be defined as a key
Error Number 1075
I've visited there
http://dev.mysql.com/doc/refman/5.1/en/create-table.html wrote:AUTO_INCREMENT

The initial AUTO_INCREMENT value for the table. In MySQL 5.1, this works for MyISAM, MEMORY, and InnoDB tables. To set the first auto-increment value for engines that do not support the AUTO_INCREMENT table option, insert a “dummy” row with a value one less than the desired value after creating the table, and then delete the dummy row.

For engines that support the AUTO_INCREMENT table option in CREATE TABLE statements, you can also use ALTER TABLE tbl_name AUTO_INCREMENT = N to reset the AUTO_INCREMENT value.
------------------------------------------------------------------------------------------------
But Does it mean only one auto_increment is possible ??
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

not necessarily, but
http://dev.mysql.com/doc/refman/5.1/en/create-table.html wrote:Note: There can be only one AUTO_INCREMENT column per table, it must be indexed, and it cannot have a DEFAULT value.
does ;)
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

yes
Thanks a lot I got it.
I was Just Trying to Know This answer.
Thank you .
Post Reply