SQL 如何查看HSQLDB数据库中的所有表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/591518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to see all the tables in an HSQLDB database?
提问by nobody
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-specific question and not plain SQL, but the point is: how can I see the tables so I can drop/alter them?
我通常使用 SQLDeveloper 来浏览数据库,但是我不能让它与 HSQLDB 一起工作,我不知道已经创建了哪些表......我猜这是一个特定于供应商的问题而不是简单的 SQL,但重点是:如何我可以查看表格以便删除/更改它们吗?
回答by Steve Weet
The ANSI SQL92 standard for querying database metadata is contained within the INFORMATION_SCHEMA
data structures.
用于查询数据库元数据的 ANSI SQL92 标准包含在INFORMATION_SCHEMA
数据结构中。
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.
在进一步研究中,HSQLDB 似乎确实支持INFORMATION_SCHEMA
,但命名略有不规范。
All of the tables have SYSTEM_*
prepended to them, so the above example would read
所有的表都SYSTEM_*
在它们前面,所以上面的例子会读
SELECT *
FROM INFORMATION_SCHEMA.SYSTEM_TABLES
I have no means of testing this, and the answer was found on sourceforge.
我没有办法测试这个,答案是在sourceforge 上找到的。
回答by nobody
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
您可以从INFORMATION_SCHEMA.SYSTEM_TABLES
. 必须喜欢 oo 文档 :p
回答by Mister_Tom
If you're on the command line, you may want to try the Hsqldb SqlTool, documented in the SqlTool Manual(hsqldb.org).
如果您在命令行上,您可能想尝试SqlTool 手册(hsqldb.org) 中记录的HsqldbSqlTool。
- 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:?
- 将您的数据库连接信息放在“
~/sqltool.rc
”中并选择您想要的任何 DBNAME,替换正确的用户名和密码(如果知道)。urlid DBNAME
url jdbc:hsqldb:/path/to/hsql/database
- 用户名 SA
- 密码
- 安装工具:(
apt-get install hsqldb-utils
在 Ubuntu 上) hsqldb-sqltool DBNAME
在 Ubuntu 上用#连接- 其他系统提示:
java -jar YourHsqlJar.jar DBNAME
- 显示表格:
\dt
- 显示列:\d TABLENAME
- 标准查询,如:
SELECT * FROM …;
- 使用以下命令编辑(附加)最后一个命令:
:a
- 退出:
\q
- 使用以下命令查看特殊命令:
\?
或:?
Good luck!
祝你好运!
回答by specialk1st
Use the \dt
command when you hit the >sql
prompt in the command line for HSQLDB.
\dt
当您>sql
在 HSQLDB 的命令行中点击提示符时使用该命令。
回答by anand.trex
Check out DBVisualiserand SQuirreL SQL Client. Both of these have support for HSQLDB, and a GUI for editing/modifying/viewing the tables.
查看DBVisualiser和SQuirreL SQL 客户端。这两者都支持 HSQLDB,以及用于编辑/修改/查看表的 GUI。
回答by parsifal
You run querying using hsql database manager
, are you?
If you use this, below may give some hints:
您使用 运行查询hsql database manager
,是吗?如果你使用这个,下面可能会给出一些提示:
Select your connection:
选择您的连接:
- type:
HSQL DATABASE ENGINE SERVER
- Driver:
jdbc.hsqldb.jdbcDriver
- URL:
jdbc:hsqldb:hsql://localhost/
- 类型:
HSQL DATABASE ENGINE SERVER
- 司机:
jdbc.hsqldb.jdbcDriver
- 网址:
jdbc:hsqldb:hsql://localhost/
Then, you will browse the database.
然后,您将浏览数据库。