Sunday, November 18

SQL Made Easy

What is SQL?

  • SQL stands for Structured Query Language
  • SQL lets you access and manipulate databases

What Can SQL do?

  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert records in a database
  • SQL can update records in a database
  • SQL can delete records from a database
  • SQL can create new databases
  • SQL can create new tables in a database
  • SQL can create stored procedures in a database
  • SQL can create views in a database
  • SQL can set permissions on tables, procedures, and views
Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language such as MySQL, SQL Server, Access, Oracle, Sybase, DB2.
**SQL Server is a product of MicroSoft.

In SQL Server we can:
  •          Managing Databases and Tables using DDL Statements
  •          Manipulating Data in Tables using DML Statements
  •          Controlling Data in Tables using DCL Statements
  •          Accessing Data using DAL Statement and
  •          Transaction Control Language Statements(TCL)


   What are DDL Statements?

DDL(Data Definition Language) contains Create, Alter, Drop, Truncate and Rename commands.
Data Definition Language is used manage Databases and its Structure, Using this statements we can Create, Alter, Drop, Truncate and Rename database. See the diagrammatic presentation below.


  ** Change and Rename are MySQL commands


What are DML Statements?

Data Manipulation Language(DML), Used to manipulate data in database objects(Table) using commands Insert, Delete, Update. See the diagrammatic presentation below.



What are DCL Statements?

Data Control Language(DCL), It is used to control the data access in the database. Some of the DCL commands are:


  • GRANT: Used to assign permissions to users to access a database object
  • REVOKE: Used to deny permissions to users to access a database object



What is DQL(Data Query Language) or DAL(Data Access Language)?

It is used to query data from the database objects. SELECT  is the DQL/DAL command that is used to select data from the database in different ways and formats.



What is Transaction Control Language Statements(TCL)?

It used to control transactional processing in a database. A transaction is logical unit of work that comprises one or more SQL statements, usually a group of DML statements. Examples of TCL commands include:
  •      COMMIT         : To apply the transaction by saving the database changes.
  •      ROLLBACK    : To undo all changes of a transaction.
  •      SAVEPOINT  : To divide the transaction into smaller sections. It defines breakpoints for a transaction to allow partial rollbacks.

In detail query will be explained in coming posts, Hope this will help.