When you create a table in mysql such as this one :
CREATE TABLE UserBase (
UserID INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
Username VARCHAR(20),
Password VARCHAR(20),
FullName VARCHAR(50),
Email VARCHAR(50),
unique(Username)
);
Each insert into the table will increase the UserID field by one.
Deleting all of the records from the table will not cause the next inserted record to begin with 1 like it did when you 1st created the table.
To reset the sequence there are two options :
1. Drop the table and create it again : DROP TABLE UserBase;
2. Truncate the table : TRUNCATE TABLE UserBase;
Newbie Notes #4 - Trapping dumb MySQL query errors Categories : PHP , Databases , MySQL , Debugging , Beginner Guides email new items in db Categories : PHP , Email , Databases , MySQL , Beginner Guides bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL , PHP , MySQL , Complete Programs , Databases How to Insert a Date Format Into MySQL from PHP Categories : PHP , Databases , MySQL , Date Time , Beginner Guides This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases , MySQL , Complete Programs , PHP , Databases Making a simple Hit-Log using PHP and MySql Categories : PHP , Log Files , Beginner Guides , Databases , MySQL Newbie Notes #10 - Generating drop downs Categories : PHP , MySQL , HTML , Beginner Guides , Databases Add, Edit /Update & Delete all in one Contact Management Form Categories : PHP , MySQL , Databases , Beginner Guides for each record, do this to the first record, and do that to any subsequent record Categories : PHP , Databases , MySQL , Beginner Guides Specify your connection settings and create a link to a MySQL database. Categories : PHP , PHP Classes , Databases , MySQL , Beginner Guides Cut your MySQL Connections to 1 line of code Categories : PHP , Beginner Guides , Databases , MySQL mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP , Beginner Guides , MySQL , HTML and PHP , Databases Convert a File database into MySQL Categories : PHP , Filesystem , Databases , MySQL , Beginner Guides phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. Categories : Databases , MySQL , Complete Programs , PHP Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays. Categories : Calendar , Date Time , PHP , Databases , MySQL
Potchavit Aphinives wrote : 887
It`s unnecessary to drop the table, just drop the field ID. Then recreate it, MySQL will set the new sequence automatically.
salem65 salem65 wrote : 890
alter table <table name> auto_increment = 0;