DB2 sql报错后查证原因与解决问题的方法

1.对于执行中的报错,可以在db2命令行下运行命令 : db2=>? SQLxxx 查看对应的报错原因及解决方法。

2.错误SQL0206N SQLSTATE=42703  检测到一个未定义的列、属性或参数名。
  SQL0206N  "SQL_COU_ALL" is not valid in the context where it is used.  SQLSTATE=42703
      db2 => ? "42703"    
      db2 => ? SQL0206N
   
3.错误SQL0668N code "7" SQLSTATE=57016   表处于pending state,需要重组该表。
  SQL0668N  Operation not allowed for reason code "7" on table "xxx.Z_BP_TMPBATCH_TB_HIS".  SQLSTATE=57016
     db2 => ? SQL0668N code 7  
     SQL0668N  Operation not allowed for reason code "<reason-code>" on table "<table-name>".
     Explanation:说明
       Access to table "<table-name>" is restricted. The cause is based on the following reason codes "<reason-code>":
       7   The table is in the reorg pending state. This can occur after an ALTER TABLE statement containing a REORG-recommended operation.
     User response:用户响应  
       7   Reorganize the table using the REORG TABLE command.
    For a table in the reorg pending state, note that the following clauses are not allowed when reorganizing the table:
    *  The INPLACE REORG TABLE clause
    *  The ON DATA PARTITION clause for a partitioned table when table has nonpartitioned indexes defined on the table

4.错误SQL20054N code="23" SQLSTATE=55019 对表的修改次数达到3次,必须重组表
  ALTER TABLE xxx.FM_BORRO ALTER COLUMN DOCUMENT_TYPE_1 SET NOT NULL
  报错:SQL20054N  The table "xxx.FM_BORROW" is in an invalid state for the operation. Reason code="23".  SQLSTATE=55019
  db2 => ? SQL20054N
    SQL20054N  The table "<table-name>" is in an invalid state for the operation. Reason code="<reason-code>".
  Explanation:
    The table is in a state that does not allow the operation. The "<reason-code>" indicates the state of the table that prevents the operation.
    23   The maximum number of REORG-recommended alters have been
         performed. Up to three REORG-recommended operations are allowed
         on a table before a reorg must be performed, to update the
         tables rows to match the current schema.
  User response:
    23        Reorg the table using the reorg table command.
    说明:当对表结构进行更改时,也可能导致表状态异常。比如,以下操作可能会导致表处于reorg-pending状态。
 (1)        alter table <tablename> alter <colname> set data type <new data type>
 (2)        alter table <tablename> alter <colname> set not null
 (3)        alter table <tablename> drop column <colname>
 (4)        ……   
 出现reorg pending的根源是当表结构变化后影响了数据行中的数据格式,这时需要对表做reorg。可能的错误号是:
 01.SQL0668N  Operation not allowed for reason code "7" on table "SDD.ST_INCRE008".  SQLSTATE=57016
 03.SQL20054N  The table "<table-name>" is in an invalid state for the operation. Reason code="7".
 复制代码每一个表在不进行重组(Reorg)的前提下,只允许进行3次结构上的修改。三次更改后必须对表进行重组。
 REORG TABLE "xx"."FM_BORROW" ALLOW NO ACCESS KEEPDICTIONARY;

5.报错 SQL0670N  SQLSTATE=54010 该表所有字段长度之和大于当前数据库页大小(8K)
  ALTER TABLE xxx.FAQ ALTER COLUMN FAQ_UNIT_NAME SET DATA TYPE VARCHAR(800)
  报错 SQL0670N  The row length of the table exceeded a limit of "8101" bytes. (Table space "SHJD_DATA".)  SQLSTATE=54010
  db2 => ? SQL0670N
    SQL0670N  The row length of the table exceeded a limit of "<length>" bytes. (Table space "<tablespace-name>".)
  Explanation:
    The row length of a table in the database manager cannot exceed:
 *  4005 bytes in a table space with a 4K page size
 *  8101 bytes in a table space with an 8K page size
 *  16293 bytes in a table space with an 16K page size
 *  32677 bytes in a table space with an 32K page size
    The length is calculated by adding the internal lengths of the columns.Details of internal column lengths can be found under CREATE TABLE in the SQL Reference.
  User response:
    指定页大小更大的表空间;消除表中的一列或多列

6.报错 SQL0190N  SQLSTATE=42837 不能改变该列,因为它的属性与当前的列属性不兼容
  ALTER TABLE xxx.BP_TMPDATA_1_TB_1903 ALTER COLUMN RATE SET DATA TYPE DECIMAL(6,4) 
  报错 SQL0190N  ALTER TABLE "BP_TMPDATA_1_TB_1903" specified attributes for column "RATE" that are not compatible with the existing column.  SQLSTATE=42837
  说明: BP_TMPDATA_1_TB_1903 现有数据的精度超过了 DECIMAL(6,4)  ,比如100.00

