我想改变我的数据库上的一些表,这是一个sql和错误消息。我搜索过db2文档和谷歌,但我没有找到它。
答案 0 :(得分:5)
当您看到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
消息主题
答案 1 :(得分:0)
标记为答案的消息是正确的!
以下是一些查找特定语句的示例(就像我以前一样):
alter table table_example add SAMPLE_ID int not null default 0;
alter table table_example alter column SAMPLE_ID drop default;