7.9 <query specification>
ここで指定されている SQL 標準のセクションを考えてみましょう。
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
<query specification> ::=
SELECT [ <set quantifier> ] <select list> <table expression>
[...]
<select list> ::=
<asterisk>
| <select sublist> [ { <comma> <select sublist> }... ]
[...]
Syntax Rules
1) Let T be the result of the <table expression>.
3) Case:
a) [...]
b) Otherwise, the <select list> "*" is equivalent to a <value
expression> sequence in which each <value expression> is a
<column reference> that references a column of T and each
column of T is referenced exactly once. The columns are ref-
erenced in the ascending sequence of their ordinal position
within T.
つまり、はい、SQL 標準では、列が 内の序数位置に従って射影されることを指定していますT
。or句<table expression>
を含む複数のテーブルで構成されている場合、少し注意が必要です。ただし、単純なテーブルから選択する場合は、順序が期待どおりであると想定して、おそらく問題ありません。JOIN .. USING
NATURAL JOIN
ordinal position within T
完全を期すために、 for テーブルの意味は でさらに説明されてい11.4 <column definition>
ます。
General Rules
5) [...] The ordinal position included
in the column descriptor is equal to the degree of T. [...]
そして、11.11 <add column definition>
(ALTER TABLE
ステートメントの場合)
General Rules
4) [...] In particular, the degree of T
is increased by 1 and the ordinal position of that column is
equal to the new degree of T as specified in the General Rules
of Subclause 11.4, "<column definition>".
ordinal positions
withinの正式な仕様に依存する SQL ステートメントと句は他にもかなりあります<table expressions>
。いくつかの例:
13.8 <insert statement>
(when omitting the `<insert column list>`)
20.2 <direct select statement: multiple rows>
(when `<sort specification>` contains an `<unsigned integer>`)
特に、Postgres は標準に完全に準拠しているため、本当に準拠したい場合はSELECT *
、先に進んでください。