Like what:
The code is as follows |
Copy Code |
TRUNCATE TABLE table1 |
TRUNCATE table table1 (table name) or this can also be:
The code is as follows |
Copy Code |
ALTER TABLE table_name AUTO |
Method Two
Will not empty the existing data, the operation is more flexible, not only can return to zero, but also for the deletion of a large number of consecutive rows, reset the value and insert new data, or starting from the new value, of course, can not and existing conflicts.
The code is as follows |
Copy Code |
$sql = "Delete from $table _vote"; mysql_query ($sql, $link); $sql = "ALTER TABLE $table _vote auto_increment=1"; mysql_query ($sql, $link); |
MySQL Database unique number field (AutoNumber field)
In database applications, we often use a unique number to identify the record. Auto_increment Properties of data columns available in MySQL
From dynamic generation. MySQL supports a variety of data tables, each of which has a different properties of the data table, which will introduce the data in various tables
Column self-increasing property.
ISAM table
If you insert a null into a auto_increment data column, MySQL automatically generates the next sequence number. Number is open from 1
Beginning, and 1 for cardinality increment.
The effect of inserting 0 into a auto_increment data column is the same as inserting a null value. This is not recommended, however, or it is better to insert a null value.
When you insert a record without explicitly specifying a value for Auto_increment, the equivalent is to insert a null value.
When you insert a record, if you explicitly specify a numeric value for the auto_increment data column, there are two situations where, if
The inserted value repeats with the existing number, and an error message occurs because the value of the Auto_increment data column must be unique;