Saturday, May 28, 2011

ACID Rules in Sql Server


ACID Rules

ACID Rules:- It is a concept for evaluation of databases and their architecture.

A:- (Atomicity) – Atomicity  states the principle of  All or none. This means that either all the SQL Statements within the transaction will be executed or no Sql statement will be executed.

C:- Consistency:- Consistency states that only valid data will be written into the database. That means if any Sql transaction violets the rules or constraints define on the database to make it consistent, then all the statements within the transaction will be Rollback. Or in other words the whole transaction will be rolled back.

I:- Isolation :- The Isolation state that if multiple transaction try to work on the database at the same time,then these transaction will not interfere with each other. It means the second transaction will not work unless and until the previous transaction completes its work and the work is commited.

D:- Durability:- Durability states that once the transaction is committed, then the database should not be lost in case of Software failures or hardware failures. Durability is maintained with the help of the  database backups and transaction logs. 

DML, DDL, DCL, TCL in SQL Server


Different Types of Sql Statements:-

DML
DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database.

Examples: SELECT, UPDATE, INSERT statements

Select :- This Sql Statement is used to extract the data from one or combination of tables
Update:- This Sql Statement is used to update the data in a database table.
Delete:- This Sql Statement is used to delete data from the database table.
Insert Into :- This Sql Statement is used to insert data into a database(table)

DDL
DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database.

Examples: CREATE, ALTER, DROP statements

Create Table:- This Sql Statements is used to create a Table
Alter Table:- This Sql Statement is used to Alter the table definition like adding any columns or deleting any table column.
Drop table:- This Sql Statement is used to Drop the table.
Create Index:- This Sql Statement is used to Create a Index on a table
Drop Index:- This Sql Statement is used to drop a table from the table

DCL

DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.

Examples: GRANT, REVOKE statements
Grant :- This Sql Statement is used to give access rights to the user for the database
Revoke:- This Sql Statement is used to revoke or delete the access rights of some of the users for a given database.

TCL

TCL is abbreviation of Transactional Control Language. It is used to manage different transactions occurring within a database.

Examples: COMMIT, ROLLBACK statements

Commit:- This command is used to save the work done by the user.
Rollback:-  This command is used to delete the data till the last committed state of the database.