MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
May
Sun Mon Tue Wed Thu Fri Sat
       
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
2025
Months
MayJun
Jul Aug Sep
Oct Nov Dec


Sun, May 04, 2025 2:26 pm

Deleting all records from an SQLite table

If you wish to delete all of the records from a table in an SQLite database, you can do so using a command in the form delete from tableName where tableName is the name of the table from which you wish to remove all of the rows in the table. E.g., if I wished to delete all of the records in a table named TimeStamps, I could use the delete command below.

sqlite> select * from Timestamps;
2025-05-01 21:26:22|2025-05-01 21:23|10947739
2025-05-01 21:28:33|2025-05-01 21:28|10967247
2025-05-04 13:37:47|2025-05-04 13:36|18079581
sqlite> delete from Timestamps;
sqlite> select * from Timestamps;
sqlite>

If I only wanted to delete a record or records meeting a specific condition, I could specify that condition in a WHERE clause. E.g., if the columns in the table were CurrentTimestamp, LastUpdateTimestamp, and Size and I only wanted to remove the row where the value of CurrentTimestamp is 2025-05-04 13:37:47, I could use the command below, instead.

sqlite> .schema Timestamps
CREATE TABLE "Timestamps" (
        "CurrentTimestamp"      TEXT NOT NULL,
        "LastUpdateTimestamp"   TEXT NOT NULL,
        "Size"  INTEGER NOT NULL
);
sqlite> delete from Timestamps where CurrentTimestamp='2025-05-04 13:37:47';

[/software/database/sqlite] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo