2018-05-16 10:22 GMT-03:00 PG Doc comments form <nore...@postgresql.org>: > The documentation of the SELECT statement lists FETCH FIRST/OFFSET as an > alternative to the proprietary LIMIT clause. > > https://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT > > However, chapter 7.6 about LIMIT/OFFSET does not mention the alternative. > > https://www.postgresql.org/docs/current/static/queries-limit.html > Make sense. I propose the attached patch that adds a link to the LIMIT section in the SELECT reference page. I also renamed the "number" variables to the same names used in the SELECT reference page and put OFFSET in a new line (it looks visually better).
-- Euler Taveira Timbira - http://www.timbira.com.br/ PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
From 433c22ffec27136f2867736075915ccfc9227cd0 Mon Sep 17 00:00:00 2001 From: Euler Taveira <eu...@timbira.com.br> Date: Wed, 13 Jun 2018 18:56:19 +0000 Subject: [PATCH] Add a link to SELECT reference page Mention that Postgres also provides an alternative syntax to LIMIT and OFFSET (that conforms with SQL standard). --- doc/src/sgml/queries.sgml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml index b72be9b..1e3825e 100644 --- a/doc/src/sgml/queries.sgml +++ b/doc/src/sgml/queries.sgml @@ -1787,7 +1787,8 @@ SELECT a + b AS sum, c FROM table1 ORDER BY sum + c; -- wrong SELECT <replaceable>select_list</replaceable> FROM <replaceable>table_expression</replaceable> <optional> ORDER BY ... </optional> - <optional> LIMIT { <replaceable>number</replaceable> | ALL } </optional> <optional> OFFSET <replaceable>number</replaceable> </optional> + <optional> LIMIT { <replaceable>count</replaceable> | ALL } </optional> + <optional> OFFSET <replaceable>start</replaceable></optional> </synopsis> </para> @@ -1812,6 +1813,11 @@ SELECT <replaceable>select_list</replaceable> </para> <para> + SQL:2008 adds a different syntax to achieve the same result. See <xref + linkend="sql-limit" endterm="sql-limit-title"/> for details. + </para> + + <para> When using <literal>LIMIT</literal>, it is important to use an <literal>ORDER BY</literal> clause that constrains the result rows into a unique order. Otherwise you will get an unpredictable subset of -- 2.7.4