Structured Query Language (SQL)

Structured Query Language (SQL)

Structured Query Language (SQL) is also pronounced as “sequel” which stands for Structured English Query Language.

SQL was developed by IBM in the 1970s and is an ISO/ANSI standard. It was one of the first commercial languages for Edgar F. Codd’s relational model.

It provides an interface to Relational Database Systems, which is used to modify and access data or information from database.

Now it is being used by most of the Relational Database management Systems (RDBMS) like Oracle, Microsoft SQL Server, etc.

 

SQL commands are divided into four categories as below:

 

  1. DML (Data Manipulation Language): DML is used for changing data within the database.

Examples:

INSERT:- insert data into a table .

UPDATE: updates existing data within a table .

DELETE: deletes all records from a table, the space for the records remain .

CALL: call a PL/SQL or Java subprogram .

EXPLAIN PLAN: explain query access path to data .

LOCK: control concurrency .

MERGE: UPSERT operation (insert or update) .

 

  1. DDL (Data Definition Language): It is used to create, delete, modify the database structure, not data.

Examples:

CREATE: to create objects in the database

ALTER: alters the structure of the database

DROP: delete objects from the database

COMMENT: add comments to the data dictionary

TRUNCATE: remove all records from a table, including all spaces allocated for the records are removed .

RENAME: rename an object .

 

  1. DCL (Data Control Language): It is used to control access to data and database.

Examples:

        GRANT: gives user's access privileges to database.

REVOKE: withdraw access privileges given with the GRANT command .

 

4. TCL (Transaction Control Language): statements used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.

Examples:

COMMIT: save work done

ROLLBACK: restore database to original since the last COMMIT

SAVEPOINT: identify a point in a transaction to which you can later roll back

       SET TRANSACTION: Change transaction options like isolation level and what rollback  segment to use

 

        5. DQL (Data Query Language): It is used to fetch data from the database using  select statement.

Examples:

SELECT: retrieve data from the a database

 

 

 

Source: Internet