Total Pageviews

October 2, 2016

10/02/2016 09:58:00 PM


Oracle SQL interviw questions

Oracle SQL Interview Questions
 
1. 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.
 
2. What is a transaction ?
 
Transaction is logical unit between two commits and commit and rollback.
 
3. What is difference between TRUNCATE & DELETE ?
 
TRUNCATE commits after deleting entire table i.e., can not 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.
 
4. 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 retrive rows that do not have corresponding join value in the other table.
 
5. What is the  Subquery ?
 
Subquery is a query whose return values are used in filtering conditions of the main query.
 
6. What is correlated sub-query ?
 
Correlated sub_query is a sub_query which has reference to the main query.
 
7. Explain   Connect by Prior ?
 
Retrives rows in hierarchical order.
e.g. select empno, ename from emp where.
 
8. Difference between SUBSTR and INSTR ?
 
INSTR (String1,String2(n,(m)),
INSTR  returns  the  position  of  the  mth  occurrence  of the string 2 in
string1. The search begins from nth position of string1.
 
SUBSTR (String1 n,m)
SUBSTR  returns  a character string of size m in string1, starting from nth postion of string1.
 
9. Explain UNION,MINUS,UNION ALL, INTERSECT ?
 
INTERSECT returns all distinct rows selected by both queries.
MINUS  -  returns  all distinct rows selected by the first query but not by the second.
UNION - returns all distinct rows selected by either query
UNION  ALL  -  returns  all  rows  selected  by  either query,including all duplicates.
 
10. What is ROWID ?
 
ROWID  is  a  pseudo  column  attached  to  each  row  of a table. It is 18 character long, blockno, rownumber are the components of ROWID.
 
11. What is the fastest way of accessing a row in a table ?
 
Using ROWID.
 
CONSTRAINTS
 
12. What is an Integrity  Constraint ?
 
Integrity  constraint  is  a  rule  that  restricts values to a column in a table.
 
13. What is Referential Integrity ?
 
Maintaining  data integrity through a set of rules that restrict the values of  one or more columns of the tables based on the values of primary key or unique key of the referenced table.
 
14. What are the usage of  SAVEPOINTS ?
 
SAVEPOINTS  are  used  to  subdivide  a  transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.
 
15.  What is ON DELETE CASCADE ?
 
When  ON DELETE CASCADE is specified ORACLE maintains referential integrity by  automatically  removing  dependent  foreign  key values if a referenced primary or unique key value is removed.
 
16. What are the data types allowed in a table ?
 
CHAR,VARCHAR2,NUMBER,DATE,RAW,LONG and LONG RAW.
 
17.  What  is  difference  between  CHAR  and VARCHAR2 ?        What is the maximum SIZE allowed for each type ?
 
CHAR  pads  blank spaces to the maximum length. VARCHAR2 does not pad blank spaces. For CHAR it is 255 and 2000 for VARCHAR2.
 
18.   How  many LONG columns are allowed in a table ? Is it possible to use LONG columns in WHERE clause or ORDER BY ?
 
Only one LONG columns is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.
 
19. What are the pre requisites  ?
     I. to modify datatype of a column ?
     ii. to add a column with NOT NULL constraint ?
 
  To Modify the datatype of a column the column  must be empty.
         to add a column with NOT NULL constrain, the table must be empty.
 
20. Where the integrity constrints are stored in Data Dictionary ?
 
The integrity constraints are stored in  USER_CONSTRAINTS.
 
Related Posts Plugin for WordPress, Blogger...