Structured Query Language

Structured Query Language is the language used by DBA and programmers for accessing data from a Database. This language is used to send request to Database and retrieve the required data. With SQL a developer or user can write queries. DBMS processes and fetches the data from table(s) and returns to the user.

Structured Query LanguageSQL involves the process of requesting the data from a Database stored in tables. What a user sends to DBMS is a Database Query written by following the syntax and rules of structured Query Language.

  • SQL is the query language used to query data in all RDBMSs.
  • SQL is not a programming language and it doesn’t need to be compiled. It is non-procedural language.
  • A programmer or developer doesn’t need to write programs like in C/C++, Java etc. It is just like posing questions to the DBMS that fetches required data rows matching the criteria from the database.

Structured Query Language Sub-languages

SQL is divided in four sub languages

  • DDL (Data Definition Language)
    • CREATE – for creating Database objects like tables, views, procedures, functions, triggers, users, roles etc.
    • ALTER- for altering or modifying definitions of existing Database Objects
    • DROP- for permanent removal of existing Database Objects
    • TRUNCATE- to delete the data of table while retaining its structure
  • DML (Data Manipulation Language)
    • INSERT- for inserting or appending new rows in a table
    • UPDATE- For updating the data rows stored in tables
    • DELETE- for deleting the data rows from the tables
    • SELECT- for fetching the data from table(s)
  • DCL (Data Control Language)
    • GRANT – to permit a user or a role to access privileges on Database Objects
    • REVOKE – to revoke previously assigned access privileges to a user or a role
    • COMMENT – to add comments to the data dictionary
  • TCL ( Transaction Control Language)
    • COMMIT- to save the changes in the Database incurred after INSERT, UPDATE and DELETE commands
    • ROLLBACK- to erase changes in the Database incurred after INSERT, UPDATE and DELETE commands
    • SAVEPOINT – to set a marker or a point in a transaction so that in case of inconsistency ROLLBACK can be used to erase changes done after this point
    • SET TRANSACTION – Change transaction options usually for roll backing to a segment