DB2 400 下降列 [英] DB2 400 drop column

查看:20
本文介绍了DB2 400 下降列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除一个名为 id 的列,它是一个自动递增的 PK.

I want to drop a column called id which is an auto incrementing PK.

SQL:

alter table "CO88GT"."XGLCTL" drop column id cascade;

我得到:

Error: [SQL0952] Processing of the SQL statement ended.  Reason code 10.

SQLState:  57014

ErrorCode: -952

我可能是错的,但我认为这与防止表丢失数据有关.为了解决这个问题,我需要创建一个没有列的新表,并将旧表中的数据复制到新表中,然后用新表替换旧表.

I could be wrong but I think it has something to do with preventing the table from losing data. To get around this issue I need to create a new table without the column and copy the data from the old table into the new table and then replace the old table with the new table.

推荐答案

信息

由于可能的数据丢失,AS400 向您发出警告(查询消息),要求您取消或忽略请求的操作.因此,由于这是一个交互式请求,因此您不能通过 JDBC/ODBC 键入I"来忽略,并且 AS 会向您抛出 ErrorCode: -952 with SQLState: 57014 and Reason code 10.

Info

AS400 is giving you a warning (inquiry message) because of possible data loss, asking you to Cancel or Ignore the requested operation. So, beacuse of this being a interactive request, over JDBC/ODBC you cannot type 'I' to ignore, and AS throws you an ErrorCode: -952 with SQLState: 57014 and Reason code 10.

SQL0952 说:

Message Text:   Processing of the SQL statement ended. Reason code &1.
Cause Text:     The SQL operation was ended before normal completion. The reason code is &1. Reason codes and their meanings are:

* 1 - An SQLCancel API request has been processed, for example from ODBC.
* 2 - SQL processing was ended by sending an exception.
* 3 - Abnormal termination.
* 4 - Activation group termination.
* 5 - Reclaim activation group or reclaim resources.
* 6 - Process termination.
* 7 - An EXIT function was called.
* 8 - Unhandled exception.
* 9 - A Long Jump was processed.
* 10 - A cancel reply to an inquiry message was received.
* 11 - Open Database File Exit Program (QIBM_QDB_OPEN).
* 0 - Unknown cause.

如果您使用 JDBC 并且 SQL 错误不是不言自明的,您可以使用参数errors=full"建立 JDBC 连接,这将提供有关错误的更多信息.有关其他连接参数,请参阅 this.

If you are using JDBC and the SQL error isn't self-explanatory, you can make a JDBC connection with parameter 'errors=full', which will give much more info on the error. For other connection parameters see this.

示例连接字符串:

jdbc:as400://serverName;libraries=*libl;naming=system;errors=full;

jdbc:as400://serverName;libraries=*libl;naming=system;errors=full;

使用该连接产生的错误将如下所示:

With that connection the resulting error would be like this:

Error: [SQL0952] Processing of the SQL statement ended.  Reason code 10.
Cause . . . . . :   The SQL operation was ended before normal completion.
The reason code is 10.
Reason codes and their meanings are:
1 -- An SQLCancel API request has been processed, for example from ODBC.
2 -- SQL processing was ended by sending an exception.
3 -- Abnormal termination.
4 -- Activation group termination.
5 -- Reclaim activation group or reclaim resources.
6 -- Process termination.
7 -- An EXIT function was called.
8 -- Unhandled exception.
9 -- A Long Jump was processed.
10 -- A cancel reply to an inquiry message was received.
11 -- Open Database File Exit Program (QIBM_QDB_OPEN).
0 -- Unknown cause.
Recovery  . . . :   If the reason code is 1, a client request was made to cancel SQL processing.  For all other reason codes, see previous messages to determine why SQL processing was ended.

SQLState:  57014
ErrorCode: -952

<小时>

解决方案

最后,如果您不能使用 STRSQL,另一种解决方案是使用 iSeries Navigator,确切地说是它的运行 SQL 脚本"(通常在这里 -->%Program Files%IBMClient AccessSharedcwbundbs.exe").


The solution

So finally, if you cannot use STRSQL, another solution is to use iSeries Navigator, to be exact its "Run SQL scripts" (it is usually here --> "%Program Files%IBMClient AccessSharedcwbundbs.exe").

但首先你必须添加一个系统回复参数(每台机器仅一次)

But first of all you have to add a system reply parameter (only once per machine)

ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY('I')

ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY('I')

这是在绿屏"中完成的.这会在 CPA32B2 查询消息上设置默认答案 ('I').CPA32B2 是一个内部消息 id,它与 drop column 操作相关联.

This is done in "green screen". This sets a deafult answer ('I') on CPA32B2 inquiry message. The CPA32B2 is an internal massage id, which is tied to an drop column operation.

(实际上不必在绿屏"中完成,像CHGJOB命令一样使用它.示例:

(It actually doesn't have to be done in "green screen", use it like CHGJOB command. Example :

cl: ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY('I');

cl: ADDRPYLE SEQNBR(1500) MSGID(CPA32B2) RPY('I');

)

现在你可以开始运行 SQL 脚本"了,第一个运行的命令是:

Now you can start "Run SQL scripts", the first command to run is:

cl: CHGJOB INQMSGRPY(*SYSRPYL);

cl: CHGJOB INQMSGRPY(*SYSRPYL);

这会更改当前作业参数 INQMSGRPY,到 *SYSRPYL.*SYSRPYL 导致在应显示查询消息时查看是否存在系统回复参数.

this changes the current job parameter INQMSGRPY, to *SYSRPYL. *SYSRPYL causes to look if exists a system reply parameter when an inquiry message should be displayed.

现在你可以运行你的 alter 来删除列.

Now you can run your alter which drops the column.

不幸的是,我不知道如何删除列,只是使用 JDBC.如果有人知道,请告诉我.

Unfortunately, I don't know how to drop a column, just using JDBC. If someone knows please let me know.

参考资料:

这篇关于DB2 400 下降列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