RAVINDRA'S BLOG

Thursday, 12 April 2018

Introduction to SQL

What is SQL?

  • SQL is structured Query Language.
  • It is a computer language for storing, manipulating and retrieving data.
  • SQL is the standard language for relational data base system.

Why SQL?

  • Allows users to 
    • Access data in the relational database management systems.
    • Describe the data.
    • Define the data and manipulate that data.
    • Embed within other languages.
    • Create and drop databases and tables.
    • Create view, stored procedure, functions in a database.
    • Set permissions on tables, procedures and views.

SQL Process:

  • Query Dispatcher
  • Optimization Engines
  • Classic Query Engine
  • SQL Query Engine

SQL Commands:

  • SQL Commands are used to manipulate or retrieve the data base.
  • Base on the functionality SQL Commands are classified to below types.
    • Data Definition Language
    • Data Manipulation Language
    • Data Control Language
    • Transaction Control Language
    • Data Query Language

Data Definition Language(DDL):

  • Deals with descriptions of the database schema.
  • To create and modify the structure of database objects in database.
  • Commands of DDL are:
    • CREATE      : Used to define new objects.
    • ALTER         : Used to modify the definition of existing objects.
    • DROP          : Removes existing entities.
    • TRUNCATE : Removes all rows from a table.
    • COMMENT  : Add comments to the data dictionary
    • RENAME     : Used to rename an object.

Data Manipulation Language(DML):

  • Commands deals with manipulation of data.
  • Commands of DML are:
    • INSERT   : Inserts data in a table.
    • UPDATE : Updates existing data.
    • DELETE : Deletes records from a data base table.

Data Control Language(DCL):

  • Deals with right, permissions and other controls of the data base system.
  • Commands of DCL are:
    • GRANT    : Gives User's access privileges.
    • REVOKE : Withdraw user's access privileges given by using the GRANT command.

Transaction Control Language(TCL):

  • Used to manage transactions in database.
  • To manage changes by DML statements.
  • Commands of TCL are:
    • COMMIT      : Permanently saves any transaction into data base.
    • ROLL BACK : Restores the database to last committed state.
    • SAVEPOINT : Temporarily saves a transaction. 

Data Query Language(DQL):

  • Used to extract data from the relations.
  • SELECT is only command comes under DQL.
  • SELECT retrieves the data from the database using conditions.