ANSI/ISO LIMIT 标准化计划?

chu*_*ash 12 limits sql-standard

目前是否计划标准化一种限制查询返回结果数量的最佳方法?

是否有 ANSI SQL 替代 MYSQL LIMIT 关键字的堆栈溢出问题列出了用不同语言处理这种行为的各种方法:

DB2 -- select * from table fetch first 10 rows only 
Informix -- select first 10 * from table 
Microsoft SQL Server and Access -- select top 10 * from table 
MySQL and PostgreSQL -- select * from table limit 10 
Oracle -- select * from (select * from table) where rownum <= 10
Run Code Online (Sandbox Code Playgroud)

我不经常玩数据库,所以我在这里说的是无知,但似乎这是一个非常重要的功能 - 至少足够重要,当我看到它被留给供应商时我会挠头。

Phi*_*lᵀᴹ 20

我可以在 Internet 上找到的最新 SQL 标准草案(日期为 21/12/2011)具有以下可用于查询表达式的内容:

<result offset clause> ::=
    OFFSET <offset row count> { ROW | ROWS }

<fetch first clause> ::=
    FETCH { FIRST | NEXT } [ <fetch first quantity> ] { ROW | ROWS } { ONLY | WITH TIES }
Run Code Online (Sandbox Code Playgroud)

  • 这也是 Postgres 手册声称的内容:http://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT (5认同)
  • @chucksmash 当然,MySQL 除外。因为他们不喜欢标准。(参考:GROUP BY。) (4认同)