- 浏览: 478440 次
- 性别:
- 来自: 武汉
文章分类
最新评论
-
excellent95:
谢楼主分享,确实是CSS图片问题
Struts2判断页面是POST方式提交还是GET方式提交 -
wangluo2:
javaBase那个包显示有问题啊pom文件那一行报错了
微信公众平台开发实战(08) 基于地理信息的服务(LBS) -
andilyliao:
jd技术这么渣也好意思出书,真是醉了
《京东技术解密》试读--十年磨一剑 -
bitray:
刘强东作序多什么,他也不会什么技术,腾讯出来帮他还不是因为腾讯 ...
《京东技术解密》试读--十年磨一剑 -
come_for_dream:
想试试搞这个
《大型分布式网站架构设计与实践》试读
1、将某个表导出为IXF档:
CONNECT TO CSI; EXPORT TO "C:\T_R_FORM.ixf" OF IXF MESSAGES "aa" SELECT * FROM CSIDDBD3.T_REFERRAL_FORM; CONNECT RESET; CONNECT TO CSI; EXPORT TO "C:\T_R_FORM_FLAG.ixf" OF IXF MESSAGES "bb" SELECT * FROM CSIDDBD3.T_REFERRAL_FORM_FLAG; CONNECT RESET;
2、日期类型(Date)作为查询条件:
SELECT * FROM CSIDDBD3.T_ID_MSGPOP WHERE BEG_DATE > '2007-01-01';
3、时间类型(TimeStamp)作为查询条件:
SELECT * FROM CSIDDBD3.T_ID_MSGPOP WHERE INPUT_DATE > '2007-01-01 00:00:00';
4、取前N条记录
SELECT * FROM CSIDDBD3.T_ID_MSGPOP FETCH FIRST 1000 ROWS ONLY;
5、如何利用表的NOT LOGGED INITIALLY特性清空表中的数据
alter table table_name activate not logged initially with empty table
6、批量更新某一查询结果集的第N条到第M条的记录的SQL(DB2)
update tableName b set b.A=2 ,b.B=current date --B字段为日期类型 where exists ( select 1 from ( select a.id,row_number()over(order by a.id) req --以tableName表的主键id字段进行排序 from tableName a where a.C =22 and a.D=1) c --加上查询结果集的限制条件 where b.id=c.id and c.req>=1 and c.req<=3);--将要更新查询结果集的第1到第3条记录
7、DB2 如何设置最大连接数?
db2 connect to dbname user username using passwd db2 update db cfg using MAXAPPLS number
8、SUBSTR()函数的使用
函数原型:
SUBSTR(string-expression,start,length)
【 示例】Sample table DSN8810.PROJ contains column PROJNAME, which is defined as VARCHAR(24). Select all rows from that table for which the string in PROJNAME begins with 'W L PROGRAM '.
SELECT * FROM DSN8810.PROJ WHERE SUBSTR(PROJNAME,1,12) = 'W L PROGRAM ';
【示例2】DB2函数substr分析
错误SQL:
select pk_invcl from bd_invcl where length (invclasscode) <= length ('501') and substr ('501', 1, length (invclasscode)) = invclasscode order by invclasscode
错误日志:
2007-01-18 19:10:13 SO|java.sql.SQLException: [IBM][CLI Driver][DB2/AIX64] SQL0138N The second or third argument of the SUBSTR function is out of range. SQLSTATE=22011
分析:虽然第一个条件已经限制length (invclasscode) <= length ('501') ,但是不满足第一个条件时,DB2第二个条件还会执行。
但是以下SQL却可以执行,并且以下两个SQL返回结果相同
select count(*) from bd_invcl where substr (invclasscode, 1,length(invclasscode)+2) = invclasscode select count(*) from bd_invcl
修正后:
select pk_invcl from bd_invcl where length (invclasscode) < length ('501') and substr ('501', 1, case when length (invclasscode)>length ('501') then length ('501') else length (invclasscode) end ) = invclasscode order by invclasscode
9、自动增长列
《Understanding DB2® Learning Visually with Examples》
7.8.6. Identity Columns
An identity column is a numeric column in a table that automatically generates a unique numeric value in sequence for each row inserted. A unique identifier is often used in applications to identify a specific row. Unlike sequence objects, which we discuss in section 7.16 , Sequences, identity columns are bound to the table they are defined on. There can be only one identity column per table. DB2 can generate the identity column values in two ways.
-
Generated always : The values are always generated by DB2. Applications are not allowed to provide an explicit value.
-
Generated by default : The values can be explicitly provided by an application; if no value is given, DB2 generates one. In this case, however, DB2 cannot guarantee the uniqueness of the value generated.
To create an identity column, use the CREATE TABLE statement with the GENERATED clause and make sure it contains the IDENTITY keyword because GENERATED can also be used to generate other values automatically that are not identity columns. Here is an example.
CREATE TABLE product ( productno INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 200 INCREMENT BY 1), description VARCHAR(50) )
The column productno is an INTEGER defined as an identity column that is always generated. The value generated will start from 200, and it will be incremented by 1. Let's perform a few INSERT statements and see the results obtained.
INSERT INTO product VALUES
(DEFAULT,'banana');
--->inserts 200,banana
INSERT INTO product (description) VALUES
('apple');
--->inserts 201,apple
INSERT INTO product VALUES
(300,'pear');
--->error SQL0798N
COMMIT;
INSERT INTO product (description) VALUES
('orange');
--->inserts 202,orange
ROLLBACK;
INSERT INTO product (description) VALUES
('plum');
--->inserts 203,plum
COMMIT
;
The following query shows the final result.
SELECT * FROM product; PRODUCTNO DESCRIPTION ----------- ------------ 200 banana 201 apple 203 plum
The first two INSERT statements show that two identity column values were generated: 200 and 201. The third INSERT statement returns an error because you cannot explicitly insert a value for an identity column generated as ALWAYS . After the third INSERT statement, we issue a COMMIT to guarantee these rows are stored in the database. The fourth INSERT statement causes another identity column value, 202, to be generated; however, we issue a ROLLBACK statement right after, so this row is not stored in the database. Note that the final INSERT statement, which inserts the product plum, generates a value of 203, not 202. (COMMIT and ROLLBACK statements are explained in more detail in Chapter 13 , Developing Database Backup and Recovery Solutions.)
NOTE
An identity column value is generated only once. Once the value has been generated, even if a ROLLBACK statement is performed, it will not be generated again.
Now let's review another example, this time creating the same table product with the GENERATED BY DEFAULT clause.
CREATE TABLE product ( productno INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 200 INCREMENT BY 1), description VARCHAR(50) )
Next, we insert a few rows.
INSERT INTO product VALUES (DEFAULT,'banana'); --->inserts 200,banana INSERT INTO product (description) VALUES ('apple'); --->inserts 201,apple INSERT INTO product VALUES (300,'pear'); --->inserts 300,pear INSERT INTO product VALUES (201,'orange'); --->inserts 201,orange COMMIT; INSERT INTO product (description) VALUES ('papaya'); --->inserts 202,papaya ROLLBACK; INSERT INTO product (description) VALUES ('plum'); --->inserts 203,plum COMMIT;
The following query shows the final result.
SELECT * FROM product PRODUCTNO DESCRIPTION ----------- --------------------- 200 banana 201 apple 300 pear 201 orange 203 plum
The first two INSERT statements show that two identity column values were generated: 200 and 201. For the third and fourth INSERT statements, we explicitly provided the values 300 and 201, respectively, for the identity column. Note that DB2 did not return an error as in the previous example because we defined the identity column as GENERATED BY DEFAULT . After the fourth INSERT statement, we issue a COMMIT to guarantee these rows are stored in the database. The fifth INSERT statement causes another identity column value, 202, to be generated; however, we issue a ROLLBACK statement right after, so this row is not stored in the database. Note that the final INSERT statement, which inserts the product plum, generates a value of 203, not 202.
The following final example illustrates a GENERATED value, which is not an identity column. The example uses GENERATED ALWAYS , but you can also use GENERATED BY DEFAULT .
CREATE TABLE income ( empno INTEGER, salary INTEGER, taxRate DECIMAL(5,2), netSalary DECIMAL(7,2) GENERATED ALWAYS AS (salary * (1 - taxRate)) )
If you insert the following row:
INSERT INTO income (empno, salary, taxRate) VALUES (111, 50000, 0.3)
The result is:
EMPNO SALARY TAXRATE NETSALARY ----------- ----------- ------- --------- 111 50000 0.30 35000.00
DB2 generates the value of the last column NETSALARY based on the SALARY and TAXRATE columns.
发表评论
-
DBUnit最佳实践之数据备份与恢复
2014-10-15 00:11 9047在做测试之前,我们需要对数据进行备份,用DBUnit可 ... -
Oracle数据库安装及配置(二)
2009-10-18 17:08 24564、创建表空间 打开sqlplus工具: sqlplus ... -
Oracle数据库安装及配置(一)
2009-10-18 16:21 76821、安装 Oracle 版本:Oracle Database ... -
Oracle中实现自增长列
2009-06-16 15:02 1089在使用Oracle数据的过程中,经常会用到自增长列,但Orac ... -
Oracle数据库
2009-05-07 17:15 01、添加链接 如果要想通过“PLSQL Developer” ... -
Oracle数据库备份命令
2009-03-17 09:48 0exp testcamds/123@camdsora file ... -
Oracle经验:企业组织信息表内联查询
2009-03-09 16:15 1384该文章内容有争议,已删除! -
Oracle时间精确到时、分、秒处理方法
2009-02-24 11:41 2804Oracle的to_date('DateString',' ... -
Oracle使用经验点滴
2008-12-29 19:53 14781、由setLong()产生的空指针异常: ref = jdb ... -
DB2信息大全2
2008-11-11 11:46 3076訊息參照 表 23. 類別碼 42:語法錯誤或存取規則違規 ... -
DB2信息大全1
2008-11-11 11:41 2586訊息參照 訊息參照 第 11 章 SQLSTATE 訊息 ... -
用SQL语句增加删除修改字段
2008-10-16 15:40 8793用SQL语句添加删除修改字段 1.增加字段 AL ...
相关推荐
《DB2 Version 9.1 for z/OS》是一份详尽的技术文档,主要针对IBM的DB2数据库管理系统在z/OS操作系统环境下的使用指南,特别聚焦于命令参考部分。这份文档是第九版,发布于2013年6月,涵盖了DB2 Version 9.1 for z/...
搜了一下这个license发现都是索取金币的,我给大家分享一个免费版的,支持共享~~~ ps.这个是V9.7 的license 用法: 把db2ese_c.lic放到某个目录下: ...db2licm -a /opt/ibm/db2/V9.7/license/db2ese_c.lic
这份"db2使用经验积累.rar"压缩包文件显然包含了作者在实际工作中对DB2操作和管理的总结,对于学习和理解DB2的功能、性能优化以及问题解决等方面具有较高的参考价值。 文档中的知识点可能涵盖以下几个方面: 1. **...
在使用DB2的过程中,开发者可能会遇到各种问题,以下是一些关键的知识点和经验分享,旨在帮助你理解和解决DB2使用中可能遇到的困惑。 1. **实例(INSTANCE)**:DB2实例是一个运行中的DB2软件实体,它包含一组共享的...
解析:在这个情境下,正确的命令是使用`DROP PACKAGE`命令来删除不再需要的DB2包。因此,正确答案为: - C. `DROP Package(<collid>.<nameofpackage>.)` 以上解析涵盖了IBM 000-732 DB2 9 DBA for z/OS认证考试中...
这些实验数据表明,在特定场景下,如处理大量变长数据时,DB2 9可以显著降低CPU使用率,提高数据处理速度。 综上所述,DB2 9 for z/OS不仅在技术层面上带来了许多创新,还在实际应用中展示了其强大的性能优势。无论...
### DB2使用经验积累 #### 一、DB2专有名词解释 - **Instance(实例)**:DB2实例是DB2数据库系统的核心组件之一,它指的是运行DB2数据库引擎的一个独立进程组。每个实例都有其自己的配置文件和一组运行参数,可以...
/opt/IBM/db2/V8.1/adm/db2licm -a /mnt/cdrom/db2/license/db2ese.lic ``` #### 八、允许SMS的多页分配 **第七步:允许SMS的多页分配** DB2支持多种内存管理策略,其中包括允许SMS(Shared Memory Segments)...
IBM 000-732 DB2 9 DBA for z/OS 是一项针对z/OS平台的数据库管理员的专业认证考试,题库内容涵盖了DB2数据库管理的众多方面。以下从题库中提取的知识点解析: 1. 在DB2数据库中,当一个对象是通过在一个受信任的...
标题中的"db2jcc_license_cu/db2java/db2jcc"揭示了这些文件与IBM的DB2数据库连接器有关,特别是Java版本的驱动程序。DB2是IBM提供的一款关系型数据库管理系统,广泛用于企业级的数据存储和管理。在Java环境中,为了...
DB2是IBM开发的一款关系型数据库管理系统,广泛应用于企业级数据...提供的文档"DB2数据库性能优化的几个小技巧.docx"和"DB2使用经验总结.docx"可能会提供更具体的操作步骤和实战经验,建议详细阅读以获取更全面的知识。
DB2 V10是IBM推出的一个版本的数据库管理系统,它是DB2数据库软件系列的重要更新之一,该系列最初于1996年发布。DB2 V10这个版本特别针对Linux、UNIX和Windows操作系统进行了优化,它提供了丰富的功能以及性能改进,...
IBM DB2 Version 9.1 for z/OS(以下简称DB2 V9.1 for z/OS)是IBM在2007年推出的针对大型主机z/OS操作系统的数据库管理软件的重要更新。此次版本的升级旨在提升数据处理能力,增强安全性,优化性能,并引入了一系列...
- 将 DB2 的许可证文件(例如 `db2pe.lic`)复制到 `/opt/IBM/db2/V8.1/adm/db2licm/` 目录下,并使用 `-a` 参数安装许可证。 ``` /opt/IBM/db2/V8.1/adm/db2licm -a /mnt/cdrom/db2/license/db2pe.lic ``` ###...
这篇文章将深入探讨DB2的使用经验和一些实用案例,帮助你更好地理解和掌握这个强大的数据库系统。 一、DB2安装与配置 在开始使用DB2之前,我们需要进行安装和配置。DB2提供多种版本,包括个人版、企业版和云版本。...
- `./db2licm -a /home/db2install/server/db2/license/db2ese_t.lic` #### 五、创建DAS和数据库实例 1. **创建DAS**: - `./dascrt -udasusr` 2. **创建数据库实例**: - `./db2icrt -p50000 -udb2fenc db2...
【DB2 使用经验积累】 DB2,全称IBM DB2,是一款由IBM公司开发的关系型数据库管理系统,广泛应用于企业级数据存储与管理。本篇经验积累主要针对已有一定基础的DB2用户,旨在通过深入解析DB2的专业名词、编程技巧等...