sqlite的
使用:
DELETE FROM your_table;
DELETE FROM sqlite_sequence WHERE name = 'your_table';
sqlite keeps track of the largest ROWID that a table has ever held using the special sqlITE_SEQUENCE table. The sqlITE_SEQUENCE table is created and initialized automatically whenever a normal table that contains an AUTOINCREMENT column is created. The content of the sqlITE_SEQUENCE table can be modified using ordinary UPDATE,INSERT,and DELETE statements. But making modifications to this table will likely perturb the AUTOINCREMENT key generation algorithm. Make sure you know what you are doing before you undertake such changes.
使用:
ALTER TABLE tbl AUTO_INCREMENT = 1;
在這兩種情況下,數據庫不關心ID號是否是順序的 – 只有值是唯一的.如果用戶從未看到主鍵值(他們不應該,因為數據可能會改變并不總是在該主鍵值),我不會打擾這些選項.