Resetting auto_increment

Dear List -

Thanks for all your help.

How do I reset auto_increment so that the primary key will start from
1. The primary key is now 2421. I have deleted all the data in the
table and started over, and the primary key just increments from its
previous value. Setting auto_increment=0 does not work for me, why I
don't know.

Help and advice, please.

Thanks in advance.

Ethan

MySQL 5.1 PHP 5 Linux [Debian (sid)]



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ethan Rosenberg [ Di, 14 Dezember 2010 18:34 ] [ ID #2051632 ]

Re: Resetting auto_increment

On Tue, Dec 14, 2010 at 12:34, Ethan Rosenberg <ethros [at] earthlink.net> wrote=
:
> Dear List -
>
> Thanks for all your help.
>
> How do I reset auto_increment so that the primary key will start from 1.
> =A0The primary key is now 2421. =A0I have deleted all the data in the tab=
le and
> started over, and the primary key just increments from its previous value=
..
> =A0Setting auto_increment=3D0 does not work for me, why I don't know.

UPDATE tablename AUTO_INCREMENT=3D1;

--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Daniel Brown [ Di, 14 Dezember 2010 18:38 ] [ ID #2051633 ]

Re: Resetting auto_increment

At 12:38 PM 12/14/2010, Daniel Brown wrote:
>On Tue, Dec 14, 2010 at 12:34, Ethan Rosenberg <ethros [at] earthlink.net> wrote:
> > Dear List -
> >
> > Thanks for all your help.
> >
> > How do I reset auto_increment so that the primary key will start from 1.
> > The primary key is now 2421. I have deleted all the data in the table and
> > started over, and the primary key just increments from its previous value.
> > Setting auto_increment=0 does not work for me, why I don't know.
>
> UPDATE tablename AUTO_INCREMENT=1;
>
>--
></Daniel P. Brown>
>Network Infrastructure Manager
>Documentation, Webmaster Teams
>http://www.php.net/

======
Daniel -

Thanks.

This is what I get -

mysql> update Visit3 auto_increment=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '=1' at line 1

Same error if auto_increment is in caps.

What did I do wrong?

Thanks in advance.

Ethan


MySQL 5.1 PHP 5 Linux [Debian (sid)]



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ethan Rosenberg [ Di, 14 Dezember 2010 19:02 ] [ ID #2051634 ]

Re: Resetting auto_increment

On 12/14/2010 1:02 PM, Ethan Rosenberg wrote:
> At 12:38 PM 12/14/2010, Daniel Brown wrote:
>> On Tue, Dec 14, 2010 at 12:34, Ethan Rosenberg <ethros [at] earthlink.net>
>> wrote:
>> > Dear List -
>> >
>> > Thanks for all your help.
>> >
>> > How do I reset auto_increment so that the primary key will start
>> from 1.
>> > The primary key is now 2421. I have deleted all the data in the
>> table and
>> > started over, and the primary key just increments from its previous
>> value.
>> > Setting auto_increment=0 does not work for me, why I don't know.
>>
>> UPDATE tablename AUTO_INCREMENT=1;
>>
>> --
>> </Daniel P. Brown>
>> Network Infrastructure Manager
>> Documentation, Webmaster Teams
>> http://www.php.net/
>
> ======
> Daniel -
>
> Thanks.
>
> This is what I get -
>
> mysql> update Visit3 auto_increment=1;
> ERROR 1064 (42000): You have an error in your SQL syntax; check the
> manual that corresponds to your MySQL server version for the right
> syntax to use near '=1' at line 1
>

Use 'ALTER tablename AUTO_INCREMENT=1' rather than 'UPDATE tablename
AUTO_INCREMENT=1'.

Toby


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Toby Hart Dyke [ Di, 14 Dezember 2010 19:43 ] [ ID #2051635 ]

Re: Resetting auto_increment

On Tue, Dec 14, 2010 at 13:02, Ethan Rosenberg <ethros [at] earthlink.net> wrote=
:
>>
>> =A0 =A0UPDATE tablename AUTO_INCREMENT=3D1;
>
> mysql> update Visit3 auto_increment=3D1;
> ERROR 1064 (42000): You have an error in your SQL syntax; check the manua=
l
> that corresponds to your MySQL server version for the right syntax to use
> near '=3D1' at line 1
>
> Same error if auto_increment is in caps.
>
> What did I do wrong?

Sorry, you didn't --- I did. I was working on something for
myself simultaneously and somehow crossed wires. My apologies.

That's not an UPDATE query, it's an ALTER TABLE query.

ALTER TABLE Visit3 AUTO_INCREMENT=3D1;

Again, my apologies.

--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Daniel Brown [ Di, 14 Dezember 2010 19:44 ] [ ID #2051636 ]

Re: Resetting auto_increment

On Tue, Dec 14, 2010 at 13:43, Toby Hart Dyke <toby [at] hartdyke.com> wrote:
>
> Use =A0'ALTER tablename AUTO_INCREMENT=3D1' rather than 'UPDATE tablename
> AUTO_INCREMENT=3D1'.

Yeah, again, my fault. Not enough coffee on this cold (~7F)
winter's day, perhaps.

--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Daniel Brown [ Di, 14 Dezember 2010 19:45 ] [ ID #2051637 ]
PHP » gmane.comp.php.database » Resetting auto_increment

Vorheriges Thema: NULL to 0 result
Nächstes Thema: Is this syntax is correct?