Saturday, October 6, 2012

Oracle Topics and Example


 Type of Data Command in SQL

DDL -- Create, Alter, Drop, Rename, Comment, Truncate
 Create is used to create a table
 Alter is used to change the structure of the table
The drop is used to removing the structure of table and data.
Rename is used to renaming the name of the table and column of the table.
Comment is used to an additional description about table or column in the database.


DML --- Insert, Update, Delete, Merge
 Insert is used to insert the data into tables.
 The update is used to modify the content of the data in the table.
 Delete is used to deleting the data from table using where condition option.
 Merget is used to execute 2 operations at a time insert and update in a single command.

TCL --- Commit, Rollback, Savepoint
  this is transactions command. This DDL command is auto-commit.
  this command is used whenever we are using DML operations.
  Commit is used to permit commit into the database
  Rollback is used to go back the previous status.
  Savepoint is like a checklist for the data to saving point when we required we rollback using save      point checklist

DCL-- Grant and Revoke
    Grant is used for the user can read & write on a certain database objects
    Revoke withdraw access privileges given with the GRANT command

SQL Constraints

 Not Null, Unique, Primary Key, Foreign Key, Check, Default, Index

NOT NULL - Ensures that a column cannot have a NULL value
UNIQUE - Ensures that all values in a column are different
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table
FOREIGN KEY - Uniquely identifies a row/record in another table
CHECK - Ensures that all values in a column satisfy a specific condition
DEFAULT - Sets a default value for a column when no value is specified
INDEX - Used to create and retrieve data from the database very quickly

Different Types of SQL JOINs

Here are the different types of the JOINs in SQL:

(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Return all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Return all records from the right table, and the matched records from the left table
FULL (OUTER) JOIN: Return all records when there is a match in either left or right table




No comments: