auto_increment

auto_increment

am 14.04.2007 04:03:59 von Ron Piggott

--=-xK5L7HjLIUaeMS/bzYQr
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Does anyone see anything wrong with the $query syntax? Ron

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="ALTER TABLE sessions auto_increment = '1'";
mysql_query($query);
mysql_close();


--=-xK5L7HjLIUaeMS/bzYQr--

Re: auto_increment

am 14.04.2007 11:54:07 von robleyd

Ron Piggott wrote:

> Does anyone see anything wrong with the $query syntax? Ron
>
> mysql_connect(localhost,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
> $query="ALTER TABLE sessions auto_increment = '1'";
> mysql_query($query);
> mysql_close();
The value would be an integer, not a string but that shouldn't cause a
problem. To quote the docs:

ALTER TABLE t2 AUTO_INCREMENT = value;

You cannot reset the counter to a value less than or equal to any that have
already been used. For MyISAM, if the value is less than or equal to the
maximum value currently in the AUTO_INCREMENT column, the value is reset to
the current maximum plus one.

It probably should be said that there is normally no reason to play with
auto-increment values.



Cheers
--
David Robley

An ulcer is what you get mountain climbing over molehills.
Today is Prickle-Prickle, the 31st day of Discord in the YOLD 3173.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: auto_increment

am 16.04.2007 19:29:14 von ljbuesch

One of two things comes to my mind:

1.) auto_increment *might* have to be AUTO_INCREMENT, as that is how the
manual states it and *some* things in MySQL are case-sensitive (such as
table names).

2.) Make sure you have satisfied the following (From the MySQL manual):
--
You cannot reset the counter to a value less than or equal to any that
have already been used. For MyISAM, if the value is less than or equal
to the maximum value currently in the AUTO_INCREMENT column, the value
is reset to the current maximum plus one. For InnoDB, you can use ALTER
TABLE ... AUTO_INCREMENT =3D value as of MySQL 5.0.3, but if the value =
is
less than the current maximum value in the column, no error message is
given and the current sequence value is not changed.
--

If neither of these help, the actual error message may be of use.

-Logan

-----Original Message-----
From: Ron Piggott [mailto:ron.php@actsministries.org]=20
Sent: Friday, April 13, 2007 10:04 PM
To: PHP DB
Subject: auto_increment

Does anyone see anything wrong with the $query syntax? Ron

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query=3D"ALTER TABLE sessions auto_increment =3D '1'";
mysql_query($query);
mysql_close();

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php