1

我想更改我的数据库上的一些表,这是一条 sql 和错误消息。我在 db2 文档和谷歌上搜索过,但没有找到。

在此处输入图像描述

4

2 回答 2

6

当您看到 SQLCODE 错误消息(例如 -193)时,它与错误消息 SQL0193 相同。获得帮助的最简单方法是使用 db2 命令窗口并键入

db2 ? SQL193

该消息表明您不能在没有默认值的情况下添加非空列。添加列时包含默认值,然后如果您不想要默认值,则使用第二个 alter table 语句删除默认值。

SQL0193N
In an ALTER TABLE statement, the column column-name has been specified as NOT NULL and    either the DEFAULT clause was not specified or was specified as DEFAULT NULL.

Explanation
When new columns are added to a table that already exists, a value must be assigned to that new column for all existing rows. By default, the null value is assigned. However, since the column has been defined as NOT NULL, a default value other than null must be defined.

User response
Either remove the NOT NULL restriction on the column or provide a default value other than null for the column.

sqlcode: -193

sqlstate: 42601

Parent topic: SQL Messages

留言主题

于 2012-10-18T11:36:42.983 回答
0

标记为答案的消息是正确的!

这是寻找特定陈述的人的示例(就像我一样):

alter table table_example add SAMPLE_ID int not null default 0;
alter table table_example alter column SAMPLE_ID drop default;
于 2018-11-26T09:15:44.643 回答