Wednesday, April 7, 2010

Database Testing - SQL Lesson 2 - SQL Commands

Previous12345678910Next

What are the different types of SQL Commands?

The SQL commands are used to interact or communicate with the database to perform specific tasks. SQL commands are used to do various functions apart from searching the database. Basically SQL Commands are divided in to four categories they are Data Manipulation Language (DML), Data Definition Language (DDL), Data Control Language (DCL), Transactional Control Language (TCL) but mostly DML and DDL commands are frequently used.
Let us look into details of these different kinds of SQL Commands.

Data Manipulation Language

Data Manipulation Language or what is frequently referred as DML is used to manipulate data in a table or in the database. The basic objective of these commands are to retrieve, store, modify, delete, insert and update data.

Different types of DML Commands

The different kinds of Data Manipulation Language commands are given below. They are
1. INSERT Command: This command is used to insert records or columns in a table.
2. UPDATE command: This command is used to update the records or columns already existing in a table.
3. DELETE Command: This is used to delete an already existing record in a table. This command only deletes the values in the record of the table but not the structure.

Data Definition Language

Data Definition Language is often referred as DDL and these commands are used to create, modify the structure of tables or objects in the database.

Different types of DDL Commands

The different kinds of Data Definition Language commands are given below. They are
1. CREATE Command: The Create command is used to create any object in the database. The objects can be a Table, View, Trigger or Stored procedure.
2. ALTER Command: The Alter command is used to modify any object like Table, View, Trigger or Stored procedure in the database
3. DROP Command: The Drop command is used to delete or remove a table from the database or even a database itself from the server. The Drop command permanently removes the structure from the database or server and there is no way to recover it. One needs to be careful in using this command.
4. TRUNCATE Command: The Truncate command allows the user to delete all the rows of a table in the database.
5. RENAME Command: The Rename command is used to modify the names of the objects in the database.

Data Control Language

Data Control Language is often referred as DCL and these commands are used in providing security to the database like creating roles, setting permissions, maintaining integrity and also to control access to the database. The commands used are GRANT and REVOKE.

Transactional Control Language

Transactional Control Language is often referred as TCL and these commands are used in managing changes affecting the database. The commands used are COMMIT and ROLLBACK.

Previous12345678910Next

No comments:

Post a Comment