DB2修改唯一性索引(Unix Index)所在列字段类型时,SQL0478N
来源:互联网 发布:java 指定jdk版本 编辑:程序博客网 时间:2024/06/18 02:08
问题描述:
1.) DB2中,如果某一列上有唯一性索引,那么当修改这个列的字段类型的时候,会报SQL0478N的错误,例如,将表T2的ID列由int型修改为varchar型。
$ db2 "create table t2(id int not null, age int not null)"$ db2 "create unique index idx21 on t2(id)"$ db2 "insert into t2 values(1100,23)"$ db2 "alter table t2 alter column id set data type varchar(64)"DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:SQL0478N The statement failed because one or more dependencies exist on the target object. Target object type: "COLUMN". Name of an object that is dependent on the target object: "IDX21". Type of object that is dependent on the target object: "INDEX". SQLSTATE=42893
2.) 如果索引不是唯一性索引,则修改没有任何报错。
问题解决:
尝试测试唯一性约束,发现有类似的报错:db2 "create table t3(id int not null, age int not null)"db2 "alter table t3 add constraint cons1 unique (id)"db2 "alter table t3 alter column id set data type varchar(64)"DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:SQL0478N The statement failed because one or more dependencies exist on the target object. Target object type: "COLUMN". Name of an object that is dependent on the target object: "CONS1". Type of object that is dependent on the target object: "UNIQUE CONSTRAINT". SQLSTATE=42893
解释如下,原因是唯一性约束不能被修改,若想修改,只能重建:
Creating and modifying unique constraints, To modify this constraint, you would have to drop it, and then re-create it.
http://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.dbobj.doc/doc/t0020167.html
0 0
- DB2修改唯一性索引(Unix Index)所在列字段类型时,SQL0478N
- DB2修改字段类型
- db2修改列类型
- gridview通过字段列名获取字段所在列索引
- mysql创建多列组合唯一索引,unique index
- db2修改列长度,或者类型
- 利用散列算法优化唯一索引性能(长文本字段的唯一索引优化)
- mysql字段类型 唯一索引 记录不重复设置
- 唯一性索引(Unique Index)与普通索引(Normal Index)差异(上)
- 唯一性索引(Unique Index)与普通索引(Normal Index)性能差异
- 唯一性索引(Unique Index)与普通索引(Normal Index)差异(上)
- 唯一性索引(Unique Index)与普通索引(Normal Index)差异(中)
- 唯一性索引(Unique Index)与普通索引(Normal Index)差异(下)
- 数据库字段类型-DB2
- DB2的字段类型
- DB2字段类型转换
- db2 修改字段
- DB2索引类型介绍
- Swap Nodes in Pairs
- 泛型
- Linux笔记
- Java系列(一)Annotation(注解)
- 流体布局与浮动元素
- DB2修改唯一性索引(Unix Index)所在列字段类型时,SQL0478N
- 表单自动验证
- spring cloud-前端跨域问题的解决方案
- linux的RPM包管理(1、2)-rpm命令安装、yum在线管理
- 推荐系统评测指标—准确率(Precision)、召回率(Recall)、F值(F-Measure)
- Python基础知识总结(1)
- nginx安装SSL证书,搭建https网站
- 泛型方法
- C#操作XML