Re: reset auto increment to a lesser value

2008-08-02 Thread Mark Goodge

Chris W wrote:


Mark Goodge wrote:
On a more general note, if the actual value of the primary key matters 
for anything other than simply existing as a primary key, then you 
shouldn't be using auto-increment at all. You should generate the 
value through some other means and insert it with the value that you 
want it to be.


Can you elaborate on that point?  Do you not use auto-increment values 
to link records in a one to many relationship?


Yes, but the relevant factor here is that in the table where the 
auto-increment value is generated it has no meaning other than as a 
unique id. In the other tables that use it as a reference, then it has 
meaning there and needs to be inserted as a known value.


An auto-increment field can only be used where that value never needs to 
be set by reference to an external value. It can be a value that other 
external values are set to (such as in a one-to-many relationship), but 
in the other tables that use it as a reference then it isn't inserted as 
an auto-increment.


Mark

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: reset auto increment to a lesser value

2008-08-02 Thread Chris W


Mark Goodge wrote:
On a more general note, if the actual value of the primary key matters 
for anything other than simply existing as a primary key, then you 
shouldn't be using auto-increment at all. You should generate the 
value through some other means and insert it with the value that you 
want it to be.


Mark



Can you elaborate on that point?  Do you not use auto-increment values 
to link records in a one to many relationship?


Chris W

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: reset auto increment to a lesser value

2008-08-02 Thread Mark Goodge

abhishek jain wrote:
On Sat, Aug 2, 2008 at 10:49 
But as per a thread on this link, if the resetted value is less than the

highest value already in table then the effective increment value will start
from highest number and not from 100.
I have deleted some rows and i want the increment to start from those
row-ids.


That can't be done. An auto-increment value must be higher than the 
highest existing value. Otherwise, it would not be an auto-increment 
value at all - it would be an auto-interpolate.


On a more general note, if the actual value of the primary key matters 
for anything other than simply existing as a primary key, then you 
shouldn't be using auto-increment at all. You should generate the value 
through some other means and insert it with the value that you want it 
to be.


Mark

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: reset auto increment to a lesser value

2008-08-02 Thread abhishek jain
On Sat, Aug 2, 2008 at 10:49 PM, Nacho Garcia <[EMAIL PROTECTED]> wrote:

> http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
>
> mysql> *ALTER TABLE tbl AUTO_INCREMENT = 100;*
>
>
>
> On Sat, Aug 2, 2008 at 5:28 PM, abhishek jain <[EMAIL PROTECTED]> wrote:
>
>> Hello friends,
>> I need to reset auto increment to a lesser value, is there a metod to do
>> so
>> in any version of mysql.
>> Pl. help me.
>> Thanks
>> abhi
>>
>
>
Hi Nacho,
Thanks for the reply,
But as per a thread on this link, if the resetted value is less than the
highest value already in table then the effective increment value will start
from highest number and not from 100.
I have deleted some rows and i want the increment to start from those
row-ids.
Pl. reply,
Thanks,
Abhi


reset auto increment to a lesser value

2008-08-02 Thread abhishek jain
Hello friends,
I need to reset auto increment to a lesser value, is there a metod to do so
in any version of mysql.
Pl. help me.
Thanks
abhi