Monday, June 2, 2008

SQL*Plus Statements 1

100. What are the types of SQL statement?
Data Definition Language: CREATE, ALTER, DROP, TRUNCATE, REVOKE, NO AUDIT & COMMIT.
Data Manipulation Language: INSERT, UPDATE, DELETE, LOCK TABLE, EXPLAIN PLAN & SELECT.
Transactional Control: COMMIT & ROLLBACK
Session Control: ALTERSESSION & SET ROLE
System Control: ALTER SYSTEM.

101. What is a transaction?
Transaction is logical unit between two commits and commit and rollback.

102. What is difference between TRUNCATE & DELETE?
TRUNCATE commits after deleting entire table i.e., cannot be rolled back.
Database triggers do not fire on TRUNCATE

DELETE allows the filtered deletion. Deleted records can be rolled back or committed.
Database triggers fire on DELETE.

103. What is a join? Explain the different types of joins?
Join is a query, which retrieves related columns or rows from multiple tables.
Self Join - Joining the table with itself.
Equi Join - Joining two tables by equating two common columns.
Non-Equi Join - Joining two tables by equating two common columns.
Outer Join - Joining two tables in such a way that query can also retrieve rows that do not have corresponding join value in the other table.

104. What is the sub-query?
Sub-query is a query whose return values are used in filtering conditions of the main query.

105. What is correlated sub-query?
Correlated sub-query is a sub-query, which has reference to the main query.

No comments:

Useful Information