Google Keep Document
Google Keep Document
2 MARKS
Advantages of RDBMS:
1. Data Integrity
2. Data Redundancy
3. Data Security
4. Data Independence
5. Query Capability
1. Active State
2. Partially Committed
3. Committed
4. Failed
5. Aborted
3) Define:
1. Growing Phase:
2. Shrinking Phase:
Read(Q):
This operation reads the value of data item Q from the database and stores it in a local variable
(in memory) used by the transaction.
Does not change the data in the database.
Write(Q):
This operation writes the value of data item Q from the local variable back to the database.
Modifies the actual data in the database.
A cursor is a pointer or handle used to process and retrieve rows from a result set one at a time
in PL/SQL.
Types of Cursors:
1. Implicit Cursor
2. Explicit Cursor
3. Cursor FOR Loop
4. Parameterized Cursor
Types of Locks:
Shared Lock (S): Allows multiple transactions to read, but not write.
Exclusive Lock (X): Allows a transaction to both read and write. No other transaction can read or
write the data item.
These are PL/SQL attributes used to declare variables with the same datatype as a table
column or row.
%TYPE:
Declares a variable with the same data type as a table column.
salary employee.salary%TYPE;
%ROWTYPE:
Declares a record that represents a full row of a table.
emp_record employee%ROWTYPE;
1. Atomicity
2. Consistency
3. Isolation
4. Durability
9) Define:
Required when a transaction initially reads a data item but later needs to write .
Rarely used; done when transaction no longer needs to write but still needs to read.
Types of Schedules:
1. Serial Schedule:
2. Concurrent (Non-Serial) Schedule
3. Conflict-Serializable Schedule
4. View-Serializable Schedule
5. Cascadeless Schedule
6. Strict Schedule
7. Recoverable Schedule
In PL/SQL (Oracle) and similar systems, cursors are used to retrieve and process query result
rows one at a time. Cursor attributes provide status information about the cursor during or after
its operation.
What is a Lock?
Types of Locks:
3. Row-Level Lock
4. Table-Level Lock
Exception Handling in PL/SQL is used to manage runtime errors so the program can continue or
exit gracefully.
Types of Exceptions:
3. Unnamed System Exceptions – Not predefined but raised automatically (can be caught using
OTHERS).
---
DBMS RDBMS
---
A Procedure is a named PL/SQL block that performs a task and may or may not return values.
Syntax:
Example:
---
PL/SQL (Procedural Language/SQL) is Oracle’s extension of SQL with procedural features like
loops, conditions, and error handling.
DECLARE
-- Declarations
BEGIN
-- Executable statements
EXCEPTION
-- Error handling
END;
Example:
DECLARE
v_num NUMBER := 10;
BEGIN
DBMS_OUTPUT.PUT_LINE('Value: ' || v_num);
END;
---
Deadlock occurs when two or more transactions wait indefinitely for each other to release locks.
Prevention Methods:
---
Example: T2 waits to read from T1 only after T1 commits, preventing cascading rollback.
---
Syntax:
Example:
---
---
A Trigger is a stored PL/SQL block that automatically executes in response to DML operations
(INSERT, UPDATE, DELETE).
Types of Triggers:
---
1. Basic LOOP
2. WHILE LOOP
3. FOR LOOP
BEGIN
FOR i IN 1..5 LOOP
DBMS_OUTPUT.PUT_LINE('Count: ' || i);
END LOOP;
END;
---
IF condition THEN
-- statements
ELSIF condition THEN
-- statements
ELSE
-- statements
END IF;
Example:
DECLARE
marks NUMBER := 75;
BEGIN
IF marks >= 90 THEN
DBMS_OUTPUT.PUT_LINE('Grade: A');
ELSIF marks >= 60 THEN
DBMS_OUTPUT.PUT_LINE('Grade: B');
ELSE
DBMS_OUTPUT.PUT_LINE('Grade: C');
END IF;
END;