Thought Sharing

Wednesday, December 5, 2012

List of SQL Queries


SQL Queries
Table Structure Related Queries:
1)      Create table
2)      Rename a table
3)      Creating a table from another table
4)      Deleting a table
5)      Adding a new column in an existing table
6)      Modifying a column in an existing table
7)      Deleting a column from an existing table
8)      Adding Primary Key during creating a table
9)      Adding Primary Key in an existing table
10)   Adding Foreign Key during creating a table
11)   Adding Foreign Key in an existing table
12)   Dropping a Primary Key from a table
13)   Dropping a Foreign Key from a table
14)   Defining Check constraint at Column Level while creating a table
15)   Defining Check constraint at Column Level using alter table
16)   Defining Check constraint at Table Level while creating a table
17)   Defining Check constraint at Table Level using alter table
18)   Dropping a Check constraint

Working with Table:
1)      Insert values in the table
2)      Update values in the table
3)      Delete values in the table
4)      Truncate Table (To empty a table- to delete all records)
5)      Selecting values from table
6)      Where Clause
7)      Desc (Description)
8)      Order BY Clause
9)      Group By Clause
10)   Having Clause
11)   Distinct Clause
12)   Searching Record using: Between, IN, NOT IN, Like
13)   Oracle Functions: AVG (), MIN (), MAX (), COUNT (), SUM (), SQRT (), EXP (), MOD (), TRUNC (), FLOOR (), CEIL (), LOWER (), UPPER (), ASCII ().

Sub Queries:
1)      Finding Duplicate Records from a Table
2)      Deleting Duplicate Records from a Table
3)      Finding Highest Salary from Employee Table
4)      Finding 2nd Highest Salary from Employee Table
5)      Finding 5th Highest Salary from Employee Table
6)      Finding Nth    Highest Salary from Employee Table

Database Objects:
1)      Creating View
2)      Deleting View
3)      Creating Join
4)      Create Index
6)      Delete Index