提交 8ea55147 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 c5c20246
...@@ -858,6 +858,9 @@ need to wait. ...@@ -858,6 +858,9 @@ need to wait.
<p> <p>
The database uses table level locks to give each connection a consistent state of the data. The database uses table level locks to give each connection a consistent state of the data.
There are two kinds of locks: read locks (shared locks) and write locks (exclusive locks). There are two kinds of locks: read locks (shared locks) and write locks (exclusive locks).
All locks are released when the transaction commits or rolls back.
When using the default transaction isolation level 'read committed', read locks are already released after each statement.
</p><p>
If a connection wants to reads from a table, and there is no write lock on the table, If a connection wants to reads from a table, and there is no write lock on the table,
then a read lock is added to the table. If there is a write lock, then this connection waits then a read lock is added to the table. If there is a write lock, then this connection waits
for the other connection to release the lock. If a connection cannot get a lock for a specified time, for the other connection to release the lock. If a connection cannot get a lock for a specified time,
......
...@@ -197,6 +197,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -197,6 +197,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Feature matrix like in <a href="http://www.inetsoftware.de/products/jdbc/mssql/features/default.asp">i-net software</a>. </li><li>Feature matrix like in <a href="http://www.inetsoftware.de/products/jdbc/mssql/features/default.asp">i-net software</a>.
</li><li>Updatable result set on table without primary key or unique index </li><li>Updatable result set on table without primary key or unique index
</li><li>Use LinkedList instead of ArrayList where applicable </li><li>Use LinkedList instead of ArrayList where applicable
</li><li>Optimizer: use an index for IS NULL and IS NOT NULL (including linked tables).
ID IS NOT NULL could be converted to ID >= Integer.MIN_VALUE.
</li><li>Support % operator (modulo) </li><li>Support % operator (modulo)
</li><li>Support 1+'2'=3, '1'+'2'='12' (MS SQL Server compatibility) </li><li>Support 1+'2'=3, '1'+'2'='12' (MS SQL Server compatibility)
</li><li>Support nested transactions </li><li>Support nested transactions
...@@ -212,7 +214,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -212,7 +214,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Support parameterized views (similar to CSVREAD, but using just SQL for the definition) </li><li>Support parameterized views (similar to CSVREAD, but using just SQL for the definition)
</li><li>A way (JDBC driver) to map an URL (jdbc:h2map:c1) to a connection object </li><li>A way (JDBC driver) to map an URL (jdbc:h2map:c1) to a connection object
</li><li>Option for SCRIPT to only process one or a set of tables, and append to a file </li><li>Option for SCRIPT to only process one or a set of tables, and append to a file
</li><li>Support using a unique index for IS NULL (including linked tables)
</li><li>Support linked tables to the current database </li><li>Support linked tables to the current database
</li><li>Support dynamic linked schema (automatically adding/updating/removing tables) </li><li>Support dynamic linked schema (automatically adding/updating/removing tables)
</li><li>Compatibility with Derby: VALUES(1), (2); SELECT * FROM (VALUES (1), (2)) AS myTable(c1) </li><li>Compatibility with Derby: VALUES(1), (2); SELECT * FROM (VALUES (1), (2)) AS myTable(c1)
...@@ -415,6 +416,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -415,6 +416,8 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Connection pool: 'reset session' command (delete temp tables, rollback, autocommit true). </li><li>Connection pool: 'reset session' command (delete temp tables, rollback, autocommit true).
</li><li>Improve SQL documentation, see http://www.w3schools.com/sql/ </li><li>Improve SQL documentation, see http://www.w3schools.com/sql/
</li><li>MySQL compatibility: DatabaseMetaData.stores*() methods should return the same values. Test with SquirrelSQL. </li><li>MySQL compatibility: DatabaseMetaData.stores*() methods should return the same values. Test with SquirrelSQL.
</li><li>Support table partitioning.
</li><li>MS SQL Server compatibility: support DATEPART syntax.
</li></ul> </li></ul>
<h2>Not Planned</h2> <h2>Not Planned</h2>
......
...@@ -10,7 +10,7 @@ Initial Developer: H2 Group ...@@ -10,7 +10,7 @@ Initial Developer: H2 Group
H2 Database Engine H2 Database Engine
</title> </title>
<style type="text/css"> <style type="text/css">
td, input, select, textarea, body, code, pre, td, th { td, input, select, textarea, body, td, th {
font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif; font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif;
font-weight: normal; font-weight: normal;
} }
...@@ -20,21 +20,6 @@ h1, h2, h3, h4, h5 { ...@@ -20,21 +20,6 @@ h1, h2, h3, h4, h5 {
font-weight: bold; font-weight: bold;
} }
td, input, select, textarea, body, code, pre {
font-size: 9pt;
}
pre {
background-color: #ece9d8;
border: 1px solid rgb(172, 168, 153);
padding: 4px;
}
code {
background-color: #ece9d8;
padding: 0px 2px;
}
h1 { h1 {
background-color: #0000bb; background-color: #0000bb;
padding: 2px 4px 2px 4px; padding: 2px 4px 2px 4px;
...@@ -44,21 +29,28 @@ h1 { ...@@ -44,21 +29,28 @@ h1 {
} }
h2 { h2 {
font-size: 13pt;
}
h3 {
font-size: 10pt; font-size: 10pt;
} }
h4 { td, input, select, textarea, body, code, pre {
font-size: 9pt; font-size: 9pt;
} }
pre {
background-color: #ece9d8;
border: 1px solid rgb(172, 168, 153);
padding: 4px;
}
code {
background-color: #ece9d8;
padding: 0px 2px;
}
table { table {
background-color: #ffffff; background-color: #ffffff;
border-collapse: collapse; border-collapse: collapse;
border: 1px solid #aca899; border: 0px solid #aca899;
} }
th { th {
...@@ -72,104 +64,123 @@ td { ...@@ -72,104 +64,123 @@ td {
background-color: #ffffff; background-color: #ffffff;
text-align: left; text-align: left;
vertical-align: top; vertical-align: top;
border: 1px solid #aca899; border: 0px solid #aca899;
padding: 2px; padding: 2px;
} }
</style>
</head><body>
<h1>H2 Database Engine Cheat Sheet</h1>
<h2>Downloads</h2>
<a href="http://www.h2database.com/h2-setup-2009-04-10.exe">Windows Installer</a> -
<a href="http://www.h2database.com/h2-2009-04-10.zip">Zip</a> -
<a href="http://repo1.maven.org/maven2/com/h2database/h2/1.1.111/h2-1.1.111.jar">Jar</a>
<h2>Using H2</h2>
<ul><li>Add h2*.jar to the classpath (the only dependency is Java 1.4 or newer)
</li><li>JDBC driver class: <code>org.h2.Driver</code>
</li><li>Database URL: <code>jdbc:h2:~/test</code>
</li><li>A new database is automatically created if it does not exist
</li><li>Closing the last connection closes a database
</li><li>H2 is open source, free to use and distribute. See also license.
</li></ul>
<h2>Database URL Shortlist</h2>
<table>
<tr><td rowspan="3">Embedded</td>
<td>jdbc:h2:~/test</td><td>'test' in the current user home directory</td></tr>
<tr><td>jdbc:h2:/data/test</td><td>'test' in the directory /data/</td></tr>
<tr><td>jdbc:h2:test</td><td>'test' in the current working directory</td></tr>
<tr><td rowspan="2">In-Memory</td>
<td>jdbc:h2:mem:test</td><td>named; multiple connections within the same process</td></tr>
<tr><td>jdbc:h2:mem:</td><td>unnamed private database; only one connections</td></tr>
<tr><td rowspan="2">Server Mode</td> ul, ol {
<td>jdbc:h2:tcp://localhost/~/test</td><td>'test' in the current user home directory</td></tr> list-style-position: outside;
<tr><td>jdbc:h2:tcp://localhost//data/test</td><td>'test' in the directory /data/</td></tr> padding-left: 20px;
}
<tr><td>Compatibility</td> li {
<td>jdbc:h2:...;MODE=MySQL</td><td>or DB2, Derby, HSQLDB, MSSQLServer, Oracle, PostgreSQL</td></tr> margin-top: 2px;
}
<tr><td>Debug</td> </style>
<td>jdbc:...;TRACE_LEVEL_FILE=3</td><td>logs JDBC calls to test.trace.db</td></tr> </head><body>
</table>
<h2>H2 Console Tool</h2> <div style="width:660px; margin:0 auto;">
Start: double click the h2*.jar file, or run <code>java -jar h2*.jar</code>, <code>h2.bat</code> or <code>h2.sh</code>.
<h2>Maven</h2> <h1>H2 Database Engine Cheat Sheet</h1>
<pre> <div style="float:left; margin:5px; width:320px;">
&lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&gt;
&lt;artifactId&gt;h2&lt;/artifactId&gt;
&lt;version&gt;${version}&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<h2>Hibernate</h2>
Use the H2 or the HSQLDB dialect.
<h2>TopLink and Glassfish</h2> <h2>Using H2</h2>
Datasource Classname: org.h2.jdbcx.JdbcDataSource<br /> <ul><li>Download the
toplink.target-database: oracle.toplink.essentials.platform.database.H2Platform <a href="http://repo1.maven.org/maven2/com/h2database/h2/1.1.111/h2-1.1.111.jar">jar file</a>,
<a href="http://www.h2database.com/h2-setup-2009-04-10.exe">Windows installer</a>, or
<a href="http://www.h2database.com/h2-2009-04-10.zip">zip file</a>.
</li><li>To start the H2 Console tool, double click the jar file, or run <code>java -jar h2*.jar</code>, <code>h2.bat</code> or <code>h2.sh</code>.
</li><li>A new database is automatically created if it does not yet exist.
</li><li>Closing the last connection closes a database.
</li><li>H2 is open source, free to use and distribute.
</li></ul>
<h2>Connect using JDBC</h2> <h2>Database URLs</h2>
<p>
<b>Embedded</b><br />
<code>jdbc:h2:~/test</code> 'test' in the user home directory<br />
<code>jdbc:h2:/data/test</code> 'test' in the directory /data/<br />
<code>jdbc:h2:test</code> in the current(!) working dir<br />
</p><p>
<b>In-Memory</b><br />
<code>jdbc:h2:mem:test</code> multiple connections in one process<br />
<code>jdbc:h2:mem:</code> unnamed private database; one connection<br />
</p><p>
<b>Server Mode</b><br />
<code>jdbc:h2:tcp://localhost/~/test</code> user home dir<br />
<code>jdbc:h2:tcp://localhost//data/test</code> absolute dir<br />
</p><p>
<b>Settings</b><br />
<code>jdbc:h2:..;MODE=MySQL</code> compatibility (or HSQLDB,...)<br />
<code>jdbc:h2:..;TRACE_LEVEL_FILE=3</code> log to .trace.db<br />
<p>
<h2>Documentation</h2>
Reference:
<a href="http://www.h2database.com/html/grammar.html">SQL grammar</a>,
<a href="http://www.h2database.com/html/functions.html">functions</a>,
<a href="http://www.h2database.com/html/datatypes.html">data types</a>,
<a href="http://www.h2database.com/html/datatypes.html">tools</a>.
<br />
Features:
<a href="http://www.h2database.com/html/grammar.html">fulltext search</a>,
<a href="http://www.h2database.com/html/functions.html">database encryption</a>,
<a href="http://www.h2database.com/html/datatypes.html">read-only databases</a>
<a href="http://www.h2database.com/html/datatypes.html">(in a zip or jar file)</a>,
<a href="http://www.h2database.com/html/datatypes.html">CSV files</a>,
<br />
</div>
<div style="float:right; padding:5px; width:320px;">
<h2>Using the JDBC API</h2>
<pre> <pre>
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:~/test", "sa", ""); Connection conn = DriverManager.
getConnection("jdbc:h2:~/test");
conn.close(); conn.close();
</pre> </pre>
<h2>Connection Pool</h2> <h2>Connection Pool</h2>
<pre> <pre>
JdbcConnectionPool cp = JdbcConnectionPool.create("jdbc:h2:~/test", "sa", ""); import org.h2.jdbcx.JdbcConnectionPool;
Connection conn = cp.getConnection(); ... conn.close(); DataSource cp = JdbcConnectionPool.
cp.dispose(); create("jdbc:h2:~/test");
Connection conn = cp.getConnection();
conn.close(); cp.dispose();
</pre> </pre>
<h2>Start a Server</h2> <h2>Start a Server</h2>
<pre> <pre>
java -cp h2*.jar org.h2.tools.Server java -cp h2*.jar org.h2.tools.Server
</pre> </pre>
<h2>Reference</h2> <h2>Hibernate</h2>
<a href="http://www.h2database.com/html/grammar.html">SQL Grammar</a> In the file hibernate.cfg.xml, set:
(or run 'HELP &lt;command&gt;' in the H2 Console) - <pre>
<a href="http://www.h2database.com/html/functions.html">Functions</a> - &lt;property name="dialect"&gt;
<a href="http://www.h2database.com/html/datatypes.html">Data Types</a> org.hibernate.dialect.H2Dialect
&lt;/property&gt;
</pre>
As an alternative, use the HSQLDialect.
<h2>Maven</h2>
<pre>
&lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&gt;
&lt;artifactId&gt;h2&lt;/artifactId&gt;
&lt;version&gt;${version}&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<h2>Other Features</h2> <h2>TopLink and Glassfish</h2>
Fulltext search - Datasource Classname: org.h2.jdbcx.JdbcDataSource
Database Files Encryption - toplink.target-database: oracle.toplink.essentials.platform.database.H2Platform
Read Only Databases -
Read Only Databases in Zip or Jar File
<h2>Command Line Tools</h2> </div>
Backup - ChangeFileEncryption - Console - ConvertTraceFile - CreateCluster -
DeleteDbFiles - Recover - Restore - RunScript - Script - Server - Shell
<h2>Reading CSV files</h2> </div>
SELECT * FROM CSVREAD('test.csv');
</body></html> </body></html>
\ No newline at end of file
...@@ -26,7 +26,6 @@ function set(s) { ...@@ -26,7 +26,6 @@ function set(s) {
<h3>${text.helpImportantCommands}</h3> <h3>${text.helpImportantCommands}</h3>
<table> <table>
<tr><th>${text.helpIcon}</th><th>${text.helpAction}</th></tr>
<tr> <tr>
<td style="padding:0px"><img src="icon_help.gif" alt="${text.a.help}"/></td> <td style="padding:0px"><img src="icon_help.gif" alt="${text.a.help}"/></td>
<td style="vertical-align: middle;"> <td style="vertical-align: middle;">
...@@ -52,8 +51,9 @@ function set(s) { ...@@ -52,8 +51,9 @@ function set(s) {
</td> </td>
</tr> </tr>
</table> </table>
<h3>${text.helpSampleSQL}</h3> <h3>${text.helpSampleSQL}</h3>
<table><tr><th>${text.helpOperations}</th><th>${text.helpStatements}</th></tr> <table>
<tr><td><a href="javascript:set('DROP TABLE IF EXISTS TEST;\rCREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255));\rINSERT INTO TEST VALUES(1, \'Hello\');\rINSERT INTO TEST VALUES(2, \'World\');\rSELECT * FROM TEST ORDER BY ID;\rUPDATE TEST SET NAME=\'Hi\' WHERE ID=1;\rDELETE FROM TEST WHERE ID=2;');"> <tr><td><a href="javascript:set('DROP TABLE IF EXISTS TEST;\rCREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255));\rINSERT INTO TEST VALUES(1, \'Hello\');\rINSERT INTO TEST VALUES(2, \'World\');\rSELECT * FROM TEST ORDER BY ID;\rUPDATE TEST SET NAME=\'Hi\' WHERE ID=1;\rDELETE FROM TEST WHERE ID=2;');">
${text.helpDropTable}<br /> ${text.helpDropTable}<br />
${text.helpCreateTable}<br /> ${text.helpCreateTable}<br />
...@@ -73,7 +73,13 @@ function set(s) { ...@@ -73,7 +73,13 @@ function set(s) {
UPDATE TEST SET NAME='Hi' WHERE ID=1;<br /> UPDATE TEST SET NAME='Hi' WHERE ID=1;<br />
DELETE FROM TEST WHERE ID=2; DELETE FROM TEST WHERE ID=2;
</td></tr> </td></tr>
<tr><td><a href="javascript:set('HELP ');">
${text.a.help}
</a></td><td>
HELP ...
</td></tr>
</table> </table>
<h3>${text.helpAddDrivers}</h3> <h3>${text.helpAddDrivers}</h3>
<p> <p>
${text.helpAddDriversText} ${text.helpAddDriversText}
......
...@@ -290,12 +290,12 @@ java org.h2.test.TestAll timer ...@@ -290,12 +290,12 @@ java org.h2.test.TestAll timer
/* /*
disable page store files, move multi dimension tool what do other databases do when calling prepareStatement(null)
integrate grammar help or move to docs (except syntax) and execute(null)?
test case for running out of disk space (using a special file system) test case for running out of disk space (using a special file system)
test shell tool on windows with special characters, try with shell tool: document encoding problem. mac: use
java -Dfile.encoding=UTF-8 java -Dfile.encoding=UTF-8
auto-build: prepare release auto-build: prepare release
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论