FOR UPDATE is the shared spelling in PostgreSQL, MySQL and Oracle. SQL Server uses the WITH (UPDLOCK) hint, and SQLite locks the whole database with BEGIN IMMEDIATE. NOWAIT and SKIP LOCKED exist in PostgreSQL, MySQL 8 and Oracle; SQL Server spells them as the NOWAIT and READPAST hints.
Where they differ
PostgreSQL, MySQL and Oracle say FOR UPDATE; SQL Server uses a table hint. SQLite has no row locks at all: the whole database is the unit.
How each engine writes it
SQL Server
BEGIN TRANSACTION;
SELECT * FROM accounts WITH (UPDLOCK, ROWLOCK) WHERE id = 1;
UPDATE accounts SET balance = balance - 10 WHERE id = 1;
COMMIT;
No FOR UPDATE. UPDLOCK takes update locks (plain readers still read, another UPDLOCK waits) held to the end of the transaction; ROWLOCK asks for row granularity. Add READPAST to skip locked rows or NOWAIT to fail at once.
PostgreSQL
BEGIN;
SELECT * FROM accounts WHERE id = 1 FOR UPDATE;
UPDATE accounts SET balance = balance - 10 WHERE id = 1;
COMMIT;
FOR UPDATE row-locks the selected rows until commit. Variants: FOR NO KEY UPDATE (weaker: foreign-key checks from inserts into child tables do not wait), FOR SHARE, and NOWAIT or SKIP LOCKED.
MySQL
BEGIN;
SELECT * FROM accounts WHERE id = 1 FOR UPDATE;
UPDATE accounts SET balance = balance - 10 WHERE id = 1;
COMMIT;
FOR UPDATE works in InnoDB inside a transaction. Also supports NOWAIT and SKIP LOCKED (8.0+), the basis for many job-queue patterns.
SQLite
BEGIN IMMEDIATE;
-- read then write; the database file is write-locked for the whole transaction
UPDATE accounts SET balance = balance - 10 WHERE id = 1;
COMMIT;
No row locks and no FOR UPDATE. BEGIN IMMEDIATE takes the write lock up front, which is the equivalent guarantee at database granularity.
Oracle
SELECT * FROM accounts WHERE id = 1 FOR UPDATE;
UPDATE accounts SET balance = balance - 10 WHERE id = 1;
COMMIT;
FOR UPDATE plus WAIT n, NOWAIT or SKIP LOCKED. Rows stay locked across the transaction; the transaction starts implicitly with the SELECT.
Questions that come up
What is the deadlock risk here?
Two transactions locking the same rows in different orders deadlock. Always touch rows in a consistent order, and keep the lock window short.
What does SKIP LOCKED do?
It skips rows already locked by others instead of waiting, which lets many workers safely pull from the same queue table without coordination.
Does FOR UPDATE lock the gaps too?
InnoDB at REPEATABLE READ also takes next-key (gap) locks on the scanned range, which blocks inserts into it. PostgreSQL and Oracle lock only the rows returned.