语句:select TASKID from beps.pubszdt0420 fetch first 1 row only
证明:
1、select count(*) from beps.pubszdt0420
结果 7
2、
select TASKID from beps.pubszdt0420
TASKID
--------
10000010
10000020
10000030
10000040
10000050
10000060
10000070
3、
select TASKID from beps.pubszdt0420 fetch first 1 row only
TASKID
--------
10000010
2、 EXEC SQL LOCK TABLE * IN EXCLUSIVE MODE
3、 查看当前模式
select current schema from sysibm.sysdummy1
4、一条有待优化的SQL语句
db2 错误码大全
http://wenku.baidu.com/view/e28972b8c77da26925c5b050.html
SELECT count(DRBANK) FROM IBPS.PUBSZDT0414 WHERE (DRBANK NOT IN (SELECT SENDBANK FROM IBPS.IBPSZDT0101 WHERE RECVDATE = '2014-08-15' AND NETNO = 3 )) AND (DRBANK NOT IN (SELECT DEBTORBANK FROM IBPS.IBPSZDT0101 WHERE RECVDATE = '2014-08-15' AND NETNO = 3 )) AND (DRBANK NOT IN (SELECT CREDITORAGENT FROM IBPS.IBPSZDT0101 WHERE RECVDATE ='2014-08-15' AND NETNO = 3 )) AND (DRBANK <> '0000' ) AND (BANKCATALOG = 'CL00' OR BANKCATALOG = 'CL01' ) AND ((RUNSTAT <> '06') OR (RUNSTAT = '06' AND EFFDATE > '2014-08-15'))
NOT IN ,DRBANK只能对应查询结果的一个行而不能对应三个行,所以出现了不优化的语句。留待日后能力提高了再优化
5、数据库实例的创建
db2icrt -s ESE -w 64 -p 50000 -u db2fenc1 db2inst1
-s 数据库的类型
-w 数据库的位数 (32 or 64)
-p 指定数据库实例的端口号
-u 指定被防护的用户定义函数和被防护的存储过程会使用的用户ID。这个参数是需要的,如果没有创建client用户
db2inst1 实例名
http://www.2cto.com/database/201309/242278.html
5.1 查看数据库实例
db2ilist
5.2 查看当前实例中定义的数据库
db2 list db directory
参考:http://hi.baidu.com/gianthappy/item/54f47e31fd847fbd633affcc