Saturday 4 April 2015

SQL in breif

In this tutorial we are going to see the need of SQL in a database and what it is capable of doing to the database.

Basically SQL stands for Structured Query Language. The main purpose of SQL is manage the data which is available in any Database. SQL are mainly classified as following

DDL – Data Definition Language
DML – Data Manipulation Language
DCL – Data Control Language
TCL – Transaction Control Language
DQL – Data Query Language

SQL is mainly used to perform CRUD (Create Read Update Delete) operations in the database objects. Now lets the see in brief each of the classifications

Note: We are going to discuss the important things, to see the detailed please refer Oracle documentation.

Data Definition Language:
          DDL statements allows you to mainly create, modify, and drop any database objects. Also allows to control the privileges of the objects between the schema/user.

CREATE – Used to create any database objects.
ALTER – Modify any existing database objects.
DROP – Remove objects from the database.
RENAME – Rename an existing object.
TRUNCATE –Remove all the data of the table.
PURGE – Permanently remove an object from the database.

Data Control Language:
               DCL statements make sure which the data are accessed between the schemas

GRANT – Allows a user to perform a specific task.
REVOKE – Removes the access provided to a user.

Data Manipulation Language:
          DML statements mainly helps us in creating, modifying, deleting the contents of an existing table.

INSERT – Insert new data into the table.
UPDATE – Update any existing data in the table.
DELETE – Delete the existing data in the table.
MERGE – Merge the data between two tables.

Note: All the transactions need to be committed so that the changes are saved in the database. If any DDL statements occurs

Transaction Control Language:
          TCL statements are used to control the data changed by DML statements. The changes can be either saved or discarded.


SAVEPOINT – Make a point for rolling back a transaction
SET TRANSACTION – Change transaction option like isolation level and what segment to use.
ROLLBACK – Rollback all the changes made during this transaction
COMMIT – Save all the changes made to the disk

Data Query Language:
            DQL allows mainly used to query existing data in the table, and display it to the user it’s SELECT statement. The select statement has the capability to only to display the data which is already available it can also modify the data before displaying it to the user.

SELECT - Used to select the data from the database object.

Please provide your comments below the blog.


No comments: