Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
bb06cbdb
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bb06cbdb
编写于
11月 04, 2003
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Copy-editing.
上级
b720fa96
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
35 deletion
+45
-35
doc/src/sgml/ref/select.sgml
doc/src/sgml/ref/select.sgml
+45
-35
未找到文件。
doc/src/sgml/ref/select.sgml
浏览文件 @
bb06cbdb
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.7
1 2003/11/01 01:56:29 petere
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.7
2 2003/11/04 00:34:45 tgl
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -41,11 +41,6 @@ where <replaceable class="parameter">from_item</replaceable> can be one of:
...
@@ -41,11 +41,6 @@ where <replaceable class="parameter">from_item</replaceable> can be one of:
<replaceable class="parameter">from_item</replaceable> [ NATURAL ] <replaceable class="parameter">join_type</replaceable> <replaceable class="parameter">from_item</replaceable> [ ON <replaceable class="parameter">join_condition</replaceable> | USING ( <replaceable class="parameter">join_column</replaceable> [, ...] ) ]
<replaceable class="parameter">from_item</replaceable> [ NATURAL ] <replaceable class="parameter">join_type</replaceable> <replaceable class="parameter">from_item</replaceable> [ ON <replaceable class="parameter">join_condition</replaceable> | USING ( <replaceable class="parameter">join_column</replaceable> [, ...] ) ]
</synopsis>
</synopsis>
<comment>FIXME: This last syntax is incorrect if the join type is an
INNER or OUTER join (in which case one of NATURAL, ON ..., or USING
... is mandatory, not optional). What's the best way to fix
this?</comment>
</refsynopsisdiv>
</refsynopsisdiv>
<refsect1>
<refsect1>
...
@@ -107,7 +102,7 @@ this?</comment>
...
@@ -107,7 +102,7 @@ this?</comment>
<listitem>
<listitem>
<para>
<para>
The actual output rows are computed the
The actual output rows are computed
using
the
<command>SELECT</command> output expressions for each selected
<command>SELECT</command> output expressions for each selected
row. (See
row. (See
<xref linkend="sql-select-list" endterm="sql-select-list-title">
<xref linkend="sql-select-list" endterm="sql-select-list-title">
...
@@ -125,15 +120,6 @@ this?</comment>
...
@@ -125,15 +120,6 @@ this?</comment>
</para>
</para>
</listitem>
</listitem>
<listitem>
<para>
If the <literal>LIMIT</literal> or <literal>OFFSET</literal>
clause is specified, the <command>SELECT</command> statement
only returns a subset of the result rows. (See <xref
linkend="sql-limit" endterm="sql-limit-title"> below.)
</para>
</listitem>
<listitem>
<listitem>
<para>
<para>
<literal>DISTINCT</literal> eliminates duplicate rows from the
<literal>DISTINCT</literal> eliminates duplicate rows from the
...
@@ -145,6 +131,15 @@ this?</comment>
...
@@ -145,6 +131,15 @@ this?</comment>
</para>
</para>
</listitem>
</listitem>
<listitem>
<para>
If the <literal>LIMIT</literal> or <literal>OFFSET</literal>
clause is specified, the <command>SELECT</command> statement
only returns a subset of the result rows. (See <xref
linkend="sql-limit" endterm="sql-limit-title"> below.)
</para>
</listitem>
<listitem>
<listitem>
<para>
<para>
The <literal>FOR UPDATE</literal> clause causes the
The <literal>FOR UPDATE</literal> clause causes the
...
@@ -291,17 +286,21 @@ this?</comment>
...
@@ -291,17 +286,21 @@ this?</comment>
</para>
</para>
<para>
<para>
A <literal>JOIN</literal> clause, combines two
A <literal>JOIN</literal> clause combines two
<literal>FROM</> items. (Use parentheses if necessary to
<literal>FROM</> items. Use parentheses if necessary to
determine the order of nesting.)
determine the order of nesting. In the absence of parentheses,
<literal>JOIN</literal>s nest left-to-right. In any case
<literal>JOIN</literal> binds more tightly than the commas
separating <literal>FROM</> items.
</para>
</para>
<para>
<para>
<literal>CROSS JOIN</> and <literal>INNER JOIN</literal>
<literal>CROSS JOIN</> and <literal>INNER JOIN</literal>
produce a simple Cartesian product, the same as you get from
produce a simple Cartesian product, the same result as you get from
listing the two items at the top level of <literal>FROM</>.
listing the two items at the top level of <literal>FROM</>,
but restricted by the join condition (if any).
<literal>CROSS JOIN</> is equivalent to <literal>INNER JOIN ON
<literal>CROSS JOIN</> is equivalent to <literal>INNER JOIN ON
(
true
)</>, that is, no rows are removed by qualification.
(
TRUE
)</>, that is, no rows are removed by qualification.
These join types are just a notational convenience, since they
These join types are just a notational convenience, since they
do nothing you couldn't do with plain <literal>FROM</> and
do nothing you couldn't do with plain <literal>FROM</> and
<literal>WHERE</>.
<literal>WHERE</>.
...
@@ -315,7 +314,7 @@ this?</comment>
...
@@ -315,7 +314,7 @@ this?</comment>
condition. This left-hand row is extended to the full width
condition. This left-hand row is extended to the full width
of the joined table by inserting null values for the
of the joined table by inserting null values for the
right-hand columns. Note that only the <literal>JOIN</>
right-hand columns. Note that only the <literal>JOIN</>
clauses own condition is considered while deciding which rows
clause
'
s own condition is considered while deciding which rows
have matches. Outer conditions are applied afterwards.
have matches. Outer conditions are applied afterwards.
</para>
</para>
...
@@ -410,7 +409,7 @@ GROUP BY <replaceable class="parameter">expression</replaceable> [, ...]
...
@@ -410,7 +409,7 @@ GROUP BY <replaceable class="parameter">expression</replaceable> [, ...]
expressions. <replaceable
expressions. <replaceable
class="parameter">expression</replaceable> can be an input column
class="parameter">expression</replaceable> can be an input column
name, or the name or ordinal number of an output column
name, or the name or ordinal number of an output column
(<command>SELECT</command> list
), or it can be
an arbitrary
(<command>SELECT</command> list
item), or
an arbitrary
expression formed from input-column values. In case of ambiguity,
expression formed from input-column values. In case of ambiguity,
a <literal>GROUP BY</literal> name will be interpreted as an
a <literal>GROUP BY</literal> name will be interpreted as an
input-column name rather than an output column name.
input-column name rather than an output column name.
...
@@ -497,7 +496,7 @@ HAVING <replaceable class="parameter">condition</replaceable>
...
@@ -497,7 +496,7 @@ HAVING <replaceable class="parameter">condition</replaceable>
<para>
<para>
Currently, <literal>FOR UPDATE</> may not be specified either for
Currently, <literal>FOR UPDATE</> may not be specified either for
a <literal>UNION</> result or for
the inputs of
<literal>UNION</>.
a <literal>UNION</> result or for
any input of a
<literal>UNION</>.
</para>
</para>
</refsect2>
</refsect2>
...
@@ -613,7 +612,7 @@ ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC |
...
@@ -613,7 +612,7 @@ ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC |
</synopsis>
</synopsis>
<replaceable class="parameter">expression</replaceable> can be the
<replaceable class="parameter">expression</replaceable> can be the
name or ordinal number of an output column
name or ordinal number of an output column
(<command>SELECT</command> list), or it can be an arbitrary
(<command>SELECT</command> list
item
), or it can be an arbitrary
expression formed from input-column values.
expression formed from input-column values.
</para>
</para>
...
@@ -623,7 +622,7 @@ ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC |
...
@@ -623,7 +622,7 @@ ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC |
equal according to the leftmost expression, the are compared
equal according to the leftmost expression, the are compared
according to the next expression and so on. If they are equal
according to the next expression and so on. If they are equal
according to all specified expressions, they are returned in
according to all specified expressions, they are returned in
random
order.
an implementation-dependent
order.
</para>
</para>
<para>
<para>
...
@@ -660,7 +659,7 @@ SELECT name FROM distributors ORDER BY code;
...
@@ -660,7 +659,7 @@ SELECT name FROM distributors ORDER BY code;
<para>
<para>
Optionally one may add the key word <literal>ASC</> (ascending) or
Optionally one may add the key word <literal>ASC</> (ascending) or
<literal>DESC</> (descending) after
each
expression in the
<literal>DESC</> (descending) after
any
expression in the
<literal>ORDER BY</> clause. If not specified, <literal>ASC</> is
<literal>ORDER BY</> clause. If not specified, <literal>ASC</> is
assumed by default. Alternatively, a specific ordering operator
assumed by default. Alternatively, a specific ordering operator
name may be specified in the <literal>USING</> clause.
name may be specified in the <literal>USING</> clause.
...
@@ -689,15 +688,18 @@ SELECT name FROM distributors ORDER BY code;
...
@@ -689,15 +688,18 @@ SELECT name FROM distributors ORDER BY code;
<para>
<para>
The <literal>LIMIT</literal> clause consists of two independent
The <literal>LIMIT</literal> clause consists of two independent
clauses:
sub-
clauses:
<synopsis>
<synopsis>
LIMIT { <replaceable class="parameter">count</replaceable> | ALL }
LIMIT { <replaceable class="parameter">count</replaceable> | ALL }
OFFSET <replaceable class="parameter">start</replaceable>
OFFSET <replaceable class="parameter">start</replaceable>
</synopsis>
</synopsis>
<replaceable class="parameter">count</replaceable> specifies the
<replaceable class="parameter">count</replaceable> specifies the
maximum number of rows to return,
and
<replaceable
maximum number of rows to return,
while
<replaceable
class="parameter">start</replaceable> specifies the number of rows
class="parameter">start</replaceable> specifies the number of rows
to skip before starting to return rows.
to skip before starting to return rows. When both are specified,
<replaceable class="parameter">start</replaceable> rows are skipped
before starting to count the <replaceable
class="parameter">count</replaceable> rows to be returned.
</para>
</para>
<para>
<para>
...
@@ -754,6 +756,13 @@ SELECT DISTINCT ON (location) location, time, report
...
@@ -754,6 +756,13 @@ SELECT DISTINCT ON (location) location, time, report
of time values for each location, we'd have gotten a report from
of time values for each location, we'd have gotten a report from
an unpredictable time for each location.
an unpredictable time for each location.
</para>
</para>
<para>
The <literal>DISTINCT ON</> expression(s) must match the leftmost
<literal>ORDER BY</> expression(s). The <literal>ORDER BY</> clause
will normally contain additional expression(s) that determine the
desired precedence of rows within each <literal>DISTINCT ON</> group.
</para>
</refsect2>
</refsect2>
<refsect2 id="SQL-FOR-UPDATE">
<refsect2 id="SQL-FOR-UPDATE">
...
@@ -889,10 +898,10 @@ SELECT * FROM distributors ORDER BY 2;
...
@@ -889,10 +898,10 @@ SELECT * FROM distributors ORDER BY 2;
</para>
</para>
<para>
<para>
Th
is
example shows how to obtain the union of the tables
Th
e next
example shows how to obtain the union of the tables
<literal>distributors</literal> and
<literal>distributors</literal> and
<literal>actors</literal>, restricting the results to those that begin
<literal>actors</literal>, restricting the results to those that begin
with letter W in each table. Only distinct rows are wanted, so the
with
the
letter W in each table. Only distinct rows are wanted, so the
key word <literal>ALL</literal> is omitted.
key word <literal>ALL</literal> is omitted.
<programlisting>
<programlisting>
...
@@ -925,7 +934,7 @@ SELECT actors.name
...
@@ -925,7 +934,7 @@ SELECT actors.name
<para>
<para>
This example shows how to use a function in the <literal>FROM</>
This example shows how to use a function in the <literal>FROM</>
clause, both with and without a column definition list
.
clause, both with and without a column definition list
:
<programlisting>
<programlisting>
CREATE FUNCTION distributors(int) RETURNS SETOF distributors AS '
CREATE FUNCTION distributors(int) RETURNS SETOF distributors AS '
...
@@ -1048,7 +1057,8 @@ SELECT distributors.* FROM distributors d, distributors distributors;
...
@@ -1048,7 +1057,8 @@ SELECT distributors.* FROM distributors d, distributors distributors;
</para>
</para>
<para>
<para>
SQL99 uses a slightly different definition which is not upward compatible
SQL99 uses a slightly different definition which is not entirely upward
compatible
with SQL92. In most cases, however, <productname>PostgreSQL</productname>
with SQL92. In most cases, however, <productname>PostgreSQL</productname>
will interpret an <literal>ORDER BY</literal> or <literal>GROUP
will interpret an <literal>ORDER BY</literal> or <literal>GROUP
BY</literal> expression the same way SQL99 does.
BY</literal> expression the same way SQL99 does.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录