auto_increment
am 27.12.2004 00:41:53 von Ron Piggott
I have the auto_increment on one of my variables. During the past few days
I have been doing testing on a "live" database and created several test
records which I now have deleted from my table. Is there any way of setting
the auto_increment value to match the last "correct" number? Ron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: auto_increment
am 27.12.2004 02:47:37 von LarryUllman
> I have the auto_increment on one of my variables. During the past few
> days
> I have been doing testing on a "live" database and created several test
> records which I now have deleted from my table. Is there any way of
> setting
> the auto_increment value to match the last "correct" number? Ron
You don't say what database application you're using, but if it's
MySQL, you can change the auto increment value using:
ALTER TABLE tablename AUTO_INCREMENT = 1
That being said, you actually don't have to do this (and often
shouldn't, really). Having gaps in your auto increment sequence
shouldn't be a problem.
Larry
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: auto_increment
am 28.12.2004 12:39:24 von Ron Piggott
Thanks Larry.
It was mySQL ...
Ron
On Sun, 26 Dec 2004 20:47:37 -0500, Larry E. Ullman wrote
> > I have the auto_increment on one of my variables. During the past few
> > days
> > I have been doing testing on a "live" database and created several test
> > records which I now have deleted from my table. Is there any way of
> > setting
> > the auto_increment value to match the last "correct" number? Ron
>
> You don't say what database application you're using, but if it's
> MySQL, you can change the auto increment value using:
> ALTER TABLE tablename AUTO_INCREMENT = 1
>
> That being said, you actually don't have to do this (and often
> shouldn't, really). Having gaps in your auto increment sequence
> shouldn't be a problem.
>
> Larry
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: RE: auto_increment
am 17.04.2007 15:05:18 von Ron Piggott
--=-b2OP+3hQTuVDokxHimRP
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
I will explain myself a bit more:
I wrote my own session handler function so I could use session files. I
have been able to specify a directory for session files as well as their
life expectancy is +- 90 minutes, not to exceed 99 minutes from
inactivity.
My purpose in setting auto_increment back to 1 is that I won't exceed
the auto_increment maximum integer value and that the table is
maintenance free when I am able to get this working with a cron.
I have noticed that when putting a script onto a cron sometimes requires
minor tweaking from how it runs when called on the web. I am able to
change the value to 1 using the original syntax I posted to the list ---
not with the cron. I changed AUTO_INCREMENT to be in capital letters
and will see if this works tomorrow when the cron runs.
I have been using the session_regenerate_id(); command to keep the
logins secure with session variables controlling which account is being
accessed. There are a few other things running in the background to
help protect the sessions. It is feasible that when a user accessed
their account they use 10 to 15 entries in the mySQL table. I just want
to keep bringing the auto_increment field back to 1 because of this. Am
I making sense? I am trying to get ready for a marketing campaign for a
home based business I have started so I may eventually quit my day job
do when I have a passion for (caring for people.)
Ron
On Tue, 2007-04-17 at 08:20 -0400, Michael Keyser wrote:
> You could also use phpMyAdmin if no one else has mentioned it. It's
> pretty simplistic and is a collaboration of PHP scripts specifically for
> maintaining MySQL databases. I think you should check it out:
>
> http://www.phpmyadmin.net
>
> -----Original Message-----
> From: Buesching, Logan J [mailto:ljbuesch@purdue.edu]
> Sent: Tuesday, April 17, 2007 8:17 AM
> To: ron.php@actsministries.org; PHP DB
> Subject: [PHP-DB] RE: auto_increment
>
> 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 = 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]
> 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="ALTER TABLE sessions auto_increment = '1'";
> mysql_query($query);
> mysql_close();
>
--=-b2OP+3hQTuVDokxHimRP--
Re: auto_increment
am 07.09.2010 18:05:35 von ron.piggott
I am receiving the following error Adriano:
SQL query:
ALTER TABLE `stats` DROP `visits` CREATE TABLE `stats2` LIKE `stats` ;
MySQL said: Documentation
#1064 - 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
'CREATE TABLE `stats2` LIKE `stats`' at line 2
The complete commands were:
ALTER TABLE `stats` DROP `visits`
CREATE TABLE `stats2` LIKE `stats`;
ALTER TABLE `stats2` ADD COLUMN `visits` INT( 25 ) NOT NULL
AUTO_INCREMENT, ADD PRIMARY KEY(`visits`) FIRST;
INSERT INTO `stats2` SELECT *, 0 FROM `stats` ORDER BY `initial_access`;
I don't understand the error, your way of creating a table is new to me.
Did something small get missed?
Ron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: auto_increment
am 07.09.2010 18:10:34 von kapuoriginal
You are missing a semicolon after the first alter statement.
Kapu
On 7. 9. 2010 18:05, Ron Piggott wrote:
> I am receiving the following error Adriano:
>
> SQL query:
>
> ALTER TABLE `stats` DROP `visits` CREATE TABLE `stats2` LIKE `stats` ;
>
> MySQL said: Documentation
> #1064 - 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
> 'CREATE TABLE `stats2` LIKE `stats`' at line 2
>
> The complete commands were:
>
> ALTER TABLE `stats` DROP `visits`
> CREATE TABLE `stats2` LIKE `stats`;
> ALTER TABLE `stats2` ADD COLUMN `visits` INT( 25 ) NOT NULL
> AUTO_INCREMENT, ADD PRIMARY KEY(`visits`) FIRST;
> INSERT INTO `stats2` SELECT *, 0 FROM `stats` ORDER BY `initial_access`;
>
> I don't understand the error, your way of creating a table is new to me.
> Did something small get missed?
>
> Ron
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: auto_increment
am 08.09.2010 12:31:47 von Adriano Rodrigo Guerreiro Laranjeira
Hello!
I didn't use any DROP statements. Do exactly as following:
mysql> CREATE TABLE stats2 LIKE stats;
mysql> ALTER TABLE stats2 ADD COLUMN id INT NOT NULL AUTO_INCREMENT,=20
ADD PRIMARY KEY(id);
mysql> INSERT INTO stats2 SELECT *, 0 FROM stats ORDER BY
The first line copies the structure of table stats to a new table=20
called stats2;
The second one, create a new field called id;
The third inserts all records from stats to stats2, in correct order.
After all, you need drop the table stats and rename the table stats2=20
to stats:
mysql> DROP TABLE stats;
mysql> RENAME TABLE stats2 TO stats;
Be careful, I don't know your environment.
[]'s
Adriano!
> > > > > > > > >=20
> On Tue, 07 Sep 2010 18:10:34 +0200
> Kapu wrote:
> You are missing a semicolon after the first alter statement.
>=20
> Kapu
>=20
> On 7. 9. 2010 18:05, Ron Piggott wrote:
>> I am receiving the following error Adriano:
>>
>> SQL query:
>>
>> ALTER TABLE `stats` DROP `visits` CREATE TABLE `stats2` LIKE `stats`=20
>>;
>>
>> MySQL said: Documentation
>> #1064 - You have an error in your SQL syntax; check the manual that
>> corresponds to your MySQL server version for the right syntax to use=20
>>near
>> 'CREATE TABLE `stats2` LIKE `stats`' at line 2
>>
>> The complete commands were:
>>
>> ALTER TABLE `stats` DROP `visits`
>> CREATE TABLE `stats2` LIKE `stats`;
>> ALTER TABLE `stats2` ADD COLUMN `visits` INT( 25 ) NOT NULL
>> AUTO_INCREMENT, ADD PRIMARY KEY(`visits`) FIRST;
>> INSERT INTO `stats2` SELECT *, 0 FROM `stats` ORDER BY=20
>>`initial_access`;
>>
>> I don't understand the error, your way of creating a table is new to=20
>>me.
>> Did something small get missed?
>>
>> Ron
>>
>>
>=20
> --=20
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>=20
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php