Chapter 24. Regions, Runs, Gaps, Sequences, and Series

TABLES DO NOT HAVE an ordering to their rows. Yes, the physical storage of the rows in many SQL products might be ordered if the product is built on an old file system. More modern implementations might not construct and materialize the result set rows until the end of the query execution.

The first rule in a relational database is that all relationships are shown in tables by values in columns. This means that things involving an ordering must have a table with at least two columns. One column, the sequence number, is the primary key; the other column has the value that holds that position in the sequence.

The sequence column has consecutive unique integers, without any gaps in the numbering. ...

Get Joe Celko's SQL for Smarties, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.