- 浏览: 1523157 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (532)
- 软件设计师 (7)
- PSP (5)
- NET MD (9)
- Hibernate (8)
- DIY (51)
- Work (43)
- GAME (24)
- 未分类 (44)
- iPod (6)
- MySQL (39)
- JSP (7)
- 日语能力考试 (36)
- 小说 (4)
- 豆包网 (23)
- 家用电脑 (7)
- DB2 (36)
- C/C++ (18)
- baby (9)
- Linux (13)
- thinkpad (23)
- OA (1)
- UML (6)
- oracle (24)
- 系统集成 (27)
- 脑梗塞 (6)
- 车 (8)
- MainFrame (8)
- Windows 7 (13)
- 手机 (8)
- git (12)
- AHK (2)
- COBOL (2)
- Java (9)
最新评论
-
安静听歌:
... ...
UUID做主键,好还是不好?这是个问题。 -
lehehe:
http://www.haoservice.com/docs/ ...
天气预报 -
lehehe:
[url http://www.haoservice.com/ ...
天气预报 -
liubang201010:
监控TUXEDO 的软件推荐用这个,专业,权威.并能提供报警和 ...
(转载)Tuxedo中间件简介 -
tinkame:
Next[j] =-1 当j=0时;=Max{k|0<k ...
KMP字符串模式匹配详解
ALTER TABLE操作在日常开发中很常见,下面是摘自DB2官网关于ALTER TABLE操作的一段话。 Perhaps the most important thing to realize when running an ALTER TABLE statement containing a REORG-recommended operation is that once the ALTER TABLE statement has executed, the table will be placed in the Reorg Pending state. This means that the table is inaccessible for almost all operations until you perform a REORG. See the ALTER TABLE statement in the SQL Referencefor the complete list of ALTER TABLE operations, some of which are also called REORG-recommended operations. 简单地说就是运行ALTER TABLE时要注意当前运行的语句是否需要执行REORG操作,对于这样的ALTER TABLE语句,如果不执行REORG操作的话,基本上目标表就不再可用。至于什么样的语句需要REORG,什么样的不需要,看SQL Reference去!下面是一个具体的例子演示: 代码有四种颜色,绿色代表不需要执行REORG的语句,红色代表需要执行REORG的语句,黄色是REORG语句,白色你懂的。从代码上可以看出,红色高亮语句虽然要求使用REORG,但不及时运行REORG还可以让后续的几个语句继续执行。原因是DB2允许最多三条语句处于Reorg Pending状态,假如去除第一个REORG,语句“ALTER TABLE my_test ALTER COLUMN sla_priority4_time DROP NOT NULL;”就会执行失败。 结论:如果不确定那个是需要REORG哪个是不需要REORG,索性都用上REORG;虽然在允许有三条语句处于Reorg Pending状态,但最好每条ALTER TABLE对应一个REORG,因为处于Reorg Pending状态的表有可能会阻碍后续操作,具体详情请参考文档:http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/c0023297.htm PS:REORG TABLE本身是DB2的command,不是正常的SQL语句(Statement)。如果在非命令行环境中想使用REORG的话,可以像下面那样调用存储过程间接执行REORG操作,执行前确保你所使用的帐号有调用这个存储过程的权限:http://www.flatws.cn/article/program/db2/2011-05-04/24074.html
DB2中ALTER TABLE为什么需要REORG操作?
CREATE TABLE my_test AS ( SELECT id, ... sla_priority1_time, sla_priority2_time, sla_priority3_time, sla_priority4_time, CAST(NULL AS DECIMAL(11, 2)) AS approvedDouAmount, CAST(NULL AS DECIMAL(4)) AS year FROM fin_attributes)WITH NO DATA;ALTER TABLE my_test ALTER COLUMN id SET GENERATED ALWAYS AS IDENTITY;ALTER TABLE my_test ADD COLUMN datetime TIMESTAMP NOT NULL GENERATED BY DEFAULT FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP;ALTER TABLE my_test ALTER COLUMN sla_priority1_time DROP NOT NULL;ALTER TABLE my_test ALTER COLUMN sla_priority2_time DROP NOT NULL;ALTER TABLE my_test ALTER COLUMN sla_priority3_time DROP NOT NULL;REORG TABLE my_test;ALTER TABLE my_test ALTER COLUMN sla_priority4_time DROP NOT NULL;REORG TABLE my_test;INSERT INTO my_test ( ... sla_priority1_time, sla_priority2_time, sla_priority3_time, sla_priority4_time, approvedDouAmount, year)SELECT ... sla_priority1_time, sla_priority2_time, sla_priority3_time, sla_priority4_time, NVL(pg.approvedDouAmount, 0), YEAR(NOW()) FROM fin_attributes f, projgrp pg WHERE f.projgrp_id = pg.id AND f.project_id IS NULL AND f.fin_projgrp_id IS NULL UNIONSELECT ... sla_priority1_time, sla_priority2_time, sla_priority3_time, sla_priority4_time, NVL(p.approvedDouAmount, 0), YEAR(NOW()) FROM fin_attributes f, project p WHERE f.project_id = p.id AND f.projgrp_id IS NULL;
CALL SYSPROC.ADMIN_CMD('reorg table my_test')
[]
发表评论
-
(转)浅谈IBM DB2的数据库备份与恢复
2011-11-23 16:41 1807http://bzhang.mild.blog.163.com ... -
(转)DB2备份恢复数据库步骤
2011-11-23 16:23 912http://tech.it168.com/ibmtec ... -
(转)DB2 SQL Error: SQLCODE=-964, SQLSTATE=57011的原因及解决方法
2011-11-07 15:03 9462http://blog.sina.com.cn/s ... -
(转)DB2解决“数据库日志已满”操作 SQLCODE=-964
2011-11-07 14:49 2646http://www.db2china.ne ... -
(转)用哪个DB2命令查看DB2 instance是启动还是停止的?
2011-09-30 13:25 3612http://bbs.chinaunix.net/thre ... -
(转)论 LOAD 与 IMPORT 中的 codepage 转换
2011-07-11 14:55 1122http://www.ibm.com/develo ... -
(转)DB2导出数据库表结构和数据
2011-07-11 14:19 1520http://hi.baidu.com/mylovecha ... -
(转)DB2 9 中基于字符的字符串函数
2011-06-16 11:32 1396http://www.ibm.com/develo ... -
(转)db2look:生成 DDL 以便重新创建在数据库中定义的对象
2011-05-31 14:56 1614http://blog.csdn.net/hrfdotnet/ ... -
(转)【俊哥儿张】DB2:学习 DB2LOOK 命令
2011-05-31 14:54 1339http://space.itpub.net/770528 ... -
(转)Recreate optimizer access plans using db2look
2011-05-31 14:53 1243http://www.ibm.com/develo ... -
(转)DB2 3.2.2 表空间维护
2011-05-11 12:53 1147http://book.51cto.com/art/2 ... -
(转)DB2 数据类型
2011-05-11 12:52 3959http://hi.baidu.com/uvvv/blog ... -
(转)DB2 Basics: Table spaces and buffer pools
2011-05-06 15:29 1433http://www.ibm.com/develo ... -
(转)SQL1092N "USER" does not have the authority to perform therequested command -
2011-03-23 17:39 5430http://dbaspot.com/foru ... -
(转)DB2 sqlstate 57016 原因码 "7"错误详解
2011-03-07 17:38 1463http://www.db2china.net/clu ... -
(转)在英语 OS 上设置 DB2 UDB 版本 8 中的混合字节字符集(MBCS)数据库
2011-02-16 16:25 1565http://www.ibm.com/develo ... -
(转)DB2 CODEPAGE List
2011-02-15 15:15 1380http://www.db2china.net/hom ... -
(转)快速参考: DB2 命令行处理器(CLP)中的常用命令
2010-11-11 10:44 945http://www.ibm.com/develo ... -
(转)DB2 and IBM's Processor Value Unit pricing
2010-01-13 17:36 1336http://www.ibm.com/developerwor ...
相关推荐
SQL Server中alter table一些用法.doc
一个字段: ALTER TABLE table_name MODIFY(字段类型 数据类型)); 添加一个字段: ALTER TABLE table_name ADD(字段类型 数据类型);
--删除表列alter table test modify address char(10) --修改表列类型||alter table test change
alter table in Sql server
NULL 博文链接:https://zotao.iteye.com/blog/691609
mysql alter table语句可以修改表的基本结构,例如添加字段、删除字段、添加主键、添加索引、修改字段数据类型、对表重命名等等操作,本文章通过两个简单的实例向大家介绍mysql alter table的使用方法。 实例一:...
MySQL数据库中ALTER TABLE语句的用法研究.pdf
mysql alter table语句可以修改表的基本结构,例如添加字段、删除字段、添加主键、添加索引、修改字段数据类型、对表重命名等等操作,本文章通过两个简单的实例向大家介绍mysql alter table的使用方法 实例一:...
alter table tbl_name add col_name type 例如, 给pet的表增加一列 weight, mysql>alter table pet add weight int; 2. 删除列 alter table tbl_name drop col_name 例如, 删除pet表中的weight这一列 mysql>...
ALTER TABLE `ecs_brand` ADD COLUMN `brand_banner` VARCHAR(80) NOT NULL COMMENT '商品品牌banner'; ALTER TABLE `ecs_goods` ADD COLUMN `sales_count` int(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `click_...
MYSQL ALTER TABLE命令用于修改表结构,例如添加/修改/删除字段、索引、主键等等,本文章通过实例向大家介绍MYSQL ALTER TABLE语句的使用方法, MySQL ALTER语法如下: ALTER [IGNORE] TABLE tbl_name alter_spec...
ALTER TABLE and CREATE TABLE in Access/vb6
由于emlog缺少较多东西 为了能够让Lu模版更加的人性化 需要替换部分系统文件 替换的文件下面都会说一下 模版只支持php5.6 mysql5.5 且需要sg11 第一步 将压缩包里面的lu.sql文件 导入到自己的数据库中 第二步 ...
MYSQL ALTER TABLE命令用于修改表结构,例如添加/修改/删除字段、索引、主键等等,本文章通过实例向大家介绍MYSQL ALTER TABLE语句的使用方法,需要的朋友可以参考一下。
MySQL Alter Table 修改表信息.docx
数据库管理与应用 4.2.3在ALTER TABLE语句中创建索引 .pdf 学习资料 复习资料 教学资源
ALTER TABLE table_name ADD column_name datatype; 2、删除一列 代码如下: ALTER TABLE table_name DROP column_name; 3、更改列的数据类型 代码如下: ALTER TABLE table_name ALTER column_name TYPE ...
DB2删除⼤数据量表⽅法 DB2不⽀持truncate语句时,当⽤delete from table时候,会很慢很慢,笔者 做过⼀些测试对于数据量在百万上的,很慢。故找了⼏种解决 办法: DB2不⽀持truncate语句,当⽤delete from table时候...
table hyspjg add sl decimal(12,3) null,yzxj decimal(12,2) null,hyzxj decimal(12,2) null,zdr char(6) null, zdrq smalldatetime null,zxr char(6) null,zxrq smalldatetime null go create table dbo.sjjhjld ...