In my last post, I discussed some of the DML commands in SQL Server. This week I want to discuss another category of commands – Data Definition Language, or DDL.
DDL is used to define or redefine the structure of the database.
The commands that are used for DDL are as follows:
- CREATE
- DROP
- ALTER
- RENAME
- TRUNCATE
So many of these should make sense how they are categorized as DDL.
- The CREATE command actually creates the objects.
- The DROP command drops the object specified.
- The ALTER command alters the object in some way.
- The RENAME command changes the name of the object.
And then there’s the TRUNCATE command.
![](https://i0.wp.com/c.tenor.com/w76KQ71POPAAAAAd/and-then-there-was-you-tom.gif?w=750&ssl=1)
Upon first glance at the TRUNCATE command, you’re probably thinking something along the lines of “This gets rid of the data from a table. That has nothing to do with the structure of the table.”
![](https://i0.wp.com/y.yarn.co/2d216ccf-d1f9-44c4-bbd5-49798f03ac9d_text.gif?w=750&ssl=1)
Behind the scenes, what the TRUNCATE command actually does is to completely drop the table and recreate it. This – for all you fun-loving SQL Server people – is why it is a non-logging event and takes a heck of a lot less time to run than DELETE.
To continue with last week’s bonus, I wanted to go with a song about defining yourself. Few songs do it better than a recent song from the hit musical “The Greatest Showman.”
Next time, we’ll go over yet another group of commands that make SQL Server… well, SQL Server. Until then my friends!