REVIEW - THEORY QUESTIONS Flashcards

1
Q

What is the purpose of the SAVEPOINT statement?

A

The SAVEPOINT statement allows you to set a point within a transaction to which you can later roll back, making it possible to undo part of a transaction without affecting the rest.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the ACID Properties?

A

Atomicity, Consistency, Isolation and Durability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is atomicity?

A

Ensures that all parts of a transaction are completed successfully, or none are. If any part fails, the entire transaction is rolled back.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is consistency?

A

Guarantees that a transaction brings the database from one valid state to another, preserving database integrity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is isolation?

A

Ensures that transactions are executed independently without interference, preventing issues like dirty reads or lost updates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is durability?

A

Once a transaction is committed, its results are permanent and survive system failures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the Isolation Levels in PL/SQL?

A

Read Uncommitted, Read Committed, Repeatable Read, Serializable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Read Uncommitted?

A

Allows dirty reads, where transactions can see uncommitted changes from others.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Read Committed?

A

Prevents dirty reads by only allowing transactions to see committed changes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Repeatable Read?

A

Ensures that if a transaction reads a record, it will see the same record throughout the transaction, but doesn’t prevent phantom reads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Serializable?

A

Highest isolation level, ensuring transactions are executed as if they were serially executed, preventing dirty reads, non-repeatable reads, and phantom reads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between role and user privilege?

A

A role is a collection of privileges that can be assigned to users, simplifying the management of permissions. User privileges are individual permissions granted directly to a user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you end a transaction?

A

A transaction is explicitly ended using the COMMIT statement (to save changes) or the ROLLBACK statement (to undo changes).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why are roles so important for a database’s security?

A

Roles group multiple privileges, making it easier to manage user permissions. Assigning roles instead of individual privileges reduces administrative overhead and enhances security by ensuring users have only the necessary access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between object and system privileges?

A

Object Privileges: Specific to database objects, such as SELECT, INSERT, or DELETE on a table.

System Privileges: Broader permissions that affect the entire database, like CREATE TABLE or ALTER DATABASE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does consistency do in ACID?

A

This property ensures that a transaction moves the database from one consistent state to another, preserving data integrity by enforcing all constraints.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Why is isolation so important in ACID?

A

Isolation levels like Serializable ensure that transactions are executed without interference, preventing one transaction from overwriting the changes made by another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What’s a scenario without atomicity?

A

In a banking application, if a transaction to transfer funds fails after debiting one account but before crediting another, the system could become inconsistent, with funds lost or duplicated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How is durability implemented?

A

Durability is implemented through techniques like write-ahead logging, where changes are recorded in a log before being committed to the database. This ensures that, in case of a crash, the database can recover committed transactions by reapplying the changes from the log.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

When does non-repeatable read occur?

A

When a transaction reads the same row twice and finds different data due to another transaction modifying the row in between.

21
Q

What isolation level allows dirty reads?

A

Read Uncommitted

22
Q

What is the difference between repeatable read and serializable?

A

Repeatable Read ensures consistent reads within a transaction but does not prevent phantom reads.

Serializable ensures no other transactions can affect the data being read, preventing all types of data anomalies but at the cost of performance due to higher locking.

23
Q

How do the higher and lower levels of isolation impact concurrency and performance?

A

Lower isolation levels allow more concurrent transactions at the cost of potential data anomalies, while higher isolation levels, like Serializable, ensure data consistency but reduce concurrency due to increased locking and potential deadlocks.

24
Q

What is the difference between implicit and explicit cursors?

A

An implicit cursor is automatically created for single SQL statements, while an explicit cursor must be manually declared and controlled.

25
Q

How do you fetch rows using a cursor?

A

You fetch rows from a cursor using the FETCH statement, which retrieves the next row and assigns the values to specified variables.

26
Q

What is the lifecycle of an explicit cursor?

A

Declare: Define the cursor with a SELECT statement.

Open: Execute the query and allocate memory for the result set.

Fetch: Retrieve individual rows from the result set.

Close: Release the resources associated with the cursor.

27
Q

What use do cursors have on large datasets?

A

Cursors allow processing of large datasets by fetching one row at a time, reducing memory usage. However, they can slow down performance due to the overhead of context switching and increased processing time.

28
Q

What is the purpose of a PL/SQL procedure?

A

Encapsulates reusable logic to perform specific tasks, enabling modularity and code reuse.

29
Q

How do you return values from procedures?

A

Procedures do not return values directly but can use OUT parameters to return data.

30
Q

How do you call functions in PL/SQL?

A

Functions are called in SQL statements by using their name and providing any required arguments within the SQL query.

31
Q

What do IN parameters do?

A

Pass values to the procedure.

32
Q

What do OUT parameters do?

A

Return values from the procedure.

33
Q

What do IN OUT parameters do?

A

Both pass values to the procedure and return modified values.

34
Q

What is the difference between a function and a procedure?

A

Functions are designed to return a value and can be used in SQL statements, while procedures are meant for executing a series of operations and do not return values directly.

35
Q

What are the benefits of using functions?

A

Encapsulate complex logic, enhance code reuse, and simplify maintenance by isolating business logic into reusable components that can be called from multiple places in the application.

36
Q

What are User-Defined Exceptions?

A

Declared in the EXCEPTION section of a PL/SQL block, allowing custom error handling for specific conditions.

37
Q

What is the WHEN OTHERS handler?

A

Catches all exceptions not explicitly handled by other exception handlers, ensuring that the program can manage unexpected errors.

38
Q

How is exception handling reliable?

A

Exception handling ensures that programs can gracefully handle errors, avoiding abrupt failures and maintaining data integrity. It also allows for error logging and recovery, which is essential for building robust applications.

39
Q

What is the difference between full and incremental backups?

A

A full backup captures the entire database at a specific point in time, while an incremental backup only captures changes made since the last backup, saving time and storage.

40
Q

What are the types of backups?

A

Full, differential and incremental.

41
Q

What is differential backup?

A

Captures all changes since the last full backup.

41
Q

What is full backup?

A

Captures the entire database.

42
Q

What is incremental backup?

A

Captures only the changes made since the last backup, whether full or incremental.

43
Q

What is GROUPING SETS clause?

A

GROUPING SETS clause allows for complex grouping of data in SQL queries by specifying multiple groupings within a single query.

44
Q

What are CASE statements in groupings?

A

Used to apply conditional logic within grouping functions, enabling custom aggregations based on specific conditions.

45
Q

What’s the level pseudo-column?

A

Represents the level of a row in a hierarchy, helping in constructing hierarchical queries.

46
Q

What is the CUBE operator?

A

Generates a result set with all possible combinations of specified dimensions.

47
Q

What is the ROLLUP operator?

A

Creates subtotals that roll up from a specific dimension hierarchy, useful for creating summary reports.