SQL Statements – DDL, DML, DCL and TCL

The SQL Statements are generally divided into following broad categories:

  • Data Definition Language (DDL)

The part of SQL that you use to create a database, modify its structure, and destroy it when you no longer need it.

Example:

  • CREATE – to create object in database
  • ALTER – alters the structure of objects in the database
  • DROP – delete objects form the database
  • TRUNCATE – remove all the records from a table.
  • RENAME – rename an object

  • Data Manipulation Language (DML)

Performs database management. You can specify what you want to do with data in your database – enter it, change it, or extract it.

Example:

  • SELECT – retrieve data from database
  • INSERT – insert data into a table
  • UPDATE – updates existing data within a table
  • DELETE – deletes some or all records from a table.
  • Data Control Language (DCL)

Protects you database from being corrupted. The DCL command provides security for your database.

Example:

  • GRANT – gives user’s access privileges to database
  • REVOKE – withdraw access privileges given with the GRAND command
  • Transaction Control Language (TCL )

It is used to manage different transactions occurring within a database.

Example:

  • COMMET – save work done
  • ROLLBACK – restore the database to original since last COMMIT
  • SAVEPOINT – identify point in transaction to which you can later roll back.

This article has been inspired from ‘SQL for Dummies’ by Allen G. Taylor.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: