日期:2014-05-16 浏览次数:20378 次
学习和部署 h2 database 算了, h2 database 是 hsqldb 的作者后来的又一力作 ,更好用,更高效
?
1.hsqldb 有如下功能:
?
核心:
??? HyperSQL RDBMS Engine (HSQLDB)
??? HyperSQL JDBC Driver
?
扩展:
??? Database Manager (GUI database access tool, with Swing and AWT versions)
??? Sql Tool (command line database access tool) - sqltool.jar
?
?
2.启动gui
?
方式a:
设置环境变量后
bat方式启动:
方式b:
双击hsqldb.jar,更爽
?
3.hsqldb三种数据保存方式:
->内存
->文件
->jar中
?
若file则生成这些文件:
test.properties 记录数据库设置
test.script 表定义和数据库对象的定义语句
test.log 记录数据库最近的日志和更改
test.data 缓存表中的数据
test.backup 对最近表中数据的备份
test.lobs
->test.lck用来记录数据库正在open
->当SHUTDOWN则移除test.log,
test.lck
?
4.若在window下,则在c盘下的对应路径创建数据库
Connection c = DriverManager.getConnection("jdbc:hsqldb:file:/opt/db/testdb", "SA", "123");
?
5.两个或许不同
Class.forName("org.hsqldb.jdbc.JDBCDriver" ); Class.forName("org.hsqldb.jdbcDriver" );
?
6.当最后一个连接关闭,则关闭数据库.[我也不太明白??]
jdbc:hsqldb:file:/opt/db/testdb;shutdown=true
?
7.
如果testdb存在,则连接到testdb,如果不存在则抛出异常
jdbc:hsqldb:file:/opt/db/testdb;ifexists=true
如果testdb不存在,则创建
jdbc:hsqldb:file:/opt/db/testdb
?
8.支持的数据类型
Numeric types TINYINT, SMALLINT, INTEGER and BIGINT are types with fixed binary precision. These types are more efficient to store and retrieve. NUMERIC and DECIMAL are types with user-defined decimal precision. They can be used with zero scale to store very large integers, or with a non-zero scale to store decimal fractions. The DOUBLE type is a 64 bit, approximate floating point types. HyperSQL even allows you to store infinity in this type.
The BOOLEAN type is for logical values and can hold TRUE, FALSE or UNKNOWN. Although HyperSQL allows you to use one and zero in assignment or comparison, you should use the standard values for this type.
Character string types are CHAR(L), VARCHAR(L) and CLOB . CHAR is for fixed width strings and any string that is assigned to this type is padded with spaces at the end. Do not use this type for general storage of strings. If you use CHAR without the length L, then it is interpreted as a single character string. Use VARCHAR(L) for general strings. There are only memory limits and performance implications for the maximum length of VARCHAR(L). If the strings are larger than a few kilobytes, consider using CLOB. The CLOB types is for very large strings. Do not use this type for short strings as there are performance implications. The CLOB type is a better choice for the storage of long strings. By defaul