MySQL Forums
Forum List  »  Newbie

AUTO_INCREMENT
Posted by: nizar a
Date: April 22, 2005 07:15AM

Hello,

It's probably a very simple question, excuse a newbie :)

In a simple database for email addresses:
First Name :: Last Name :: email

I want to add a column at the first and call it 'num' that is auto incremented
I do the following
ALTER TABLE emails ADD num INT AUTO_INCREMENT FIRST, ADD UNIQUE KEY(num);

I'm adding the UNIQUE KEY because Mysql refuses to add AUTO_INCREMENT without being defined as a key.

It works great but if I delete one of the records the 'num' column isn't updated, example.

1 f l f_l@email.dom
2 ab cd ad@bd.dom
3 ef gh eh@fg.com

When 2 ab cd ad@bd.dom is deleted the DB looks like
1 f l f_l@email.dom
3 ef gh eh@fg.com

I want it to be
1 f l f_l@email.dom
2 ef gh eh@fg.com

Is it possible without deleting the 'num' column and adding it again everytime I delete a row?

Many thanks.

Options: ReplyQuote


Subject
Written By
Posted
AUTO_INCREMENT
April 22, 2005 07:15AM
April 22, 2005 07:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.