Commands in SQL SERVER

We have 4 types of commands in SQL Sever namely DDL,DML,DCL and TCL. In this session I will discuss more about these command types.

DDL Commands: ( Data Definition Language)

 As the name suggests , these type of commands will define the structure of the database objects like tables, stored procedures, triggers, functions, views etc.,

Here is the list of DDL Commands supported by SQL SERVER:
  1. CREATE       : Used to define(create) the structure for the database objects.
  2. ALTER         : Used to Alter or change the structure of database objects.
  3. DROP          : Used to drop the database objects.
  4. TRUNCATE  : Use to remove data completely from a table.
Note: 
  1. TRUNCATE Command is used only on Tables. This command is not applicable for remaining database objects.
  2. RENAME , COMMENT are also DDL Commands.
DML Commands: ( Data Manipulation Language)

DML Commands are used to manipulate data. This is the reason those commands are named as Data Manipulation Language Commands or DML commands.

Some of the most commonly used DML Commands are:
  • INSERT  : Used to insert Data into a table
  • UPDATE : Used to update data in a table
  • SELECT  : This command is used to retrieve/select data
  • DELETE  : Used to delete records from table

DCL Commands: ( Data Control Language)

These commands are used to control the user access over the data. Using DCL commands access can be granted to a user to use database and it can be revoked back if necessary.

Commands used to grant and revoke database access are:

GRANT  : Grants database access to the user
REVOKE : Database access rights are revoked back for an user.

TCL Commands: ( Transaction Control Language)

Just like DCL commands which control data access, TCL commands are used to control the transactions.

Frequently used commands used to control transactions are:

  • COMMIT    : This command saves the transactions performed in transaction block.
  • ROLLBACK : This command is used to rollback the transactions which are performed as part of Transaction block.
Note: SAVEPOINT, SET TRANSACTION are also TCL Commands . But, these commands are not frequently used.


Summary:
  • In this article we have learnt about DDL,DCL, DML and TCL Commands
Commands Learnt:
  • CREATE,ALTER,DROP,TRUNCATE,SELECT,INSERT,UPDATE,DELETE,
  • GRANT,REVOKE,COMMIT,ROLLBAK


This entry was posted in . Bookmark the permalink.

Leave a reply