SQL TRUNCATE TABLE Keyword
The TRUNCATE TABLE command is used to delete all data inside a table without deleting the table structure itself. It is faster than DELETE FROM table_name because it does not log individual row deletions.
Important: The table structure (columns, indexes, constraints) remains intact after
TRUNCATE TABLE
.
SQL TRUNCATE TABLE Syntax
SQL
x
1
TRUNCATE TABLE table_name;
SQL TRUNCATE TABLE Example
SQL
1
1
TRUNCATE TABLE Patients;
Note: This syntax does not work in TechKubo playground. SQLite (and therefore TechKubo) does not support the
TRUNCATE TABLE
command.
SQL DELETE Equivalent Example
In SQLite (TechKubo Playground), you can achieve the same result using:
SQL
1
1
DELETE FROM Patients;
