提交 19dad98c authored 作者: Thomas Mueller's avatar Thomas Mueller

Documentation

上级 f9a1f17c
......@@ -686,7 +686,7 @@ The schema name does not need to be specified when creating the trigger.
This command commits an open transaction in this connection.
","
CREATE TRIGGER TRIG_INS BEFORE INSERT ON TEST FOR EACH ROW CALL ""MyTrigger"";
CREATE TRIGGER TRIG_SRC BEFORE INSERT ON TEST AS $$org.h2.api.Trigger create(){ return new MyTrigger(""constructorParam""); } $$;
CREATE TRIGGER TRIG_SRC BEFORE INSERT ON TEST AS $$org.h2.api.Trigger create() { return new MyTrigger(""constructorParam""); } $$;
"
"Commands (DDL)","CREATE USER","
CREATE USER [ IF NOT EXISTS ] newUserName
......@@ -1068,7 +1068,8 @@ Depending on the virtual machine, the actual memory required may be higher.
This setting is persistent and affects all connections as there is only one cache per database.
Using a very small value (specially 0) will reduce performance a lot.
This setting only affects the database engine (the server in a client/server environment).
This setting only affects the database engine (the server in a client/server environment;
in embedded mode, the database engine is in the same process as the application).
It has no effect for in-memory databases.
Admin rights are required to execute this command, as it affects all connections.
......
......@@ -21,6 +21,8 @@ Advanced
Large Objects</a><br />
<a href="#linked_tables">
Linked Tables</a><br />
<a href="#spatial_features">
Spatial Features</a><br />
<a href="#recursive_queries">
Recursive Queries</a><br />
<a href="#updatable_views">
......@@ -211,11 +213,19 @@ For details, see the sample application <code>org.h2.samples.UpdatableView</code
<h2 id="transaction_isolation">Transaction Isolation</h2>
<p>
Transaction isolation is provided for all data manipulation language (DML) statements.
Most data definition language (DDL) statements commit the current transaction.
Please note that most data definition language (DDL) statements,
such as "create table", commit the current transaction.
See the <a href="grammar.html">Grammar</a> for details.
</p>
<p>
Transaction isolation is provided for all data manipulation language (DML) statements.
<p>
</p>
Please note MVCC is enabled in version 1.4.x by default, when using the MVStore.
In this case, table level locking is not used.
Instead, rows are locked for update, and read committed is used in all cases
(changing the isolation level has no effect).
<p>
This database supports the following transaction isolation levels:
</p>
<ul>
......@@ -1407,6 +1417,60 @@ one's annual risk of being hit by a meteorite is estimated to be one chance in 1
that means the probability is about 0.000'000'000'06.
</p>
<h2 id="spatial_features">Spatial Features</h2>
<p>
H2 supports the geometry data type and spatial indexes if
the <a href="http://tsusiatsoftware.net/jts/main.html">JTS Topology Suite</a>
is in the classpath.
To run the H2 Console tool with the JTS tool, you need to download the
<a href="http://search.maven.org/remotecontent?filepath=com/vividsolutions/jts/1.13/jts-1.13.jar">JTS 1.13 jar file</a>
and place it in the h2 bin directory. Then edit the <code>h2.sh</code> file as follows:
</p>
<pre>
#!/bin/sh
dir=$(dirname "$0")
java -cp "$dir/h2.jar:jts-1.13.jar:$H2DRIVERS:$CLASSPATH" org.h2.tools.Console "$@"
</pre>
<p>
Here is an example SQL script to create a table with a spatial column and index:
</p>
<pre>
CREATE TABLE GEOTABLE(GID SERIAL, THE_GEOM GEOMETRY);
INSERT INTO GEOTABLE(THE_GEOM) VALUES
('POINT(500 505)'),
('LINESTRING(550 551, 525 512, 565 566)'),
('POLYGON ((550 521, 580 540, 570 564, 512 566, 550 521))');
CREATE SPATIAL INDEX GEOTABLE_SPATIALINDEX ON GEOTABLE(THE_GEOM);
</pre>
<p>
To query the table using geometry envelope intersection,
use the operation <code>&&</code>, as in PostGIS:
</p>
<pre>
SELECT * FROM GEOTABLE
WHERE THE_GEOM && 'POLYGON ((490 490, 536 490, 536 515, 490 515, 490 490))';
</pre>
<p>
You can verify that the spatial index is used using the "explain plan" feature:
</p>
<pre>
EXPLAIN SELECT * FROM GEOTABLE
WHERE THE_GEOM && 'POLYGON ((490 490, 536 490, 536 515, 490 515, 490 490))';
-- Result
SELECT
GEOTABLE.GID,
GEOTABLE.THE_GEOM
FROM PUBLIC.GEOTABLE
/* PUBLIC.GEOTABLE_SPATIALINDEX:
THE_GEOM && 'POLYGON ((490 490, 536 490, 536 515, 490 515, 490 490))' */
WHERE INTERSECTS(THE_GEOM,
'POLYGON ((490 490, 536 490, 536 515, 490 515, 490 490))')
</pre>
<p>
For persistent databases, the spatial index is stored on disk;
for in-memory databases, the index is kept in memory.
</p>
<h2 id="recursive_queries">Recursive Queries</h2>
<p>
H2 has experimental support for recursive queries using so called "common table expressions" (CTE).
......
......@@ -32,7 +32,8 @@ Change Log
</li><li>In version 1.4.184, a bug was introduced that broke queries
that have both joins and wildcards, for example:
select * from dual join(select x from dual) on 1=1
</li><li>Issue 598: parser fails on timestamp "24:00:00.1234" - prevent the creation of out-of-range time values.
</li><li>Issue 598: parser fails on timestamp "24:00:00.1234" - prevent the creation of out-of-range time values.
</li><li>Allow declaring triggers as source code (like functions). Patch by Sylvain CUAZ.
</li></ul>
<h2>Version 1.4.185 Beta (2015-01-16)</h2>
......@@ -51,7 +52,6 @@ Change Log
the logic that cleared the flag could never be reached, resulting in performance degradation.
Reported by Alexander Nesterov.
</li><li>Issue 552: Implement BIT_AND and BIT_OR aggregate functions.
</li><li>Allow declaring triggers as source code (like functions). Patch by Sylvain CUAZ.
</li></ul>
<h2>Version 1.4.184 Beta (2014-12-19)</h2>
......
......@@ -97,7 +97,7 @@ Features
<h3>Additional Features</h3>
<ul>
<li>Disk based or in-memory databases and tables, read-only database support, temporary tables
</li><li>Transaction support (read committed and serializable transaction isolation), 2-phase-commit
</li><li>Transaction support (read committed), 2-phase-commit
</li><li>Multiple connections, table level locking
</li><li>Cost based optimizer, using a genetic algorithm for complex queries, zero-administration
</li><li>Scrollable and updatable result set support, large result set, external result sorting,
......@@ -863,7 +863,10 @@ access to the same connection, but other databases may not do this.
<h3>Locking, Lock-Timeout, Deadlocks</h3>
<p>
Unless <a href="advanced.html#mvcc">multi-version concurrency</a> is used,
Please note MVCC is enabled in version 1.4.x by default, when using the MVStore.
In this case, table level locking is not used.
If <a href="advanced.html#mvcc">multi-version concurrency</a> is not used,
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).
All locks are released when the transaction commits or rolls back.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论