C++ with SQLite3: Part 4: Removing Data

C++ with SQLite3

SQLite3 is the most-used SQL implementation in the world. It is a self-contained C library included in everything from portable devices to web browsers.

Note: This tutorial assumes some familiarity with using the command-line to create and compile files. It was written using a MacOS X machine and also assumes easy access to g++. (For Windows systems, consider using MinGW.)


Removing Data

Removing data from a table is the same as inserting in SQL. Using DELETE FROM and the table name, data can be removed based on conditions.

To see the changes in the table, an additional SELECT statement can be run.

Removing All Data

Running DELETE without a condition (using WHERE) will delete all of the data. Unless this is intentional, it should be avoided.

Deleting (Dropping) a Table

As with SQL, a table can be truly deleted through using the DROP keyword. This will be completely erased and removed.