How to see all the tables in an HSQLDB database?

前端 未结 6 1331
自闭症患者
自闭症患者 2020-11-30 04:44

I usually use SQLDeveloper to browse the database, but I couldn\'t make it work with HSQLDB and I don\'t know which tables are already created… I guess it\'s a vendor-specif

相关标签:
6条回答
  • 2020-11-30 05:04

    Awesome, thanks! Been scouring the Web for that info. This will fetch only your tables' field info:

    SELECT TABLE_NAME, COLUMN_NAME, TYPE_NAME, COLUMN_SIZE, DECIMAL_DIGITS, IS_NULLABLE FROM INFORMATION_SCHEMA.SYSTEM_COLUMNS WHERE TABLE_NAME NOT LIKE 'SYSTEM_%'
    

    You can retrieve indexes, primary key info, all kinds of stuff from INFORMATION_SCHEMA.SYSTEM_TABLES. Gotta love oo documentation :p

    0 讨论(0)
  • 2020-11-30 05:05

    Use the \dt command when you hit the >sql prompt in the command line for HSQLDB.

    0 讨论(0)
  • 2020-11-30 05:07

    Check out DBVisualiser and SQuirreL SQL Client. Both of these have support for HSQLDB, and a GUI for editing/modifying/viewing the tables.

    0 讨论(0)
  • 2020-11-30 05:16

    The ANSI SQL92 standard for querying database metadata is contained within the INFORMATION_SCHEMA data structures.

    I have no idea whether your database supports this or not, but try the following:

    SELECT *
    FROM   INFORMATION_SCHEMA.TABLES
    

    On further research, it appears that HSQLDB does support INFORMATION_SCHEMA, but with slightly non-standard naming.

    All of the tables have SYSTEM_* prepended to them, so the above example would read

    SELECT *
    FROM   INFORMATION_SCHEMA.SYSTEM_TABLES
    

    I have no means of testing this, and the answer was found on sourceforge.

    0 讨论(0)
  • 2020-11-30 05:22

    You run querying using hsql database manager, are you? If you use this, below may give some hints:

    Select your connection:

    1. type: HSQL DATABASE ENGINE SERVER
    2. Driver: jdbc.hsqldb.jdbcDriver
    3. URL: jdbc:hsqldb:hsql://localhost/

    Then, you will browse the database.

    0 讨论(0)
  • 2020-11-30 05:25

    If you're on the command line, you may want to try the Hsqldb SqlTool, documented in the SqlTool Manual (hsqldb.org).

    • Put your database connection information in "~/sqltool.rc" and choose any DBNAME you want, substitute correct username and password, if known.
      • urlid DBNAME
      • url jdbc:hsqldb:/path/to/hsql/database
      • username SA
      • password
    • Install tool with: apt-get install hsqldb-utils (on Ubuntu)
    • Connect with hsqldb-sqltool DBNAME # on Ubuntu
    • Hint for other systems: java -jar YourHsqlJar.jar DBNAME
    • Show tables with: \dt
    • Show columns with: \d TABLENAME
    • Standard queries like: SELECT * FROM …;
    • Edit (append) last command with: :a
    • Quit with: \q
    • View special commands with: \? OR :?

    Good luck!

    0 讨论(0)
提交回复
热议问题