如何在db2 sql中设置列数据类型

时间:2015-03-02 01:26:58

标签: sql db2

我想在sql table EN_NO中将TB_TRANSACTION长度从21更改为16。下面是我当前的sql列字段。

sql命令 -

describe table tb_transaction

column | type schema  | type name | length | scale | nulls
EN_NO|   SYSIBM    | VARCHAR   |   21  |  0   | Yes

我试过这个命令但失败了。

alter table tb_transaction alter column EN_NO set data type varchar(16)<br/>

Error message:
SQL0190N  ALTER TABLE "EASC.TB_TRANSACTION" specified attributes for column
"EN_NO" that are not compatible with the existing column.  SQLSTATE=42837

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我们可以增加列的大小,但是我们不能减小列的大小,因为数据会丢失,这就是系统不允许减小大小的原因。

如果您仍想减小尺寸,则需要删除该列并重新添加。