一般在清空表的時候,還須要把自增列歸零。在SQLite中定義自增列的方法以下:sql
1
|
CREATE TABLE TableName ( id INTEGER PRIMARY KEY AUTOINCREMENT, ... );
|
當SQLite數據庫中包含自增列時,會自動創建一個名爲 sqlite_sequence 的表。這個表包含兩個列:name和seq。name記錄自增列所在的表,seq記錄當前序號(下一條記錄的編號就是當前序號加1)。若是想把某個自增列的序號歸零,只須要修改 sqlite_sequence表就能夠了。數據庫
2
|
UPDATE sqlite_sequence SET seq = 0 WHERE name = 'TableName';
|
也能夠直接把該記錄刪掉:.net
3
|
DELETE FROM sqlite_sequence WHERE name = 'TableName';
|
4
|
DELETE FROM sqlite_sequence;
|