Limiting Query Results
The LIMIT
and OFFSET
clauses restrict the operation of:
- A selection query, including when it occursas part of
INSERT
orUPSERT
. UPDATE
andDELETE
statements.
Synopsis
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
and
limit_val ROWS ONLYFETCH NEXT limit_val ROWS ONLY
as aliasesfor LIMIT
. If limit_val
is omitted, then one row is fetched.
Examples
For example uses with SELECT
, see Limiting Row Count andPagination.
See also
当前内容版权归 cockroachlabs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 cockroachlabs.com .