|
17 | 17 | a <quote>constant table</quote> within a larger command, but it can be |
18 | 18 | used on its own. |
19 | 19 | </span> |
20 | | -<code class="command">VALUES</code> は、値の式で指定された行あるいは行の集合を計算します。 |
21 | | -大きなコマンドの中で<span class="quote">「<span class="quote">定数テーブル</span>」</span>を作成するために使用することが多いですが、 |
22 | | -それ単独で使用することも可能です。 |
| 20 | +<code class="command">VALUES</code>は、値の式で指定された行あるいは行の集合を計算します。 |
| 21 | +大きなコマンドの中で<span class="quote">「<span class="quote">定数テーブル</span>」</span>を作成するために使用することが多いですが、それ単独で使用することも可能です。 |
23 | 22 | </p><p> |
24 | 23 | <span class="original"> |
25 | 24 | When more than one row is specified, all the rows must have the same |
|
29 | 28 | (see <xref linkend="typeconv-union-case"/>). |
30 | 29 | </span> |
31 | 30 | 複数行を指定した場合は、すべての行の要素数が同じでなければなりません。 |
32 | | -できあがるテーブル列のデータ型を決定するには、 |
33 | | -明示的に指定されている型やその列に登場する式から推測できる型を組み合わせて使用します。 |
34 | | -これは <code class="literal">UNION</code> と同じ方式です |
35 | | -(<a class="xref" href="typeconv-union-case.html" title="10.5. UNION、CASEおよび関連する構文">10.5</a> を参照ください)。 |
| 31 | +できあがるテーブル列のデータ型を決定するには、明示的に指定されている型やその列に登場する式から推測できる型を組み合わせて使用します。 |
| 32 | +これは<code class="literal">UNION</code>と同じ方式です(<a class="xref" href="typeconv-union-case.html" title="10.5. UNION、CASEおよび関連する構文">10.5</a>を参照してください)。 |
36 | 33 | </p><p> |
37 | 34 | <span class="original"> |
38 | 35 | Within larger commands, <command>VALUES</command> is syntactically allowed |
|
43 | 40 | and <literal>OFFSET</literal> clauses with a |
44 | 41 | <command>VALUES</command> command. |
45 | 42 | </span> |
46 | | -大きなコマンドの中において、 |
47 | | -<code class="command">SELECT</code> が文法上使える場所ならどこでも<code class="command">VALUES</code>を使用することができます。 |
48 | | -文法上は<code class="command">SELECT</code>と同じ扱いであるため、<code class="literal">ORDER BY</code>、<code class="literal">LIMIT</code>(、これと等価な<code class="literal">FETCH FIRST</code>)そして<code class="literal">OFFSET</code>句を<code class="command">VALUES</code>コマンドで使用することができます。 |
| 43 | +大きなコマンドの中において、<code class="command">SELECT</code>が文法上使える場所ならどこでも<code class="command">VALUES</code>を使用することができます。 |
| 44 | +文法上は<code class="command">SELECT</code>と同じ扱いであるため、<code class="literal">ORDER BY</code>、<code class="literal">LIMIT</code>(これと等価な<code class="literal">FETCH FIRST</code>)、そして<code class="literal">OFFSET</code>句を<code class="command">VALUES</code>コマンドで使用することができます。 |
49 | 45 | </p></div><div class="refsect1" id="id-1.9.3.185.6"><h2>パラメータ</h2><span class="original"> |
50 | 46 | <title>Parameters</title> |
51 | 47 | </span><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>expression</code></em></span></dt><dd><p> |
|
58 | 54 | default value should be inserted. <literal>DEFAULT</literal> cannot |
59 | 55 | be used when <command>VALUES</command> appears in other contexts. |
60 | 56 | </span> |
61 | | -定数あるいは式です。これを計算した結果が、 |
62 | | -表 (行セット) の中の指定した場所に挿入されます。 |
63 | | -<code class="command">VALUES</code> リストを <code class="command">INSERT</code> の最上位レベルで使用する場合は、 |
64 | | -<em class="replaceable"><code>expression</code></em> を <code class="literal">DEFAULT</code> |
65 | | -で置き換えることができます。これは、その列のデフォルト値を挿入することを表します。 |
66 | | -他の場所で <code class="command">VALUES</code> を使用する場合には、 |
67 | | -<code class="literal">DEFAULT</code> は使用できません。 |
| 57 | +定数あるいは式です。これを計算した結果が、表(行セット)の中の指定した場所に挿入されます。 |
| 58 | +<code class="command">VALUES</code>リストを<code class="command">INSERT</code>の最上位レベルで使用する場合は、<em class="replaceable"><code>expression</code></em>を<code class="literal">DEFAULT</code>で置き換えることができます。 |
| 59 | +これは、その列のデフォルト値を挿入することを表します。 |
| 60 | +他の場所で<code class="command">VALUES</code>を使用する場合には、<code class="literal">DEFAULT</code>は使用できません。 |
68 | 61 | </p></dd><dt><span class="term"><em class="replaceable"><code>sort_expression</code></em></span></dt><dd><p> |
69 | 62 | <span class="original"> |
70 | 63 | An expression or integer constant indicating how to sort the result |
|
75 | 68 | in the <xref linkend="sql-select"/> documentation. |
76 | 69 | </span> |
77 | 70 | 式あるいは整数の定数で、結果の行をソートする方法を表します。 |
78 | | -この式は、<code class="command">VALUES</code> の結果の列を <code class="literal">column1</code>、<code class="literal">column2</code>などのように参照することができます。 |
79 | | -詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-ORDERBY" title="ORDER BY句">ORDER BY句</a>を参照ください。 |
| 71 | +この式は、<code class="command">VALUES</code>の結果の列を<code class="literal">column1</code>、<code class="literal">column2</code>などのように参照することができます。 |
| 72 | +詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-ORDERBY" title="ORDER BY句">ORDER BY句</a>を参照してください。 |
80 | 73 | </p></dd><dt><span class="term"><em class="replaceable"><code>operator</code></em></span></dt><dd><p> |
81 | 74 | <span class="original"> |
82 | 75 | A sorting operator. For details see |
83 | 76 | <xref linkend="sql-orderby"/> |
84 | 77 | in the <xref linkend="sql-select"/> documentation. |
85 | 78 | </span> |
86 | 79 | ソート用の演算子です。 |
87 | | -詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-ORDERBY" title="ORDER BY句">ORDER BY句</a>を参照ください。 |
| 80 | +詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-ORDERBY" title="ORDER BY句">ORDER BY句</a>を参照してください。 |
88 | 81 | </p></dd><dt><span class="term"><em class="replaceable"><code>count</code></em></span></dt><dd><p> |
89 | 82 | <span class="original"> |
90 | 83 | The maximum number of rows to return. For details see |
91 | 84 | <xref linkend="sql-limit"/> |
92 | 85 | in the <xref linkend="sql-select"/> documentation. |
93 | 86 | </span> |
94 | 87 | 返す行の最大数です。 |
95 | | -詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-LIMIT" title="LIMIT句">LIMIT句</a>を参照ください。 |
| 88 | +詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-LIMIT" title="LIMIT句">LIMIT句</a>を参照してください。 |
96 | 89 | </p></dd><dt><span class="term"><em class="replaceable"><code>start</code></em></span></dt><dd><p> |
97 | 90 | <span class="original"> |
98 | 91 | The number of rows to skip before starting to return rows. |
99 | 92 | For details see <xref linkend="sql-limit"/> |
100 | 93 | in the <xref linkend="sql-select"/> documentation. |
101 | 94 | </span> |
102 | 95 | 結果を返す際に読み飛ばす行数です。 |
103 | | -詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-LIMIT" title="LIMIT句">LIMIT句</a>を参照ください。 |
| 96 | +詳細は<a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a>文書の<a class="xref" href="sql-select.html#SQL-LIMIT" title="LIMIT句">LIMIT句</a>を参照してください。 |
104 | 97 | </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.185.7"><h2>注釈</h2><span class="original"> |
105 | 98 | <title>Notes</title> |
106 | 99 | </span><p> |
|
112 | 105 | target table, and need not be inferred by scanning the <command>VALUES</command> |
113 | 106 | list), so it can handle larger lists than are practical in other contexts. |
114 | 107 | </span> |
115 | | -<code class="command">VALUES</code> で大量の行を扱うことは避けるべきです。 |
| 108 | +<code class="command">VALUES</code>で大量の行を扱うことは避けるべきです。 |
116 | 109 | メモリ不足や性能の劣化を生じさせる可能性があります。 |
117 | | -<code class="command">VALUES</code> を <code class="command">INSERT</code> の中で使用する場合は特別です。 |
118 | | -(列の型は <code class="command">INSERT</code> 先のテーブルからわかるので、 |
119 | | -<code class="command">VALUES</code> のリストを調べて型を推測する必要がないからです) |
120 | | -そのため、他の場面に比べて大きなリストを扱っても実用に耐えます。 |
| 110 | +<code class="command">VALUES</code>を<code class="command">INSERT</code>の中で使用する場合は特別です。 |
| 111 | +(列の型は<code class="command">INSERT</code>先のテーブルからわかるので、<code class="command">VALUES</code>のリストを調べて型を推測する必要がないからです)そのため、他の場面に比べて大きなリストを扱っても実用に耐えます。 |
121 | 112 | </p></div><div class="refsect1" id="id-1.9.3.185.8"><h2>例</h2><span class="original"> |
122 | 113 | <title>Examples</title> |
123 | 114 | </span><p> |
124 | 115 | <span class="original"> |
125 | 116 | A bare <command>VALUES</command> command: |
126 | 117 | </span> |
127 | | -必要最小限の <code class="command">VALUES</code> コマンドはこのようになります。 |
| 118 | +必要最小限の<code class="command">VALUES</code>コマンドはこのようになります。 |
128 | 119 |
|
129 | 120 | </p><pre class="programlisting"> |
130 | 121 | VALUES (1, 'one'), (2, 'two'), (3, 'three'); |
|
149 | 140 | More usually, <command>VALUES</command> is used within a larger SQL command. |
150 | 141 | The most common use is in <command>INSERT</command>: |
151 | 142 | </span> |
152 | | -通常は、<code class="command">VALUES</code> は大きな SQL コマンドの内部で使用します。 |
153 | | -最もよくあるのは、<code class="command">INSERT</code> での使用です。 |
| 143 | +通常は、<code class="command">VALUES</code>は大きなSQLコマンドの内部で使用します。 |
| 144 | +最もよくあるのは、<code class="command">INSERT</code>での使用です。 |
154 | 145 |
|
155 | 146 | </p><pre class="programlisting"> |
156 | 147 | INSERT INTO films (code, title, did, date_prod, kind) |
|
162 | 153 | can be <literal>DEFAULT</literal> to indicate that the column default |
163 | 154 | should be used here instead of specifying a value: |
164 | 155 | </span> |
165 | | -<code class="command">INSERT</code> 内で使用する場合には、<code class="command">VALUES</code> |
166 | | -のリストに <code class="literal">DEFAULT</code> を指定することができます。 |
| 156 | +<code class="command">INSERT</code>内で使用する場合には、<code class="command">VALUES</code>のリストに<code class="literal">DEFAULT</code>を指定することができます。 |
167 | 157 | これは、値を具体的に指定するのではなくその列のデフォルトを使用することを表します。 |
168 | 158 |
|
169 | 159 | </p><pre class="programlisting"> |
|
176 | 166 | <command>VALUES</command> can also be used where a sub-<command>SELECT</command> might |
177 | 167 | be written, for example in a <literal>FROM</literal> clause: |
178 | 168 | </span> |
179 | | -<code class="command">VALUES</code> は、副<code class="command">SELECT</code>が書ける場所に使用することができます。 |
180 | | -例えば <code class="literal">FROM</code> 句の中などでも使えます。 |
| 169 | +<code class="command">VALUES</code>は、副<code class="command">SELECT</code>が書ける場所に使用することができます。 |
| 170 | +例えば<code class="literal">FROM</code>句の中などでも使えます。 |
181 | 171 |
|
182 | 172 | </p><pre class="programlisting"> |
183 | 173 | SELECT f.* |
|
199 | 189 | these names might be different in other database systems.) |
200 | 190 | </span> |
201 | 191 | <code class="command">VALUES</code>を<code class="literal">FROM</code>句の中で使用する場合には、<code class="literal">AS</code>句が必須となることに注意しましょう。 |
202 | | -これは <code class="command">SELECT</code> の場合と同様です。 |
| 192 | +これは<code class="command">SELECT</code>の場合と同様です。 |
203 | 193 | <code class="literal">AS</code>句ですべての列の名前を指定する必要はありませんが、指定しておくことをお勧めします。 |
204 | 194 | (<code class="command">VALUES</code>のデフォルトの列名は、<span class="productname">PostgreSQL</span>においては<code class="literal">column1</code>、<code class="literal">column2</code>のようになります。 |
205 | 195 | しかし、他のデータベースシステムでは異なるかもしれません。) |
|
211 | 201 | the correct data type. If the entries are all quoted literal constants, |
212 | 202 | coercing the first is sufficient to determine the assumed type for all: |
213 | 203 | </span> |
214 | | -<code class="command">VALUES</code> を <code class="command">INSERT</code> の中で使用する場合は、 |
215 | | -値の型が挿入先列のデータ型に自動変換されます。 |
| 204 | +<code class="command">VALUES</code>を<code class="command">INSERT</code>の中で使用する場合は、値の型が挿入先列のデータ型に自動変換されます。 |
216 | 205 | それ以外の場面で使用する際には、正しいデータ型を指定する必要があるかもしれません。 |
217 | 206 | 値がすべて引用符付きのリテラル定数である場合は、最初の値にだけ型を指定しておけば十分です。 |
218 | 207 |
|
|
227 | 216 | query as shown above. The list of scalars method requires less writing |
228 | 217 | and is often more efficient. |
229 | 218 | </span> |
230 | | -単に <code class="literal">IN</code> を試したいのなら、上のような <code class="command">VALUES</code> クエリを使用するよりも |
231 | | -<code class="literal">IN</code> の<a class="link" href="functions-comparisons.html#FUNCTIONS-COMPARISONS-IN-SCALAR" title="9.25.1. IN">スカラリスト</a>形式を使用するほうがよいでしょう。 |
| 219 | +単に<code class="literal">IN</code>を試したいのなら、上のような<code class="command">VALUES</code>クエリを使用するよりも<code class="literal">IN</code>の<a class="link" href="functions-comparisons.html#FUNCTIONS-COMPARISONS-IN-SCALAR" title="9.25.1. IN">スカラリスト</a>形式を使用するほうがよいでしょう。 |
232 | 220 | スカラリストの方法の方が記述量が減りますし、たいていはより効率的になります。 |
233 | 221 | </p></div></div><div class="refsect1" id="id-1.9.3.185.9"><h2>互換性</h2><span class="original"> |
234 | 222 | <title>Compatibility</title> |
|
0 commit comments