Lets say i have have a table with 200 records and i deleted all of them now when i try to add another record to that table i want the id of the record to start from 1 instead of 201. i tried this code but doesn't work
$connection->query("ALTER TABLE table_name AUTO_INCREMENT = 1")
is there any other way to do this?
Thanks in advance
You'll need to truncate
the table:
TRUNCATE table `tablename`
Logically, TRUNCATE TABLE is similar to a DELETE statement that deletes all rows, or a sequence of DROP TABLE and CREATE TABLE statements.
Any AUTO_INCREMENT value is reset to its start value. This is true even for MyISAM and InnoDB, which normally do not reuse sequence values.
More information at http://dev.mysql.com/doc/refman/5.7/en/truncate-table.html.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments