Transactions and Concurrency Flashcards

1
Q

What are ‘Transactions’ in terms of SQL?

A

Logical unit of work – a “batch” of SQL commands. Consist of several database operations.

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

What does ‘ROLLBACK’ do?

A

Following the ROLLBACK all operations since the last COMMIT are undone

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

What does ‘COMMIT’ do?

A

Following a COMMIT the operations are done and have been saved for sure

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

What does Transaction Isolation Level control?

A

Whether locks are taken when data is read, and what type of locks are requested.

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

What are the 4 Isolation Levels?

A
  1. Read uncommitted (lowest level)
  2. Read committed
  3. Repeatable read
  4. Serialisable (highest level)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do low levels of isolation improve?

A

Performance

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

What do low levels of isolation improve?

A

reliability/reduce inconsistency

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

What are the problems with Read Uncommitted?

A
  1. Another transaction might see data that gets rolled back.

2. Oracle will not allow read uncommitted although MySQL will

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

What is concurrency?

A

Many simultaneous users

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

What are the problems with Concurrency?

A
  1. Inconsistent retrieval
  2. Lost updates
  3. Uncommitted data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the phrase ‘FOR UPDATE’ do?

A

ensures that the row is locked and so another process will see the right data - ‘Exclusive Lock’

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

What is Locking?

A

A procedure used to control concurrent access to data

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

When one transaction is accessing the same database, what will a lock do?

A
  1. Ensure that the interleaving of low level steps can’t happen
  2. Ensure one transaction must be complete before another one can make use of the same data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Deadlock?

A

A deadlock might occur when two (or more) transactions are each waiting for locks to be released that are held by the other

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

What can Transactions cause?

A
  1. A process to suffer a Read or Write fail
  2. A process to hang
  3. One or more processes to deadlock
How well did you know this?
1
Not at all
2
3
4
5
Perfectly