このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


一時期/支部 5. Data 接近 and Change

一時期/支部 5. Data 接近 and Change

Fred Toussi

The HSQL 開発 Group

$Revision: 6807 $

Copyright 2010-2024 Fred Toussi. 許可 is 認めるd to 分配する this 文書 without any alteration under the 条件 of the HSQLDB license. 付加 許可 is 認めるd to the HSQL 開発 Group to 分配する this 文書 with or without alterations under the 条件 of the HSQLDB license.

2024-10-25

(米)棚上げする/(英)提議する of Contents

Overview
Cursors And Result 始める,決めるs
Columns and 列/漕ぐ/騒動s
航海
Updatability
Sensitivity
Holdability
Autocommit
JDBC Overview
JDBC Parameters
JDBC and Data Change 声明s
JDBC Callable 声明
JDBC Returned Values
Cursor 宣言
Syntax Elements
Literals
言及/関連s, etc.
Value 表現
Predicates
Aggregate 機能(する)/行事s
Other Syntax Elements
Data 接近 声明s
Select 声明
(米)棚上げする/(英)提議する
Subquery
Query Specification
(米)棚上げする/(英)提議する 表現
Joined (米)棚上げする/(英)提議する
選択
発射/推定
計算するd Columns
指名するing
配合 操作/手術s
Aggregation
始める,決める 操作/手術s
With 条項 and Recursive Queries
Query 表現
Ordering
Slicing
索引s Used in SELECT and DML 声明s
Data Change 声明s
削除する 声明
Truncate 声明
挿入する 声明
Update 声明
合併する 声明
Diagnostics and 明言する/公表する

Overview

HyperSQL data 接近 and data change 声明s are 両立できる with the 最新の SQL:2023 基準. There are a few 拡張s and some 緩和 of 支配するs, but these do not 影響する/感情 声明s that are written to the 基準 syntax. There is 十分な support for classic SQL, as 明示するd by SQL-92, and many enhancements 追加するd in later 見解/翻訳/版s of the 基準.

Cursors And Result 始める,決めるs

An SQL 声明 can be 遂行する/発効させるd in two ways. One way is to use the java.sql.声明 interface. The 声明 反対する can be 再使用するd to 遂行する/発効させる 完全に different SQL 声明s. Alternatively, a PreparedStatment can be used to 遂行する/発効させる an SQL 声明 繰り返して, and the 声明s can use parameters. Using either form, if the SQL 声明 is a query 表現, a ResultSet is returned.

In SQL, when a query 表現 (SELECT or 類似の SQL 声明) is 遂行する/発効させるd, an ephemeral (米)棚上げする/(英)提議する is created. When this (米)棚上げする/(英)提議する is returned to the 使用/適用 program, it is returned as a result 始める,決める, which is 接近d 列/漕ぐ/騒動 by 列/漕ぐ/騒動 by a cursor. A JDBC ResultSet 代表するs an SQL result 始める,決める and its cursor.

The 極小の 鮮明度/定義 of a cursor is a 名簿(に載せる)/表(にあげる) of 列/漕ぐ/騒動s with a position that can move 今後. Some cursors also 許す the position to move backwards or jump to any position in the 名簿(に載せる)/表(にあげる).

An SQL cursor has several せいにするs. These せいにするs depend on the query 表現. Some of these せいにするs can be overridden by 明示するing qualifiers in the SQL 声明 or by 明示するing values for the parameters of the JDBC 声明 or PreparedStatement.

Columns and 列/漕ぐ/騒動s

The columns of the result 始める,決める are 決定するd by the query 表現. The number of columns and the type and 指名する 特徴 of each column are known when the query 表現 is 収集するd and before its 死刑執行. This metadata (警察などへの)密告,告訴(状) remains constant 関わりなく changes to the contents of the (米)棚上げする/(英)提議するs used in the query 表現. The metadata for the JDBC ResultSet is in the form of a ResultSetMetaData 反対する. さまざまな methods of the ResultSetMetaData interface return different 所有物/資産/財産s of each column of the ResultSet.

A result 始める,決める may 含む/封じ込める 0 or more 列/漕ぐ/騒動s. The 列/漕ぐ/騒動s are 決定するd by the 死刑執行 of the query 表現.

The setMaxRows(int) method of JDBC 声明 許すs 限界ing the number of 列/漕ぐ/騒動s returned by the 声明. This 限界 is conceptually 適用するd after the result has been built, and the 超過 列/漕ぐ/騒動s are discarded.

航海

A cursor is either scrollable or not. Scrollable cursors 許す 接近ing 列/漕ぐ/騒動s by 絶対の or 親族 positioning. No-scroll cursors only 許す moving to the next 列/漕ぐ/騒動. The cursor can be optionally 宣言するd with the SQL qualifiers SCROLL, or NO SCROLL. The JDBC 声明 parameter can be 明示するd as: TYPE_FORWARD_ONLY and TYPE_SCROLL_INSENSITIVE. The JDBC type TYPE_SCROLL_SENSITIVE is not supported by HSQLDB.

The default is NO SCROLL or TYPE_FORWARD_ONLY.

When a JDBC ResultSet is opened, it is positioned before the first 列/漕ぐ/騒動. Using the next() method, the position is moved to the first 列/漕ぐ/騒動. While the ResultSet is positioned on a 列/漕ぐ/騒動, さまざまな getter methods can be used to 接近 the columns of the 列/漕ぐ/騒動.

Updatability

The result returned by some query 表現s is updatable. HSQLDB supports 核心 SQL updatability features, 加える some enhancements from the SQL optional features.

A query 表現 is updatable if it is a SELECT from a 選び出す/独身 underlying base (米)棚上げする/(英)提議する (or updatable 見解(をとる)) either 直接/まっすぐに or 間接に. A SELECT 声明 featuring DISTINCT or GROUP BY or FETCH, LIMIT, OFFSET is not updatable. In an updatable query 表現, one or more columns are updatable. An updatable column is a column that can be traced 直接/まっすぐに to the underlying (米)棚上げする/(英)提議する. Therefore, columns that 含む/封じ込める 表現s are not updatable. Examples of updatable query 表現s are given below. The 見解(をとる) V is updatable when its query 表現 is updatable. The SELECT 声明 from this 見解(をとる) is also updatable:

 SELECT A, B FROM T WHERE C > 5
 SELECT A, B FROM (SELECT * FROM T WHERE C > 10) AS TT WHERE TT.B <10
 CREATE VIEW V(X,Y) AS SELECT A, B FROM T WHERE C > 0 AND B < 10
 SELECT X FROM V WHERE Y = 5

If a cursor is 宣言するd with the SQL qualifier, FOR UPDATE OF <column 指名する 名簿(に載せる)/表(にあげる)>, then only the 明言する/公表するd columns in the result 始める,決める become updatable. If any of the 明言する/公表するd columns is not 現実に updatable, then the cursor 宣言 will not 後継する.

If the SQL qualifier, FOR UPDATE is used, then all the updatable columns of the result 始める,決める become updatable.

If a cursor is 宣言するd with FOR READ ONLY, then it is not updatable.

In HyperSQL, if FOR READ ONLY or FOR UPDATE is not used then all the updatable columns of the result 始める,決める become updatable. This relaxes the SQL 基準 支配する that in this 事例/患者 限界s updatability to only 簡単に updatable SELECT 声明s (where all columns are updatable).

In JDBC, CONCUR_READ_ONLY or CONCUR_UPDATABLE can be 明示するd for the 声明 parameter. CONCUR_UPDATABLE is 要求するd if the returning ResultSet is to be updatable. If CONCUR_READ_ONLY, which is the default, is used, then even an updatable ResultSet becomes read-only.

When a ResultSet is updatable, さまざまな setter methods can be used to 修正する the column values. The 指名するs of the setter methods begin with "update". After all the updates on a 列/漕ぐ/騒動 are done, the updateRow() method must be called only once to finalise the 列/漕ぐ/騒動 update.

An updatable ResultSet may or may not be insertable-into. In an insertable ResultSet, all columns of the result are updatable and any column of the base (米)棚上げする/(英)提議する that is not in the result must be a 生成するd column or have a default value.

In the ResultSet 反対する, a special pseudo-列/漕ぐ/騒動, called the 挿入する 列/漕ぐ/騒動, is used to 居住させる values for insertion into the ResultSet (and その結果, into the base (米)棚上げする/(英)提議する). The setter methods must be used on all the columns, followed by a call to insertRow().

Individual 列/漕ぐ/騒動s from all updatable result 始める,決めるs can be 削除するd one at a time. The deleteRow() is called when the ResultSet is positioned on a 列/漕ぐ/騒動.

While using an updatable ResultSet to 修正する data, it is recommended not to change the same data using another ResultSet and not to 遂行する/発効させる SQL data change 声明s that 修正する the same data.

Sensitivity

The sensitivity of the cursor relates to visibility of changes made to the data by the same 処理/取引 but without using the given cursor. While the result 始める,決める is open, the same 処理/取引 may use 声明s such as INSERT or UPDATE, and change the data of the (米)棚上げする/(英)提議するs from which the result 始める,決める data is derived. A cursor is SENSITIVE if it 反映するs those changes. It is INSENSITIVE if it ignores such changes. It is ASENSITIVE if behaviour is 実施 扶養家族.

The SQL default is ASENSITIVE, i.e., implantation 扶養家族.

In HyperSQL all cursors are INSENSITIVE. They do not 反映する changes to the data made by other 声明s.

Holdability

A cursor is holdable if the result 始める,決める is not automatically の近くにd when the 現在の 処理/取引 is committed. Holdability can be 明示するd in the cursor 宣言 using the SQL qualifiers WITH HOLD or WITHOUT HOLD.

In JDBC, holdability is 明示するd using either of the に引き続いて values for the 声明 parameter: HOLD_CURSORS_OVER_COMMIT, or CLOSE_CURSORS_AT_COMMIT.

The SQL default is WITHOUT HOLD.

The JDBC default for HyperSQL result 始める,決めるs is WITH HOLD for read-only result 始める,決めるs and WITHOUT HOLD for updatable result 始める,決めるs.

If the holdability of a ResultSet is 明示するd in a 相反する manner in the SQL 声明 and the JDBC 声明 反対する, the JDBC setting takes 優先.

Autocommit

The autocommit 所有物/資産/財産 of a 関係 is a feature of JDBC and ODBC and is not part of the SQL 基準. In autocommit 方式, all transactional 声明s are followed by an implicit commit. In autocommit 方式, all ResultSet 反対するs are read-only and holdable.

JDBC Overview

The JDBC settings, ResultSet.CONCUR_READONLY and ResultSet.CONCUR_UPDATABLE are the 利用できる 代案/選択肢s for read-only or updatability. The default is ResultSet.CONCUR_READONLY.

The JDBC settings, ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE are the 利用できる 代案/選択肢s for both scrollability (航海) and sensitivity. HyperSQL does not support ResultSet.TYPE_SCROLL_SENSITIVE. The two other 代案/選択肢s can be used for both updatable and read-only result 始める,決めるs.

The JDBC settings ResultSet.CLOSE_CURSORS_AT_COMMIT and ResultSet.HOLD_CURSORS_OVER_COMMIT are the 代案/選択肢s for the lifetime of the result 始める,決める. The default is ResultSet.CLOSE_CURSORS_AT_COMMIT. The other setting can only be used for read-only result 始める,決めるs.

Examples of creating 声明s for updatable result 始める,決めるs are given below:

 関係 c = newConnection();
 声明 st;
 c.setAutoCommit(誤った);
 st = c.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
 st = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

JDBC Parameters

When a JDBC PreparedStatement or CallableStatement is used with an SQL 声明 that 含む/封じ込めるs dynamic parameters, the data types of the parameters are 解決するd and 決定するd by the engine when the 声明 is 用意が出来ている. The SQL 基準 has 詳細(に述べる)d 支配するs to 決定する the data types and 課すs 限界s on the 最大限 length or precision of the parameter. HyperSQL 適用するs the 基準 支配するs with two exceptions for parameters with String and BigDecimal Java types. HyperSQL ignores the 限界s when the parameter value is 始める,決める, and only 施行するs the necessary 限界s for 挿入するs and updates when the PreparedStatement is 遂行する/発効させるd. In all other 事例/患者s, parameter type 限界s are checked and 施行するd when the parameter is 始める,決める.

In the example below the setString() calls do not raise an exception, but one of the 遂行する/発効させる() 声明s does.

 // (米)棚上げする/(英)提議する 鮮明度/定義: CREATE TABLE T (NAME VARCHAR(12), ...)
 関係 c = newConnection();
 PreparedStatement st = c.prepareStatement("SELECT * FROM T WHERE NAME = ?");
 // type of the parameter is VARCHAR(12), which 限界s length to 12 characters
 st.setString(1, "Eyjafjallajokull"); // string is longer than type, but no exception is raised here
 st.遂行する/発効させる(); // 遂行する/発効させるs with no exception and does not find any 列/漕ぐ/騒動s

 // but if an UPDATE is 試みる/企てるd, an exception is raised
 st = c.prepareStatement("UPDATE T SET NAME = ? WHERE ID = 10");
 st.setString(1, "Eyjafjallajokull"); // string is longer than type, but no exception is raised here
 st.遂行する/発効させる(); // exception is thrown when HyperSQL checks the value for update

JDBC parameters can be 始める,決める with any 両立できる type, as supported by the JDBC specification. For CLOB and BLOB types, you can use streams, or create instances of BLOB or CLOB before 割り当てるing them to the parameters. You can even use CLOB or BLOB 反対するs returned from 関係s to other RDBMS servers. The 関係.createBlob() and createClob() methods can be used to create the new LOBs. For very large LOBs the stream methods are より望ましい as they use いっそう少なく memory.

For array parameters, you can use a java.sql.Array 反対する that 含む/封じ込めるs the array elements before 割り当てるing to JDBC parameters. The 関係.createArrayOf(...) method can be used to create a new 反対する, or you can use an Array returned from 関係s to other RDBMS servers. You can also use Java arrays of 原始のs to 割り当てる to the SQL array parameters.

The above also 適用するs to the methods of java.sql.ResultSet that are used for setting values in new and updated 列/漕ぐ/騒動s in updatable ResultSet 反対するs.

The setObject() methods of PreparedStatement and CallableStatement also 受託する 反対するs of the new types introduced in Java 8 and 名簿(に載せる)/表(にあげる)d below under JDBC Returned Values. The new Java 8 method, getObject(int columnIndex, Class<T> type), can be used to retrieve the value of an OUT parameter from a CallableStatement.

JDBC and Data Change 声明s

Data change 声明s, also called data 巧みな操作 声明s (DML) such as INSERT, UPDATE, MERGE can be called with different executeUpdate() methods of java.sql.声明 and java.sql.PreparedStatement. Some of these methods 許す you to 明示する how values for 生成するd columns of the (米)棚上げする/(英)提議する are returned. These methods are 文書d in the JavaDoc for org.hsqldb.jdbc.JDBCStatement and org.hsqldb.jdbc.JDBCPreparedStatement. HyperSQL can return not just the 生成するd columns, but any 始める,決める of columns of the (米)棚上げする/(英)提議する. You can use this to retrieve the columns values that may be 修正するd by a BEFORE TRIGGER on the (米)棚上げする/(英)提議する.

JDBC Callable 声明

The JDBC CallableStatement interface is used to call Java or SQL 手続きs that have been defined in the database. The SQL 声明 is in the form of CALL procedureName ( ... ) with constant value arguments or with parameter markers. 公式文書,認める that you must use a parameter marker for OUT and INOUT arguments of the 手続き you are calling. The OUT arguments should not be 始める,決める before 遂行する/発効させるing the callable 声明.

After 遂行する/発効させるing the 声明, you can retrieve the OUT and INOUT parameters with the appropriate getXXX() method.

手続きs can also return one or more result 始める,決めるs. You should call the getResultSet() and getMoreResults() methods to retrieve the result 始める,決めるs one by one.

SQL 機能(する)/行事s can also return a (米)棚上げする/(英)提議する. You can call such 機能(する)/行事s the same way as 手続きs and retrieve the (米)棚上げする/(英)提議する as a ResultSet.

JDBC Returned Values

The methods of the JDBC ResultSet interface are used to return values and to 変える value to different types as supported by the JDBC specification. Methods of JDBC CallableStatement that have the same 署名 are used to return values from 手続き calls.

When a CLOB and BLOB 反対する is returned from a ResultSet, no data is transferred until the data is read by さまざまな methods of java.sql.CLOB and java.sql.BLOB. Data is streamed in large 封鎖するs to 避ける 過度の memory use.

Array 反対するs are returned as instances of java.sql.Array.

Methods 追加するd in Java 8 are supported and the behaviour of the getObject(int columnIndex) method for retrieving TIMESTAMP WITH TIME ZONE has changed. In 見解/翻訳/版s before 2.4.0, this method returned a java.sql.Timestamp 反対する. It now returns a java.time.OffsetDateTime 反対する which 含む/封じ込めるs the time zone 相殺する value 同様に as the other fields of the TIMESTAMP.

A new method, getObject(int columnIndex, Class<T> type) is 利用できる. With this method, you 明示する the 要求するd return type. The ありふれた types such as String, Integer, byte[] are supported, 同様に as new types that can be used for DATE, TIME, TIMESTAMP, and INTERVAL values. The (米)棚上げする/(英)提議する below shows which Java classes are the most appropriate for the 明示するd SQL TYPES. In 新規加入, you can use these Java types for values of SQL type that are not fully matched. For example, java.time.LocalDateTime can be used to retrieve a DATE value.

java.util.UUID = UUID
java.time.LocalDate = DATE
java.sql.Date = DATE
java.time.LocalTime = TIME
java.sql.Time = TIME
java.time.LocalDateTime = TIMESTAMP
java.sql.Timestamp = TIMESTAMP
java.time.OffsetTime = TIME WITH TIME ZONE
java.time.OffsetDateTime = TIMESTAMP WITH TIME ZONE
java.time.Duration = INTERVAL MONTH, INTERVAL YEAR, INTERVAL YEAR TO MONTH
java.time.Period = INTERVAL SECOND, INTERVAL MINUTE, INTERVAL HOUR, INTERVAL DAY, and their 範囲 combinations
java.sql.Array = all ARRAY

Cursor 宣言

The DECLARE CURSOR 声明 is used within an SQL PROCEDURE 団体/死体. In the 現在の 見解/翻訳/版 of HyperSQL, the cursor is used only to return a result 始める,決める from the 手続き. Therefore, the cursor must be 宣言するd WITH RETURN and can only be READ ONLY.

DECLARE CURSOR

宣言する cursor 声明

<宣言する cursor> ::= DECLARE <cursor 指名する>

[ { SENSITIVE | INSENSITIVE | ASENSITIVE } ] [ { SCROLL | NO SCROLL } ]

CURSOR [ { WITH HOLD | WITHOUT HOLD } ] [ { WITH RETURN | WITHOUT RETURN } ]

FOR <query 表現>

[ FOR { READ ONLY | UPDATE [ OF <column 指名する 名簿(に載せる)/表(にあげる)> ] } ]

The query 表現 is a SELECT 声明 or 類似の, and is discussed in the 残り/休憩(する) of this 一時期/支部. In the example below a cursor is 宣言するd for a SELECT 声明. It is later opened to create the result 始める,決める. The cursor is 明示するd WITHOUT HOLD, so the result 始める,決める is not kept after a commit. Use WITH HOLD to keep the result 始める,決める. 公式文書,認める that you need to 宣言する the cursor WITH RETURN as it is returned by the CallableStatement.

 DECLARE thiscursor SCROLL CURSOR WITHOUT HOLD WITH RETURN FOR SELECT * FROM INFORMATION_SCHEMA.TABLES;
 --
 OPEN thiscursor;

Syntax Elements

The syntax elements that can be used in data 接近 and data change 声明s are 述べるd in this section. The SQL 基準 has a very 広範囲にわたる 始める,決める of 鮮明度/定義s for these elements. The BNF 鮮明度/定義s given here are いつかs 簡単にするd.

Literals

Literals are used to 表明する constant values. The general type of a literal is known by its 判型. The 明確な/細部 type is based on 条約s.

unicode escape elements

unicode escape elements

<Unicode escape specifier> ::= [ UESCAPE <引用する><Unicode escape character><引用する> ]

<Unicode escape value> ::= <Unicode 4 digit escape value> | <Unicode 6 digit escape value> | <Unicode character escape value>

<Unicode 4 digit escape value> ::= <Unicode escape character><hexit><hexit><hexit><hexit>

<Unicode 6 digit escape value> ::= <Unicode escape character><加える 調印する> <hexit><hexit><hexit><hexit><hexit><hexit>

<Unicode character escape value> ::= <Unicode escape character><Unicode escape character>

<Unicode escape character> ::= a 選び出す/独身 character other than a <hexit> (a-f, A-F, 0-9), <加える 調印する>, <引用する>, <二塁打 引用する>, or <white space>

character literal

character literal

<character string literal> ::= [ <introducer><character 始める,決める specification> ] <引用する> [ <character 代表>... ] <引用する> [ { <separator> <引用する> [ <character 代表>... ] <引用する> }... ]

<introducer> ::= <強調する>

<character 代表> ::= <nonquote character> | <引用する symbol>

<nonquote character> ::= any character apart from the 引用する symbol.

<引用する symbol> ::= <引用する><引用する>

<国家の character string literal> ::= N <引用する> [ <character 代表>... ] <引用する> [ { <separator> <引用する> [ <character 代表>... ] <引用する> }... ]

<Unicode character string literal> ::= [ <introducer><character 始める,決める specification> ] U<ampersand><引用する> [ <Unicode 代表>... ] <引用する> [ { <separator> <引用する> [ <Unicode 代表>... ] <引用する> }... ] <Unicode escape specifier>

<Unicode 代表> ::= <character 代表> | <Unicode escape value>

The type of a character literal is CHARACTER. The length of the string literal is the character length of the type. If the 引用する character is used in a string, it is 代表するd with two 引用する characters. Long literals can be divided into 多重の 引用するd strings, separated with a space or end-of-line character.

Unicode literals start with U& and can 含む/封じ込める ordinary characters and Unicode escapes. A Unicode escape begins with the backslash ( \ ) character and is followed by four hexadecimal characters which 明示する the character code. The Unicode escape character can be custom defined for a literal string by 追加するing UESPACE as in one of the examples below.

Example of character literals are given below:

 'a literal'  ' string seperated'  ' into parts'
 'a string''s literal form with 引用する character'
 U&'Unicode string with Greek delta \0394 and phi \03a6 letters'
 U&'Unicode string with 今後 削除する // as custom escape character'UESCAPE'/'

binary literal

binary literal

<binary string literal> ::= X <引用する> [ <space>... ] [ { <hexit> [ <space>... ] <hexit> [ <space>... ] }... ] <引用する> [ { <separator> <引用する> [ <space>... ] [ { <hexit> [ <space>... ] <hexit> [ <space>... ] }... ] <引用する> }... ]

<hexit> ::= <digit> | A | B | C | D | E | F | a | b | c | d | e | f

The type of a binary literal is BINARY. The octet length of the binary literal is the length of the type. 事例/患者-insensitive hexadecimal characters are used in the binary string. Each pair of characters in the literal 代表するs a byte in the binary string. Long literals can be divided into 多重の 引用するd strings, separated with a space or end-of-line character.

 X'1abACD34' 'Af'

bit literal

bit literal

<bit string literal> ::= B <引用する> [ <bit> ... ] <引用する> [ { <separator> <引用する> [ <bit>... ] <引用する> }... ]

<bit> ::= 0 | 1

The type of a binary literal is BIT. The bit length of the bit literal is the length of the type. Digits 0 and 1 are used to 代表する the bits. Long literals can be divided into 多重の 引用するd strings, separated with a space or end-of-line character.

 B'10001001' '00010'

numeric literal

numeric literal

<調印するd numeric literal> ::= [ <調印する> ] <unsigned numeric literal>

<unsigned numeric literal> ::= <exact numeric literal> | <approximate numeric literal>

<exact numeric literal> ::= <unsigned integer> [ <period> [ <unsigned integer> ] ] | <period> <unsigned integer>

<調印する> ::= <加える 調印する> | <minus 調印する>

<approximate numeric literal> ::= <mantissa> E <exponent>

<mantissa> ::= <exact numeric literal>

<exponent> ::= <調印するd integer>

<調印するd integer> ::= [ <調印する> ] <unsigned integer>

<unsigned integer> ::= <digit>...

The type of an exact numeric literal without a decimal point is INTEGER, BIGINT, or DECIMAL, depending on the value of the literal (the smallest type that can 代表する the value is the type).

The type of an exact numeric literal with a decimal point is DECIMAL. The precision of a decimal literal is the total number of digits of the literal. The 規模 of the literal is the total number of digits to the 権利 of the decimal point.

The type of an approximate numeric literal is DOUBLE. An approximate numeric literal always 含むs the mantissa and exponent, separated by E.

 12
 34.35
 +12E-2

boolean literal

boolean literal

<boolean literal> ::= TRUE | FALSE | UNKNOWN

The boolean literal is one of the 明示するd keywords.

datetime and interval literal

datetime and interval literal

<datetime literal> ::= <date literal> | <time literal> | <timestamp literal>

<date literal> ::= DATE <date string>

<time literal> ::= TIME <time string>

<timestamp literal> ::= TIMESTAMP <timestamp string>

<date string> ::= <引用する> <unquoted date string> <引用する>

<time string> ::= <引用する> <unquoted time string> <引用する>

<timestamp string> ::= <引用する> <unquoted timestamp string> <引用する>

<time zone interval> ::= <調印する> <hours value> <結腸> <minutes value>

<date value> ::= <years value> <minus 調印する> <months value> <minus 調印する> <days value>

<time value> ::= <hours value> <結腸> <minutes value> <結腸> <seconds value>

<interval literal> ::= INTERVAL [ <調印する> ] <interval string> <interval qualifier>

<interval string> ::= <引用する> <unquoted interval string> <引用する>

<unquoted date string> ::= <date value>

<unquoted time string> ::= <time value> [ <time zone interval> ]

<unquoted timestamp string> ::= <unquoted date string> <space> <unquoted time string>

<unquoted interval string> ::= [ <調印する> ] { <year-month literal> | <day-time literal> }

<year-month literal> ::= <years value> [ <minus 調印する> <months value> ] | <months value>

<day-time literal> ::= <day-time interval> | <time interval>

<day-time interval> ::= <days value> [ <space> <hours value> [ <結腸> <minutes value> [ <結腸> <seconds value> ] ] ]

<time interval> ::= <hours value> [ <結腸> <minutes value> [ <結腸> <seconds value> ] ] | <minutes value> [ <結腸> <seconds value> ] | <seconds value>

<years value> ::= <datetime value>

<months value> ::= <datetime value>

<days value> ::= <datetime value>

<hours value> ::= <datetime value>

<minutes value> ::= <datetime value>

<seconds value> ::= <seconds integer value> [ <period> [ <seconds fraction> ] ]

<seconds integer value> ::= <unsigned integer>

<seconds fraction> ::= <unsigned integer>

<datetime value> ::= <unsigned integer>

The type of a datetime or interval type is 明示するd in the literal. The わずかの second precision is the number of digits in the わずかの part of the literal. 詳細(に述べる)s are 述べるd in the SQL Language 一時期/支部

 DATE '2008-08-08'
 TIME '20:08:08'
 TIMESTAMP '2008-08-08 20:08:08.235'

 INTERVAL '10' DAY
 INTERVAL -'08:08' MINUTE TO SECOND

言及/関連s, etc.

言及/関連s are identifier chains, which can be a 選び出す/独身 identifiers or identifiers chains composed of 選び出す/独身 identifiers chained together with the period symbol.

identifier chain

identifier chain

<identifier chain> ::= <identifier> [ { <period> <identifier> }... ]

<basic identifier chain> ::= <identifier chain>

A period-separated chain of identifiers. The identifiers in an identifier chain can 言及する to database 反対するs in a 階層制度. The possible 階層制度s are as follows. In each 階層制度, elements from the start or the end can be 行方不明の, but the order of elements cannot be changed.

catalog, schema, database 反対する

catalog, schema, (米)棚上げする/(英)提議する, column

correlation 指名する, column

Examples of identifier chain are given below:

 SELECT MYCATALOG.MYSCHEMA.MYTABLE.MYCOL FROM MYCATALOG.MYSCHEMA.MYTABLE
 SELECT MYTABLE.MYCOL FROM MYSCHEMA.MYTABLE
 DROP TABLE MYCATALOG.MYSCHEMA.MYTABLE CASCADE
 ALTER SEQUENCE MYCATALOG.MYSCHEMA.MYSEQUENCE RESTART WITH 100

column 言及/関連

column 言及/関連

<column 言及/関連> ::= <basic identifier chain> | MODULE <period> <qualified identifier> <period> <column 指名する>

言及/関連 a column or a 決まりきった仕事 variable.

SQL parameter 言及/関連

SQL parameter 言及/関連

<SQL parameter 言及/関連> ::= <basic identifier chain>

言及/関連 an SQL 決まりきった仕事 parameter.

contextually typed value specification

contextually typed value specification

<contextually typed value specification> ::= <null specification> | <default specification>

<null specification> ::= NULL

<default specification> ::= DEFAULT

明示する a value whose data type or value is inferred from its 状況.

DEFAULT is used for assignments to (米)棚上げする/(英)提議する columns that have a default value, or to (米)棚上げする/(英)提議する columns that are 生成するd either as an IDENTITY value or as an 表現.

NULL can be used only in a 状況 where the type of the value is known. For example, a NULL can be 割り当てるd to a column of the (米)棚上げする/(英)提議する in an INSERT or UPDATE 声明, because the type of the column is known. But if NULL is used in a SELECT 名簿(に載せる)/表(にあげる), it must be used in a CAST 声明.

Value 表現

Value 表現 is a general 指名する for all 表現s that return a value. Different types of 表現s are 許すd in different 状況s.

value 表現 最初の/主要な

value 表現 最初の/主要な

<value 表現 最初の/主要な> ::= <parenthesized value 表現> | <nonparenthesized value 表現 最初の/主要な>

<parenthesized value 表現> ::= <left paren> <value 表現> <権利 paren>

<nonparenthesized value 表現 最初の/主要な> ::= <unsigned value specification> | <column 言及/関連> | <始める,決める 機能(する)/行事 specification> | <scalar subquery> | <事例/患者 表現> | <cast specification> | <next value 表現> | <現在の value 表現> | <決まりきった仕事 invocation>

明示する a value that is syntactically self-delimited.

value specification

value specification

<value specification> ::= <literal> | <general value specification>

<unsigned value specification> ::= <unsigned literal> | <general value specification>

<的 specification> ::= <host parameter specification> | <SQL parameter 言及/関連> | <column 言及/関連> | <dynamic parameter specification>

<simple 的 specification> ::= <host parameter specification> | <SQL parameter 言及/関連> | <column 言及/関連> | <embedded variable 指名する>

<host parameter specification> ::= <host parameter 指名する> [ <指示する人(物) parameter> ]

<dynamic parameter specification> ::= <question 示す>

明示する one or more values, host parameters, SQL parameters, dynamic parameters, or host variables.

列/漕ぐ/騒動 value 表現

列/漕ぐ/騒動 value 表現

<列/漕ぐ/騒動 value 表現> ::= <列/漕ぐ/騒動 value special 事例/患者> | <explicit 列/漕ぐ/騒動 value 建設者>

<列/漕ぐ/騒動 value predicand> ::= <列/漕ぐ/騒動 value special 事例/患者> | <列/漕ぐ/騒動 value 建設者 predicand>

<列/漕ぐ/騒動 value special 事例/患者> ::= <nonparenthesized value 表現 最初の/主要な>

<explicit 列/漕ぐ/騒動 value 建設者> ::= <left paren> <列/漕ぐ/騒動 value 建設者 element> <comma> <列/漕ぐ/騒動 value 建設者 element 名簿(に載せる)/表(にあげる)> <権利 paren> |

ROW <left paren> <列/漕ぐ/騒動 value 建設者 element 名簿(に載せる)/表(にあげる)> <権利 paren> | <列/漕ぐ/騒動 subquery>

明示する a 列/漕ぐ/騒動 consisting of one or more elements. A comma separated 名簿(に載せる)/表(にあげる) of 表現s, enclosed in brackets, with the optional keyword ROW. In SQL, a 列/漕ぐ/騒動 含む/封じ込めるing a 選び出す/独身 element can often be used where a 選び出す/独身 value is 推定する/予想するd.

始める,決める 機能(する)/行事 specification

始める,決める 機能(する)/行事 specification

<始める,決める 機能(する)/行事 specification> ::= <aggregate 機能(する)/行事> | <配合 操作/手術>

<配合 操作/手術> ::= GROUPING <left paren> <column 言及/関連> [ { <comma> <column 言及/関連> }... ] <権利 paren>

明示する an integer value formed by bits denoting the presence of the column in the 現在の 列/漕ぐ/騒動 of the result of GROUPING SETS. HyperSQL supports <配合 操作/手術> from 見解/翻訳/版 2.5.1.

COALESCE

coalesce 表現

<coalesce 表現> := COALESCE <left paren> <value 表現> { <comma> <value 表現> }... <権利 paren>

取って代わる null values with another value. The coalesce 表現 has two or more instances of <value 表現>. If the first <value 表現> 評価するs to a 非,不,無-null value, it is returned as the result of the coalesce 表現. If it is null, the next <value 表現> is 評価するd and if it 評価するs to a 非,不,無-非,不,無 value, it is returned, and so on.

The type of the return value of a COALESCE 表現 is the aggregate type of the types of all the <value 表現> instances. Therefore, any value returned is 暗黙に cast to this type. HyperSQL also features built-in 機能(する)/行事s with 類似の functionality.

NULLIF

nullif 表現

<nullif 表現> := NULLIF <left paren> <value 表現> <comma> <value 表現> <権利 paren>

Return NULL if two values are equal. If the result of the first <value 表現> is not equal to the result of the second, then it is returned, さもなければ NULL is returned. The type of the return value is the type of the first <value 表現>.

 SELECT i, NULLIF(n, 'not defined') FROM t

CASE

事例/患者 specification

<事例/患者 specification> ::= <simple 事例/患者> | <searched 事例/患者>

<simple 事例/患者> ::= CASE <事例/患者 operand> <simple when 条項>... [ <else 条項> ] END

<searched 事例/患者> ::= CASE <searched when 条項>... [ <else 条項> ] END

<simple when 条項> ::= WHEN <when operand 名簿(に載せる)/表(にあげる)> THEN <result>

<searched when 条項> ::= WHEN <search 条件> THEN <result>

<else 条項> ::= ELSE <result>

<事例/患者 operand> ::= <列/漕ぐ/騒動 value predicand> | <overlaps predicate part 1>

<when operand 名簿(に載せる)/表(にあげる)> ::= <when operand> [ { <comma> <when operand> }... ]

<when operand> ::= <列/漕ぐ/騒動 value predicand> | <comparison predicate part 2> | <between predicate part 2> | <in predicate part 2> | <character like predicate part 2> | <octet like predicate part 2> | <類似の predicate part 2> | <regex like predicate part 2> | <null predicate part 2> | <quantified comparison predicate part 2> | <match predicate part 2> | <overlaps predicate part 2> | <際立った predicate part 2>

<result> ::= <result 表現> | NULL

<result 表現> ::= <value 表現>

明示する a 条件付きの value. The result of a 事例/患者 表現 is always a value. All the values introduced with THEN must be of the same type or 転換できる to the same type. The WHEN 条項 of CASE can be used in two different forms. The first form starts with a variable and the WHEN 条項s follow, either as possible values for the variable, or as 条件s. The second form does not start with a variable and each WHEN is followed by a self-含む/封じ込めるd 条件付きの 表現 which can use any variables.

Some simple examples of the CASE 表現 are given below. The first two examples return 'Britain', 'Germany', or 'Other country' depending on the value of dial code. The third example uses IN and smaller-than predicates.

 CASE dialcode WHEN 44 THEN 'Britain' WHEN 49 THEN 'Germany' ELSE 'Other country' END
 CASE WHEN dialcode=44 THEN 'Britain' WHEN dialcode=49 THEN 'Germany' WHEN dialcode < 0 THEN 'bad dial code' ELSE 'Other country' END
 CASE dialcode WHEN IN (44,49,30) THEN 'Europe' WHEN IN (86,91,92) THEN 'Asia' WHEN < 0 THEN 'bad dial code' ELSE 'Other continent' END

The 事例/患者 声明 can be far more コンビナート/複合体 and 伴う/関わる several 条件s.

CAST

cast specification

<cast specification> ::= CAST <left paren> <cast operand> AS <cast 的> <権利 paren>

<cast operand> ::= <value 表現> | <暗黙に typed value specification>

<cast 的> ::= <domain 指名する> | <data type>

明示する a data 転換. Data 転換 takes place automatically の中で variants of a general type. For example, numeric values are 自由に 変えるd from one type to another in 表現s.

Explicit type 転換 is necessary in two 事例/患者s. One 事例/患者 is to 決定する the type of a NULL value. The other 事例/患者 is to 軍隊 転換 for special 目的s. Values of data types can be cast to a character type. The exception is BINARY and OTHER types. The result of the cast is the literal 表現 of the value. Conversely, a value of a character type can be 変えるd to another type if the character value is a literal 代表 of the value in the 的 type. Special 転換s are possible between numeric and interval types, which are 述べるd in the section covering interval types.

The examples below show examples of cast with their result:

 CAST (NULL AS TIMESTAMP)
 CAST ('   199  ' AS INTEGER) = 199
 CAST ('tRue ' AS BOOLEAN) = TRUE
 CAST (INTERVAL '2' DAY AS INTEGER) = 2
 CAST ('1992-04-21' AS DATE) = DATE '1992-04-21'

NEXT VALUE FOR

next value 表現

<next value 表現> ::= NEXT VALUE FOR <sequence 発生させる人(物) 指名する>

Return the next value of a sequence 発生させる人(物). This 表現 can be used as a select 名簿(に載せる)/表(にあげる) element in queries, or in assignments to (米)棚上げする/(英)提議する columns in data change 声明s. If the 表現 is used more than once in a 選び出す/独身 列/漕ぐ/騒動 that is 存在 評価するd, the same value is returned for each invocation. After evaluation of the particular 列/漕ぐ/騒動 is 完全にする, the sequence 発生させる人(物) will return a different value from the old value. The new value is 生成するd by the sequence 発生させる人(物) by 追加するing the increment to the last value it 生成するd. In SQL syntax compatibility 方式s, variants of this 表現 in different SQL dialects are supported. In the example below the 表現 is used in an 挿入する 声明:

INSERT INTO MYTABLE(COL1, COL2) VALUES 2, NEXT VALUE FOR MYSEQUENCE

CURRENT VALUE FOR

現在の value 表現

<現在の value 表現> ::= CURRENT VALUE FOR <sequence 発生させる人(物) 指名する>

Return the 最新の value that was returned by the NEXT VALUE FOR 表現 for a sequence 発生させる人(物) in this 開会/開廷/会期. In the example below, the value that was 生成するd by the sequence for the first 挿入する, is 再使用するd for the second 挿入する:

 INSERT INTO MYTABLE(COL1, COL2) VALUES 2, NEXT VALUE FOR MYSEQUENCE;
 INSERT INTO CHILDTABLE(COL1, COL2) VALUES 10, CURRENT VALUE FOR MYSEQUENCE;

value 表現

value 表現

<value 表現> ::= <numeric value 表現> | <string value 表現> | <datetime value 表現> | <interval value 表現> | <boolean value 表現> | <列/漕ぐ/騒動 value 表現>

An 表現 that returns a value. The value can be a 選び出す/独身 value, or a 列/漕ぐ/騒動 consisting more than one value.

numeric value 表現

numeric value 表現

<numeric value 表現> ::= <称する,呼ぶ/期間/用語> | <numeric value 表現> <加える 調印する> <称する,呼ぶ/期間/用語> | <numeric value 表現> <minus 調印する> <称する,呼ぶ/期間/用語>

<称する,呼ぶ/期間/用語> ::= <factor> | <称する,呼ぶ/期間/用語> <asterisk> <factor> | <称する,呼ぶ/期間/用語> <solidus> <factor>

<factor> ::= [ <調印する> ] <numeric 最初の/主要な>

<numeric 最初の/主要な> ::= <value 表現 最初の/主要な> | <numeric value 機能(する)/行事>

明示する a numeric value. The BNF 示すs that <asterisk> and <solidus> (the 操作者s for multiplication and 分割) have 優先 over <minus 調印する> and <加える 調印する>.

numeric value 機能(する)/行事

numeric value 機能(する)/行事

<numeric value 機能(する)/行事> ::= <position 表現> | <抽出する 表現> | <length 表現> ...

明示する a 機能(する)/行事 産する/生じるing a value of type numeric. The supported numeric value 機能(する)/行事s are 名簿(に載せる)/表(にあげる)d and 述べるd in the Built In 機能(する)/行事s 一時期/支部.

string value 表現

string value 表現

<string value 表現> ::= <string concatenation> | <string factor>

<string factor> ::= <value 表現 最初の/主要な> | <string value 機能(する)/行事>

<string concatenation> ::= <string value 表現> <concatenation 操作者> <string factor>

<concatenation 操作者> ::= ||

明示する a character string value, a binary string value, or a bit string value. The BNF 示すs that a string value 表現 can be formed by concatenation of two or more <value 表現 最初の/主要な>. The types of the <value 表現 最初の/主要な> elements must be 両立できる, that is, all must be string, or binary or bit string values.

character value 機能(する)/行事

string value 機能(する)/行事

<string value 機能(する)/行事> ::= ...

明示する a 機能(する)/行事 that returns a character string or binary string. The supported character value 機能(する)/行事s are 名簿(に載せる)/表(にあげる)d and 述べるd in the Built In 機能(する)/行事s 一時期/支部.

datetime value 表現

datetime value 表現

<datetime value 表現> ::= <datetime 称する,呼ぶ/期間/用語> | <interval value 表現> <加える 調印する> <datetime 称する,呼ぶ/期間/用語> | <datetime value 表現> <加える 調印する> <interval 称する,呼ぶ/期間/用語> | <datetime value 表現> <minus 調印する> <interval 称する,呼ぶ/期間/用語>

<datetime 称する,呼ぶ/期間/用語> ::= <datetime factor>

<datetime factor> ::= <datetime 最初の/主要な> [ <time zone> ]

<datetime 最初の/主要な> ::= <value 表現 最初の/主要な> | <datetime value 機能(する)/行事>

<time zone> ::= AT <time zone specifier>

<time zone specifier> ::= LOCAL | TIME ZONE { <interval 最初の/主要な> | <time zone 指名する> }

明示する a datetime value. 詳細(に述べる)s are 述べるd in the SQL Language 一時期/支部.

datetime value 機能(する)/行事

datetime value 機能(する)/行事

<datetime value 機能(する)/行事> ::= ...

明示する a 機能(する)/行事 that returns a datetime value. The supported datetime value 機能(する)/行事s are 名簿(に載せる)/表(にあげる)d and 述べるd in the Built In 機能(する)/行事s 一時期/支部.

interval 称する,呼ぶ/期間/用語

interval value 表現

<interval value 表現> ::= <interval 称する,呼ぶ/期間/用語> | <interval value 表現 1> <加える 調印する> <interval 称する,呼ぶ/期間/用語 1> | <interval value 表現 1> <minus 調印する> <interval 称する,呼ぶ/期間/用語 1> | <left paren> <datetime value 表現> <minus 調印する> <datetime 称する,呼ぶ/期間/用語> <権利 paren> <interval qualifier>

<interval 称する,呼ぶ/期間/用語> ::= <interval factor> | <interval 称する,呼ぶ/期間/用語 2> <asterisk> <factor> | <interval 称する,呼ぶ/期間/用語 2> <solidus> <factor> | <称する,呼ぶ/期間/用語> <asterisk> <interval factor>

<interval factor> ::= [ <調印する> ] <interval 最初の/主要な>

<interval 最初の/主要な> ::= <value 表現 最初の/主要な> [ <interval qualifier> ] | <interval value 機能(する)/行事>

<interval value 表現 1> ::= <interval value 表現>

<interval 称する,呼ぶ/期間/用語 1> ::= <interval 称する,呼ぶ/期間/用語>

<interval 称する,呼ぶ/期間/用語 2> ::= <interval 称する,呼ぶ/期間/用語>

明示する an interval value. 詳細(に述べる)s are 述べるd in the SQL Language 一時期/支部.

interval 絶対の value 機能(する)/行事

interval value 機能(する)/行事

<interval value 機能(する)/行事> ::= <interval 絶対の value 機能(する)/行事>

<interval 絶対の value 機能(する)/行事> ::= ABS <left paren> <interval value 表現> <権利 paren>

明示する a 機能(する)/行事 that returns the 絶対の value of an interval. If the interval is 消極的な, it is negated, さもなければ the 初めの value is returned.

boolean value 表現

boolean value 表現

<boolean value 表現> ::= <boolean 称する,呼ぶ/期間/用語> | <boolean value 表現> OR <boolean 称する,呼ぶ/期間/用語>

<boolean 称する,呼ぶ/期間/用語> ::= <boolean factor> | <boolean 称する,呼ぶ/期間/用語> AND <boolean factor>

<boolean factor> ::= [ NOT ] <boolean 実験(する)>

<boolean 実験(する)> ::= <boolean 最初の/主要な> [ IS [ NOT ] <truth value> ]

<truth value> ::= TRUE | FALSE | UNKNOWN

<boolean 最初の/主要な> ::= <predicate> | <boolean predicand>

<boolean predicand> ::= <parenthesized boolean value 表現> | <nonparenthesized value 表現 最初の/主要な>

<parenthesized boolean value 表現> ::= <left paren> <boolean value 表現> <権利 paren>

明示する a boolean value.

Predicates

Predicates are 条件s and 評価する to a boolean value. Some predicates have two 味方するs. The left 味方する of the predicate, the <列/漕ぐ/騒動 value predicand>, is the ありふれた element of all two-味方するd predicates. This element is a generalisation of both <value 表現>, which is a scalar, and of <explicit 列/漕ぐ/騒動 value 建設者>, which is a 列/漕ぐ/騒動. The two 味方するs of a predicate can be 分裂(する) in CASE 表現s where the <列/漕ぐ/騒動 value predicand> is part of 多重の predicates.

In the に引き続いて example, a column of the (米)棚上げする/(英)提議する is the left 味方する of two predicates in a CASE 表現.

SELECT CASE city WHEN 'Oslo' THEN 'Scandinavia' WHEN IN ('Dallas', 'Boston') THEN 'America' ELSE '?' END FROM 顧客

The number of fields in all <列/漕ぐ/騒動 value predicand> used in predicates must be the same and the types of the fields in the same position must be 両立できる for comparison. If either of these 条件s does not 持つ/拘留する, an exception is raised. The number of fields in a 列/漕ぐ/騒動 is called the degree.

In many types of predicates (but not all of them), if the <列/漕ぐ/騒動 value predicand> 評価するs to NULL, the result of the predicate is UNKNOWN. If the <列/漕ぐ/騒動 value predicand> has more than one element, and one or more of the fields 評価する to NULL, the result depends on the particular predicate.

comparison predicand

comparison predicate

<comparison predicate> ::= <列/漕ぐ/騒動 value predicand> <comp op> <列/漕ぐ/騒動 value predicand>

<comp op> ::= <equals 操作者> | <not equals 操作者> | <いっそう少なく than 操作者> | <greater than 操作者> | <いっそう少なく than or equals 操作者> | <greater than or equals 操作者>

明示する a comparison of two 列/漕ぐ/騒動 values. If either <列/漕ぐ/騒動 value predicand> 評価するs to NULL, the result of <comparison predicate> is UNKNOWN. さもなければ, the result is TRUE, FALSE or UNKNOWN.

If the degree of <列/漕ぐ/騒動 value predicand> is larger than one, comparison is 成し遂げるd between each field and the corresponding field in the other <列/漕ぐ/騒動 value predicand> from left to 権利, one by one.

When comparing two elements, if either field is NULL then the result is UNKNOWN.

For <equals 操作者>, if the result of comparison is TRUE for all field, the result of the predicate is TRUE. If the result of comparison is FALSE for one field, the result of predicate is FALSE. さもなければ the result is UNKNOWN.

The <not equals 操作者> is translated to NOT (<列/漕ぐ/騒動 value predicand> = <列/漕ぐ/騒動 value predicand>).

The <いっそう少なく than or equals 操作者> is translated to (<列/漕ぐ/騒動 value predicand> = <列/漕ぐ/騒動 value predicand>) OR (<列/漕ぐ/騒動 value predicand> < <列/漕ぐ/騒動 value predicand>). The <greater than or equals 操作者> is translated in a 類似の way.

For the <いっそう少なく than 操作者> and <greater than 操作者>, if two fields at a given position are equal, then comparison continues to the next field. さもなければ, the result of the last 成し遂げるd comparison is returned as the result of the predicate. This means that if the first field is NULL, the result is always UNKNOWN.

The logic that 治める/統治するs NULL values and UNKNOWN result is as follows: Suppose the NULL values were 代用品,人d by 独断的な real values. If substitution cannot change the result of the predicate, then the result is TRUE or FALSE, based on the 存在するing 非,不,無-NULL values, さもなければ the result of the predicate is UNKNOWN.

The examples of comparison given below use literals, but the literals 現実に 代表する the result of evaluation of some 表現.

 ((1, 2, 3, 4) = (1, 2, 3, 4)) IS TRUE
 ((1, 2, 3, 4) = (1, 2, 3, 5)) IS FALSE
 ((1, 2, 3, 4) < (1, 2, 3, 4)) IS FALSE
 ((1, 2, 3, 4) < (1, 2, 3, 5)) IS TRUE
 ((NULL, 1, NULL) = (NULL, 1, NULL)) IS UNKNOWN  
 ((NULL, 1, NULL) = (NULL, 2, NULL)) IS FALSE  
 ((NULL, 1, NULL) <> (NULL, 2, NULL)) IS TRUE  
 ((NULL, 1, 2) <all 操作者s> (NULL, 1, 2)) IS UNKNOWN
 ((1, NULL, ...) < (1, 2, ...)) IS UNKNOWN  
 ((1, NULL, ...) < (2, NULL, ...)) IS TRUE
 ((2, NULL, ...) < (1, NULL, ...)) IS FALSE

BETWEEN

between predicate

<between predicate> ::= <列/漕ぐ/騒動 value predicand> <between predicate part 2>

<between predicate part 2> ::= [ NOT ] BETWEEN [ ASYMMETRIC | SYMMETRIC ] <列/漕ぐ/騒動 value predicand> AND <列/漕ぐ/騒動 value predicand>

明示する a 範囲 comparison. The default is ASYMMETRIC. The 表現 X BETWEEN Y AND Z is 同等(の) to (X >= Y AND X <= Z). Therefore, if Y > Z, the BETWEEN 表現 is never true. The 表現 X BETWEEN SYMMETRIC Y AND Z is 同等(の) to (X >= Y AND X <= Z) OR (X >= Z AND X <= Y). The 表現 Z NOT BETWEEN ... is 同等(の) to NOT (Z BETWEEN ...). If any of the three <列/漕ぐ/騒動 value predicand> 評価するs to NULL, the result is UNKNOWN.

IN

in predicate

<in predicate> ::= <列/漕ぐ/騒動 value predicand> [ NOT ] IN <in predicate value>

<in predicate value> ::= <(米)棚上げする/(英)提議する subquery> | <left paren> <in value 名簿(に載せる)/表(にあげる)> <権利 paren>

| <left paren> UNNEST <left paren> <array value 表現> <権利 paren> <権利 paren>

<in value 名簿(に載せる)/表(にあげる)> ::= <列/漕ぐ/騒動 value 表現> [ { <comma> <列/漕ぐ/騒動 value 表現> }... ]

明示する a quantified comparison. The 表現 X NOT IN Y is 同等(の) to NOT (X IN Y). The ( <in value 名簿(に載せる)/表(にあげる)> ) is 変えるd into a (米)棚上げする/(英)提議する with one or more 列/漕ぐ/騒動s. The 表現 X IN Y is 同等(の) to X = ANY Y, which is a <quantified comparison predicate>.

If the <(米)棚上げする/(英)提議する subquery> returns no 列/漕ぐ/騒動s, the result is FALSE. さもなければ the <列/漕ぐ/騒動 value predicand> is compared one by one with each 列/漕ぐ/騒動 of the <(米)棚上げする/(英)提議する subquery>.

If the comparison is TRUE for at least one 列/漕ぐ/騒動, the result is TRUE. If the comparison is FALSE for all 列/漕ぐ/騒動s, the result is FALSE. さもなければ the result is UNKNOWN.

HyperSQL supports an 拡張 to the SQL 基準 to 許す an array to be used in the <in predicate value>. This is ーするつもりであるd to be used with 用意が出来ている 声明s where a variable length array of values can be used as the parameter value for each call. The example below shows how this is used in SQL. The JDBC code must create a new java.sql.Array 反対する that 含む/封じ込めるs the values and 始める,決める the parameter with this array.

 SELECT * FROM 顧客 WHERE firstname IN ( UNNEST(?) )

 関係 conn;
 PreparedStatement ps;
 // conn and ps are instantiated here
 Array arr = conn.createArrayOf("INTEGER", new Integer[] {1, 2, 3});
 ps.setArray(1, arr);
 ResultSet rs = ps.executeQuery();

LIKE

like predicate

<like predicate> ::= <character like predicate> | <octet like predicate>

<character like predicate> ::= <列/漕ぐ/騒動 value predicand> [ NOT ] LIKE <character pattern> [ ESCAPE <escape character> ]

<character pattern> ::= <character value 表現>

<escape character> ::= <character value 表現>

<octet like predicate> ::= <列/漕ぐ/騒動 value predicand> [ NOT ] LIKE <octet pattern> [ ESCAPE <escape octet> ]

<octet pattern> ::= <binary value 表現>

<escape octet> ::= <binary value 表現>

明示する a pattern-match comparison for character or binary strings. The <列/漕ぐ/騒動 value predicand> is always a <string value 表現> of character or binary type. The <character pattern> or <octet pattern> is a <string value 表現> in which the 強調する and パーセント characters have special meanings. The 強調する means match any one character, while the パーセント means match a sequence of 無 or more characters. The <escape character> or <escape octet> is also a <string value 表現> that 評価するs to a string of 正確に/まさに one character length. If the 強調する or the パーセント is 要求するd as normal characters in the pattern, the 明示するd <escape character> or <escape octet> can be used in the pattern before the 強調する or the パーセント. The <列/漕ぐ/騒動 value predicand> is compared with the <character pattern> and the result of comparison is returned. If any of the 表現s in the predicate 評価するs to NULL, the result of the predicate is UNKNOWN. The 表現 A NOT LIKE B is 同等(の) to NOT (A LIKE B). If the length of the escape is not 1 or it is used in the pattern not すぐに before an 強調する or a パーセント character, an exception is raised.

IS NULL

null predicate

<null predicate> ::= <列/漕ぐ/騒動 value predicand> IS [ NOT ] NULL

明示する a 実験(する) for a null value. The 表現 X IS NOT NULL is NOT 同等(の) to NOT (X IS NULL)if the degree of the <列/漕ぐ/騒動 value predicand> is larger than 1. The 支配するs are: If all fields are null, X IS NULL is TRUE and X IS NOT NULL is FALSE. If only some fields are null, both X IS NULL and X IS NOT NULL are FALSE. If all fields are not null, X IS NULL is FALSE and X IS NOT NULL is TRUE.

ALL and ANY

quantified comparison predicate

<quantified comparison predicate> ::= <列/漕ぐ/騒動 value predicand> <comp op> <quantifier> <(米)棚上げする/(英)提議する subquery>

<quantifier> ::= <all> | <some>

<all> ::= ALL

<some> ::= SOME | ANY

明示する a quantified comparison. For a quantified comparison, the <列/漕ぐ/騒動 value predicand> is compared one by one with each 列/漕ぐ/騒動 of the <(米)棚上げする/(英)提議する sub query>.

If the <(米)棚上げする/(英)提議する subquery> returns no 列/漕ぐ/騒動s, then if ALL is 明示するd the result is TRUE, but if SOME or ANY is 明示するd the result is FALSE.

If ALL is 明示するd, if the comparison is TRUE for all 列/漕ぐ/騒動s, the result of the predicate is TRUE. If the comparison is FALSE for at least one 列/漕ぐ/騒動, the result is FALSE. さもなければ the result is UNKNOWN.

If SOME or ANY is 明示するd, if the comparison is TRUE for at least one 列/漕ぐ/騒動, the result is TRUE. If the comparison is FALSE for all 列/漕ぐ/騒動s, the result is FALSE. さもなければ the result is UNKNOWN. 公式文書,認める that the IN predicate is 同等(の) to the SOME or ANY predicate using the <equals 操作者>.

In the examples below, the date of an invoice is compared to holidays in a given year. In the first example the invoice date must equal one of the holidays, in the second example it must be later than all holidays (later than the last holiday), in the third example it must be on or after some holiday (on or after the first holiday), and in the fourth example, it must be before all holidays (before the first holiday).

 invoice_date = SOME (SELECT holiday_date FROM holidays)
 invoice_date > ALL (SELECT holiday_date FROM holidays)
 invoice_date >= ANY (SELECT holiday_date FROM holidays)
 invoice_date < ALL (SELECT holiday_date FROM holidays)

EXISTS

存在するs predicate

<存在するs predicate> ::= EXISTS <(米)棚上げする/(英)提議する subquery>

明示する a 実験(する) for a 非,不,無-empty 始める,決める. If the evaluation of <(米)棚上げする/(英)提議する subquery> results in one or more 列/漕ぐ/騒動s, then the 表現 is TRUE, さもなければ FALSE.

UNIQUE

unique predicate

<unique predicate> ::= UNIQUE <(米)棚上げする/(英)提議する subquery>

明示する a 実験(する) for the absence of duplicate 列/漕ぐ/騒動s. The result of the 実験(する) is either TRUE or FALSE (never UNKNOWN). The 列/漕ぐ/騒動s of the <(米)棚上げする/(英)提議する subquery> that 含む/封じ込める one or more NULL values are not considered for this 実験(する). If the 残り/休憩(する) of the 列/漕ぐ/騒動s are 際立った from each other, the result of the 実験(する) is TRUE, さもなければ it is FALSE. The distinctness of 列/漕ぐ/騒動s X and Y is 実験(する)d with the predicate X IS DISTINCT FROM Y.

MATCH

match predicate

<match predicate> ::= <列/漕ぐ/騒動 value predicand> MATCH [ UNIQUE ] [ SIMPLE | PARTIAL | FULL ] <(米)棚上げする/(英)提議する subquery>

明示する a 実験(する) for matching 列/漕ぐ/騒動s. The default is MATCH SIMPLE without UNIQUE. The result of the 実験(する) is either TRUE or FALSE (never UNKNOWN).

The 解釈/通訳 of NULL values is different from other predicates and やめる 反対する-intuitive. If the <列/漕ぐ/騒動 value predicand> is NULL, or all of its fields are NULL, the result is TRUE.

さもなければ, the <列/漕ぐ/騒動 value predicand> is compared with each 列/漕ぐ/騒動 of the <(米)棚上げする/(英)提議する subquery>.

If SIMPLE is 明示するd, if some field of <列/漕ぐ/騒動 value predicate> is NULL, the result is TRUE. さもなければ if <列/漕ぐ/騒動 value predicate> is equal to one or more 列/漕ぐ/騒動s of <(米)棚上げする/(英)提議する subquery> the result is TRUE if UNIQUE is not 明示するd, or if UNIQUE is 明示するd and only one 列/漕ぐ/騒動 matches. さもなければ the result is FALSE.

If PARTIAL is 明示するd, if the 非,不,無-null values <列/漕ぐ/騒動 value predicate> are equal to those in one or more 列/漕ぐ/騒動s of <(米)棚上げする/(英)提議する subquery> the result is TRUE if UNIQUE is not 明示するd, or if UNIQUE is 明示するd and only one 列/漕ぐ/騒動 matches. さもなければ the result is FALSE.

If FULL is 明示するd, if some field of <列/漕ぐ/騒動 value predicate> is NULL, the result is FALSE. さもなければ if <列/漕ぐ/騒動 value predicate> is equal to one or more 列/漕ぐ/騒動s of <(米)棚上げする/(英)提議する subquery> the result is TRUE if UNIQUE is not 明示するd, or if UNIQUE is 明示するd and only one 列/漕ぐ/騒動 matches.

公式文書,認める that MATCH can also be used in FOREIGN KEY 強制 鮮明度/定義s. The exact meaning is 述べるd in the Schemas and Database 反対するs 一時期/支部.

CONTAINS

含む/封じ込めるs predicate

<含む/封じ込めるs predicate> ::= PERIOD <列/漕ぐ/騒動 value predicand> CONTAINS PERIOD <列/漕ぐ/騒動 value predicand>

明示する a 実験(する) for two datetime periods. Each <列/漕ぐ/騒動 value predicand> must have two fields and the fields together 代表する a datetime period. So the predicates is always in the form PERIOD (X1, X2) CONTAINS PERIOD (Y1, Y2). Fields in each period are always a datetime value of the same type (DATE or TIMESTAMP).

All datetime values are 変えるd to TIMESTAMP WITH TIME ZONE. The second datetime value must be after the first, さもなければ a data error is returned.

If the second period is fully within the first period, the result is TRUE. さもなければ it is 誤った.

If any of the values is NULL, the result is UNDEFINED.

EQUALS

equals predicate

<equals predicate> ::= PERIOD <列/漕ぐ/騒動 value predicand> EQUALS PERIOD <列/漕ぐ/騒動 value predicand>

明示する a 実験(する) for two datetime periods. The 転換s and checks are 適用するd the same way as with the CONTAINS predicate. If the two periods have the same begin and end datetime values the result is TRUE. さもなければ it is 誤った.

If any of the values is NULL, the result is UNDEFINED.

IS DISTINCT

is 際立った predicate

<際立った predicate> ::= <列/漕ぐ/騒動 value predicand> IS [ NOT ] DISTINCT FROM <列/漕ぐ/騒動 value predicand>

明示する a 実験(する) of whether two 列/漕ぐ/騒動 values are 際立った. The result of the 実験(する) is either TRUE or FALSE (never UNKNOWN). The degree the two <列/漕ぐ/騒動 value predicand> must be the same. Each field of the first <列/漕ぐ/騒動 value predicand> is compared to the field of the second <列/漕ぐ/騒動 value predicand> at the same position. If one field is NULL and the other is not NULL, or if the elements are NOT equal, then the result of the 表現 is TRUE. If no comparison result is TRUE, then the result of the predicate is FALSE. The 表現 X IS NOT DISTINCT FROM Y is 同等(の) to NOT (X IS DISTINCT FORM Y). The に引き続いて check returns true if startdate is not equal to enddate. It also returns true if either startdate or enddate is NULL. It returns 誤った in other 事例/患者s.

 startdate IS DISTINCT FROM enddate

OVERLAPS

overlaps predicate

<overlaps predicate> ::= <列/漕ぐ/騒動 value predicand> OVERLAPS <列/漕ぐ/騒動 value predicand>

<overlaps predicate> ::= PERIOD <列/漕ぐ/騒動 value predicand> OVERLAPS PERIOD <列/漕ぐ/騒動 value predicand>

The OVERLAPS predicate 実験(する)s for an overlap between two datetime periods. This predicate has two forms. The one without the PERIOD keywords is more relaxed ーに関して/ーの点でs of valid periods.

If there is there is any overlap between the two datetime periods, the result is TRUE. さもなければ it is 誤った.

If any of the values is NULL, the result is UNDEFINED.

In the example below, the period is compared with a week long period ending yesterday.

 (startdate, enddate) OVERLAPS (CURRENT_DATE - 7 DAY, CURRENT_DATE - 1 DAY)

PRECEDES

に先行するs predicate

<に先行するs predicate> ::= PERIOD <列/漕ぐ/騒動 value predicand> [ IMMEDIATELY] PRECEDES PERIOD <列/漕ぐ/騒動 value predicand>

明示する a 実験(する) for two datetime periods. The 転換s and checks are 適用するd the same way as with the CONTAINS predicate. If the second period begins after the end of the first period, the result is TRUE. さもなければ it is 誤った.

If IMMEDIATELY is 明示するd, the second period must follow すぐに after the end of the first period. This means the end of the first period is the same point of time as the start of the second period.

If any of the values is NULL, the result is UNDEFINED.

SUCCEEDS

後継するs predicate

<後継するs predicate> ::= PERIOD <列/漕ぐ/騒動 value predicand> [ IMMEDIATELY ] SUCCEEDS PEDIOD <列/漕ぐ/騒動 value predicand>

明示する a 実験(する) for two datetime periods with 類似の syntax to PRECEDES. If the first period begins after the end of the second period, the result is TRUE. さもなければ it is 誤った.

If IMMEDIATELY is 明示するd, the first period must follow すぐに after the end of the second period.

If any of the values is NULL, the result is UNKNOWN.

The example below shows a predicate that returns TRUE.

PERIOD (CURRENT_DATE - 7 DAY, CURRENT_DATE) IMMEDIATELY PRECEDES (CURRENT_DATE, CURRENT_DATE + 7 DAY)

Aggregate 機能(する)/行事s

aggregate 機能(する)/行事

aggregate 機能(する)/行事

<aggregate 機能(する)/行事> ::= COUNT <left paren> <asterisk> <権利 paren> [ <filter 条項> ] | <general 始める,決める 機能(する)/行事> [ <filter 条項> ] | <array aggregate 機能(する)/行事> [ <filter 条項> ]

<general 始める,決める 機能(する)/行事> ::= <始める,決める 機能(する)/行事 type> <left paren> [ <始める,決める quantifier> ] <value 表現> <権利 paren>

<始める,決める 機能(する)/行事 type> ::= <computational 操作/手術>

<computational 操作/手術> ::= AVG | MAX | MIN | ANY_VALUE | SUM | EVERY | ANY | SOME | COUNT | STDDEV_POP | STDDEV_SAMP | VAR_SAMP | VAR_POP | MEDIAN

<始める,決める quantifier> ::= DISTINCT | ALL

<filter 条項> ::= FILTER <left paren> WHERE <search 条件> <権利 paren>

<array aggregate 機能(する)/行事> ::= ARRAY_AGG <left paren> [ <始める,決める quantifier> ] <value 表現> [ <order by 条項> ] <権利 paren>

<listagg 始める,決める 機能(する)/行事> ::= LISTAGG <left paren> [ <始める,決める quantifier> ] <value 表現> <comma> <separator> [ <fetch first 条項> ] [ <listagg 洪水 条項> ] <権利 paren> <within group specification>

<listagg 洪水 条項> ::= ON OVERFLOW <洪水 行為>

<洪水 行為> ::= ERROR | TRUNCATE [ <listagg truncation filler> ] [ <listagg count 指示,表示する物> ]

<listagg truncation filler> ::= <character string literal>

<listagg count 指示,表示する物> ::= WITH COUNT | WITHOUT COUNT

<group concat 機能(する)/行事> ::= GROUP_CONCAT <left paren> [ <始める,決める quantifier> ] <value 表現> [ <order by 条項> ] [ SEPARATOR <separator> ] <権利 paren>

<string agg 機能(する)/行事> ::= STRING_AGG <left paren> [ <始める,決める quantifier> ] <value 表現> [ <order by 条項> ] [ <comma> <separator> ] <権利 paren> [ <within group specification> ]

<separator> ::= <character string literal>

<within group specification> ::= WITHIN GROUP <left paren> ORDER BY <sort specification 名簿(に載せる)/表(にあげる)> <権利 paren>

明示する a value 計算するd from a collection of 列/漕ぐ/騒動s.

An aggregate 機能(する)/行事 is used 排他的に in a <query specification> and its use transforms a normal query into an aggregate query returning a 選び出す/独身 列/漕ぐ/騒動 instead of the 多重の 列/漕ぐ/騒動s that the 初めの query returns. For example, SELECT acolumn <(米)棚上げする/(英)提議する 表現> is a query that returns the value of acolumn for all the 列/漕ぐ/騒動s the 満足させる the given 条件. But SELECT MAX(acolumn) <(米)棚上げする/(英)提議する 表現> returns only one 列/漕ぐ/騒動, 含む/封じ込めるing the largest value in that column. The query SELECT COUNT(*) <(米)棚上げする/(英)提議する 表現> returns the count of 列/漕ぐ/騒動s, while SELECT COUNT(acolumn) <(米)棚上げする/(英)提議する 表現> returns the count of 列/漕ぐ/騒動s where acolumn IS NOT NULL.

If the <(米)棚上げする/(英)提議する 表現> is a grouped (米)棚上げする/(英)提議する (has a GROUP BY 条項), the aggregate 機能(する)/行事 returns the result of the COUNT or <computational 操作/手術> for each group. In this 事例/患者 the result has the same number of 列/漕ぐ/騒動s as the 初めの grouped query. For example, SELECT SUM(acolumn) <(米)棚上げする/(英)提議する 表現> when <(米)棚上げする/(英)提議する 表現> has a GROUP BY 条項, returns the sum of values for acolumn in each group.

If all values are NULL, the aggregate 機能(する)/行事 (except COUNT) returns NULL.

The SUM 操作/手術s can be 成し遂げるd on numeric and interval 表現s only. AVG and MEDIAN can be 成し遂げるd on numeric, interval or datetime 表現s. AVG returns the 普通の/平均(する) value, while SUM returns the sum of all values. MEDIAN returns the middle value in the sorted 名簿(に載せる)/表(にあげる) of values.

MAX and MIN can be 成し遂げるd on all types of 表現s and return the 最小限 or the 最大限 value.

ANY_VALUE returns a value from a 選び出す/独身 列/漕ぐ/騒動 of the 初めの query. The filter 条件 can be used to 限界 the 適格の values.

COUNT(*) returns the count of all values, 含むing nulls, while COUNT(<value 表現>) returns the count of 非,不,無-NULL values. COUNT with DISTINCT also 受託するs 多重の arguments. In this usage the 際立った combinations of the arguments are counted. Examples below:

 SELECT COUNT(DISTINCT firstname, lastname) FROM 顧客
 SELECT COUNT(DISTINCT (firstname, lastname)) FROM 顧客

The EVERY, ANY and SOME 操作/手術s can be 成し遂げるd on boolean 表現s only. EVERY returns TRUE if all the values are TRUE, さもなければ FALSE. ANY and SOME are the same 操作/手術 and return TRUE if one of the values is TRUE, さもなければ it returns FALSE.

The other 操作/手術s 成し遂げる the 統計に基づく 機能(する)/行事s STDDEV_POP, STDDEV_SAMP, VAR_SAMP, VAR_POP on numeric values. NULL values are ignored in 計算/見積りs.

使用者-defined aggregate 機能(する)/行事s can be defined and used instead of the built-in aggregate 機能(する)/行事s. Syntax and examples are given in the SQL-Invoked 決まりきった仕事s 一時期/支部.

The <filter 条項> 許すs you to 追加する a search 条件. When the search 条件 評価するs to TRUE for a 列/漕ぐ/騒動, the 列/漕ぐ/騒動 is 含むd in aggregation. さもなければ the 列/漕ぐ/騒動 is not 含むd. In the example below a 選び出す/独身 query returns two different filtered counts:

 SELECT COUNT(ITEM) FILTER (WHERE GENDER = 'F') AS "FEMALE COUNT", COUNT(ITEM) FILTER (WHERE GENDER = 'M') AS "MALE COUNT" FROM PEOPLE

ARRAY_AGG is different from all other aggregate 機能(する)/行事s as it does not ignore the NULL values. This 始める,決める 機能(する)/行事 returns an array that 含む/封じ込めるs all the values, for different 列/漕ぐ/騒動s, of the <value 表現>. For example, if the <value 表現> is a column 言及/関連, the SUM 機能(する)/行事 追加するs the values for all the 列/漕ぐ/騒動 together, while the ARRAY_AGG 機能(する)/行事 追加するs the value for each 列/漕ぐ/騒動 as a separate element of the array. ARRAY_AGG can 含む an optional <order by 条項> which can 言及/関連 all the 利用できる columns of the query, not just the <value 表現> that is used as the ARRAY_AGG argument. The <order by 条項> can have 多重の elements (columns) and each element can 含む NULLS LAST or DESC qualifiers. The elements of the returned array are sorted によれば the <order by 条項>,

LISTAGG, GROUP_CONCAT and STRING_AGG are 同等(の) specialised 機能(する)/行事s derived from ARRAY_AGG. These 機能(する)/行事s 計算する the array in the same way as ARRAY_AGG, 除去する all the NULL elements, then return a string that is a concatenation of the elements of the array. If <separator> has been 明示するd, it is used to separate the elements of the array, さもなければ the comma is used to separate the elements.

LISTAGG is an SQL:2023 機能(する)/行事 and more 柔軟な than the other two 機能(する)/行事s. HyperSQL 延長するs the 基準 syntax by 許すing an optional <fetch first 条項> to 限界 the number of elements. The <within group specification> 決定するs the sort order. The optional <listagg 洪水 条項> 許すs an error to be returned or truncates the returned string. The optional <listagg truncation filler> is appended to a truncated result. The optional <listagg count 指示,表示する物> can 明示する that the count of truncated elements is appended to a truncated result.

The example below shows a grouped query with LISTAGG, ARRAY_AGG and GROUP_CONCAT. The CUSTOMER (米)棚上げする/(英)提議する that is 含むd in the DatabaseManagerSwing GUI app is the source of the data.

 SELECT LASTNAME, ARRAY_AGG(FIRSTNAME ORDER BY FIRSTNAME) FROM 顧客 GROUP BY LASTNAME

 LASTNAME  C2                                                         
 --------- ---------------------------------------------------------- 
 Steel     ARRAY['John','John','Laura','Robert']                      
 King      ARRAY['George','George','James','Julia','Robert','Robert'] 
 Sommer    ARRAY['Janet','Robert']                                    

 SELECT LASTNAME, LISTAGG(DISTINCT FIRSTNAME, '; ' FETCH 3 ROWS ONLY ON OVERFLOW TRUNCATE WITH COUNT)
    WITHIN GROUP (ORDER BY FIRSTNAME DESC) FROM 顧客 GROUP BY LASTNAME

 LASTNAME  C2                                                
 --------- ------------------------------------------------- 
 Steel     Robert; Laura; John                   
 King      Robert; Julia; James; ...(1)         
 Sommer    Robert; Janet
 
 SELECT LASTNAME, GROUP_CONCAT(DISTINCT FIRSTNAME ORDER BY FIRSTNAME DESC SEPARATOR ' * ') FROM 顧客  GROUP BY LASTNAME

 LASTNAME  C2                                                
 --------- ------------------------------------------------- 
 Steel     Robert * Laura * John                   
 King      Robert * Julia * James * George         
 Sommer    Robert * Janet

Other Syntax Elements

search 条件

search 条件

<search 条件> ::= <boolean value 表現>

明示する a 条件 that is TRUE, FALSE, or UNKNOWN. A search 条件 is often a predicate.

PATH

path specification

<path specification> ::= PATH <schema 指名する 名簿(に載せる)/表(にあげる)>

<schema 指名する 名簿(に載せる)/表(にあげる)> ::= <schema 指名する> [ { <comma> <schema 指名する> }... ]

明示する an order for searching for a 使用者-defined SQL-invoked 決まりきった仕事. This is not 現在/一般に supported by HyperSQL.

決まりきった仕事 invocation

決まりきった仕事 invocation

<決まりきった仕事 invocation> ::= <決まりきった仕事 指名する> <SQL argument 名簿(に載せる)/表(にあげる)>

<決まりきった仕事 指名する> ::= [ <schema 指名する> <period> ] <qualified identifier>

<SQL argument 名簿(に載せる)/表(にあげる)> ::= <left paren> [ <SQL argument> [ { <comma> <SQL argument> }... ] ] <権利 paren>

<SQL argument> ::= <value 表現> | <的 specification>

Invoke an SQL-invoked 決まりきった仕事. Examples are given in the SQL-Invoked 決まりきった仕事s 一時期/支部.

COLLATE

collate 条項

<collate 条項> ::= COLLATE <collation 指名する>

明示する a collation for a column or for an ORDER BY 表現. This collation is used for comparing the values of the column in different 列/漕ぐ/騒動s. Comparison can happen during the 死刑執行 of SELECT, UPDATE or DELETE 声明s, when a UNIQUE 強制 or 索引 is defined on the column, or when the 列/漕ぐ/騒動s are sorted by an ORDER BY 条項.

CONSTRAINT

強制 指名する 鮮明度/定義

<強制 指名する 鮮明度/定義> ::= CONSTRAINT <強制 指名する>

<強制 特徴> ::= <強制 check time> [ [ NOT ] DEFERRABLE ] | [ NOT ] DEFERRABLE [ <強制 check time> ]

<強制 check time> ::= INITIALLY DEFERRED | INITIALLY IMMEDIATE

明示する the 指名する of a 強制 and its 特徴. The deferrable characteristic is an optional element of CONSTRAINT 鮮明度/定義, not yet supported by HyperSQL.

Data 接近 声明s

HyperSQL fully supports all of SQL-92 data 接近 声明s, 加える most of the 新規加入s from SQL:2011. 予定 to time 強制s, the 現在の 見解/翻訳/版 of this Guide does not cover the 支配する fully. You are advised to 協議する an SQL 調書をとる/予約する such as the O'Reilly 肩書を与える, "SQL and Relational Theory" by C. J. Date.

Database queries are data 接近 声明s. The most 一般的に used data 接近 声明 is the SELECT 声明, but there are other 声明s that 成し遂げる a 類似の 役割. Data 接近 声明s 接近 (米)棚上げする/(英)提議するs and return result (米)棚上げする/(英)提議するs. The returned result (米)棚上げする/(英)提議するs are 誤って called result 始める,決めるs, as they are not やむを得ず 始める,決めるs of 列/漕ぐ/騒動s, but multisets of 列/漕ぐ/騒動s.

Result (米)棚上げする/(英)提議するs are formed by 成し遂げるing the に引き続いて 操作/手術s on base (米)棚上げする/(英)提議するs and 見解(をとる)s. These 操作/手術s are loosely based on Relational Algebra.

JOIN 操作/手術s

SET and MULTISET 操作/手術s

SELECTION

PROJECTION

COMPUTING

COLUMN NAMING

GROUPING and AGGREGATION

SELECTION AFTER GROUPING OR AGGREGATION

SET and MULTISET (COLLECTION) OPERATIONS

ORDERING

SLICING

Conceptually, the 操作/手術s are 成し遂げるd one by one in the above order if they 適用する to the given data 接近 声明. In the example below a simple select 声明 is made more コンビナート/複合体 by 追加するing さまざまな 操作/手術s.

 CREATE TABLE atable (a INT, b INT, c INT, d INT, e INT, f INT);
 /* in the next SELECT, no join is 成し遂げるd and no その上の 操作/手術 takes place */
 SELECT * FROM atable
 /* in the next SELECT, 選択 is 成し遂げるd by the WHERE 条項, with no その上の 活動/戦闘 */
 SELECT * FROM atable WHERE a + b = c
 /* in the next SELECT, 発射/推定 is 成し遂げるd after the other 操作/手術s */
 SELECT d, e, f FROM atable WHERE a + b = c
 /* in the next SELECT, computation is 成し遂げるd after 発射/推定 */
 SELECT (d + e) / f FROM atable WHERE a + b = c
 /* in the next two SELECT 声明s, column 指名するing is 成し遂げるd in different ways*/
 SELECT (a + e) / f AS calc, f AS div FROM atable WHERE a + b = c
 SELECT dcol, ecol, fcol FROM atable(acol, bcol, ccol, dcol, ecol, fcol) WHERE acol + bcol = ccol
 /* in the next SELECT, both 配合 and aggregation is 成し遂げるd */
 SELECT d, e, SUM(f) FROM atable GROUP BY d, e
 /* in the next SELECT, 選択 is 成し遂げるd after 配合 and aggregation is 成し遂げるd */
 SELECT d, e, SUM(f) FROM atable GROUP BY d, e HAVING SUM(f) > 10
 /* in the next SELECT, a UNION is 成し遂げるd on two selects from the same (米)棚上げする/(英)提議する */
 SELECT d, e, f FROM atable WHERE d = 3 UNION SELECT a, b, c FROM atable WHERE a = 30
 /* in the next SELECT, ordering is 成し遂げるd */
 SELECT (a + e) / f AS calc, f AS div FROM atable WHERE a + b = c ORDER BY calc DESC, div NULLS LAST
 /* in the next SELECT, slicing is 成し遂げるd after ordering */
 SELECT * FROM atable WHERE a + b = c ORDER BY a FETCH 5 ROWS ONLY

The に引き続いて sections discuss さまざまな types of (米)棚上げする/(英)提議するs and 操作/手術s 伴う/関わるd in data 接近 声明s.

Select 声明

The SELECT 声明 itself does not cover all types of data 接近 声明s, which may 連合させる 多重の SELECT 声明s. The <query specification> is the most ありふれた data 接近 声明 and begins with the SELECT keyword.

SELECT STATEMENT

select 声明 (general)

使用者s 一般に 言及する to the SELECT 声明 when they mean a <query specification> or <query 表現>. If a 声明 begins with SELECT and has no UNION or other 始める,決める 操作/手術s, then it is a <query specification>. さもなければ it is a <query 表現>.

(米)棚上げする/(英)提議する

In data 接近 声明s, a (米)棚上げする/(英)提議する can be a database (米)棚上げする/(英)提議する (or 見解(をとる)) or an ephemeral (米)棚上げする/(英)提議する formed for the duration of the query. Some types of (米)棚上げする/(英)提議する are <(米)棚上げする/(英)提議する 最初の/主要な> and can 参加する in joins without the use of extra parentheses. The BNF in the (米)棚上げする/(英)提議する 最初の/主要な section below 名簿(に載せる)/表(にあげる)s different types of <(米)棚上げする/(英)提議する 最初の/主要な>:

(米)棚上げする/(英)提議するs can also be formed by 明示するing the values that are 含む/封じ込めるd in them:

<(米)棚上げする/(英)提議する value 建設者> ::= VALUES <列/漕ぐ/騒動 value 表現 名簿(に載せる)/表(にあげる)>

<列/漕ぐ/騒動 value 表現 名簿(に載せる)/表(にあげる)> ::= <(米)棚上げする/(英)提議する 列/漕ぐ/騒動 value 表現> [ { <comma> <(米)棚上げする/(英)提議する 列/漕ぐ/騒動 value 表現> }... ]

In the example below a (米)棚上げする/(英)提議する with two 列/漕ぐ/騒動s and 3 columns is 建設するd out of some values:

 VALUES (12, 14, null), (10, 11, CURRENT_DATE)

When a (米)棚上げする/(英)提議する is used 直接/まっすぐに in a UNION or 類似の 操作/手術, the keyword TABLE is used with the 指名する:

<explicit (米)棚上げする/(英)提議する> ::= TABLE <(米)棚上げする/(英)提議する or query 指名する>

In the examples below, all 列/漕ぐ/騒動s of the two (米)棚上げする/(英)提議するs are 含むd in the union. The keyword TABLE is used in the first example. The two examples below are 同等(の).

 TABLE atable UNION TABLE anothertable
 SELECT * FROM atable UNION SELECT * FROM anothertable

Subquery

A subquery is 簡単に a query 表現 in brackets. A query 表現 is usually a 完全にする SELECT 声明 and is discussed in the 残り/休憩(する) of this 一時期/支部. A scalar subquery returns one 列/漕ぐ/騒動 with one column. A 列/漕ぐ/騒動 subquery returns one 列/漕ぐ/騒動 with one or more columns. A (米)棚上げする/(英)提議する subquery returns 無 or more 列/漕ぐ/騒動s with one or more columns. The distinction between different forms of subquery is syntactic. Different forms are 許すd in different 状況s. If a scalar subquery or a 列/漕ぐ/騒動 subquery return more than one 列/漕ぐ/騒動, an exception is raised. If a scalar or 列/漕ぐ/騒動 subquery returns no 列/漕ぐ/騒動, it is usually 扱う/治療するd as returning a NULL. Depending on the 状況, this has different consequences.

<scalar subquery> ::= <subquery>

<列/漕ぐ/騒動 subquery> ::= <subquery>

<(米)棚上げする/(英)提議する subquery> ::= <subquery>

<subquery> ::= <left paren> <query 表現> <権利 paren>

Query Specification

A query specification is also known as a SELECT 声明. It is the most ありふれた form of <derived (米)棚上げする/(英)提議する> . A <(米)棚上げする/(英)提議する 表現> is a base (米)棚上げする/(英)提議する, a 見解(をとる) or any form of 許すd derived (米)棚上げする/(英)提議する. The SELECT 声明 成し遂げるs 発射/推定, 指名するing, 計算するing, or aggregation on the 列/漕ぐ/騒動s of the <(米)棚上げする/(英)提議する 表現> .

<query specification> ::= SELECT [ DISTINCT | ALL ] <select 名簿(に載せる)/表(にあげる)> <(米)棚上げする/(英)提議する 表現>

<select 名簿(に載せる)/表(にあげる)> ::= <asterisk> | <select sublist> [ { <comma> <select sublist> }... ]

<select sublist> ::= <derived column> | <qualified asterisk>

<qualified asterisk> ::= <asterisked identifier chain> <period> <asterisk>

<asterisked identifier chain> ::= <asterisked identifier> [ { <period> <asterisked identifier> }... ]

<asterisked identifier> ::= <identifier>

<derived column> ::= <value 表現> [ <as 条項> ]

<as 条項> ::= [ AS ] <column 指名する>

The qualifier DISTINCT or ALL 適用する to the results of the SELECT 声明 after all other 操作/手術s have been 成し遂げるd. ALL 簡単に returns the 列/漕ぐ/騒動s, while DISTINCT compares the 列/漕ぐ/騒動s and 除去するs the duplicate ones.

発射/推定 is 成し遂げるd by the <select 名簿(に載せる)/表(にあげる)>.

A 選び出す/独身 <asterisk> means all columns of the <(米)棚上げする/(英)提議する 表現> are 含むd, in the same order as they appear in the <(米)棚上げする/(英)提議する 表現>. An asterisk qualified by a (米)棚上げする/(英)提議する 指名する means all the columns of the qualifier (米)棚上げする/(英)提議する 指名する are 含むd. If an unqualified asterisk is used, then no other items are 許すd in the <select 名簿(に載せる)/表(にあげる)>. When the <(米)棚上げする/(英)提議する 表現> is the direct result of NATURAL or USING joins, the use of <asterisk> 含むs the columns used for the join before the other columns. A qualified asterisk does not cover the join columns.

A derived column is a <value 表現>, optionally 指名するd with the <as 条項>. A <value 表現> can be many things. ありふれた types 含む: the 指名する of a column in the <(米)棚上げする/(英)提議する 表現>; an 表現 based on different columns or constant values; a 機能(する)/行事 call; an aggregate 機能(する)/行事; a CASE WHEN 表現.

(米)棚上げする/(英)提議する 表現

A (米)棚上げする/(英)提議する 表現 is part of the SELECT 声明 and consists of the FROM 条項 with optional other 条項s that 成し遂げるs 選択 (of 列/漕ぐ/騒動s) and 配合 from the (米)棚上げする/(英)提議する(s) in the FROM 条項.

<(米)棚上げする/(英)提議する 表現> ::= <from 条項> [ <where 条項> ] [ <group by 条項> ] [ <having 条項> ]

<from 条項> ::= FROM <(米)棚上げする/(英)提議する 言及/関連> [ { <comma> <(米)棚上げする/(英)提議する 言及/関連> }... ]

<(米)棚上げする/(英)提議する 言及/関連> ::= <(米)棚上げする/(英)提議する 最初の/主要な> | <joined (米)棚上げする/(英)提議する>

<(米)棚上げする/(英)提議する 最初の/主要な> ::= <(米)棚上げする/(英)提議する or query 指名する> [ <query system time period specification> ] [ [ AS ] <correlation 指名する> [ <left paren> <derived column 名簿(に載せる)/表(にあげる)> <権利 paren> ] ]

| <derived (米)棚上げする/(英)提議する> [ AS ] <correlation 指名する> [ <left paren> <derived column 名簿(に載せる)/表(にあげる)> <権利 paren> ]

| <lateral derived (米)棚上げする/(英)提議する> [ AS ] <correlation 指名する> [ <left paren> <derived column 名簿(に載せる)/表(にあげる)> <権利 paren> ]

| <collection derived (米)棚上げする/(英)提議する> [ AS ] <correlation 指名する> [ <left paren> <derived column 名簿(に載せる)/表(にあげる)> <権利 paren> ]

| <(米)棚上げする/(英)提議する 機能(する)/行事 derived (米)棚上げする/(英)提議する> [ AS ] <correlation 指名する> [ <left paren> <derived column 名簿(に載せる)/表(にあげる)> <権利 paren> ]

| <parenthesized joined (米)棚上げする/(英)提議する> [ AS ] <correlation 指名する> [ <left paren> <derived column 名簿(に載せる)/表(にあげる)> <権利 paren> ]

<where 条項> ::= WHERE <boolean value 表現>

<group by 条項> ::= GROUP BY [ <始める,決める quantifier> ] <配合 element> [ { <comma> <配合 element> }... ]

<having 条項> ::= HAVING <boolean value 表現>

<query system time period specification> ::= FOR SYSTEM_TIME AS OF <point in time 1>

| FOR SYSTEM_TIME BETWEEN [ SYMMETRIC ] <point in time 1> AND <point in time 2>

| FOR SYSTEM_TIME FROM <point in time 1> TO <point in time 2>

The <from 条項> 含む/封じ込めるs one or more <(米)棚上げする/(英)提議する 言及/関連> separated by commas. A (米)棚上げする/(英)提議する 言及/関連 is often a (米)棚上げする/(英)提議する or 見解(をとる) 指名する or a joined (米)棚上げする/(英)提議する.

The <where 条項> filters the 列/漕ぐ/騒動s of the (米)棚上げする/(英)提議する in the <from 条項> and 除去するs the 列/漕ぐ/騒動s for which the search 条件 is not TRUE.

(米)棚上げする/(英)提議する 最初の/主要な 言及するs to different forms of (米)棚上げする/(英)提議する 言及/関連 in the FROM 条項.

(米)棚上げする/(英)提議する or Query 指名する

The simplest form of 言及/関連 is 簡単に a 指名する. This is the 指名する of a (米)棚上げする/(英)提議する, a 見解(をとる), a 移行 (米)棚上げする/(英)提議する in a 誘発する/引き起こす 鮮明度/定義, or a query 指名する 明示するd in the WITH 条項 of a query 表現.

<(米)棚上げする/(英)提議する or query 指名する> ::= <(米)棚上げする/(英)提議する 指名する> | <移行 (米)棚上げする/(英)提議する 指名する> | <query 指名する>

System Time Period

The <query system time period specification> can be used after the 指名する of a system-見解/翻訳/版d (米)棚上げする/(英)提議する to query historic data in the (米)棚上げする/(英)提議する. Without this 条項, only the 現在の 列/漕ぐ/騒動s of the (米)棚上げする/(英)提議する are returned and historic 列/漕ぐ/騒動s are ignored. The first example below shows a 名簿(に載せる)/表(にあげる) of 顧客s as of a year ago. The second example also shows any changes made to the email column over the previous year.

SELECT firstname, lastname, email FROM 顧客 FOR SYSTEM_TIME AS OF CURRENT_TIMESTAMP - 1 YEAR

SELECT DISTINCT firstname, lastname, email FROM 顧客 FOR SYSTEM_TIME FROM CURRENT_TIMESTAMP - 2 YEAR TO CURRENT_TIMESTAMP - 1 YEAR

Derived (米)棚上げする/(英)提議する

derived (米)棚上げする/(英)提議する

A query 表現 that is enclosed in parentheses and returns from 無 to many 列/漕ぐ/騒動s is a <(米)棚上げする/(英)提議する subquery>. In a <derived (米)棚上げする/(英)提議する> the query 表現 is self 含む/封じ込めるd and cannot 言及/関連 the columns of other (米)棚上げする/(英)提議する 言及/関連s. This is the 伝統的な and most ありふれた form of use of a <(米)棚上げする/(英)提議する subquery>.

<derived (米)棚上げする/(英)提議する> ::= <(米)棚上げする/(英)提議する subquery>

Lateral

LATERAL

When the word LATERAL is used before a <(米)棚上げする/(英)提議する subquery>, it means the query 表現 can 言及/関連 the columns of other (米)棚上げする/(英)提議する 言及/関連s that go before it.

<lateral derived (米)棚上げする/(英)提議する> ::= LATERAL <(米)棚上げする/(英)提議する subquery>

The use of <lateral derived (米)棚上げする/(英)提議する> 完全に transforms the way a query is written. For example, the two queries below are 同等(の), but with different forms. The query with LATERAL is 評価するd 分かれて for each 列/漕ぐ/騒動 of the first (米)棚上げする/(英)提議する that 満足させるs the WHERE 条件. The example below uses the (米)棚上げする/(英)提議するs that are created and 居住させるd in DatabaseManagerSwing with the "挿入する 実験(する) data" menu 選択. The first query uses a scalar subquery to 計算する the sum of invoice values for each 顧客. The second query is 同等(の) and uses a join with a LATERAL (米)棚上げする/(英)提議する.

SELECT firstname, lastname, (SELECT SUM(total) FROM invoice WHERE customerid = 顧客.id) s FROM 顧客

SELECT firstname, lastname, a.c FROM 顧客, LATERAL(SELECT SUM(total) FROM invoice WHERE customerid = 顧客.id) a (c)

UNNEST

UNNEST

UNNEST is 類似の to LATERAL, but instead of a query 表現, one or more 表現s that return an array are used. These 表現s are 変えるd into a (米)棚上げする/(英)提議する which has one column for each 表現 and 含む/封じ込めるs the elements of the array. If WITH ORDINALITY is used, an extra column that 含む/封じ込めるs the 索引 of each element is 追加するd to this (米)棚上げする/(英)提議する. The number of 列/漕ぐ/騒動s in the (米)棚上げする/(英)提議する equals the length of the largest arrays. The smaller arrays are padded with NULL values. If an <array value 表現> 評価するs to NULL, an empty array is used in its place. The array 表現 can 含む/封じ込める 言及/関連s to any column of the (米)棚上げする/(英)提議する 言及/関連s 先行する the 現在の (米)棚上げする/(英)提議する 言及/関連.

<collection derived (米)棚上げする/(英)提議する> ::= UNNEST <left paren> <array value 表現>, ... <権利 paren> [ WITH ORDINALITY ]

The <array value 表現> can be the result of a 機能(する)/行事 call. If the arguments of the 機能(する)/行事 call are values from the (米)棚上げする/(英)提議するs on the left of the UNNEST, then the 機能(する)/行事 is called for each 列/漕ぐ/騒動 of (米)棚上げする/(英)提議する.

In the first example below, UNNEST is used with the built in-機能(する)/行事 SEQUENCE_ARRAY to build a (米)棚上げする/(英)提議する 含む/封じ込めるing dates for the last seven days and their ordinal position. In the second example, a select 声明 returns costs for the last seven days . In the third example, the WITH 条項 turns the two selects into 指名するd subqueries which are used in a SELECT 声明 that uses a LEFT join.

 SELECT * FROM UNNEST(SEQUENCE_ARRAY(CURRENT_DATE - 7 DAY, CURRENT_DATE - 1 DAY, 1 DAY)) WITH ORDINALITY AS T(D, I)  

 D          I 
 ---------- - 
 2010-07-25 1 
 2010-07-26 2 
 2010-07-27 3 
 2010-07-28 4 
 2010-07-29 5 
 2010-07-30 6 
 2010-07-31 7 

 CREATE TABLE expenses (item_date DATE, cost DECIMAL(8,2))
 --
 SELECT item_date, SUM(cost) AS total FROM expenses WHERE item_date >= CURRENT_DATE - 7 DAY GROUP BY item_date

 ITEM_DATE  TOTAL      
 ---------- ------ 
 2010-07-27 100.12 
 2010-07-29 50.45  

 WITH costs(item_date, total) AS (SELECT item_date, SUM(cost) FROM expenses WHERE item_date >= CURRENT_DATE - 7 DAY GROUP BY item_date),
 dates(d, i) AS (SELECT * FROM UNNEST(SEQUENCE_ARRAY(CURRENT_DATE - 7 DAY, CURRENT_DATE - 1 DAY, 1 DAY)) WITH ORDINALITY)   
 SELECT i, d, total FROM dates LEFT OUTER JOIN costs ON dates.d = costs.item_date

 I D          TOTAL      
 - ---------- ------ 
 1 2010-07-25 (null) 
 2 2010-07-26 (null) 
 3 2010-07-27 100.12 
 4 2010-07-28 (null) 
 5 2010-07-29 50.45  
 6 2010-07-30 (null) 
 7 2010-07-31 (null) 

(米)棚上げする/(英)提議する 機能(する)/行事 Derived (米)棚上げする/(英)提議する

(米)棚上げする/(英)提議する 機能(する)/行事 Derived (米)棚上げする/(英)提議する

When TABLE is used in this 状況, the <collection value 表現> must be the result of a 機能(する)/行事 call to a built-in 機能(する)/行事 or 使用者-defined 機能(する)/行事 that returns an array or a (米)棚上げする/(英)提議する. When the 機能(する)/行事 returns an array, this array is 変えるd into a (米)棚上げする/(英)提議する, 類似の to the way UNNEST operates. When the 機能(する)/行事 returns a (米)棚上げする/(英)提議する, the result is a MULTISET and is used as is.

<(米)棚上げする/(英)提議する 機能(する)/行事 derived (米)棚上げする/(英)提議する> ::= TABLE <left paren> <collection value 表現> <権利 paren>

Parenthesized Joined (米)棚上げする/(英)提議する

A parenthesized joined (米)棚上げする/(英)提議する is 簡単に a joined (米)棚上げする/(英)提議する 含む/封じ込めるd in parentheses. Joined (米)棚上げする/(英)提議するs are discussed below.

<parenthesized joined (米)棚上げする/(英)提議する> ::= <left paren> <parenthesized joined (米)棚上げする/(英)提議する> <権利 paren> | <left paren> <joined (米)棚上げする/(英)提議する> <権利 paren>

Column 指名する 名簿(に載せる)/表(にあげる)

column 指名する 名簿(に載せる)/表(にあげる)

The column 名簿(に載せる)/表(にあげる) that is 明示するd for the (米)棚上げする/(英)提議する 言及/関連 must 含む/封じ込める 指名するs that are unique within the 名簿(に載せる)/表(にあげる)

<derived column 名簿(に載せる)/表(にあげる)> ::= <column 指名する 名簿(に載せる)/表(にあげる)>

<column 指名する 名簿(に載せる)/表(にあげる)> ::= <column 指名する> [ { <comma> <column 指名する> }... ]

Joined (米)棚上げする/(英)提議する

Joins are 操作者s with two (米)棚上げする/(英)提議する as the operands, resulting in a third (米)棚上げする/(英)提議する, called joined (米)棚上げする/(英)提議する. All join 操作者s are 評価するd left to 権利, therefore, with 多重の joins, the (米)棚上げする/(英)提議する resulting from the first join 操作者 becomes an operand of the next join 操作者. Parentheses can be used to group sequences of joined (米)棚上げする/(英)提議するs and change the evaluation order. So if more than two (米)棚上げする/(英)提議するs are joined together with join 操作者s, the end result is also a joined (米)棚上げする/(英)提議する. There are different types of join, each producing the result (米)棚上げする/(英)提議する in a different way.

<joined (米)棚上げする/(英)提議する> ::= <cross join> | <qualified join> | <natural join>

<cross join> ::= <(米)棚上げする/(英)提議する 言及/関連> CROSS JOIN <(米)棚上げする/(英)提議する factor>

<qualified join> ::= <(米)棚上げする/(英)提議する 言及/関連> | [ <join type> ] JOIN <(米)棚上げする/(英)提議する 言及/関連> <join specification>

<natural join> ::= <(米)棚上げする/(英)提議する 言及/関連> NATURAL [ <join type> ] JOIN <(米)棚上げする/(英)提議する factor>

<join specification> ::= <join 条件> | <指名するd columns join>

<join 条件> ::= ON <search 条件>

<指名するd columns join> ::= USING <left paren> <join column 名簿(に載せる)/表(にあげる)> <権利 paren>

<join type> ::= INNER | <outer join type> [ OUTER ]

<outer join type> ::= LEFT | RIGHT | FULL

<join column 名簿(に載せる)/表(にあげる)> ::= <column 指名する 名簿(に載せる)/表(にあげる)>

CROSS JOIN

The simplest form of join is CROSS JOIN. The CROSS JOIN of two (米)棚上げする/(英)提議するs is a (米)棚上げする/(英)提議する that has all the columns of the first (米)棚上げする/(英)提議する, followed by all the columns of the second (米)棚上げする/(英)提議する, in the 初めの order. Each 列/漕ぐ/騒動 of the first (米)棚上げする/(英)提議する is 連合させるd with each 列/漕ぐ/騒動 of the second (米)棚上げする/(英)提議する to fill the 列/漕ぐ/騒動s of the new (米)棚上げする/(英)提議する. If the 列/漕ぐ/騒動s of each (米)棚上げする/(英)提議する form a 始める,決める, then the 列/漕ぐ/騒動s of the CROSS JOIN (米)棚上げする/(英)提議する form the Cartesian 製品 of the 列/漕ぐ/騒動s of the two (米)棚上げする/(英)提議する operands.

条件s are not 許すd as part of a cross join, which is 簡単に A CROSS JOIN B. Any 条件s in a WHERE 条項 are later 適用するd to the (米)棚上げする/(英)提議する resulting from the cross join.

(米)棚上げする/(英)提議するs in the FROM CLAUSE separated with commas, are 同等(の) to cross joins between the (米)棚上げする/(英)提議するs. Two joined (米)棚上げする/(英)提議するs separated with a comma, such as A, B, is 同等(の) to (A) CROSS JOIN (B), which means the joined (米)棚上げする/(英)提議するs A and B are 居住させるd 分かれて before they are joined.

CROSS JOIN is not is not 一般に very useful, as it returns large result (米)棚上げする/(英)提議するs unless WHERE 条件s are used.

UNION JOIN

The UNION JOIN has 限られた/立憲的な use in queries. The result (米)棚上げする/(英)提議する has the same columns as that of CROSS JOIN. Each 列/漕ぐ/騒動 of the first (米)棚上げする/(英)提議する is 延長するd to the 権利 with nulls and 追加するd to the new (米)棚上げする/(英)提議する. Each 列/漕ぐ/騒動 of the second (米)棚上げする/(英)提議する is 延長するd to the left with nulls and 追加するd to the new (米)棚上げする/(英)提議する. The UNION JOIN is 表明するd as A UNION JOIN B. This should not be 混乱させるd with A UNION B, which is a 始める,決める 操作/手術. Union join is for special 使用/適用s and is not 一般的に used.

JOIN ... ON

The 条件 join is 類似の to CROSS JOIN, but a 条件 is 実験(する)d for each 列/漕ぐ/騒動 of the new (米)棚上げする/(英)提議する and the 列/漕ぐ/騒動 is created only if the 条件 is true. This form of join is 表明するd as A JOIN B ON (<search 条件>).

Equijoin is a 条件 join in which the search 条件 is an equality 条件 between on or more pairs of columns from the two (米)棚上げする/(英)提議する. Equijoin is the most 一般的に used type of join.

SELECT a.*, b.* FROM a INNER JOIN b ON a.col_one = b.col_two

JOIN ... USING

NATURAL JOIN

Joins with USING or NATURAL keywords are 類似の to an equijoin but they cannot be 取って代わるd 簡単に with an equijoin. The new (米)棚上げする/(英)提議する is formed with the 明示するd or 暗示するd 株d columns of the two (米)棚上げする/(英)提議するs, followed by the 残り/休憩(する) of the columns from each (米)棚上げする/(英)提議する. In NATURAL JOIN, the 株d columns are all the column pairs that have the same 指名する in the first and second (米)棚上げする/(英)提議する. In JOIN USING, only columns 指名するs that are 明示するd by the USING 条項 are 株d. The joins are 表明するd as A NATURAL JOIN B, and A JOIN B USING (<comma separated column 指名する 名簿(に載せる)/表(にあげる)>).

The columns of the joined (米)棚上げする/(英)提議する are formed by the に引き続いて 手続きs: In JOIN ... USING the 株d columns are 追加するd to the joined (米)棚上げする/(英)提議する in the same order as they appear in the column 指名する 名簿(に載せる)/表(にあげる). In NATURAL JOIN the 株d columns are 追加するd to the joined (米)棚上げする/(英)提議する in the same order as they appear in the first (米)棚上げする/(英)提議する. In both forms of join, the 非,不,無-株d columns of the first (米)棚上げする/(英)提議する are 追加するd in the order they appear in the first (米)棚上げする/(英)提議する, finally the 非,不,無-株d columns of the second (米)棚上げする/(英)提議する are 追加するd in the order they appear in the second (米)棚上げする/(英)提議する.

The type of each 株d column of the joined (米)棚上げする/(英)提議する is based on the type of the columns in the 初めの (米)棚上げする/(英)提議するs. If the 初めの types are not 正確に/まさに the same, the type of the 株d column is formed by type aggregation. Type aggregations selects a type that can 代表する values of both aggregated types. Simple type aggregation 選ぶs one of the types. For example, SMALLINT and INTEGER, results in INTEGER, or VARCHAR(10) and VARCHAR(20) results in VARCHAR(20). More コンビナート/複合体 type aggregation 相続するs 所有物/資産/財産s from both types. For example DECIMAL(8) and DECIMAL (6,2) results in DECIMAL (8,2).

In the examples below, the 列/漕ぐ/騒動s are joined 正確に/まさに the same way, but the first query 含む/封じ込めるs a.col_two and b.col_two together with all the 残り/休憩(する) of the columns of both (米)棚上げする/(英)提議するs, while the second query returns only one copy of col_two.

 SELECT * FROM a INNER JOIN b ON a.col_two = b.col_two
 SELECT * FROM a INNER JOIN b USING (col_two)

OUTER JOIN

LEFT, RIGHT and FULL OUTER JOIN

The three qualifiers can be 追加するd to all types of JOIN except CROSS JOIN and UNION JOIN. First the new (米)棚上げする/(英)提議する is 居住させるd with the 列/漕ぐ/騒動s from the 初めの join. If LEFT is 明示するd, all the 列/漕ぐ/騒動s from the first (米)棚上げする/(英)提議する that did not make it into the new (米)棚上げする/(英)提議する are 延長するd to the 権利 with nulls and 追加するd to the (米)棚上げする/(英)提議する. If RIGHT is 明示するd, all the 列/漕ぐ/騒動s from the second (米)棚上げする/(英)提議する that did not make it into the new (米)棚上げする/(英)提議する are 延長するd to the left with nulls and 追加するd to the (米)棚上げする/(英)提議する. If FULL is 明示するd, the 新規加入 of leftover 列/漕ぐ/騒動s is 成し遂げるd from both the first and the second (米)棚上げする/(英)提議する. These forms are 表明するd by prefixing the join specification with the given keyword. For example, A LEFT OUTER JOIN B ON (<search 条件>) or A NATURAL FULL OUTER JOIN B or A FULL OUTER JOIN B USING (<comma separated column 指名する 名簿(に載せる)/表(にあげる)>).

 SELECT a.*, b.* FROM a LEFT OUTER JOIN b ON a.col_one = b.col_two

選択

にもかかわらず the 指名する, 選択 has nothing to do with the 名簿(に載せる)/表(にあげる) of columns in a SELECT 声明. In fact, it 言及するs to the search 条件 used to 限界 the 列/漕ぐ/騒動s that from a result (米)棚上げする/(英)提議する (選択 of 列/漕ぐ/騒動s, not columns). In SQL, simple 選択 is 表明するd with a WHERE 条件 appended to a 選び出す/独身 (米)棚上げする/(英)提議する or a joined (米)棚上げする/(英)提議する. In some 事例/患者s, this method of 選択 is the only method 利用できる; for example in DELETE and UPDATE 声明s. But when it is possible to 成し遂げる the 選択 with join 条件s, this is the better method, as it results in a clearer 表現 of the query.

発射/推定

発射/推定 is 選択 of the columns from a simple or joined (米)棚上げする/(英)提議する to form a result (米)棚上げする/(英)提議する. Explicit 発射/推定 is 成し遂げるd in the SELECT 声明 by 明示するing the select column 名簿(に載せる)/表(にあげる). Some form of 発射/推定 is also 成し遂げるd in JOIN ... USING and NATURAL JOIN.

The joined (米)棚上げする/(英)提議する has columns that are formed によれば the 支配するs について言及するd above. But in many 事例/患者s, not all the columns are necessary for the ーするつもりであるd 操作/手術. If the 声明 is in the form, SELECT * FROM <joined (米)棚上げする/(英)提議する>, then all the columns of <joined (米)棚上げする/(英)提議する> are returned. But 普通は, the columns to be returned are 明示するd after the SELECT keyword, separated from each other with commas.

計算するd Columns

In the select 名簿(に載せる)/表(にあげる), it is possible to use 表現s that 言及/関連 any columns of <joined (米)棚上げする/(英)提議する>. Each of these 表現s forms a 計算するd column. It is 計算するd for each 列/漕ぐ/騒動 of the result (米)棚上げする/(英)提議する, using the values of the columns of the <joined (米)棚上げする/(英)提議する> for that 列/漕ぐ/騒動.

指名するing

指名するing is used to hide the 初めの 指名するs of (米)棚上げする/(英)提議するs or (米)棚上げする/(英)提議する columns and to 取って代わる them with new 指名するs in the 範囲 of the query. 指名するing is also used for defining 指名するs for 計算するd columns.

Without explicit 指名するing, the 指名する of a column is a predefined 指名する. If the column is a column of a (米)棚上げする/(英)提議する, or is a 指名するd parameter, the 指名する is of the (米)棚上げする/(英)提議する column or parameter is used. さもなければ it is 生成するd by the database engine. HyperSQL 生成するs column 指名するs such as C1, C2, etc. As 生成するd 指名するing is 実施 defined (許可,名誉などを)与えるing to the SQL 基準, it is better to explicitly 指名する the 計算するd and derived columns in your 使用/適用s.

指名するing in Joined (米)棚上げする/(英)提議する

指名するing is 成し遂げるd by 追加するing a new 指名する after a (米)棚上げする/(英)提議する's real 指名する and by 追加するing a 名簿(に載せる)/表(にあげる) of column 指名するs after the new (米)棚上げする/(英)提議する 指名する. Both (米)棚上げする/(英)提議する 指名するing and column 指名するing are optional, but (米)棚上げする/(英)提議する 指名するing is 要求するd for column 指名するing. The 表現 A [AS] X (<comma separated column 指名する 名簿(に載せる)/表(にあげる)>) means (米)棚上げする/(英)提議する A is used in the query 表現 as (米)棚上げする/(英)提議する X and its columns are 指名するd as in the given 名簿(に載せる)/表(にあげる). The 初めの 指名する A, or its 初めの column 指名するs, are not 明白な in the 範囲 of the query. The BNF is given below. The <correlation 指名する> can be the same or different from the 指名する of the (米)棚上げする/(英)提議する. The <derived column 名簿(に載せる)/表(にあげる)> is a comma separated 名簿(に載せる)/表(にあげる) of column 指名するs. The degree of this 名簿(に載せる)/表(にあげる) must be equal to the degree of the (米)棚上げする/(英)提議する. The column 指名するs in the 名簿(に載せる)/表(にあげる) must be 際立った. They can be the same or different from the 指名するs of the (米)棚上げする/(英)提議する's columns.

<(米)棚上げする/(英)提議する or query 指名する> [ [ AS ] <correlation 指名する> [ <left paren> <derived column 名簿(に載せる)/表(にあげる)> <権利 paren> ] ]

In the examples below, the columns of the 初めの (米)棚上げする/(英)提議するs are 指名するd (a, b, c, d, e, f). The two queries are 同等(の). In the second query, the (米)棚上げする/(英)提議する and its columns are 改名するd and the new 指名するs are used in the WHERE 条項s:

 CREATE TABLE atable (a INT, b INT, c INT, d INT, e INT, f INT);
 SELECT d, e, f FROM atable WHERE a + b = c
 SELECT x, y, z FROM atable AS t (u, v, w, x, y, z)  WHERE u + v = w

指名するing in Select 名簿(に載せる)/表(にあげる)

指名するing in the SELECT 名簿(に載せる)/表(にあげる) 論理(学)上 takes place after 指名するing in the joined (米)棚上げする/(英)提議する. The new 指名するs for columns are not 明白な in the 即座の query 表現 or query 表現. They become 明白な in the ORDER BY 条項 and in the result (米)棚上げする/(英)提議する that is returned to the 使用者. Or if the query 表現 is used as a derived (米)棚上げする/(英)提議する in an enclosing query 表現.

In the example below, the query is on the same (米)棚上げする/(英)提議する but with column 改名するing in the Select 名簿(に載せる)/表(にあげる). The new 指名するs are used in the ORDER BY 条項:

 SELECT x + y AS xysum, y + z AS yzsum FROM atable AS t (u, v, w, x, y, z)  WHERE u + v = w ORDER BY xysum, yzsum

If the 指名するs xysum or yzsum are not used, the 計算するd columns cannot be 言及/関連d in the ORDER BY 名簿(に載せる)/表(にあげる).

指名する 決意/決議

In a joined (米)棚上げする/(英)提議する, if a column 指名する appears in (米)棚上げする/(英)提議するs on both 味方するs then any 言及/関連 to the 指名する must use the (米)棚上げする/(英)提議する 指名する ーするために 明示する which (米)棚上げする/(英)提議する is 存在 referred to.

配合 操作/手術s

配合 操作/手術s

配合 results in the 排除/予選 of duplicate 列/漕ぐ/騒動s. A 配合 操作/手術 is 成し遂げるd after the 操作/手術s discussed above. A simple form of 配合 is 成し遂げるd by the use of DISTINCT after SELECT. This 除去するs all the duplicate 列/漕ぐ/騒動s (列/漕ぐ/騒動s that have the same value in each of their columns when compared to another 列/漕ぐ/騒動). The other form of 配合 is 成し遂げるd with the GROUP BY 条項. This form is usually used together with aggregation.

GROUP BY

<group by 条項> ::= GROUP BY [ <始める,決める quantifier> ] <配合 element> [ { <comma> <配合 element> }... ]

<配合 element> ::= <ordinary 配合 始める,決める> | <rollup 名簿(に載せる)/表(にあげる)> | <cube 名簿(に載せる)/表(にあげる)> | <配合 始める,決めるs specification> | <empty 配合 始める,決める>

<ordinary 配合 始める,決める> ::= <配合 column 言及/関連> | <left paren> <配合 column 言及/関連 名簿(に載せる)/表(にあげる)> <権利 paren>

<配合 column 言及/関連 名簿(に載せる)/表(にあげる)> ::= <配合 column 言及/関連> [ { <comma> <配合 column 言及/関連> }... ]

<配合 column 言及/関連> ::= <column 言及/関連> [ <collate 条項> ]

<rollup 名簿(に載せる)/表(にあげる)> ::= ROLLUP <left paren> <ordinary 配合 始める,決める 名簿(に載せる)/表(にあげる)> <権利 paren>

<ordinary 配合 始める,決める 名簿(に載せる)/表(にあげる)> ::= <ordinary 配合 始める,決める> [ { <comma> <ordinary 配合 始める,決める> }... ]

<cube 名簿(に載せる)/表(にあげる)> ::= CUBE <left paren> <ordinary 配合 始める,決める 名簿(に載せる)/表(にあげる)> <権利 paren>

<配合 始める,決めるs specification> ::= GROUPING SETS <left paren> <配合 始める,決める 名簿(に載せる)/表(にあげる)> <権利 paren>

<配合 始める,決める 名簿(に載せる)/表(にあげる)> ::= <配合 始める,決める> [ { <comma> <配合 始める,決める> }... ]

<配合 始める,決める> ::= <ordinary 配合 始める,決める> | <rollup 名簿(に載せる)/表(にあげる)> | <cube 名簿(に載せる)/表(にあげる)> | <配合 始める,決めるs specification> | <empty 配合 始める,決める>

<empty 配合 始める,決める> ::= <left paren> <権利 paren>

An ordinary <group by 条項> is a comma separated 名簿(に載せる)/表(にあげる) of columns of the (米)棚上げする/(英)提議する formed by the <from 条項> or 表現s based on the columns. This is the most ありふれた usage and can be 述べるd as GROUP BY <column 言及/関連> [ { <comma> <配合 column 言及/関連> }... ].

When a <group by 条項> is used, only the columns used in the <group by 条項> or 表現s used there, can be used in the <select 名簿(に載せる)/表(にあげる)>, together with any <aggregate 機能(する)/行事> on other columns. In other words, the column 指名するs or 表現s 名簿(に載せる)/表(にあげる)d in the GROUP BY 条項 dictate what can be used in the <select 名簿(に載せる)/表(にあげる)>. After the 列/漕ぐ/騒動s of the (米)棚上げする/(英)提議する formed by the <from 条項> and the <where 条項> are finalised, the 配合 操作/手術 groups together the 列/漕ぐ/騒動s that have the same values in the columns of the <group by 条項>. Then any <aggregate 機能(する)/行事> in the <select 名簿(に載せる)/表(にあげる)> is 成し遂げるd on each group, and for each group, a 列/漕ぐ/騒動 is formed that 含む/封じ込めるs the values of the columns of the <group by 条項> and the values returned from each <aggregate 機能(する)/行事>.

When the type of <column 言及/関連> is character string, the <collate 条項> can be used to 明示する the collation used for 配合 the 列/漕ぐ/騒動s. For example, a collation that is not 事例/患者 極度の慎重さを要する can be used, or a collation for a different language than the 初めの collation of the column.

The first example below shows a simple GROUP BY, while in the second example, has a HAVING 条件.

 CREATE TABLE REVENUE(CHANNEL VARCHAR(20), YEAR INTEGER, COUNTRY VARCHAR(2), PROVINCE VARCHAR(20), SALES INTEGER);
 SELECT CHANNEL, YEAR, COUNTRY, SUM(SALES) FROM REVENUE GROUP BY CHANNEL, YEAR, COUNTRY;
 SELECT CHANNEL, YEAR, COUNTRY, SUM(SALES) FROM REVENUE GROUP BY CHANNEL, YEAR, COUNTRY HAVING SUM(SALES) > 50000;

An 延長するd <group by 条項> may 構成する elements such as GROUPING SETS, ROLLUP, CUBE and the empty 配合 始める,決める. These syntax elements are 拡大するd and then 簡単にするd into a 名簿(に載せる)/表(にあげる) of parenthesized column elements, which result in 多重の 配合 操作/手術s. HyperSQL supports all the syntax 名簿(に載せる)/表(にあげる)d above. The example below uses ROLLUP for 配合.

 SELECT CHANNEL, YEAR, COUNTRY, SUM(SALES) AS S
 FROM REVENUE 
 GROUP BY ROLLUP(CHANNEL, YEAR, COUNTRY);

The ROLLUP is translated into 4 配合s: (channel, year, country), (channel, year), (channel), (). The result 始める,決める will 含む/封じ込める the 列/漕ぐ/騒動s as grouped by (channel, year, country), then 列/漕ぐ/騒動s as grouped by (channel, year) with the country column 取って代わるd by null, then 列/漕ぐ/騒動s as grouped by (channel) only, with year and country columns 取って代わるd by null, then a 選び出す/独身 列/漕ぐ/騒動 代表するing the () empty group with all three columns 取って代わるd by null.

CHANNEL      YEAR   COUNTRY S       
------------ ------ ------- ------- 
INTERNET     2009   GB      25000   
INTERNET     2009   US      275000  
INTERNET     2010   GB      45000   
INTERNET     2010   US      500000  
DIRECT SALES 2009   GB      162000  
DIRECT SALES 2009   US      1602500 
DIRECT SALES 2010   GB      181000  
DIRECT SALES 2010   US      1833000 
INTERNET     2009   (null)  300000  
INTERNET     2010   (null)  545000  
DIRECT SALES 2009   (null)  1764500 
DIRECT SALES 2010   (null)  2014000 
INTERNET     (null) (null)  845000  
DIRECT SALES (null) (null)  3778500 
(null)       (null) (null)  4623500 

If CUBE is used instead of ROLLUP, other permutations of the three columns are 追加するd to those produced by ROLLUP. These 含む (channel, country), (year, country), (year) and (country).

The optional <始める,決める quantifier> is either ALL or DISTINCT and defaults to ALL. When GROUPING SETS is used and 多重の 始める,決めるs are 明示するd and some duplicate groups are created as a result, use of DISTINCT 除去するs the duplicate groups.

公式文書,認める any ordering of the 列/漕ぐ/騒動s returned by GROUP BY in incidental. You need to use ORDER BY for the ordering you 要求する.

HAVING

A <having 条項> filters the 列/漕ぐ/騒動s of the (米)棚上げする/(英)提議する that is formed after 適用するing the <group by 条項> using its search 条件. The search 条件 must be an 表現 based on the 表現s in the GROUP BY 名簿(に載せる)/表(にあげる) or the aggregate 機能(する)/行事s used.

DISTINCT

SELECT DISTINCT

When the keyword DISTINCT is used after SELECT, it 作品 as a shortcut 交替/補充 for a simple GROUP BY 条項. The 表現s in the SELECT 名簿(に載せる)/表(にあげる) are used 直接/まっすぐに as the <group by 条項>. The に引き続いて examples of SELECT DISTINCT and SELECT with GROUP BY are 同等(の).

 SELECT DISTINCT d, e + f FROM atable WHERE a + b = c
 SELECT d, e + f FROM atable WHERE a + b = c GROUP BY d, e + f

Aggregation

Aggregation is an 操作/手術 that 計算するs a 選び出す/独身 value from the values of a column over several 列/漕ぐ/騒動s. The 操作/手術 is 成し遂げるd with an aggregate 機能(する)/行事. The simplest form of aggregation is counting, 成し遂げるd by the COUNT 機能(する)/行事.

Other ありふれた aggregate 機能(する)/行事s return the 最大限, 最小限 and 普通の/平均(する) value の中で the values in different 列/漕ぐ/騒動s. Aggregate 機能(する)/行事s were discussed earlier in this 一時期/支部.

始める,決める 操作/手術s

始める,決める and Multiset 操作/手術s

While join 操作/手術s 一般に result in laterally 拡大するd (米)棚上げする/(英)提議するs, SET and COLLECTION 操作/手術s are 成し遂げるd on two (米)棚上げする/(英)提議するs that have the same degree and result in a (米)棚上げする/(英)提議する of the same degree. The SET 操作/手術s are UNION, INTERSECT and EXCEPT (difference). When each of these 操作/手術s is 成し遂げるd on two (米)棚上げする/(英)提議するs, the collection of 列/漕ぐ/騒動s in each (米)棚上げする/(英)提議する and in the result is 減ずるd to a 始める,決める of 列/漕ぐ/騒動s, by 除去するing duplicates. The 始める,決める 操作/手術s are then 成し遂げるd on the two (米)棚上げする/(英)提議するs, resulting in the new (米)棚上げする/(英)提議する which itself is a 始める,決める of 列/漕ぐ/騒動s. Collection 操作/手術s are 類似の but the (米)棚上げする/(英)提議するs are not 減ずるd to 始める,決めるs before or after the 操作/手術 and the result is not やむを得ず a 始める,決める, but a collection of 列/漕ぐ/騒動s.

The 始める,決める 操作/手術s on two (米)棚上げする/(英)提議するs A and B are: A UNION [DISTINCT] B, A INTERSECT [DISTINCT] B and A EXCEPT [DISTINCT] B. The result (米)棚上げする/(英)提議する is formed in the に引き続いて way: The UNION 操作/手術 追加するs all the 列/漕ぐ/騒動s from A and B into the new (米)棚上げする/(英)提議する, but 避けるs copying duplicate 列/漕ぐ/騒動s. The INTERSECT 操作/手術 copies only those 列/漕ぐ/騒動s from each (米)棚上げする/(英)提議する that also 存在する in the other (米)棚上げする/(英)提議する, but 避けるs copying duplicate 列/漕ぐ/騒動s. The EXCEPT 操作/手術 copies those 列/漕ぐ/騒動s from the first (米)棚上げする/(英)提議する which do not 存在する in the second (米)棚上げする/(英)提議する, but 避けるs copying duplicate 列/漕ぐ/騒動s.

The collection 操作/手術s are 類似の to the 始める,決める 操作/手術s, but can return duplicate 列/漕ぐ/騒動s. They are: A UNION ALL B, A INTERSECT ALL B and A EXCEPT ALL B. The UNION ALL 操作/手術 追加するs all the 列/漕ぐ/騒動s from A and B into the new (米)棚上げする/(英)提議する. The INTERSECT 操作/手術 copies only those 列/漕ぐ/騒動s from each (米)棚上げする/(英)提議する that also 存在する in the other (米)棚上げする/(英)提議する. If n copies of a 列/漕ぐ/騒動s 存在するs in one (米)棚上げする/(英)提議する, and m copies in the other (米)棚上げする/(英)提議する, the number of copies in the result (米)棚上げする/(英)提議する is the smaller of n and m. The EXCEPT 操作/手術 copies those 列/漕ぐ/騒動s from the first (米)棚上げする/(英)提議する which do not 存在する in the second (米)棚上げする/(英)提議する. If n copies of a 列/漕ぐ/騒動 存在する in the first (米)棚上げする/(英)提議する and m copies in the second (米)棚上げする/(英)提議する the number of copies in the result (米)棚上げする/(英)提議する is n-m, or if n < m, then 無.

With 条項 and Recursive Queries

The optional WITH 条項 can be used in a query 表現. The WITH 条項 名簿(に載せる)/表(にあげる)s one or more 指名するd ephemeral (米)棚上げする/(英)提議するs that can be 言及/関連d in the query 表現 団体/死体. The ephemeral (米)棚上げする/(英)提議するs are created and 居住させるd before the 残り/休憩(する) of the query 表現 is 遂行する/発効させるd. Their contents do not change during the 死刑執行 of the <query 表現 団体/死体> that follows the WITH 条項.

<with 条項> ::= WITH [ RECURSIVE ] <with 名簿(に載せる)/表(にあげる)>

<with 名簿(に載せる)/表(にあげる)> ::= <with 名簿(に載せる)/表(にあげる) element> [ { <comma> <with 名簿(に載せる)/表(にあげる) element> }... ]

<with 名簿(に載せる)/表(にあげる) element> ::= <query 指名する> [ <left paren> <with column 名簿(に載せる)/表(にあげる)> <権利 paren> ] AS <left paren> <query 表現> <権利 paren>

<with column 名簿(に載せる)/表(にあげる)> ::= <column 指名する 名簿(に載せる)/表(にあげる)>

An example of the use of the WITH 条項 is given above under UNNEST. The <query 表現> in the WITH 条項 is 評価するd and its result (米)棚上げする/(英)提議する can be 言及/関連d in the 団体/死体 of the main <query 表現 団体/死体> using the 明示するd <query 指名する>.

When RECURSIVE is used, the <with column 名簿(に載せる)/表(にあげる)> must be defined. The RECURSIVE keyword changes the way the <with 名簿(に載せる)/表(にあげる)> is 解釈する/通訳するd. The <query 表現> 含む/封じ込めるd in the <with 名簿(に載せる)/表(にあげる) element> must be the UNION or UNION ALL of two <query 表現 団体/死体> elements (VALUES or SELECT 声明s). A working (米)棚上げする/(英)提議する is created and the left 味方する SELECT of the UNION is 評価するd only once and its result is copied to the working (米)棚上げする/(英)提議する. This result is also copied to the general result of the <query 表現>. Iteration starts after this step. In each iteration, the 権利 味方する SELECT is 評価するd. The contents of the working (米)棚上げする/(英)提議する is used when the <query 指名する> is 言及/関連d in the 権利 味方する SELECT 声明 of the UNION. The result of this SELECT is then 追加するd to the previous general result of the <query 表現> with UNION or UNION ALL. The working (米)棚上げする/(英)提議する is (疑いを)晴らすd and filled with the 最新の result. These 操作/手術s are repeated again and again, until the 最新の result is empty and the general result of the <query 表現> stops changing. The result of the <with 名簿(に載せる)/表(にあげる) element> is now fully 居住させるd and is later used in the 死刑執行 of the <query 表現 団体/死体> that follows the WITH 条項.

HyperSQL 限界s recursion to 256 一連の会議、交渉/完成するs. If this is 越えるd, an error is raised.

From 見解/翻訳/版 2.6, HyperSQL 延長するs recursive query 過程ing by 許すing the use of RECURSIVE_TABLE to 言及/関連 the 現在の general result of the <query 表現>. This (米)棚上げする/(英)提議する 指名する can be used in subqueries with an IN predicate ーするために 減ずる and 限界 the new result created in each iteration.

A trivial example of a recursive query is given below. 公式文書,認める the first column GEN. For example, if each 列/漕ぐ/騒動 of the (米)棚上げする/(英)提議する 代表するs a member of a family of dogs, together with its parent, the first column of the result 示すs the calculated 世代 of each dog, 範囲ing from first to fourth 世代.

 CREATE TABLE pptree (pid INT, id INT, 指名する VARCHAR(10));
 INSERT INTO pptree VALUES (NULL, 1, 'dizzi'),(1,2, 'fizzi'),
                           (1,3, 'gizzi'),(2,4, 'kizzi'),
                           (4,5, 'mizzi'),(3,6, 'pizzi'),
                           (3,7, 'tizzi');

 WITH RECURSIVE tree (gen, par, child, 指名する) AS (
   VALUES(1, CAST(null as int), 1, 'dizzi')
   UNION
   SELECT gen + 1, pid, id, 指名する FROM pptree, tree WHERE pid = child
   ) SELECT * FROM tree;

 GEN PAR    CHILD NAME  
 --- ------ ----- ----- 
 1   (null) 1     dizzi 
 2   1      2     fizzi 
 2   1      3     gizzi 
 3   2      4     kizzi 
 3   3      6     pizzi 
 3   3      7     tizzi 
 4   4      5     mizzi 

If recursive queries become コンビナート/複合体, they also become very difficult to develop and debug. HyperSQL 供給するs an 代案/選択肢 to this with 使用者-defined SQL 機能(する)/行事s which return (米)棚上げする/(英)提議するs. 機能(する)/行事s can 成し遂げる any コンビナート/複合体, repetitive 仕事 with better 支配(する)/統制する, using 宙返り飛行s, variables and, if necessary, recursion.

The query below 計算するs the Fibonacci numbers up to 100 digits. The WHERE 条項 限界s the iteration.

 WITH RECURSIVE Fibonacci(N1, F1, N2, F2) AS (
   VALUES(0, CAST(0 AS DECIMAL(100)), 1, CAST(1 AS DECIMAL(100))
   UNION
   SELECT N1 + 1, F1 + F2, N1 +2, F1 + 2 * F2
   FROM Fibonacci p 
   WHERE N1 < 100
 ) SELECT * FROM Fibonacci

Query 表現

A query 表現 consists of an optional WITH 条項 and a query 表現 団体/死体. The optional WITH 条項 名簿(に載せる)/表(にあげる)s one or more 指名するd ephemeral (米)棚上げする/(英)提議するs that can be 言及/関連d, just like the database (米)棚上げする/(英)提議するs in the query 表現 団体/死体.

<query 表現> ::= [ <with 条項> ] <query 表現 団体/死体>

A query 表現 団体/死体 言及するs to a (米)棚上げする/(英)提議する formed by using UNION and other 始める,決める 操作/手術s. The query 表現 団体/死体 is 評価するd from left to 権利 and the INTERSECT 操作者 has 優先 over the UNION and EXCEPT 操作者s. A 簡単にするd BNF is given below:

<query 表現 団体/死体> ::= <query 称する,呼ぶ/期間/用語> | <query 表現 団体/死体> UNION | EXCEPT [ ALL | DISTINCT ] [ <corresponding spec> ] <query 称する,呼ぶ/期間/用語>

<query 称する,呼ぶ/期間/用語> ::= <query 最初の/主要な> | <query 称する,呼ぶ/期間/用語> INTERSECT [ ALL | DISTINCT ] [ <corresponding spec> ] <query 称する,呼ぶ/期間/用語>

<query 最初の/主要な> ::= <simple (米)棚上げする/(英)提議する> | <left paren> <query 表現 団体/死体> [ <order by 条項> ] [ <result 相殺する 条項> ] [ <fetch first 条項> ] <権利 paren>

<simple (米)棚上げする/(英)提議する> ::= <query specification> | <(米)棚上げする/(英)提議する value 建設者> | <explicit (米)棚上げする/(英)提議する> <explicit (米)棚上げする/(英)提議する> ::= TABLE <(米)棚上げする/(英)提議する or query 指名する>

<corresponding spec> ::= CORRESPONDING [ BY <left paren> <column 指名する 名簿(に載せる)/表(にあげる)> <権利 paren> ]

A <query 称する,呼ぶ/期間/用語> and a <query 最初の/主要な> can be a SELECT 声明, an <explicit (米)棚上げする/(英)提議する>, or a <(米)棚上げする/(英)提議する value 建設者>.

The CORRESPONDING 条項 is optional. If it is not 明示するd, then the <query 称する,呼ぶ/期間/用語> and the <query 最初の/主要な> must have the same number of columns. If CORRESPONDING is 明示するd, the two 味方するs need not have the same number of columns. If no column 名簿(に載せる)/表(にあげる) is used with CORRESPONDING, then all the column 指名するs that are ありふれた in the (米)棚上げする/(英)提議するs on two 味方するs are used in the order in which they appear in the first (米)棚上げする/(英)提議する. If a columns 名簿(に載せる)/表(にあげる) is used, it 許すs you to select only some columns of the (米)棚上げする/(英)提議するs on the left and 権利 味方する to create the new (米)棚上げする/(英)提議する. In the example below the columns 指名するd u and v from the two SELECT 声明s are used to create the UNION (米)棚上げする/(英)提議する.

 SELECT * FROM atable UNION CORRESPONDING BY (u, v) SELECT * FROM anothertable

The type of each column of the query 表現 is 決定するd by 連合させるing the types of the corresponding columns from the two 参加するing (米)棚上げする/(英)提議するs.

Ordering

When the 列/漕ぐ/騒動s of the result (米)棚上げする/(英)提議する have been formed, it is possible to 明示する the order in which they are returned to the 使用者. The ORDER BY 条項 is used to 明示する the columns used for ordering, and whether 上がるing or descending ordering is used. It can also 明示する whether NULL values are returned first or last.

 SELECT x + y AS xysum, y + z AS yzsum FROM atable AS t (u, v, w, x, y, z)  WHERE u + v = w ORDER BY xysum NULLS LAST, yzsum NULLS FIRST

The ORDER BY 条項 明示するs one or more <value 表現s>. The 名簿(に載せる)/表(にあげる) of 列/漕ぐ/騒動s is sorted によれば the first <value 表現>. When some 列/漕ぐ/騒動s are sorted equal then they are sorted によれば the next <value 表現> and so on.

<order by 条項> ::= ORDER BY <sort specification 名簿(に載せる)/表(にあげる)>

<sort specification 名簿(に載せる)/表(にあげる)> ::= <sort specification> [ { <comma> <sort specification> }... ]

<sort specification> ::= <value 表現> [ <collate 条項> ] [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]

The defaults are ASC and NULLS FIRST. Two database 所有物/資産/財産s SQL NULLS FIRST and SQL NULLS ORDER can be 修正するd to change the default behaviour.

A collation is used for columns of an ORDER BY 表現 that are of the type CHAR or VARCHAR. If a <collate 条項> is not 明示するd then the collation of the column, or the default collation of the database is used.

The default collation for a database is ASCII, with lowercase letters sorted after all uppercase letters. The example below shows the 影響 of collation on an ordered 名簿(に載せる)/表(にあげる).

 -- default collation collation for the database is ASCII
 SELECT id, lastname FROM 顧客 ORDER BY lastname
 ID LASTNAME 
 -- -------- 
 40 Clancy   
 36 King     
 35 White    
 6  king

 -- a language collation is used, it 扱う/治療するs king and King as 隣接する 入ること/参加(者)s
 SELECT id, lastname FROM 顧客 ORDER BY lastname COLLATE "English"
 ID LASTNAME 
 -- -------- 
 40 Clancy   
 6  king     
 36 King     
 35 White

In the above example, if the LASTNAME column is itself defined in the (米)棚上げする/(英)提議する 鮮明度/定義 with COLLATE "English", then the COLLATE 条項 is not necessary in the ORDER BY 表現.

An ORDER BY 操作/手術 can いつかs be optimised by the engine when it can use the same 索引 for 接近ing the (米)棚上げする/(英)提議する data and ordering. Optimisation can happen both with DESC + NULLS LAST and ASC + NULLS FIRST.

sort specification 名簿(に載せる)/表(にあげる)

sort specification 名簿(に載せる)/表(にあげる)

<sort specification 名簿(に載せる)/表(にあげる)> ::= <value 表現> [ASC | DESC] [NULLS FIRST | NULLS LAST]

明示する a sort order. A sort 操作/手術 is 成し遂げるd on the result of a <query 表現> or <query specification> and sorts the result によれば one or more <value 表現>. The <value 表現> is usually a 選び出す/独身 column of the result, but in some 事例/患者s it can be a column of the <(米)棚上げする/(英)提議する 表現> that is not used in the select 名簿(に載せる)/表(にあげる). The default is ASC and NULLS FIRST.

Slicing

A different form of 限界ing the 列/漕ぐ/騒動s can be 成し遂げるd on the result (米)棚上げする/(英)提議する after it has been formed によれば all the other 操作/手術s (選択, 配合, ordering etc.). This is 明示するd by the FETCH ... ROWS and OFFSET 条項s of a SELECT 声明. In this form, the 明示するd OFFSET 列/漕ぐ/騒動s are 除去するd from start of the (米)棚上げする/(英)提議する, then up to the 明示するd FETCH 列/漕ぐ/騒動s are kept and the 残り/休憩(する) of the 列/漕ぐ/騒動s are discarded.

<result 相殺する 条項> ::= OFFSET <相殺する 列/漕ぐ/騒動 count> { ROW | ROWS }

<fetch first 条項> ::= FETCH { FIRST | NEXT } [ <fetch first 列/漕ぐ/騒動 count> ] { ROW | ROWS } ONLY [ USING INDEX ]

<限界 条項> ::= LIMIT <fetch first 列/漕ぐ/騒動 count> [ USING INDEX ]

A slicing 操作/手術 takes the result 始める,決める that has been already 過程d and ordered. It then discards the 明示するd number of 列/漕ぐ/騒動s from the start of the result 始める,決める and returns the 明示するd number of 列/漕ぐ/騒動s after the discarded 列/漕ぐ/騒動s. The <相殺する 列/漕ぐ/騒動 count> and <fetch first 列/漕ぐ/騒動 count> can be constants, dynamic variables, 決まりきった仕事 parameters, or 決まりきった仕事 variables. The type of the constants must be INTEGER.

 SELECT a, b FROM atable WHERE d < 5 ORDER BY absum OFFSET 3 FETCH 2 ROWS ONLY 
 SELECT a, b FROM atable WHERE d < 5 ORDER BY absum OFFSET 3 LIMIT 2 /* 代案/選択肢 keyword */ 

When the FETCH keyword is used, the 明示するd number of 列/漕ぐ/騒動s must be at least 1, さもなければ an error is returned. This behaviour is 一貫した with the SQL 基準. When the LIMIT keyword is used, the 明示するd number of 列/漕ぐ/騒動s can be 無, which means return all 列/漕ぐ/騒動s (no LIMIT). In MySQL and PostgreSQL syntax 方式s, 無 限界 means no 列/漕ぐ/騒動s (empty result).

If there is an 索引 on all the columns 明示するd in the ORDER BY 条項, it is 普通は used for slicing. In some queries, an 索引 on another column may take 優先 because it is used to 過程 the WHERE 条件. It is possible to 追加する USING INDEX to the end of the slicing 条項 to 軍隊 the use of the 索引 for ordering and slicing, instead of the 索引 for the WHERE 条件.

索引s Used in SELECT and DML 声明s

A query 表現, for example a SELECT 声明, uses 索引s for efficient data retrieval. The EXPLAIN PLAN 声明 名簿(に載せる)/表(にあげる)s the 索引s used, together with other useful (警察などへの)密告,告訴(状) about the query. EXPLAIN PLAN can also be used for data 巧みな操作 声明s such as UPDATE.

EXPLAIN PLAN

explain 計画(する)

<explain 計画(する)> ::= EXPLAIN PLAN FOR <query 表現>

For example, EXPLAIN PLAN FOR SELECT * FROM REVENUE WHERE COUNTRY = 'UK' .

Data Change 声明s

削除する 声明

DELETE FROM

削除する 声明: searched

<削除する 声明: searched> ::= DELETE FROM <的 (米)棚上げする/(英)提議する> [ [ AS ] <correlation 指名する> ] [ WHERE <search 条件> ][ LIMIT <fetch first 列/漕ぐ/騒動 count> ]

削除する 列/漕ぐ/騒動s of a (米)棚上げする/(英)提議する. The search 条件 is a <boolean value 表現> that is 評価するd for each 列/漕ぐ/騒動 of the (米)棚上げする/(英)提議する. If the 条件 is true, the 列/漕ぐ/騒動 is 削除するd. If the 条件 is not 明示するd, all the 列/漕ぐ/騒動s of the (米)棚上げする/(英)提議する are 削除するd. In fact, an implicit SELECT is 成し遂げるd in the form of SELECT * FROM <的 (米)棚上げする/(英)提議する> [ WHERE <search 条件>] and the selected 列/漕ぐ/騒動s are 削除するd. When used in JDBC, the number of 列/漕ぐ/騒動s returned by the implicit SELECT is returned as the update count.

If there are FOREIGN KEY 強制s on other (米)棚上げする/(英)提議するs that 言及/関連 the 支配する (米)棚上げする/(英)提議する, and the FOREIGN KEY 強制s have referential 活動/戦闘s, then 列/漕ぐ/騒動s from those other (米)棚上げする/(英)提議するs that 言及/関連 the 削除するd 列/漕ぐ/騒動s are either 削除するd, or updated, によれば the 明示するd referential 活動/戦闘s.

The LIMIT 条項, or alternatively the ROWNUM() 機能(する)/行事 in the WHERE 条項, can be used to 限界 the number of 列/漕ぐ/騒動s that are 削除するd. This is useful when a very large number of 列/漕ぐ/騒動s needs to be 削除するd. In this 状況/情勢, you can 成し遂げる the 操作/手術 is chunks and commit after each chunk to 減ずる memory usage and the total time of the 操作/手術.

In the second example below the 列/漕ぐ/騒動s that have the 最大限 value for column A are 削除するd;

 DELETE FROM T WHERE C > 5
 DELETE FROM T AS TT WHERE TT.A = (SELECT MAX(A) FROM T)

Truncate 声明

TRUNCATE TABLE

truncate (米)棚上げする/(英)提議する 声明

<truncate (米)棚上げする/(英)提議する 声明> ::= TRUNCATE TABLE <的 (米)棚上げする/(英)提議する> [ <身元 column 再開する 選択> ] [ <truncate 選択s> ]

<身元 column 再開する 選択> ::= CONTINUE IDENTITY | RESTART IDENTITY

<truncate 選択s> ::= AND COMMIT [ NO CHECK ]

<truncate (米)棚上げする/(英)提議する 見解/翻訳/版ing 声明> ::= TRUNCATE TABLE <的 (米)棚上げする/(英)提議する> VERSIONING TO { TIMESTAMP'YYYY-MM-DD HH:MM:SS' | CURRENT_TIMESTAMP }

削除する all 列/漕ぐ/騒動s of a (米)棚上げする/(英)提議する without 解雇する/砲火/射撃ing its 誘発する/引き起こすs. This 声明 can only be used on base (米)棚上げする/(英)提議するs (not 見解(をとる)s). If the (米)棚上げする/(英)提議する is 言及/関連d in a FOREIGN KEY 強制 defined on another (米)棚上げする/(英)提議する, the 声明 原因(となる)s an exception. 誘発する/引き起こすs defined on the (米)棚上げする/(英)提議する are not 遂行する/発効させるd with this 声明. The default for <身元 column 再開する 選択> is CONTINUE IDENTITY. This means no change to the IDENTITY sequence of the (米)棚上げする/(英)提議する. If RESTART IDENTITY is 明示するd, then the sequence is reset to its start value.

TRUNCATE is faster than ordinary DELETE. The TRUNCATE 声明 is an SQL 基準 data change 声明; therefore it is 成し遂げるd under 処理/取引 支配(する)/統制する and can be rolled 支援する if the 関係 is not in the 自動車-commit 方式.

HyperSQL also supports the optional AND COMMIT and NO CHECK 選択s. If AND COMMIT is used, then the 処理/取引 is committed with the 死刑執行 of the TRUNCATE 声明. The 活動/戦闘 cannot be rolled 支援する. If the 付加 NO CHECK 選択 is also 明示するd, then the TRUNCATE 声明 is 遂行する/発効させるd even if the (米)棚上げする/(英)提議する is 言及/関連d in a FOREIGN KEY 強制 defined on another, 非,不,無-empty (米)棚上げする/(英)提議する. This form of TRUNCATE is faster than the default form and does not use much memory.

The <truncate (米)棚上げする/(英)提議する 見解/翻訳/版ing 声明> is for 除去するing old history 列/漕ぐ/騒動s from a system-見解/翻訳/版d (米)棚上げする/(英)提議する. All history 列/漕ぐ/騒動s that 満了する/死ぬd before the given timestamp are 除去するd. No 現在の 列/漕ぐ/騒動 is 除去するd.

TRUNCATE SCHEMA

truncate schema 声明

<truncate schema 声明> ::= TRUNCATE SCHEMA <的 schema> [ <身元 column 再開する 選択> ] AND COMMIT [ NO CHECK ]

成し遂げるs the 同等(の) of a TRUNCATE TABLE ... AND COMMIT on all the (米)棚上げする/(英)提議する in the schema. If the 付加 NO CHECK 選択 is also 明示するd, then the TRUNCATE 声明 is 遂行する/発効させるd even if any of the (米)棚上げする/(英)提議するs in the schema is 言及/関連d in a FOREIGN KEY 強制 defined on a 非,不,無-empty (米)棚上げする/(英)提議する in a different schema.

If RESTART IDENTITY is 明示するd, all (米)棚上げする/(英)提議する IDENTITY sequences and all SEQUENCE 反対するs in the schema are reset to their start values.

Use of this 声明 要求するs schema 所有権 or 行政の 特権s.

挿入する 声明

INSERT INTO

挿入する 声明

<挿入する 声明> ::= INSERT INTO <的 (米)棚上げする/(英)提議する> [ [ AS ] <correlation 指名する> ] <挿入する columns and source>

<挿入する columns and source> ::= <from subquery> | <from 建設者> | <from default>

<from subquery> ::= [ <left paren> <挿入する column 名簿(に載せる)/表(にあげる)> <権利 paren> ] [ <無視/無効 条項> ] <query 表現>

<from 建設者> ::= [ <left paren> <挿入する column 名簿(に載せる)/表(にあげる)> <権利 paren> ] [ <無視/無効 条項> ] <contextually typed (米)棚上げする/(英)提議する value 建設者>

<無視/無効 条項> ::= OVERRIDING USER VALUE | OVERRIDING SYSTEM VALUE

<from default> ::= DEFAULT VALUES

<挿入する column 名簿(に載せる)/表(にあげる)> ::= <column 指名する 名簿(に載せる)/表(にあげる)>

挿入する new 列/漕ぐ/騒動s in a (米)棚上げする/(英)提議する. An INSERT 声明 挿入するs one or more 列/漕ぐ/騒動s into the (米)棚上げする/(英)提議する.

The special form, INSERT INTO <的 (米)棚上げする/(英)提議する> DEFAULT VALUES can be used with (米)棚上げする/(英)提議するs which have a default value for each column.

With the other forms of INSERT, the optional (<挿入する column 名簿(に載せる)/表(にあげる)>) 明示するs to which columns of the (米)棚上げする/(英)提議する the new values are 割り当てるd.

In one form, the 挿入するd values are from a <query 表現> and all the 列/漕ぐ/騒動s that are returned by the <query 表現> are 挿入するd into the (米)棚上げする/(英)提議する. If the <query 表現> returns no 列/漕ぐ/騒動s, nothing is 挿入するd.

In the other form, a comma separated 名簿(に載せる)/表(にあげる) of values called <contextually typed (米)棚上げする/(英)提議する value 建設者> is used to 挿入する one or more 列/漕ぐ/騒動s into the (米)棚上げする/(英)提議する. This 名簿(に載せる)/表(にあげる) is contextually typed, because the keywords NULL and DEFAULT can be used for the values that are 割り当てるd to each column of the (米)棚上げする/(英)提議する. In this form, the keyword DEFAULT means the default value of the column and can be used only if the 的 column has a default value or is an IDENTITY or GENERATED column of the (米)棚上げする/(英)提議する.

The <無視/無効 条項> must be used when a value is explicitly 割り当てるd to a column that has been defined as GENERATED ALWAYS AS IDENTITY. The OVERRIDING SYSTEM VALUE 条項 must be used to 無視/無効 the sequence value with the 使用者-供給(する)d values. For columns defined as GENERATED BY DEFAULT AS IDENTITY, there is no need to use OVERRIDING when the 使用者 供給するs values to be used for the 挿入する. The OVERRIDING USER VALUE 条項 can be used with all types of GENERATED columns and means the values 供給するd by the 使用者 are 簡単に ignored and new values 生成するd by the system are used instead. Two examples of (米)棚上げする/(英)提議する 鮮明度/定義 are given below.

 CREATE TABLE t1 (id INTEGER GENERATED ALWAYS AS IDENTITY((米ソ間の)戦略兵器削減交渉 WITH 100), 指名する VARCHAR(20) PRIMARY KEY)
 CREATE TABLE t2 (id INTEGER GENERATED BY DEFAULT AS IDENTITY((米ソ間の)戦略兵器削減交渉 WITH 1) PRIMARY KEY, 指名する VARCHAR(20))

In both examples below, the value 挿入するd for the id column is 14. In the first example, it is necessary to use OVERRIDING SYSTEM VALUE when 挿入するing into the id column of (米)棚上げする/(英)提議する t1 because the column has been defined as GENERATED ALWAYS. In the second example, no OVERRIDING 条項 is 要求するd for the 挿入する into (米)棚上げする/(英)提議する t2 as its id column is defined as GENERATED BY DEFAULT. In both examples, if there is an 存在するing 列/漕ぐ/騒動 with that value as 最初の/主要な 重要な, a 強制 違反 exception is thrown.

 INSERT INTO t1 (id, 指名する) OVERRIDING SYSTEM VALUE VALUES ( 14, '実験(する) Value')
 INSERT INTO t2 (id, 指名する) VALUES ( 14, '実験(する) Value')

In the examples below, OVERRIDING USER VALUE is used to let the system 生成する values for the id column. The 生成するd values 無視/無効 the value 14 in the first example, and the 存在するing values for the id column in the (米)棚上げする/(英)提議する in the second example.

 INSERT INTO t1 (id, 指名する) OVERRIDING USER VALUE VALUES ( 14, 'Another 実験(する) Value')
 INSERT INTO t1 (id, 指名する) OVERRIDING USER VALUE (SELECT * FROM t1)

An array can be 挿入するd into a column of the array type by using literals, by 明示するing a parameter in a 用意が出来ている 声明, or by an 存在するing array returned by a query 表現. The last example below 挿入するs an array.

The 列/漕ぐ/騒動s that are 挿入するd into the (米)棚上げする/(英)提議する are checked against all the 強制s that have been 宣言するd on the (米)棚上げする/(英)提議する. The whole INSERT 操作/手術 fails if any 列/漕ぐ/騒動 fails to 挿入するd 予定 to 強制 違反. Examples:

 CREATE TABLE T (A INTEGER GENERATED BY DEFAULT AS IDENTITY, B INTEGER DEFAULT 2)
 INSERT INTO T DEFAULT VALUES /* all columns of T have DEFAULT 条項s */
 INSERT INTO T (SELECT * FROM Z) /* (米)棚上げする/(英)提議する Z has the same columns as (米)棚上げする/(英)提議する T */
 INSERT INTO T (A,B) VALUES ((1,2),(3,NULL), (DEFAULT,6)) /* three 列/漕ぐ/騒動s are 挿入するd into (米)棚上げする/(英)提議する T */
 ALTER TABLE T ADD COLUMN D VARCHAR(10) ARRAY /* an ARRAY column is 追加するd */
 INSERT INTO T VALUES DEFAULT, 3, ARRAY['hot','冷淡な']

If the (米)棚上げする/(英)提議する 含む/封じ込めるs an IDENTITY column, the value for this column for the last 列/漕ぐ/騒動 挿入するd by a 開会/開廷/会期 can be retrieved using a call to the IDENTITY() 機能(する)/行事. This call returns the last value 挿入するd by the calling 開会/開廷/会期. When the 挿入する 声明 is 遂行する/発効させるd with a JDBC 声明 or PreparedStatement method, the getGeneratedKeys() method of 声明 can be used to retrieve not only the IDENTITY column, but also any GENERATED 計算するd column, or any other column. The getGeneratedKeys() returns a ResultSet with one or more columns. This 含む/封じ込めるs one 列/漕ぐ/騒動 per 挿入するd 列/漕ぐ/騒動, and can therefore return all the 生成するd columns for a multi-列/漕ぐ/騒動 挿入する.

There are three methods of 明示するing which 生成するd 重要なs should be returned. The first method does not 明示する the columns of the (米)棚上げする/(英)提議する. With this method, the returned ResultSet will have a column for each column of the (米)棚上げする/(英)提議する that is defined as GENERATED ... AS IDENTITY or GENERATED ... AS (<表現>). The two other methods 要求する the 使用者 to 明示する which columns should be returned, either by column 索引s, or by column 指名するs. With these methods, there is no 制限 on which columns of the 挿入するd values to be returned. This is 特に useful when some columns have a default 条項 which is a 機能(する)/行事, or when there are BEFORE 誘発する/引き起こすs on the (米)棚上げする/(英)提議する that may 供給する the 挿入するd value for some of the columns.

In MySQL syntax compatibility 方式, HyperSQL supports INSERT IGNORE, REPLACE and ON DUPLICATE KEY UPDATE variations of the INSERT 声明.

Update 声明

UPDATE

update 声明: searched

<update 声明: searched> ::= UPDATE <的 (米)棚上げする/(英)提議する> [ [ AS ] <correlation 指名する> ] SET <始める,決める 条項 名簿(に載せる)/表(にあげる)> [ WHERE <search 条件> ][ LIMIT <fetch first 列/漕ぐ/騒動 count> ]

Update 列/漕ぐ/騒動s of a (米)棚上げする/(英)提議する. An UPDATE 声明 selects 列/漕ぐ/騒動s from the <的 (米)棚上げする/(英)提議する> using an implicit SELECT 声明 formed in the に引き続いて manner:

SELECT * FROM <的 (米)棚上げする/(英)提議する> [ [ AS ] <correlation 指名する> ] [ WHERE <search 条件> ]

Then it 適用するs the SET <始める,決める 条項 名簿(に載せる)/表(にあげる)> 表現 to each selected 列/漕ぐ/騒動.

If the implicit SELECT returns no 列/漕ぐ/騒動s, no update takes place. When used in JDBC, the number of 列/漕ぐ/騒動s returned by the implicit SELECT is returned as the update count.

If there are FOREIGN KEY 強制s on other (米)棚上げする/(英)提議するs that 言及/関連 the 支配する (米)棚上げする/(英)提議する, and the FOREIGN KEY 強制s have referential 活動/戦闘s, then 列/漕ぐ/騒動s from those other (米)棚上げする/(英)提議するs that 言及/関連 the updated 列/漕ぐ/騒動s are updated, によれば the 明示するd referential 活動/戦闘s.

The 列/漕ぐ/騒動s that are updated are checked against all the 強制s that have been 宣言するd on the (米)棚上げする/(英)提議する. The whole UPDATE 操作/手術 fails if any 列/漕ぐ/騒動 侵害する/違反するs any 強制.

The LIMIT 条項, or alternatively the ROWNUM() 機能(する)/行事 in the WHERE 条項, can be used to 限界 the number of 列/漕ぐ/騒動s that are updated. This is useful when a very large number of 列/漕ぐ/騒動s needs to be updated. In this 状況/情勢, you can 成し遂げる the 操作/手術 is chunks and commit after each chunk to 減ずる memory usage and the total time of the 操作/手術.

始める,決める 条項 名簿(に載せる)/表(にあげる)

始める,決める 条項 名簿(に載せる)/表(にあげる)

<始める,決める 条項 名簿(に載せる)/表(にあげる)> ::= <始める,決める 条項> [ { <comma> <始める,決める 条項> }... ]

<始める,決める 条項> ::= <多重の column assignment> | <始める,決める 的> <equals 操作者> <update source>

<多重の column assignment> ::= <始める,決める 的 名簿(に載せる)/表(にあげる)> <equals 操作者> <割り当てるd 列/漕ぐ/騒動>

<始める,決める 的 名簿(に載せる)/表(にあげる)> ::= <left paren> <始める,決める 的> [ { <comma> <始める,決める 的> }... ] <権利 paren>

<割り当てるd 列/漕ぐ/騒動> ::= <contextually typed 列/漕ぐ/騒動 value 表現>

<始める,決める 的> ::= <column 指名する>

<update source> ::= <value 表現> | <contextually typed value specification>

明示する a 名簿(に載せる)/表(にあげる) of assignments. This is used in UPDATE, MERGE and SET 声明s to 割り当てる values to a scalar or 列/漕ぐ/騒動 的.

Apart from setting a whole 的 to a value, a SET 声明 can 始める,決める individual elements of an array to new values. The last example below shows this form of assignment to the array in the column 指名するd B.

In the examples given below, UPDATE 声明s with 選び出す/独身 and 多重の assignments are shown. 公式文書,認める in the third example, a SELECT 声明 is used to 供給する the update values for columns A and C, while the update value for column B is given 分かれて. The SELECT 声明 must return 正確に/まさに one 列/漕ぐ/騒動 . In this example the SELECT 声明 言及するs to the 存在するing value for column C in its search 条件.

 UPDATE T SET A = 5 WHERE ...
 UPDATE T SET (A, B) = (1, NULL) WHERE ...
 UPDATE T SET (A, C) = (SELECT X, Y FROM U WHERE Z = C), B = 10 WHERE ...
 UPDATE T SET A = 3, B[3] = 'warm'

合併する 声明

MERGE INTO

合併する 声明

<合併する 声明> ::= MERGE INTO <的 (米)棚上げする/(英)提議する> [ [ AS ] <合併する correlation 指名する> ] USING <(米)棚上げする/(英)提議する 言及/関連> ON <search 条件> <合併する 操作/手術 specification>

<合併する correlation 指名する> ::= <correlation 指名する>

<合併する 操作/手術 specification> ::= <合併する when 条項>...

<合併する when 条項> ::= <合併する when matched 条項> | <合併する when not matched 条項>

<合併する when matched 条項> ::= WHEN MATCHED [ AND <search 条件> ] THEN <合併する update or 削除する specification>

<合併する update or 削除する specification> ::= <合併する update specification> | <合併する 削除する specification>

<合併する when not matched 条項> ::= WHEN NOT MATCHED [ AND <search 条件> ] THEN <合併する 挿入する specification>

<合併する update specification> ::= UPDATE SET <始める,決める 条項 名簿(に載せる)/表(にあげる)>

<合併する 削除する specification> ::= DELETE

<合併する 挿入する specification> ::= INSERT [ <left paren> <挿入する column 名簿(に載せる)/表(にあげる)> <権利 paren> ] [ <無視/無効 条項> ] VALUES <合併する 挿入する value 名簿(に載せる)/表(にあげる)>

<合併する 挿入する value 名簿(に載せる)/表(にあげる)> ::= <left paren> <合併する 挿入する value element> [ { <comma> <合併する 挿入する value element> }... ] <権利 paren>

<合併する 挿入する value element> ::= <value 表現> | <contextually typed value specification>

Update 列/漕ぐ/騒動s, 削除する 列/漕ぐ/騒動s or 挿入する new 列/漕ぐ/騒動s into the <的 (米)棚上げする/(英)提議する>. The MERGE 声明 uses a second (米)棚上げする/(英)提議する, 明示するd by <(米)棚上げする/(英)提議する 言及/関連>, to 決定する the 列/漕ぐ/騒動s to be updated or 挿入するd. It is possible to use the 声明 only to update 列/漕ぐ/騒動s, to 削除する 列/漕ぐ/騒動s or to 挿入する 列/漕ぐ/騒動s, but usually both update and 挿入する are 明示するd.

The <search 条件> matches each 列/漕ぐ/騒動 of the <(米)棚上げする/(英)提議する 言及/関連> with each 列/漕ぐ/騒動 of the <的 (米)棚上げする/(英)提議する>. If the two 列/漕ぐ/騒動s match then the UPDATE 条項 is used to update the matching 列/漕ぐ/騒動 of the 的 (米)棚上げする/(英)提議する. Those 列/漕ぐ/騒動s of <(米)棚上げする/(英)提議する 言及/関連> that have no matching 列/漕ぐ/騒動s are then used to 挿入する new 列/漕ぐ/騒動s into the <的 (米)棚上げする/(英)提議する>. Therefore, a MERGE 声明 can update or 削除する between 0 and all the 列/漕ぐ/騒動s of the <的 (米)棚上げする/(英)提議する> and can 挿入する between 0 and the number of the 列/漕ぐ/騒動s in <(米)棚上げする/(英)提議する 言及/関連> into the <的 (米)棚上げする/(英)提議する>. If any 列/漕ぐ/騒動 in the <的 (米)棚上げする/(英)提議する> matches more than one 列/漕ぐ/騒動 in <(米)棚上げする/(英)提議する 言及/関連> a cardinality error is raised. On the other 手渡す, several 列/漕ぐ/騒動s in the <的 (米)棚上げする/(英)提議する> can match a 選び出す/独身 列/漕ぐ/騒動 in <(米)棚上げする/(英)提議する 言及/関連> without any error. The 強制s and referential 活動/戦闘s 明示するd on the database (米)棚上げする/(英)提議するs are 施行するd the same way as for an update, a 削除する and an 挿入する 声明.

The optional <search 条件> in each WHEN 条項 can be used to filter (減ずる) the 列/漕ぐ/騒動s for the particular 活動/戦闘.

HyperSQL 許すs only one UPDATE, INSERT or DELETE 操作/手術 in a MERGE 声明. If both UPDATE and DELETE are used, the 操作/手術s are 成し遂げるd in the order they appear in the MERGE 声明. If the search 条件s of both 操作/手術s 適用する to the same 列/漕ぐ/騒動, only the first 操作/手術 is 成し遂げるd.

The MERGE 声明 can be used with only the WHEN NOT MATCHED 条項 as a 条件付きの INSERT 声明 that 挿入するs a 列/漕ぐ/騒動 if no 存在するing 列/漕ぐ/騒動s match a 条件.

In the first example below, the (米)棚上げする/(英)提議する 初めは 含む/封じ込めるs two 列/漕ぐ/騒動s for different furniture. The <(米)棚上げする/(英)提議する 言及/関連> is the (VALUES(1, '会議/協議会 (米)棚上げする/(英)提議する'), (14, 'sofa'), (5, 'coffee (米)棚上げする/(英)提議する')) 表現, which 評価するs to a (米)棚上げする/(英)提議する with 3 列/漕ぐ/騒動s. When the x value for a 列/漕ぐ/騒動 matches an 存在するing 列/漕ぐ/騒動, then the 存在するing 列/漕ぐ/騒動 is updated. When the x value does not match, the 列/漕ぐ/騒動 is 挿入するd. Therefore one 列/漕ぐ/騒動 of (米)棚上げする/(英)提議する t is updated from 'dining (米)棚上げする/(英)提議する' to '会議/協議会 (米)棚上げする/(英)提議する', and two 列/漕ぐ/騒動s are 挿入するd into (米)棚上げする/(英)提議する t.

The second example uses a SELECT 声明 as the source of the values for the MERGE.

In the third example, a new 列/漕ぐ/騒動 in 挿入するd into the (米)棚上げする/(英)提議する only when the 最初の/主要な 重要な for the new 列/漕ぐ/騒動 does not 存在する. This example uses parameters and should be 遂行する/発効させるd as a JDBC PreparedStatement. The parameter is cast as INTEGER because the MERGE 声明 does not 決定する the types of values in the USING 条項.

In the fourth example, 存在するing 列/漕ぐ/騒動s that match are 削除するd.

 CREATE TABLE t (id INT PRIMARY KEY, description VARCHAR(100))
 INSERT INTO t VALUES (1, 'dining (米)棚上げする/(英)提議する'), (2, 'deck 議長,司会を務める')

 MERGE INTO t USING (VALUES(1, '会議/協議会 (米)棚上げする/(英)提議する'), (14, 'sofa'), (5, 'coffee (米)棚上げする/(英)提議する')) 
   AS vals(x,y) ON t.id = vals.x
   WHEN MATCHED THEN UPDATE SET t.description = vals.y
   WHEN NOT MATCHED THEN INSERT VALUES vals.x, vals.y

 MERGE INTO t USING (SELECT * FROM tt WHERE acol = 2) AS vals(x,y) ON t.id = vals.x
   WHEN MATCHED THEN UPDATE SET t.description = vals.y
   WHEN NOT MATCHED THEN INSERT VALUES vals.x, vals.y

 MERGE INTO t USING (VALUES(CAST(? AS INT))) AS vals(x) ON t.id = vals.x
   WHEN NOT MATCHED THEN INSERT VALUES vals.x, ?

 MERGE INTO t USING (SELECT * FROM tt WHERE acol = 2) AS vals(x,y) ON t.id = vals.x
   WHEN MATCHED THEN DELETE
   WHEN NOT MATCHED THEN INSERT VALUES vals.x, vals.y

Diagnostics and 明言する/公表する

HyperSQL supports some SQL 声明s, 表現s, 機能(する)/行事s, and Java methods that 報告(する)/憶測 on the most recently 遂行する/発効させるd 声明.

The IDENTITY() 機能(する)/行事 returns the last 挿入するd 身元 value for the 現在の 開会/開廷/会期.

The GET DIAGNOSTICS 声明 is supported to a 限られた/立憲的な extent. The built-in 機能(する)/行事 DIAGNOSTICS() is an 代案/選択肢. These are 普通は used in SQL/PSM 決まりきった仕事s to check the result of the last data update 操作/手術.

GET DIAGNOSTICS

get diagnostics 声明

<get diagnostics 声明> ::= GET DIAGNOSTICS <simple 的 value specification> = ROW_COUNT

The <simple 的 value specification> is a 開会/開廷/会期 variable, or a 決まりきった仕事 variable or OUT parameter.

The keyword ROW_COUNT 明示するs the 列/漕ぐ/騒動 count returned by the last 遂行する/発効させるd 声明. For INSERT, UPDATE, DELETE and MERGE 声明s, this is the number of 列/漕ぐ/騒動s 影響する/感情d by the 声明. This is the same value as returned by JDBC executeUpdate() methods. For all other 声明s, 無 is returned.

The value of ROW_COUNT is 蓄える/店d in the 明示するd 的.

This 声明 is often used in CREATE PROCEDURE 声明s.

In 未来 見解/翻訳/版s, more 選択s will be supported for diagnostics values.


$Revision: 6787 $