Home > Database > Oracle > How to use limit in oracle

How to use limit in oracle

下次还敢
Release: 2024-05-07 14:42:14
Original
1032 people have browsed it

The LIMIT clause in Oracle is used to limit the number of rows retrieved. The syntax is: SELECT * FROM table_name LIMIT start_row, row_count. start_row specifies the number of rows to skip (starting from 0), and row_count specifies the number of rows to retrieve.

How to use limit in oracle

LIMIT Clause in Oracle

What is LIMIT clause?

The LIMIT clause is used to limit the number of rows retrieved from an Oracle database table.

Syntax:

<code>SELECT * FROM table_name
LIMIT start_row, row_count</code>
Copy after login

Where:

  • start_row Specifies the number of rows to skip, starting from 0 .
  • row_count Specifies the number of rows to retrieve.

Usage:

The LIMIT clause is placed at the end of the SELECT statement. It can be used to page results or retrieve a specific number of rows.

Example:

Retrieve the first 10 rows:

<code>SELECT * FROM customers
LIMIT 10;</code>
Copy after login

Retrieve the 5 rows starting from row 10 :

<code>SELECT * FROM customers
LIMIT 9, 5;</code>
Copy after login

Note:

  • If start_row is not specified, the default value is 0, starting from the first row start.
  • If row_count is negative, no rows will be retrieved.
  • The LIMIT clause, when used in conjunction with the ORDER BY clause, controls the order in which rows are retrieved.
  • In some cases, the LIMIT clause may affect query performance.

The above is the detailed content of How to use limit in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template