English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Unfortunately, we do not have the TRUNCATE TABLE command in SQLite, but you can use the SQLite DELETE command to delete all data from the existing table. However, it is recommended to use the DROP TABLE command to delete the entire table and recreate it.
The following is the basic syntax of DELETE command.
sqlite> DELETE FROM table_name;
The following is the basic syntax of DROP TABLE.
sqlite> DROP TABLE table_name;
If you use the DELETE TABLE command to delete all records, it is recommended to useVACUUMCommand to clear unused space.
Contains the following records in the COMPANY table.
ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 South-Hall 45000.0 7 James 24 Houston 10000.0
The following is an example of truncating the above table-
SQLite> DELETE FROM COMPANY; SQLite> VACUUM;
Now, the COMPANY table has been completely truncated, and the output of the SELECT statement will be zero.