![]() Statistics are tracked respecting your privacy with Fathom. For instance, any triggers “ON DELETE” will not be fired when using truncate. Do not that the truncate command is a hard-reset option. This will basically reset the table, deleting all data and resetting the auto increment index. ![]() There is a shortcut, however: TRUNCATE TABLE some_table Next, you would want to change the interval between the numbers to change. If you want to delete all records from your table and restart auto-index at 1, you might be tempted to run a DELETE query, followed by the above example, setting the auto increment value to 1. ALTER TABLE EmpDet AUTOINCREMENT newvalue The newvalue is the number pattern you want to start with and not the default value of 1. You can use the following query to set the MySQL auto-index: ALTER TABLE some_table AUTO_INCREMENT=10000 But let’s say you want to start at 10.000, because you want at least a five figure number. Normally, MySQL starts auto-incrementing at 1. Use a Prepared Statement within a Stored Procedure: drop PROCEDURE if exists reset_autoincrement ĬREATE PROCEDURE reset_autoincrement (IN schemaName varchar(255))ĭECLARE cur1 CURSOR FOR SELECT COLUMN_NAME, TABLE_NAME FROM information_schema.Sometimes it’s necessary to set the starting point of a MySQL auto-increment value. We needed to do this after cleaning out a database. Update all auto increment columns in a database to the smallest possible value based on current values in the databases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |