欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

hsqldb起步-2 博客分类: OpenSource HSQLDBJDBCSQLperformanceSwing 

程序员文章站 2024-03-22 22:30:40
...

学习和部署 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:

设置环境变量后


hsqldb起步-2
            
    
    博客分类: OpenSource HSQLDBJDBCSQLperformanceSwing 

bat方式启动:


hsqldb起步-2
            
    
    博客分类: OpenSource HSQLDBJDBCSQLperformanceSwing 

方式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 default LONGVARCHAR is a synonym for a long VARCHAR and can be used without specifying the size. You can set LONGVARCHAR to map to CLOB, with the sql.longvar_is_lob connection property or the SET DATABASE SQL LONGVAR IS LOB TRUE statement.

  • Binary string types are BINARY(L), VARBINARY(L) and BLOB. Do not use BINARY(L) unless you are storing keys such as UUID. This type pads short binary strings with zero bytes. BINARY without the length L means a single byte. Use VARBINARY(L) for general binary strings, and BLOB for large binary objects. You should apply the same considerations as with the character string types. By default LONGVARBINARY is a synonym for a long VARCHAR and can be used without specifying the size. You can set LONGVARBINARY to map to BLOB, with the sql.longvar_is_lob connection property or the SET DATABASE SQL LONGVAR IS LOB TRUE statement.

  • The BIT(L) and BITVARYING(L) types are for bit maps. Do not use them for other types of data. BIT without the length L argument means a single bit and is sometimes used as a logical type. Use BOOLEAN instead of this type.

  • The datetime types DATE, TIME and TIMESTAMP , together with their WITH TIME ZONE variations are available. Read the details in this chapter on how to use these types.

  • The INTERVAL type is very powerful when used together with the datetime types. This is very easy to use, but is supported mainly by "big iron" database systems. Note that functions that add days or months to datetime values are not really a substitute for the INTERVAL type. Expressions such as (datecol - 7 DAY) > CURRENT_DATE are optimised to use indexes when it is possible, while the equivalent function calls are not optimised.

  • The OTHER type is for storage of Java objects. If your objects are large, serialize them in your application and store them as BLOB in the database.

  • The ARRAY type supports all base types except LOB and OTHER types. ARRAY data objects are held in memory while being processed. It is therefore not recommended to store more than about a thousand objects in an ARRAY in normal operations with disk based databases. For specialised applications, use ARRAY with as many elements as your memory allocation can support.

9.关于SA

This user is automatically created with a new database and has the DBA role . Initially, the password for this user is an empty string. After connecting to the new database as this user, it is possible to change the password, create other users and created new schema objects. The SA user can be dropped by another user that has the DBA role.

 

10.

学习和部署 h2 database 算了, h2 database 是 hsqldb 的作者后来的又一力作 ,更好用,更高效

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • hsqldb起步-2
            
    
    博客分类: OpenSource HSQLDBJDBCSQLperformanceSwing 
  • 大小: 11.1 KB
  • hsqldb起步-2
            
    
    博客分类: OpenSource HSQLDBJDBCSQLperformanceSwing 
  • 大小: 21.8 KB