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

Improve MODE documentation

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