Oracle SQL and PL/SQL Concepts
1. Difference between UNIQUE and PRIMARY KEY:
- UNIQUE allows NULL values; PRIMARY KEY does not.
- A table can have multiple UNIQUE keys but only one PRIMARY KEY.
2. Use of GROUP BY Clause:
- Used to group rows with the same values in specified columns.
- Example: Summarize sales data by regions.
3. Use of HAVING Clause:
- Filters grouped records after aggregation.
- Example: Find regions with sales > 10000.
4. Difference Between WHERE and HAVING Clauses:
- WHERE filters rows before grouping; HAVING filters after grouping.
5. What is a Subquery?
- A query inside another query. Used for complex conditions.
- Example: Select employees in departments with >10 employees.
6. What is a View?
- A virtual table created by a SQL query. Does not store data physically.
7. Difference Between Named Block and Anonymous Block:
- Named blocks (Procedures/Functions) are reusable and stored in the database.
- Anonymous blocks are not stored and execute once.
8. What is a Cursor?
- A pointer to a result set of a query. Used for row-by-row processing.
9. Types of Cursors:
- Implicit: Automatically managed by Oracle for DML operations.
- Explicit: Defined and controlled by the user.
10. Explicit Cursor:
- Created for a specific query. Allows custom fetch operations.
11. Exception Handling:
- Mechanism to handle runtime errors using EXCEPTION blocks.
12. Package:
- A collection of related procedures, functions, and variables.
13. Use of APEX:
- Oracle APEX is a web-based application development tool.
14. Use of Dynamic Actions:
- Allows declarative interactions without coding.
15. Data Types:
- VARCHAR2, NUMBER, DATE, BOOLEAN, CLOB, etc.
16. What is NumPy?
- A Python library for numerical computations.
17. DECODE Function:
- Performs conditional querying (similar to CASE).
18. Views and Types of Views:
- Simple View: Based on a single table.
- Complex View: Based on multiple tables with joins.
19. Can We Update Complex Views?
- Yes, but with restrictions. Use INSTEAD OF triggers if necessary.
20. Use of INSTEAD OF Triggers:
- Used to handle DML operations on non-updatable views.
21. REF Cursor:
- A cursor that allows dynamic query results.
22. Bulk Bind and Bulk Collect:
- Efficiently process large volumes of data.
23. Indexes and Their Types:
- B-Tree, Bitmap, Unique, Composite, Function-Based Indexes.
24. Cursor vs Collections:
- Cursor processes row-by-row; Collections process sets of data.
25. Retrieving Unique Values Without DISTINCT:
- Use GROUP BY or ROW_NUMBER().
26. Types of Triggers:
- BEFORE, AFTER, INSTEAD OF triggers.
- DML triggers: Fire on INSERT, UPDATE, DELETE.
27. Collections:
- Nested Tables, VARRAYs, Associative Arrays.
28. Most Widely Used Collection:
- Associative Arrays due to their flexibility.