Definition:
PCC is a database locking strategy that prevents conflicts by locking data while it’s being read or modified, ensuring only one transaction can access it at a time.
Use Case Banking systems use PCC to prevent two users from withdrawing the same money simultaneously.
Example:
-- Transaction A locks the row for update
BEGIN;
SELECT * FROM accounts WHERE id = 1 FOR UPDATE;
-- No other transaction can read or update this row until A commits