derby & cloudscape常用操作和工具总结

        derby 是IBM捐赠给apache的java数据库实现,具有查询速度快和使用简单等特点,cloudscape是derby的IBM官方维护版本。通过一段时间的使用,对cloudscape有了一些浅显的认识,不敢独享,现总结如下:

        1. derby & cloudscape 常用操作

  • 查询数据库中的表:

derby & cloudscape可以看作是IBM DB2的一个微缩版(当然还有DB2 Express版,这个免费),其操作比较类似于DB2,但是有一些常用操作的功能并没有提供,例如列出数据库中某个模式(DB2的概念,类似于oracle的user)下的所有表等等。

             1)  查询所有模式下的所有的用户表

                 

select s.schemaname || '.' || t.tablename
  from sys.systables t, sys.sysschemas s
 where t.schemaid = s.schemaid
   and t.tabletype = 'T'
 order by s.schemaname, t.tablename

                  sys.systables 和 sys.sysschemas是两个系统表,存储的信息显而易见。

               2) 查询所有表的所有键,包括主键和外键,不过比较难于识别

         

select t.tablename,
       conglomeratename backIdxName,
       cst.constraintname,
       cst.type
  from sys.systables        t,
       sys.sysconstraints   cst,
       sys.sysconglomerates cgl,
       sys.syskeys          sk
 where isindex = 'TRUE'
   and cgl.tableid = t.tableid
   and (sk.constraintid = cst.constraintid and cst.type = 'P' and
       sk.conglomerateid = cgl.conglomerateid)
   and t.tableid = cst.tableid
   and t.tabletype = 'T'
UNION
select t.tablename,
       conglomeratename backIdxName,
       cst.constraintname,
       cst.type
  from sys.systables        t,
       sys.sysconstraints   cst,
       sys.sysconglomerates cgl,
       sys.sysforeignkeys   fk
 where isindex = 'TRUE'
   and cgl.tableid = t.tableid
   and (fk.constraintid = cst.constraintid and cst.type = 'F' and
       fk.conglomerateid = cgl.conglomerateid)
   and t.tableid = cst.tableid
   and t.tabletype = 'T'
 order by tablename, type

  •  辅助工具

derby & cloudscape提供的ij命令行工具实在是不敢恭维,幸好IBM提供了Cloudscape WorkBench这个免费的工具,这个工具是基于eclipse的图形化工具,能够为DB2,Clouscape和derby提供比较方便的操作界面。

下载地址:http://www-128.ibm.com/developerworks/db2/downloads/csworkbench/

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值