HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Why is it truncate table, and not simply truncate?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
whytruncateandsimplynottable

Problem

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?

Solution

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.

Context

StackExchange Database Administrators Q#102254, answer score: 8

Revisions (0)

No revisions yet.