Limiting Query Results

On this page Carat arrow pointing down
Warning:
CockroachDB v2.1 is no longer supported. For more details, see the Release Support Policy.

The LIMIT and OFFSET clauses restrict the operation of:

Synopsis

LIMIT count FETCH FIRST NEXT count ROW ROWS ONLY
OFFSET a_expr c_expr ROW ROWS

LIMIT restricts the operation to only retrieve limit_val number of rows.

OFFSET restricts the operation to skip the first offset_value number of rows. It is often used in conjunction with LIMIT to "paginate" through retrieved rows.

For PostgreSQL compatibility, CockroachDB also supports FETCH FIRST limit_val ROWS ONLY and FETCH NEXT limit_val ROWS ONLY as aliases for LIMIT. If limit_val is omitted, then one row is fetched.

Examples

For example uses with SELECT, see Limiting Row Count and Pagination.

See also


Yes No
On this page

Yes No