当您看到SQLCODE错误消息(如-193)时,它与错误消息SQL0193相同.获得帮助的最简单方法是使用db2命令窗口并键入
db2 ? SQL193
Run Code Online (Sandbox Code Playgroud)
该消息表明如果没有默认值,则无法添加非空列.添加列时包含默认值,然后如果不需要默认值,则使用第二个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
Run Code Online (Sandbox Code Playgroud)
消息主题