Removing all rows from the Employee table
suggest changeTRUNCATE TABLE Employee;
TRUNCATE TABLE is often faster than DELETE FROM Employee, and it does not fire DELETE triggers. It still empties indexes; it does not leave them in place. DELETE removes rows. TRUNCATE deallocates data pages. There is no DELETE TABLE statement.
DELETE can remove selected rows. TRUNCATE always removes every row. After a DELETE of all rows, an identity counter usually continues from its previous value. TRUNCATE resets that counter on many systems, including SQL Server. Whether it resets is dialect-specific.
You cannot truncate a table that is the target of a foreign key. The table having its own foreign keys is a separate question and depends on the dialect.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents