提交 37b58591 authored 作者: Thomas Mueller's avatar Thomas Mueller

Improve MODE documentation

上级 65c90c51
...@@ -121,7 +121,7 @@ Features ...@@ -121,7 +121,7 @@ Features
</li><li>Sequence and autoincrement columns, computed columns (can be used for function based indexes) </li><li>Sequence and autoincrement columns, computed columns (can be used for function based indexes)
</li><li>ORDER BY, GROUP BY, HAVING, UNION, LIMIT, TOP </li><li>ORDER BY, GROUP BY, HAVING, UNION, LIMIT, TOP
</li><li>Collation support, users, roles </li><li>Collation support, users, roles
</li><li>Compatibility modes for HSQLDB, MySQL and PostgreSQL </li><li>Compatibility modes for IBM DB2, Apache Derby, HSQLDB, MS SQL Server, MySQL, Oracle, and PostgreSQL.
</li></ul> </li></ul>
<h3>Security Features</h3> <h3>Security Features</h3>
...@@ -1036,34 +1036,26 @@ Not all features or differences of those databases are implemented. ...@@ -1036,34 +1036,26 @@ Not all features or differences of those databases are implemented.
Here is the list of currently supported modes and the difference to the regular mode: Here is the list of currently supported modes and the difference to the regular mode:
</p> </p>
<h3>PostgreSQL Compatibility Mode</h3> <h3>DB2 Compatibility Mode</h3>
<p> <p>
To use the PostgreSQL mode, use the database URL <code>jdbc:h2:~/test;MODE=PostgreSQL</code> To use the IBM DB2 mode, use the database URL <code>jdbc:h2:~/test;MODE=DB2</code>
or the SQL statement <code>SET MODE PostgreSQL</code>. or the SQL statement <code>SET MODE DB2</code>.
</p> </p>
<ul><li>Concatenation of a NULL with another value results in NULL. Usually, the NULL is treated as an empty <ul><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name
string if only one of the operators is NULL, and NULL is only returned if both values are NULL. and getTableName() returns null.
</li><li>When converting a floating point number to a integer, the fractional </li><li>Support for the syntax [OFFSET .. ROW] [FETCH ... ONLY]
digits should not be truncated, but the value should be rounded. as an alternative syntax for LIMIT .. OFFSET.
</li><li>The system columns 'CTID' and 'OID' should be supported.
</li><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name
and getTableName() returns null.
</li></ul> </li></ul>
<h3>MySQL Compatibility Mode</h3> <h3>Derby Compatibility Mode</h3>
<p> <p>
To use the MySQL mode, use the database URL <code>jdbc:h2:~/test;MODE=MySQL</code> To use the Apache Derby mode, use the database URL <code>jdbc:h2:~/test;MODE=Derby</code>
or the SQL statement <code>SET MODE MySQL</code>. or the SQL statement <code>SET MODE Derby</code>.
</p> </p>
<ul><li>When inserting data, if a column is defined to be NOT NULL and NULL is inserted, <ul><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name
then a 0 (or empty string, or the current timestamp for timestamp columns) value is used. and getTableName() returns null.
Usually, this operation is not allowed and an exception is thrown. </li><li>For unique indexes, NULL is distinct. That means only one row with NULL
</li><li>When converting a floating point number to a integer, the fractional in one of the columns is allowed.
digits should not be truncated, but the value should be rounded.
</li><li>The identifiers should be returned in lower case.
</li><li>Creating indexes in the CREATE TABLE statement should be supported.
</li><li>For aliased columns, ResultSetMetaData.getColumnName() and getTableName()
return the real column and table name.
</li></ul> </li></ul>
<h3>HSQLDB Compatibility Mode</h3> <h3>HSQLDB Compatibility Mode</h3>
...@@ -1071,15 +1063,14 @@ or the SQL statement <code>SET MODE MySQL</code>. ...@@ -1071,15 +1063,14 @@ or the SQL statement <code>SET MODE MySQL</code>.
To use the HSQLDB mode, use the database URL <code>jdbc:h2:~/test;MODE=HSQLDB</code> To use the HSQLDB mode, use the database URL <code>jdbc:h2:~/test;MODE=HSQLDB</code>
or the SQL statement <code>SET MODE HSQLDB</code>. or the SQL statement <code>SET MODE HSQLDB</code>.
</p> </p>
<ul><li>Concatenation of a NULL with another value results in NULL. Usually, the NULL is treated as an empty <ul><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name
string if only one of the operators is NULL, and NULL is only returned if both values are NULL. and getTableName() returns null.
</li><li>When converting the scale of decimal data, the number is only converted if the new scale is </li><li>When converting the scale of decimal data, the number is only converted if the new scale is
smaller then current scale. Usually, the scale is converted and 0s are added if required. smaller then current scale. Usually, the scale is converted and 0s are added if required.
</li><li>When using unique indexes, multiple rows with NULL in one of the columns </li><li>Concatenation of a NULL with another value results in NULL. Usually, the NULL is treated as an empty
are allowed by default. However many databases view NULL as distinct in string if only one of the operators is NULL, and NULL is only returned if both values are NULL.
this regard and only allow one row with NULL. </li><li>For unique indexes, NULL is distinct. That means only one row with NULL
</li><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name in one of the columns is allowed.
and getTableName() returns null.
</li></ul> </li></ul>
<h3>MS SQL Server Compatibility Mode</h3> <h3>MS SQL Server Compatibility Mode</h3>
...@@ -1087,24 +1078,25 @@ or the SQL statement <code>SET MODE HSQLDB</code>. ...@@ -1087,24 +1078,25 @@ or the SQL statement <code>SET MODE HSQLDB</code>.
To use the MS SQL Server mode, use the database URL <code>jdbc:h2:~/test;MODE=MSSQLServer</code> To use the MS SQL Server mode, use the database URL <code>jdbc:h2:~/test;MODE=MSSQLServer</code>
or the SQL statement <code>SET MODE MSSQLServer</code>. or the SQL statement <code>SET MODE MSSQLServer</code>.
</p> </p>
<ul><li>Identifiers may be quoted using square brackets as in [Test]. <ul><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name
</li><li>When using unique indexes, multiple rows with NULL in one of the columns and getTableName() returns null.
are allowed by default. However many databases view NULL as distinct in </li><li>Identifiers may be quoted using square brackets as in [Test].
this regard and only allow one row with NULL. </li><li>For unique indexes, NULL is distinct. That means only one row with NULL
</li><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name in one of the columns is allowed.
and getTableName() returns null.
</li></ul> </li></ul>
<h3>Derby Compatibility Mode</h3> <h3>MySQL Compatibility Mode</h3>
<p> <p>
To use the Derby mode, use the database URL <code>jdbc:h2:~/test;MODE=Derby</code> To use the MySQL mode, use the database URL <code>jdbc:h2:~/test;MODE=MySQL</code>
or the SQL statement <code>SET MODE Derby</code>. or the SQL statement <code>SET MODE MySQL</code>.
</p> </p>
<ul><li>When using unique indexes, multiple rows with NULL in one of the columns <ul><li>When inserting data, if a column is defined to be NOT NULL and NULL is inserted,
are allowed by default. However many databases view NULL as distinct in then a 0 (or empty string, or the current timestamp for timestamp columns) value is used.
this regard and only allow one row with NULL. Usually, this operation is not allowed and an exception is thrown.
</li><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name </li><li>Creating indexes in the CREATE TABLE statement should be supported.
and getTableName() returns null. </li><li>The identifiers should be returned in lower case.
</li><li>When converting a floating point number to a integer, the fractional
digits should not be truncated, but the value should be rounded.
</li></ul> </li></ul>
<h3>Oracle Compatibility Mode</h3> <h3>Oracle Compatibility Mode</h3>
...@@ -1112,11 +1104,25 @@ or the SQL statement <code>SET MODE Derby</code>. ...@@ -1112,11 +1104,25 @@ or the SQL statement <code>SET MODE Derby</code>.
To use the Oracle mode, use the database URL <code>jdbc:h2:~/test;MODE=Oracle</code> To use the Oracle mode, use the database URL <code>jdbc:h2:~/test;MODE=Oracle</code>
or the SQL statement <code>SET MODE Oracle</code>. or the SQL statement <code>SET MODE Oracle</code>.
</p> </p>
<ul><li>When using unique indexes, multiple rows with NULL in one of the columns <ul><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name
are allowed by default. However many databases view NULL as distinct in and getTableName() returns null.
this regard and only allow one row with NULL. </li><li>When using unique indexes, multiple rows with NULL in all columns
</li><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name are allowed, however it is not allowed to have multiple rows with the
and getTableName() returns null. same values otherwise.
</li></ul>
<h3>PostgreSQL Compatibility Mode</h3>
<p>
To use the PostgreSQL mode, use the database URL <code>jdbc:h2:~/test;MODE=PostgreSQL</code>
or the SQL statement <code>SET MODE PostgreSQL</code>.
</p>
<ul><li>For aliased columns, ResultSetMetaData.getColumnName() returns the alias name
and getTableName() returns null.
</li><li>Concatenation of a NULL with another value results in NULL. Usually, the NULL is treated as an empty
string if only one of the operators is NULL, and NULL is only returned if both values are NULL.
</li><li>When converting a floating point number to a integer, the fractional
digits should not be truncated, but the value should be rounded.
</li><li>The system columns 'CTID' and 'OID' should be supported.
</li></ul> </li></ul>
<br /><a name="auto_reconnect"></a> <br /><a name="auto_reconnect"></a>
......
...@@ -27,11 +27,12 @@ public class Mode { ...@@ -27,11 +27,12 @@ public class Mode {
// Modes are also documented in the features section // Modes are also documented in the features section
/** /**
* Concatenation of a NULL with another value results in NULL. Usually, the * When enabled, aliased columns (as in SELECT ID AS I FROM TEST) return the
* NULL is treated as an empty string if only one of the operators is NULL, * alias (I in this case) in ResultSetMetaData.getColumnName() and 'null' in
* and NULL is only returned if both values are NULL. * getTableName(). If disabled, the real column name (ID in this case) and
* table name is returned.
*/ */
public boolean nullConcatIsNull; public boolean aliasColumnName;
/** /**
* When inserting data, if a column is defined to be NOT NULL and NULL is * When inserting data, if a column is defined to be NOT NULL and NULL is
...@@ -49,10 +50,9 @@ public class Mode { ...@@ -49,10 +50,9 @@ public class Mode {
public boolean convertOnlyToSmallerScale; public boolean convertOnlyToSmallerScale;
/** /**
* When converting a floating point number to a integer, the fractional * Creating indexes in the CREATE TABLE statement should be supported.
* digits should not be truncated, but the value should be rounded.
*/ */
public boolean roundWhenConvertToLong; public boolean indexDefinitionInCreateTable;
/** /**
* The identifiers should be returned in lower case. * The identifiers should be returned in lower case.
...@@ -60,14 +60,17 @@ public class Mode { ...@@ -60,14 +60,17 @@ public class Mode {
public boolean lowerCaseIdentifiers; public boolean lowerCaseIdentifiers;
/** /**
* Creating indexes in the CREATE TABLE statement should be supported. * Concatenation of a NULL with another value results in NULL. Usually, the
* NULL is treated as an empty string if only one of the operators is NULL,
* and NULL is only returned if both values are NULL.
*/ */
public boolean indexDefinitionInCreateTable; public boolean nullConcatIsNull;
/** /**
* The system columns 'CTID' and 'OID' should be supported. * When converting a floating point number to a integer, the fractional
* digits should not be truncated, but the value should be rounded.
*/ */
public boolean systemColumns; public boolean roundWhenConvertToLong;
/** /**
* Identifiers may be quoted using square brackets as in [Test]. * Identifiers may be quoted using square brackets as in [Test].
...@@ -75,32 +78,28 @@ public class Mode { ...@@ -75,32 +78,28 @@ public class Mode {
public boolean squareBracketQuotedNames; public boolean squareBracketQuotedNames;
/** /**
* When using unique indexes, multiple rows with NULL in one of the columns * Support for the syntax [OFFSET .. ROW] [FETCH ... ONLY]
* are allowed by default. However many databases view NULL as distinct in * as an alternative syntax for LIMIT .. OFFSET.
* this regard and only allow one row with NULL.
*/ */
public boolean uniqueIndexSingleNull; public boolean supportOffsetFetch;
/** /**
* When using unique indexes, multiple rows with NULL in all columns * The system columns 'CTID' and 'OID' should be supported.
* are allowed, however it is not allowed to have multiple rows with the
* same values otherwise. This is how Oracle works.
*/ */
public boolean uniqueIndexSingleNullExceptAllColumnsAreNull; public boolean systemColumns;
/** /**
* If the syntax [OFFSET .. ROW] [FETCH ... ONLY] should be supported. * For unique indexes, NULL is distinct. That means only one row with NULL
* This is an alternative syntax for LIMIT .. OFFSET. * in one of the columns is allowed.
*/ */
public boolean supportOffsetFetch; public boolean uniqueIndexSingleNull;
/** /**
* When enabled, aliased columns (as in SELECT ID AS I FROM TEST) return the * When using unique indexes, multiple rows with NULL in all columns
* alias (I in this case) in ResultSetMetaData.getColumnName() and 'null' in * are allowed, however it is not allowed to have multiple rows with the
* getTableName(). If disabled, the real column name (ID in this case) and * same values otherwise.
* table name is returned.
*/ */
public boolean aliasColumnName; public boolean uniqueIndexSingleNullExceptAllColumnsAreNull;
private String name; private String name;
...@@ -109,48 +108,47 @@ public class Mode { ...@@ -109,48 +108,47 @@ public class Mode {
mode.aliasColumnName = SysProperties.ALIAS_COLUMN_NAME; mode.aliasColumnName = SysProperties.ALIAS_COLUMN_NAME;
add(mode); add(mode);
mode = new Mode("PostgreSQL"); mode = new Mode("DB2");
mode.nullConcatIsNull = true;
mode.roundWhenConvertToLong = true;
mode.systemColumns = true;
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.supportOffsetFetch = true;
add(mode); add(mode);
mode = new Mode("MySQL"); mode = new Mode("Derby");
mode.convertInsertNullToZero = true; mode.aliasColumnName = true;
mode.roundWhenConvertToLong = true; mode.uniqueIndexSingleNull = true;
mode.lowerCaseIdentifiers = true;
mode.indexDefinitionInCreateTable = true;
add(mode); add(mode);
mode = new Mode("HSQLDB"); mode = new Mode("HSQLDB");
mode.nullConcatIsNull = true; mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true; mode.convertOnlyToSmallerScale = true;
mode.nullConcatIsNull = true;
mode.uniqueIndexSingleNull = true; mode.uniqueIndexSingleNull = true;
mode.aliasColumnName = true;
add(mode); add(mode);
mode = new Mode("MSSQLServer"); mode = new Mode("MSSQLServer");
mode.aliasColumnName = true;
mode.squareBracketQuotedNames = true; mode.squareBracketQuotedNames = true;
mode.uniqueIndexSingleNull = true; mode.uniqueIndexSingleNull = true;
mode.aliasColumnName = true;
add(mode); add(mode);
mode = new Mode("Derby"); mode = new Mode("MySQL");
mode.uniqueIndexSingleNull = true; mode.convertInsertNullToZero = true;
mode.aliasColumnName = true; mode.indexDefinitionInCreateTable = true;
mode.lowerCaseIdentifiers = true;
mode.roundWhenConvertToLong = true;
add(mode); add(mode);
mode = new Mode("Oracle"); mode = new Mode("Oracle");
mode.uniqueIndexSingleNullExceptAllColumnsAreNull = true;
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.uniqueIndexSingleNullExceptAllColumnsAreNull = true;
add(mode); add(mode);
mode = new Mode("DB2"); mode = new Mode("PostgreSQL");
mode.supportOffsetFetch = true;
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.nullConcatIsNull = true;
mode.roundWhenConvertToLong = true;
mode.systemColumns = true;
add(mode); add(mode);
} }
private Mode(String name) { private Mode(String name) {
......
...@@ -1044,9 +1044,11 @@ SET MAX_OPERATION_MEMORY 0 ...@@ -1044,9 +1044,11 @@ SET MAX_OPERATION_MEMORY 0
" "
"Commands (Other)","SET MODE"," "Commands (Other)","SET MODE","
SET MODE {REGULAR | HSQLDB | POSTGRESQL | MYSQL} SET MODE {REGULAR | DB2 | DERBY | HSQLDB |
MSSQLSERVER | MYSQL | ORACLE | POSTGRESQL}
"," ","
Changes to another database mode. Changes to another database compatibility mode.
For details, see Compatibility Modes in the feature section.
This setting is not persistent. This setting is not persistent.
Admin rights are required to execute this command. Admin rights are required to execute this command.
This setting can be appended to the database URL: jdbc:h2:test;MODE=MYSQL This setting can be appended to the database URL: jdbc:h2:test;MODE=MYSQL
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论