7.报错 SQL30081N SQLSTATE=08001   检测到通信错误  无法与应用程序服务器或其他服务器建立连接
  SQL30081N  A communication error has been detected. 
    Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS".  
    Location where the error was detected: "10.0.0.200".  Communication function detecting the error: "selectForConnectTimeout".  
    Protocol specific error code(s): "0", "*", "*".  SQLSTATE=08001
    检查服务器的配置情况如下:
      验证存在的DB2数据库
 db2 list db directory
 db2 list db directory show detail
      验证实例使用的通讯协议,查看DB2COMM变量
 db2set -all
      查看数据库管理器的配置,查看SVCENAME(特指tcpip协议)
 db2 get dbm cfg
      查看/etc/services中,有无与上面对应SVCENAME的端口,例如:
 db2cDB2 50000/tcp
      验证远程服务器实例配置
        db2 list node directory
        db2 list node directory show detail
      ping hostname来验证通讯
      使用telnet hostname port来验证是否能连到实例
      用DB2提供的PCT工具来检测一下

时间: 2024-08-11 05:36:31

DB2 sql报错后查证原因与解决问题的方法的相关文章

转 sqlplus执行sql报错:ORA-01756:

1.sqlplus执行sql报错:ORA-01756: quoted string not properly terminated   分类: 技术 在SQLPLUS中执行SQL文件时发生错误:ORA-01756: quoted string not properly terminated 但是SQL其实是没有问题的,找了很多原因,发现可能是由于使用TOAD导出SQL insert语句,编码集的问题导致的. 首先在.bash_profile文件中添加环境变量指定编码集: export NLS_L

如何卸载掉报错后安装完成的“隐患oracle”软件

***********************************************声明**********************************************  原创作品,出自 "深蓝的blog" 博客,欢迎转载,转载时请务必注明出处,否则追究版权法律责任. 表述有错误之处,请您留言或邮件([email protected])指明,不胜感激. 本文转载必须保留此处:http://blog.csdn.net/huangyanlong/article/det

利用sql报错帮助进行sql注入

我们可以利用sql报错帮助进行sql注入,这里以sql server 为例: sql查询时,若用group by子句时,该子句中的字段必须跟select 条件中的字段(非聚合函数)完全匹配,如果是select * ,那就必须将该表中所有列名都包含在group by 中:若少了哪个,就会报错,报错中会提示如下; 选择列表中的列 '列名'无效,因为该列没有包含在聚合函数或 GROUP BY 子句中. 这个提示的列名是按该表中的顺序来的,这时我们可以利用这点进行sql注入中枚举所有列的工作: 先使用

mysql 更新sql报错:You can&#39;t specify target table &#39;wms_cabinet_form&#39; for update in FROM clause

数据库里面有两个字段的位置不对,要把他们对调换下.因为没有数据库写的权限,需要用sql语句来实现.原来以为简单的 update table a set a.字段a=(select b字段 from table  where id=?) ,set a.字段b=(select a字段 from table where id=?) where id=? ,结果报了 这个问题 You can't specify target table 'wms_cabinet_form' for update in

mysql - sql报错You can&#39;t specify target table &#39;table_name&#39; for update in FROM clause

今天写了个更新数据库表的语句,本意是根据某个条件,筛选出该表某些数据之后,对这些数据进行删除操作,如下 delete from t_person where id in (select id from t_person where name = "hello"); 然而却报错: You can't specify target table 't_person' for update in FROM clause 以下这篇博客( https://blog.csdn.net/qq_2967

python3 UnicodeEncodeError错误,cx_oracle模块执行sql报错:UnicodeEncodeError: &#39;ascii&#39; codec can&#39;t encode characters in position

问题描述: 写了一个执行sql的模块,引用了cx_oracle,在windows机器上完美运行,移植到Centos上就会报错, UnicodeEncodeError: 'ascii' codec can't encode characters in position 检查过程: 代码编码为utf-8,print编码为utf-8,文件编码为utf-8,服务器编码为utf-8,各种正常 定位代码报错位置,开始怀疑是sql执行成功,返回值有中文报错,但是后来通过观察,是传入sql,并没有执行成功,执行

python安装locustio报错error: invalid command &#39;bdist_wheel&#39;的解决方法

locust--scalable user load testing tool writen in Python(是用python写的.规模化.可扩展的测试性能的工具) 安装locustio需要的环境条件是:Python2.6+,但是不支持Python3. 今天在cmd里运行pip install locustio,报错提示:error: invalid command 'bdist_wheel'. 原因:pip和setuptools的版本较低. 解决方案:升级pip和setuptools. 一

转:Loadrunner报错“Too many local variablesAction.c”解决方法

问题描述,在Action.c里定义数组时如果数组长度过长,如char a[1024*1024]运行时即会报错: 问题原因及解决方法如下: 1. VuGen对于局部变量可以分配的最大内存为64K,如果想分配空间大于64K的变量的话,需要通过如下方法: VuGen has a limitation of 64K for local variables. If you want to declare a variable larger than 64K: a. 将其定义为全局变量,Declare it

rlwrap安装报错You need the GNU readline 解决方法

首先大家肯定知道rlwrap是干什么的? 在linux以及unix中,sqlplus的上下左右.回退无法使用,会出现乱码情况.而rlwrap这个软件就是用来解决这个的. 这个错误曾经困扰我很久很久!下载readline 安装,安装好readline 还是无法运行rlwrap的安装程序 在网上搜寻很久才找到一个靠谱的解决方法 原来rlwrap这个程序的安装,需要依赖两个包, 一个是readline,这个readline在RHEL中已经集成了.不需要去专门下载 另外一个包 libtermcap-de