Chapter 15. Numbering Rows
PROCEDURAL PROGRAMMERS CANNOT seem to shake the idea of a physical row number being exposed to them. The idea that there is no sequential access or ordering in an RDBMS, so “first,” “next,” and “last” are totally meaningless, is lost on them.
The bad news is that many vendors provide such numberings by exposing their underlying physical storage model. The most common method is to auto-increment a counter as new rows are added to a table. This assumes that the SQL product inserts whole rows in a sequence, just as we added records to the end of a magnetic tape. This is not true for SQL engines with parallelism or that work with columns rather than rows.
If you want an ordering, then you need to have a column that defines ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access