The TRUNCATE TABLE command is used to remove all rows from an existing table.
TRUNCATE TABLE tableName;
TRUNCATE TABLE EMPLOYEE;
Difference between TRUNCATE, DELETE and DROP commands:
To delete or remove all rows from a table, use the DELETE statement. The where clause can be used to delete specific rows. We can roll back the DELETE operation. TRUCATE is faster than DELETE. It is a DML command. The structure of the table will not be lost.
To remove all rows from an existing table, use the TRUNCATE statement. We can’t roll back the TRUNCATE operation. DELETE is slower than TRUCATE. It is a DDL command. Table structure will not be lost.
The DROP TABLE statement is used to delete an existing table definition, indexes, constraints, access privileges and all associated data. We can’t roll back the DROP operation. The command is DDL. The structure of the table will be lost.
One reply on “Truncate Table in SQL”
SQL Tutorials - Scaz January 26, 2023 at 5:14 pm
[…] SQL TRUNCATE Table […]