3

Upon reviewing some of our code a colleague posited that he was annoyed at always having to write TRUNCATE TABLE when there is no real other usage for TRUNCATE.

Googling this, I indeed can not find a specific reason why the TABLE part is needed.
What am I missing? Is there some historical reason for the TABLE in TRUNCATE TABLE?

8

The syntax choice is likely for consistency, albeit redundant. TRUNCATE TABLE follows the same pattern as other DDL statements (CREATE, ALTER, DROP), where the object type immediately follows the action keyword.

I should add TRUNCATE TABLE is part of the ANSI SQL Standard as of the 2008 version, although it was implemented in SQL Server long before then.

| improve this answer | |
3

Seems to me its redundancy for future extensibility. There may not be any other use for TRUNCATE currently, but one could be added in the future. Or at least that would have been the mindset of the developers.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.