How to Define objects

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.

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.”

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!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.