0% found this document useful (0 votes)
2 views2 pages

Day-16 Interview Questions

Uploaded by

Ashish Behera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Day-16 Interview Questions

Uploaded by

Ashish Behera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Day-16 Interview Questions

1. What is PL/SQL, and how does it differ from SQL?

PL/SQL (Procedural Language/Structured Query Language) is a procedural language


extension for SQL that allows you to combine SQL and procedural logic. While SQL is
used for querying and manipulating data, PL/SQL is used for writing programmatic
constructs like loops, conditions, and exception handling.

2. Explain the importance of PL/SQL in database development?

PL/SQL is important in database development because it allows for more complex and
flexible operations than SQL alone. It enables developers to create reusable code,
enforce business rules, and handle errors effectively within the database.

3. How can you handle exceptions in PL/SQL, and why is exception handling
important?

In PL/SQL, you can handle exceptions using the EXCEPTION block. Exception
handling is crucial because it helps control the flow of the program in the presence of
errors, ensuring that the application can respond gracefully to unexpected issues.

5. What is a stored procedure, and why would you use it in a database?

A stored procedure is a precompiled collection of SQL statements that can be executed


as a single unit. It is used to encapsulate business logic, improve code reusability, and
enhance security by controlling access to data.

6. How do you create a stored procedure in PL/SQL?

You can create a stored procedure using the CREATE OR REPLACE PROCEDURE
statement, followed by the procedure's name, input parameters, and the procedural
code block.

7. What is the difference between local and global variables in a stored


procedure?

Local variables are declared within a stored procedure and are only accessible within
that procedure. Global variables are typically declared at the database level and can be
accessed by multiple stored procedures.
8. What is a trigger, and how does it work in a database?

A trigger is a database object that automatically executes in response to specific events,


such as data modifications (INSERT, UPDATE, DELETE). Triggers are associated with
tables and are used to enforce business rules and automate tasks.

9. How do you create a trigger in PL/SQL?

You can create a trigger using the CREATE TRIGGER statement, specifying the event
(e.g., AFTER INSERT), the triggering table, and the trigger code block.

10. What are the common use cases for "AFTER INSERT," "AFTER UPDATE," and
"AFTER DELETE" triggers?

"AFTER INSERT" triggers are used for actions that follow the insertion of new data.
"AFTER UPDATE" triggers are used for actions following data updates, and "AFTER
DELETE" triggers are used for actions after data deletion, such as logging changes or
maintaining referential integrity.

You might also like