检查Hsqldb架构

时间:2010-03-09 03:35:14

标签: schema hsqldb

是否可以在Hsqldb独立模式下检查并随后修改现有架构?我尝试使用内置的管理工具查看该文件以及连接SQuirrel SQL Client。

我对各种表中存在的主键特别感兴趣。是否有相当于MySql的'show create table ...'或'describe'的命令?

2 个答案:

答案 0 :(得分:5)

sqltool \ d 命令近似于“describe”,主键信息存储在INFORMATION_SCHEMA下:

sql> CREATE SCHEMA STACKOVERFLOW;
sql> SET SCHEMA STACKOVERFLOW;
sql> CREATE TABLE SO2406470 (pk1 INT NOT NULL, pk2 INT NOT NULL, data VARCHAR(64), PRIMARY KEY(pk1, pk2));
sql> \d SO2406470
name  datatype  width  no-nulls
----  --------  -----  --------
PK1   INTEGER      11  *
PK2   INTEGER      11  *
DATA  VARCHAR      64  
sql> SELECT * FROM INFORMATION_SCHEMA.SYSTEM_PRIMARYKEYS WHERE TABLE_SCHEM = CURRENT_SCHEMA AND TABLE_NAME = 'SO2406470';
TABLE_CAT  TABLE_SCHEM    TABLE_NAME  COLUMN_NAME  KEY_SEQ  PK_NAME
---------  -------------  ----------  -----------  -------  ------------
PUBLIC     STACKOVERFLOW  SO2406470   PK1                1  SYS_PK_10040
PUBLIC     STACKOVERFLOW  SO2406470   PK2                2  SYS_PK_10040

Fetched 2 rows

(HSQLDB-2.0.0rc9)

答案 1 :(得分:1)

sqltool \ dt 命令将显示所有表名, \ d?命令将显示所有'describe'选项。

sql> \dt
TABLE_SCHEM  TABLE_NAME
-----------  ---------------
PUBLIC       APP_CFG
PUBLIC       CFG_REFRESH_LOG
...
sql> \d?
\dX [parameter...] where X is one of the following.
    a:  list Aliases
    c:  list Catalogs
    i:  list Indexes (for some databases, must specify literal target table)
    n:  list schema Names
    r:  list Roles
    s:  list Sequences
    S:  list System tables
    t:  list Tables
    u:  list Users
    v:  list Views
    *:  list table-like objects
    ...