db-tutorial/docs/h2.md

424 lines
14 KiB
Markdown
Raw Normal View History

2018-05-08 11:31:04 +08:00
---
title: H2 数据库
date: 2015/01/11
categories:
- database
tags:
- database
- sql
---
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
# H2 数据库
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
<!-- TOC depthFrom:2 depthTo:2 -->
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
- [概述](#概述)
- [使用说明](#使用说明)
- [Spring 整合 H2](#spring-整合-h2)
- [h2 sql 语法](#h2-sql-语法)
- [数据类型](#数据类型)
- [集群](#集群)
- [参考资料](#参考资料)
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
<!-- /TOC -->
## 概述
H2 是一个开源的嵌入式数据库引擎,采用 java 语言编写,不受平台的限制。同时 H2 提供了一个十分方便的 web 控制台用于操作和管理数据库内容。H2 还提供兼容模式,可以兼容一些主流的数据库,因此采用 H2 作为开发期的数据库非常方便。
## 使用说明
### 安装
maven 中添加依赖
2018-01-11 13:48:58 +08:00
```xml
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
</dependency>
```
2018-05-08 11:31:04 +08:00
### 运行方式
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
1. **在内存中运行**
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
数据库只在内存中运行,关闭连接后数据库将被清空,适合测试环境
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
连接字符串:`jdbc:h2:mem:DBName;DB_CLOSE_DELAY=-1`
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
如果不指定 DBName则以私有方式启动只允许一个连接。
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
2. **嵌入式**
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
数据库持久化存储为单个文件。
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
连接字符串:`~/.h2/DBName`表示数据库文件的存储位置,如果第一次连接则会自动创建数据库。
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
3. **服务模式**
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
H2 支持三种服务模式:
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
* web server此种运行方式支持使用浏览器访问 H2 Console
* TCP server支持客户端/服务器端的连接方式
* PG server支持 PostgreSQL 客户端
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
启动 tcp 服务连接字符串示例:
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```
jdbc:h2:tcp://localhost/~/test 使用用户主目录
jdbc:h2:tcp://localhost//data/test 使用绝对路径
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
4. **连接字符串参数**
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
* DB_CLOSE_DELAY要求最后一个正在连接的连接断开后不要关闭数据库
* MODE=MySQL兼容模式H2 兼容多种数据库该值可以为DB2、Derby、HSQLDB、MSSQLServer、MySQL、Oracle、PostgreSQL
* AUTO_RECONNECT=TRUE连接丢失后自动重新连接
* AUTO_SERVER=TRUE启动自动混合模式允许开启多个连接该参数不支持在内存中运行模式
* TRACE_LEVEL_SYSTEM_OUT、TRACE_LEVEL_FILE输出跟踪日志到控制台或文件 取值 0 为 OFF1 为 ERROR默认值2 为 INFO3 为 DEBUG
* SET TRACE_MAX_FILE_SIZE mb设置跟踪日志文件的大小默认为 16M
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
5. **启动服务模式**,打开 H2 Console web 页面
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
启动服务,在命令行中执行
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```shell
java -cp h2*.jar org.h2.tools.Server
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
执行如下命令,获取选项列表及默认值
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```shell
java -cp h2*.jar org.h2.tools.Server -?
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
常见的选项如下:
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
* -web启动支持 H2 Console 的服务
* -webPort <port>:服务启动端口,默认为 8082
* -browser启动 H2 Console web 管理页面
* -tcp使用 TCP server 模式启动
* -pg使用 PG server 模式启动
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
6. **maven 方式**
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
此外,使用 maven 也可以启动 H2 服务。添加以下插件
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.h2.tools.Server</mainClass>
<arguments>
<argument>-web</argument>
<argument>-webPort</argument>
<argument>8090</argument>
<argument>-browser</argument>
</arguments>
</configuration>
</plugin>
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
在命令行中执行如下命令启动 H2 Console
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```shell
mvn exec:java
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
或者建立一个 bat 文件
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```shell
@echo off
call mvn exec:java
pause
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
此操作相当于执行了如下命令:
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```shell
java -jar h2-1.3.168.jar -web -webPort 8090 -browser
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
## Spring 整合 H2
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
1. 添加依赖
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
```xml
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
</dependency>
```
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
2. spring 配置
2018-01-11 13:48:58 +08:00
```xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
<!--配置数据源-->
<bean id="dataSource" class="org.h2.jdbcx.JdbcConnectionPool"
destroy-method="dispose">
<constructor-arg>
<bean class="org.h2.jdbcx.JdbcDataSource">
<!-- 内存模式 -->
<property name="URL" value="jdbc:h2:mem:test"/>
<!-- 文件模式 -->
<!-- <property name="URL" value="jdbc:h2:testRestDB" /> -->
<property name="user" value="root"/>
<property name="password" value="root"/>
</bean>
</constructor-arg>
</bean>
<!-- JDBC模板 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
<bean id="myJdbcTemplate" class="org.zp.notes.spring.jdbc.MyJdbcTemplate">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean>
<!-- 初始化数据表结构 -->
<jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
<jdbc:script location="classpath:sql/h2/create_table_student.sql"/>
</jdbc:initialize-database>
</beans>
```
2018-05-08 11:31:04 +08:00
## h2 sql 语法
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
### SELECT
2018-01-11 13:48:58 +08:00
![SELECT](http://upload-images.jianshu.io/upload_images/3101171-a3f90c0d1f1f3437.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### INSERT
2018-01-11 13:48:58 +08:00
![INSERT](http://upload-images.jianshu.io/upload_images/3101171-6a92ae4362c3468a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### UPDATE
2018-01-11 13:48:58 +08:00
![UPDATE](http://upload-images.jianshu.io/upload_images/3101171-dddf0e26995d46c3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### DELETE
2018-01-11 13:48:58 +08:00
![DELETE](http://upload-images.jianshu.io/upload_images/3101171-96e72023445a6fd6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### BACKUP
2018-01-11 13:48:58 +08:00
![BACKUP](http://upload-images.jianshu.io/upload_images/3101171-6267894d24fab47f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### EXPLAIN
2018-01-11 13:48:58 +08:00
![EXPLAIN](http://upload-images.jianshu.io/upload_images/3101171-bbed6bb69f998b7a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
7、MERGE
![](http://upload-images.jianshu.io/upload_images/3101171-bd021648431d12a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### RUNSCRIPT
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
运行 sql 脚本文件
2018-01-11 13:48:58 +08:00
![RUNSCRIPT](http://upload-images.jianshu.io/upload_images/3101171-d6fe03eff0037e14.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### SCRIPT
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
根据数据库创建 sql 脚本
2018-01-11 13:48:58 +08:00
![SCRIPT](http://upload-images.jianshu.io/upload_images/3101171-9ba7547ab8bcaeab.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### SHOW
2018-01-11 13:48:58 +08:00
![SHOW](http://upload-images.jianshu.io/upload_images/3101171-67449c6cc5cbb8c1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### ALTER
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
#### ALTER INDEX RENAME
2018-01-11 13:48:58 +08:00
![ALTER INDEX RENAME](http://upload-images.jianshu.io/upload_images/3101171-230bd3f97e185d2f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### ALTER SCHEMA RENAME
2018-01-11 13:48:58 +08:00
![ALTER SCHEMA RENAME](http://upload-images.jianshu.io/upload_images/3101171-797a028938e46ba3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### ALTER SEQUENCE
2018-01-11 13:48:58 +08:00
![ALTER SEQUENCE](http://upload-images.jianshu.io/upload_images/3101171-46f343da1b6c6a29.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### ALTER TABLE
2018-01-11 13:48:58 +08:00
![ALTER TABLE](http://upload-images.jianshu.io/upload_images/3101171-7e146a4010f2f357.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
##### 增加约束
2018-01-11 13:48:58 +08:00
![增加约束](http://upload-images.jianshu.io/upload_images/3101171-4e5605a9c87a79cb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
##### 修改列
2018-01-11 13:48:58 +08:00
![修改列](http://upload-images.jianshu.io/upload_images/3101171-fbc1358c553e6614.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
##### 删除列
2018-01-11 13:48:58 +08:00
![删除列](http://upload-images.jianshu.io/upload_images/3101171-dc3b897413700981.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
##### 删除序列
2018-01-11 13:48:58 +08:00
![删除序列](http://upload-images.jianshu.io/upload_images/3101171-ec83899cb8724966.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### ALTER USER
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
##### 修改用户名
2018-01-11 13:48:58 +08:00
![修改用户名](http://upload-images.jianshu.io/upload_images/3101171-a1e429c0d8ece66c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
##### 修改用户密码
2018-01-11 13:48:58 +08:00
![修改用户密码](http://upload-images.jianshu.io/upload_images/3101171-5b86f98796606e54.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### ALTER VIEW
2018-01-11 13:48:58 +08:00
![ALTER VIEW](http://upload-images.jianshu.io/upload_images/3101171-8832ecbc2db63a13.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### COMMENT
2018-01-11 13:48:58 +08:00
![COMMENT](http://upload-images.jianshu.io/upload_images/3101171-467ce031883f0020.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE CONSTANT
2018-01-11 13:48:58 +08:00
![CREATE CONSTANT](http://upload-images.jianshu.io/upload_images/3101171-1231c83563bfec9c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE INDEX
2018-01-11 13:48:58 +08:00
![CREATE INDEX](http://upload-images.jianshu.io/upload_images/3101171-d66d59bd7803d5c1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE ROLE
2018-01-11 13:48:58 +08:00
![CREATE ROLE](http://upload-images.jianshu.io/upload_images/3101171-7df1dee098e1127b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE SCHEMA
2018-01-11 13:48:58 +08:00
![CREATE SCHEMA](http://upload-images.jianshu.io/upload_images/3101171-c485123c62c0866e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE SEQUENCE
2018-01-11 13:48:58 +08:00
![CREATE SEQUENCE](http://upload-images.jianshu.io/upload_images/3101171-cc25860776d361ae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE TABLE
2018-01-11 13:48:58 +08:00
![CREATE TABLE](http://upload-images.jianshu.io/upload_images/3101171-36ffc66327df8b5b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE TRIGGER
2018-01-11 13:48:58 +08:00
![CREATE TRIGGER](http://upload-images.jianshu.io/upload_images/3101171-9a7bfa4425281213.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE USER
2018-01-11 13:48:58 +08:00
![CREATE USER](http://upload-images.jianshu.io/upload_images/3101171-a1e45e308be6dac3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### CREATE VIEW
2018-01-11 13:48:58 +08:00
![CREATE VIEW](http://upload-images.jianshu.io/upload_images/3101171-45c4cd516fd36611.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### DROP
2018-01-11 13:48:58 +08:00
![DROP](http://upload-images.jianshu.io/upload_images/3101171-52a3562d76411811.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### GRANT RIGHT
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
给 schema 授权授权
2018-01-11 13:48:58 +08:00
![授权](http://upload-images.jianshu.io/upload_images/3101171-750e96ceff00c4ee.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
给 schema 授权给 schema 授权
2018-01-11 13:48:58 +08:00
![给schema授权](http://upload-images.jianshu.io/upload_images/3101171-22cfd65c2ff1eea5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### 复制角色的权限
2018-01-11 13:48:58 +08:00
![复制角色的权限](http://upload-images.jianshu.io/upload_images/3101171-6cba2f1585fd913b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### REVOKE RIGHT
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
#### 移除授权
2018-01-11 13:48:58 +08:00
![移除授权](http://upload-images.jianshu.io/upload_images/3101171-3f905669cbb331b7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### 移除角色具有的权限
2018-01-11 13:48:58 +08:00
![移除角色具有的权限](http://upload-images.jianshu.io/upload_images/3101171-af77f495222f1b30.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### ROLLBACK
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
#### 从某个还原点savepoint回滚
2018-01-11 13:48:58 +08:00
![](http://upload-images.jianshu.io/upload_images/3101171-c71a226ac4fff913.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### 回滚事务
2018-01-11 13:48:58 +08:00
![](http://upload-images.jianshu.io/upload_images/3101171-efb65c504c7d69c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
#### 创建 savepoint
2018-01-11 13:48:58 +08:00
![](http://upload-images.jianshu.io/upload_images/3101171-feefdc236d4b211d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
## 数据类型
2018-01-11 13:48:58 +08:00
![数据类型](http://upload-images.jianshu.io/upload_images/3101171-52296dd53249cdae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
### INT Type
2018-01-11 13:48:58 +08:00
![INT Type](http://upload-images.jianshu.io/upload_images/3101171-fe62e3d07eb93d11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2018-05-08 11:31:04 +08:00
## 集群
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
H2 支持两台服务器运行两个数据库成为集群,两个数据库互为备份,如果一个服务器失效,另一个服务器仍然可以工作。另外只有服务模式支持集群配置。
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
H2 可以通过 CreateCluster 工具创建集群,示例步骤如下(在在一台服务器上模拟两个数据库组成集群):
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
1. 创建目录
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
创建两个服务器工作的目录
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
2) 启动 tcp 服务
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
执行如下命令分别在 9101、9102 端口启动两个使用 tcp 服务模式的数据库
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
3. 使用 CreateCluster 工具创建集群
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
如果两个数据库不存在,该命令将会自动创建数据库。如果一个数据库失效,可以先删除坏的数据库文件,重新启动数据库,然后重新运行 CreateCluster 工具
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
4) 连接数据库现在可以使用如下连接字符串连接集群数据库
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
5) 监控集群**运行状态**
可以使用如下命令查看配置的集群服务器是否都在运行
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
6) 限制
H2 的集群并不支持针对事务的负载均衡,所以很多操作会使两个数据库产生不一致的结果
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
执行如下操作时请小心:
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
* 自动增长列和标识列不支持集群,当插入数据时,序列值需要手动创建不支持 SET AUTOCOMMIT FALSE 语句;
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
* 如果需要设置成为不自动提交,可以执行方法 Connection.setAutoCommit(false)
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
## 参考资料
2018-01-11 13:48:58 +08:00
2018-05-08 11:31:04 +08:00
[h2database 官网](http://www.h2database.com/html/main.html)