Although, there are a number of query languages that are in use both commercially and in research. The most popular and widely accepted query language is Structured Query Language-SQL. Structured Query Language-SQL is not a general-purpose language. It is domain-specific. We use it in the design and management of data held in RDBMS.
The basis of SQL is relational algebra. SQL parser translates its abstract syntax tree into a tree of relational operators, which describes the relational algebra operations.
Why SQL is a Structured Query language?
Originally SQL was named as SEQUEL which stands for Structured English Query Language. However, later it was renamed as SQL. The motive was to design a programming language just like English with formal syntax i.e. structured English.
Types of SQL commands
SQL uses certain commands to carry out the required task. SQL categorize them into 5 categories.
- DDL- Data Definition Language
- DQL- Data Query Language
- DML- Data Manipulation Language
- DCL- Data Control Language
- TCL- Transaction Control Language
Data Definition Language
We use Data Definition Language to define, delete and modify relational schema or structure. We also use DDL for defining view and integrity constraints on the data stored in the database. DDL commands are:
Create, Alter, Drop, Truncate and Rename
Data Query Language
The command used to retrieve data from the database. DQL command is Select
Data Manipulation Language
We use DML commands to manipulate the data present in the database. We apply DML commands on the data of the database table. Most commonly used DML commands are:
Insert, Update and Delete.
Data Control Language
Data Control Language includes commands which mainly deals with permissions and rights and other controls of the database. DCL commands are:
Grant and Revoke
Transaction Control Language
TCL includes commands for specifying the beginning and end of the transactions in the database. TCL commands are:
Commit, Rollback and Savepoint