Compare each ID with the next one using LEAD(); wherever the next ID is more than one higher, the numbers in between are missing. To list every missing number, generate the full sequence and keep the numbers that aren't in the table.
Gaps as ranges (works in any database with window functions):
SELECT order_id + 1 AS gap_start,
next_id - 1 AS gap_end
FROM (
SELECT order_id, LEAD(order_id) OVER (ORDER BY order_id) AS next_id
FROM orders
) t
WHERE next_id > order_id + 1
ORDER BY gap_start;
For IDs 1, 2, 4, 5, 7, 8, 12 this returns (3, 3), (6, 6) and (9, 11). One row per gap stays small even when gaps are large.
Every missing ID (PostgreSQL):
SELECT g.n AS missing_id
FROM generate_series((SELECT MIN(order_id) FROM orders),
(SELECT MAX(order_id) FROM orders)) AS g(n)
WHERE NOT EXISTS (SELECT 1 FROM orders o WHERE o.order_id = g.n)
ORDER BY g.n;
Other databases use a numbers table or a recursive CTE instead of generate_series.
A common self-join version (LEFT JOIN orders t2 ON t2.order_id = t1.order_id + 1) also reports the number after the largest ID, and only the first number of each gap, so it needs extra filtering.
Gaps in auto-increment IDs are normal (rolled-back inserts and cached sequence values leave them), so treat them as missing data only when the IDs come from a source that promises none.