P2Pprogrammer 2 programmer

Home > Interview Question and Answer > Oracle > Oracle SQL Plus

Oracle SQL Plus Statements Interview Questions and Answers


Oracle SQL Plus Statements Interview Questions and Answers includes, types of SQL Statement, transaction, difference between TRUNCATE & DELETE, different types of joins, Subquery, correlated sub-query, Connect by Prior, Difference between SUBSTR and INSTR, UNION, MINUS, UNION ALL, INTERSECT, ROWID, Integrity Constraint, Referential Integrity, usage of SAVEPOINTS, ON DELETE CASCADE, data types. Database, Tablespace and Data file. different types of joins.



Interview questions and answers for Oracle SQL Plus Statements Interview Questions and Answers


1. What are the types of SQL Statement?

  1. Data Definition Language: CREATE,ALTER,DROP,TRUNCATE,REVOKE,NO AUDIT & COMMIT.
  2. Data Manipulation Language: INSERT,UPDATE,DELETE,LOCK TABLE,EXPLAIN PLAN & SELECT.
  3. Transactional Control: COMMIT & ROLLBACK
  4. Session Control : ALTERSESSION & SET ROLE
  5. 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?

  1. TRUNCATE commits after deleting entire table i.e., can not be rolled back.
    Database triggers do not fire on TRUNCATE
  2. 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.

  1. Self Join - Joining the table with itself.
  2. Equi Join - Joining two tables by equating two common columns.
  3. Non-Equi Join - Joining two tables by equating two common columns.
  4. 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?

  1. 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.
  2. 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?

  1. INTERSECT returns all distinct rows selected by both queries.
  2. MINUS - returns all distinct rows selected by the first query but not by the second.
  3. UNION - returns all distinct rows selected by either query
  4. 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 and 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 is 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, and 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 column is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

19. What are the pre requisites o modify datatype of a column? and 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.

21. How will you a activate/deactivate integrity constraints ?

The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE constraint/DISABLE constraint.

22. If an unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE ?

It won't, because SYSDATE format contains time attached with it.

23. What is a database link ?

Database Link is a named path through which a remote database can be accessed.

24. How to access the current value and next value from a sequence? Is it possible to access the current value in a session before accessing next value?

Sequence name CURRVAL, Sequence name NEXTVAL.

It is not possible. Only if you access next value in the session, current value can be accessed.

25. What are CYCLE/NO CYCLE in a Sequence?

  1. CYCLE specifies that the sequence continues to generate values after reaching either maximum or minimum value. After pan ascending sequence reaches its maximum value, it generates its minimum value. After a descending sequence reaches its minimum, it generates its maximum.
  2. NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value.
  3. 26. What are the advantages of VIEW?

    To protect some of the columns of a table from other users.
    To hide complexity of a query.
    To hide complexity of calculations.

    27. Can a view be updated/inserted/deleted? If Yes under what conditions?

    A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or more tables then insert, update and delete is not possible.

    28. If a View on a single base table is manipulated will the changes be reflected on the base table?

    If changes are made to the tables which are base tables of a view will the changes be reference on the view.

      Go Back to Oracle Interview Qusetion and Answers

    More Oracle Database, DBA, Forms and Reports Interview Question and Answers

    1. Oracle Database Administration Interview Questions and Answers
    2. Oracle Cross Products and Matrix Reports Interview Questions and Answers
    3. Oracle Managing Distributed Databases Interview Questions and Answers
    4. Oracle Forms Interview Questions and Answers
    5. Oracle Database Security Interview Questions and Answers
    6. Oracle Database Operation Backup and Recovery Interview Questions and Answers
    7. Oracle Database Security and Administration Interview Questions and Answers
    8. Oracle Data Access Interview Questions and Answers
    9. Oracle Report Triggers Interview Questions and Answers
    10. Oracle Managing Backup and Recovery Interview Questions and Answers
    11. Forms 3.0, 4.0 Basic Interview Questions and Answers
    12. Oracle Package Procedure and Function Interview Questions and Answers
    13. Oracle System Architecture Interview Questions and Answers
    14. Oracle SQL Plus Statements Interview Questions and Answers
    15. Oracle Logical and Physical Architecture of Database Interview Questions and Answers
    16. Oracle Basics of Pl SQL Interview Questions and Answers
    17. Oracle Reports Interview Questions and Answers
    18. Oracle Concepts and Architecture Interview Questions and Answers
    19. Oracle Forms D2K 4.5 and 6i Interview Questions and Answers

    Home > Interview Question and Answer > Oracle > Oracle SQL Plus