Saturday 8 September 2012

SQL Basics


SQL is a simple, yet powerful, language used to create, access, and manipulate data and structure in the database.
SQL Statements categories: 

DDL - Data Definition Language.


DDL is used to define, alter, or drop database objects and their privileges. DDL statements will implicitly perform a commit.

DDL Statements:
Create   It is used to create objects(tables, views) in the database.
Alter   It is used to alter the structure of the database objects.
Drop       Delete database objects. It will invalidate the dependent objects ,it also drops                           triggers and indexes, referential integrity constraints.
Truncate : Remove all records from a table, including all spaces allocated for the records are removed.It is fast as compared to Delete and does not generate undo information as Delete does. It performs an implicit commit as it is a DDL. It resets the high water mark
Grant Assigning privileges

DML - Data Manipulation Language.


DML is used to access, create, modify or delete data in the structures of the database.

DML Statements:

Select Select data from the database
Insert It is used to insert data into a table
Update It is used to update existing data within a table
Delete  It removes rows from the table.

DCL - Data Control Language


Following are the examples of Data control Statements. 

DCL Statements:

Commit          It will end the current transaction making the changes permanent and visible to all users.
Savepoint         It will identify a point(named SAVEPOINT) in a transaction to which you can later roll back
Rollback        It will undo all the changes made by the current transaction.
Set-Transaction  It is used to define the properties of a transaction.

No comments:

Post a Comment