虽然我有some trouble installing and setting up derby,但我确实取得了部分成功:
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# ll
total 36
drwxr-xr-x 5 root root 4096 Aug 23 16:46 ./
drwxr-xr-x 5 501 staff 4096 Aug 23 02:07 ../
-rw-r--r-- 1 root root 4 Aug 23 02:07 dbex.lck
-rw-r--r-- 1 root root 38 Aug 23 02:07 db.lck
-rw-r--r-- 1 root root 187 Aug 23 16:46 derby.log
drwxr-xr-x 2 root root 4096 Aug 23 02:07 log/
drwxr-xr-x 2 root root 4096 Aug 23 02:07 seg0/
-rw-r--r-- 1 root root 868 Aug 23 02:07 service.properties
drwxr-xr-x 2 root root 4096 Aug 23 02:07 tmp/
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# java org.apache.derby.tools.ij
ij version 10.9
ij> quit;
root@dur:~/apache-james-3.0-beta4/var/store/derby#
我现在如何查询此特定数据库?
答案 0 :(得分:2)
使用Derby和Squirrel的完整示例,假设您已在系统上安装了Derby数据库:
$HOME/bin/squirrel
$HOME/bin/db-derby
cd $HOME/bin/squirrel ; ./squirrel-sql.sh
)$DERBY_HOME/lib/derby.jar
。seg0
的目录)。此时,Apache Derby Embedded图标不应再有红色X.
然后:
seg0
。数据库现已连接,您应该看到模式。
然后:
SELECT * FROM SYS.SYSTABLES
您现在可以对Derby数据库执行SQL语句。
注意:这在技术上没有回答这个问题,因为这个答案没有解释如何使用交互式命令行界面(ij
)。答案提出了一种使用Squirrel图形界面查询数据库的可行替代方案。
答案 1 :(得分:1)
我仍然不知道如何真正查询数据库本身,但连接相当简单,apparently:
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# pwd
/root/apache-james-3.0-beta4/var/store/derby
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# ll
total 24
drwxr-xr-x 4 root root 4096 Aug 23 18:24 ./
drwxr-xr-x 5 501 staff 4096 Aug 23 02:07 ../
-rw-r--r-- 1 root root 1092 Aug 23 18:24 derby.log
drwxr-xr-x 2 root root 4096 Aug 23 02:07 log/
drwxr-xr-x 2 root root 4096 Aug 23 02:07 seg0/
-rw-r--r-- 1 root root 868 Aug 23 02:07 service.properties
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# java org.apache.derby.tools.ij
ij version 10.9
ij> connect 'jdbc:derby:/root/apache-james-3.0-beta4/var/store/derby';
ij>
;
ij> show schema;
ERROR 42X01: Syntax error: Encountered "show" at line 1, column 1.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij>
;
ij> show schemas;
TABLE_SCHEM
------------------------------
APP
NULLID
SQLJ
SYS
SYSCAT
SYSCS_DIAG
SYSCS_UTIL
SYSFUN
SYSIBM
SYSPROC
SYSSTAT
11 rows selected
ij> show tables;
TABLE_SCHEM |TABLE_NAME |REMARKS
------------------------------------------------------------------------
SYS |SYSALIASES |
SYS |SYSCHECKS |
SYS |SYSCOLPERMS |
SYS |SYSCOLUMNS |
SYS |SYSCONGLOMERATES |
SYS |SYSCONSTRAINTS |
SYS |SYSDEPENDS |
SYS |SYSFILES |
SYS |SYSFOREIGNKEYS |
SYS |SYSKEYS |
SYS |SYSPERMS |
SYS |SYSROLES |
SYS |SYSROUTINEPERMS |
SYS |SYSSCHEMAS |
SYS |SYSSEQUENCES |
SYS |SYSSTATEMENTS |
SYS |SYSSTATISTICS |
SYS |SYSTABLEPERMS |
SYS |SYSTABLES |
SYS |SYSTRIGGERS |
SYS |SYSVIEWS |
SYSIBM |SYSDUMMY1 |
APP |JAMES_DOMAIN |
APP |JAMES_MAIL |
APP |JAMES_MAILBOX |
APP |JAMES_MAIL_PROPERTY |
APP |JAMES_MAIL_USERFLAG |
APP |JAMES_RECIPIENT_REWRITE |
APP |JAMES_SUBSCRIPTION |
APP |JAMES_USER |
APP |OPENJPA_SEQUENCE_TABLE |
31 rows selected
ij> quit;
root@dur:~/apache-james-3.0-beta4/var/store/derby#