1、创建DB2数据库的时候,报42704错误 。如:
Sql代码
=>create database test
=>SQL0204N "SYSTEM_1386_US" is an undefined name. SQLSTATE=42704
=>create database test
=>SQL0204N "SYSTEM_1386_US" is an undefined name. SQLSTATE=42704
解决办法:Sql代码
=>create database test using codeset gbk territory cn
=>create database test using codeset gbk territory cn
2、在连接数据的时候,报57017错误 。如:
Sql代码
=>connect to test user test using test
=>SQL0332N Character conversion from the source code page "1386" to the target code page "819" is not supported. SQLSTATE=57017
=>connect to test user test using test
=>SQL0332N Character conversion from the source code page "1386" to the target code page "819" is not supported. SQLSTATE=57017
解决办法:
Sql代码
=>db2set db2codepage=1386
=>db2set db2codepage=1386
3、在对DB2数据库进行操作的时候,报55039错误 。如:
Sql代码
=>db2 drop table t_base_acc_manageacc
=>SQL0290N Table space access is not allowed. SQLSTATE=55039
=>db2 list tablespaces show detail
Tablespace ID = 2
Name = USERSPACE1
Type = System managed space
Contents = Any data
State = 0x0020
Detailed explanation:
Backup pending
=>db2 drop table t_base_acc_manageacc
=>SQL0290N Table space access is not allowed. SQLSTATE=55039
=>db2 list tablespaces show detail
Tablespace ID = 2
Name = USERSPACE1
Type = System managed space
Contents = Any data
State = 0x0020
Detailed explanation:
Backup pending 原因:在归档的数据库做过load或者改了参数重新启动了db
解决办法:
Sql代码
备份DB2数据库
=>db2 backup db
备份数据库
=>db2 backup db
4、在对数据库进行备份的时候,报57019错误 。如:
Sql代码
=>db2 backup database dbname to /xx/xx compress
=>SQL1035N The database is currently in use. SQLSTATE=57019
=>db2 backup database dbname to /xx/xx compress
=>SQL1035N The database is currently in use. SQLSTATE=57019解决办法:
Sql代码
=>db2stop force
=>db2start
=>db2stop force
=>db2start
5、在对创建表空间的时候,报54047错误 。如:
Sql代码
=>create regular tablespace space1 pagesize 4 k managed by database using (device /dev/dd 25000000) prefetchsize automatic bufferpool bp1
=>SQL1139N The total size of the table space is too big. SQLSTATE=54047
=>create regular tablespace space1 pagesize 4 k managed by database using (device /dev/dd 25000000) prefetchsize automatic bufferpool bp1
=>SQL1139N The total size of the table space is too big. SQLSTATE=54047解决办法:把表空间的大小改小点或者把regular(64G)换成large就ok了 。
6、DB2数据库备份失败,报内存不足,增大了dbheap也没有用 。SQL2009C,没有足够的可用内存来运行此实用程序 。
原因:DB2 UTIL_HEAP_SZ 未设置得足够高以用于备份实用程序 。
解决办法:db2 update db cfg for dbname using UTIL_HEAP_SZ 具体的数字(db2备份使用的内存是UTIL_HEAP_SZ,请使用以上命令调整) 。
7、用JDBC往表批量插入数据时 。报23502错误 。如:
Sql代码
Error for batch element #0: DB2 SQL error: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=2, TABLEID=15, COLNO=2
Error for batch element #0: DB2 SQL error: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=2, TABLEID=15, COLNO=2 原因:往表中有非空约束的字段,插入空值 。
解决办法:查看表定义,去掉非空约束,或加入非空值 。
8、用JDBC往表批量插入数据时 。报22001错误 。如:
Sql代码
DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null
DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null
原因:表中某字段的长度不够,发生字符串截断 。
解决办法:查看表定义,加大字段长度 。
9、用JDBC往表批量插入数据时 。报-4474错误 。如:
Sql代码
非法转换:不能从“java.lang.String”转换到“byte[]” ERRORCODE=-4474, SQLSTATE=null
非法转换:不能从“java.lang.String”转换到“byte[]” ERRORCODE=-4474, SQLSTATE=null原因:表中某字段定义为‘ID CHAR(16) FOR BIT DATA NOT NULL’(这个是使用MTK从MS SQL迁移到DB2数据库时,uniqueidentifier转换成的) 。
解决办法:重新创建表,把字段属性改为VARCHAR类型 。
Sql代码
=>create database test
=>SQL0204N "SYSTEM_1386_US" is an undefined name. SQLSTATE=42704
=>create database test
=>SQL0204N "SYSTEM_1386_US" is an undefined name. SQLSTATE=42704
解决办法:Sql代码
=>create database test using codeset gbk territory cn
=>create database test using codeset gbk territory cn
2、在连接数据的时候,报57017错误 。如:
Sql代码
=>connect to test user test using test
=>SQL0332N Character conversion from the source code page "1386" to the target code page "819" is not supported. SQLSTATE=57017
=>connect to test user test using test
=>SQL0332N Character conversion from the source code page "1386" to the target code page "819" is not supported. SQLSTATE=57017
解决办法:
Sql代码
=>db2set db2codepage=1386
=>db2set db2codepage=1386
3、在对DB2数据库进行操作的时候,报55039错误 。如:
Sql代码
=>db2 drop table t_base_acc_manageacc
=>SQL0290N Table space access is not allowed. SQLSTATE=55039
=>db2 list tablespaces show detail
Tablespace ID = 2
Name = USERSPACE1
Type = System managed space
Contents = Any data
State = 0x0020
Detailed explanation:
Backup pending
=>db2 drop table t_base_acc_manageacc
=>SQL0290N Table space access is not allowed. SQLSTATE=55039
=>db2 list tablespaces show detail
Tablespace ID = 2
Name = USERSPACE1
Type = System managed space
Contents = Any data
State = 0x0020
Detailed explanation:
Backup pending 原因:在归档的数据库做过load或者改了参数重新启动了db
解决办法:
Sql代码
备份DB2数据库
=>db2 backup db
备份数据库
=>db2 backup db
4、在对数据库进行备份的时候,报57019错误 。如:
Sql代码
=>db2 backup database dbname to /xx/xx compress
=>SQL1035N The database is currently in use. SQLSTATE=57019
=>db2 backup database dbname to /xx/xx compress
=>SQL1035N The database is currently in use. SQLSTATE=57019解决办法:
Sql代码
=>db2stop force
=>db2start
=>db2stop force
=>db2start
5、在对创建表空间的时候,报54047错误 。如:
Sql代码
=>create regular tablespace space1 pagesize 4 k managed by database using (device /dev/dd 25000000) prefetchsize automatic bufferpool bp1
=>SQL1139N The total size of the table space is too big. SQLSTATE=54047
=>create regular tablespace space1 pagesize 4 k managed by database using (device /dev/dd 25000000) prefetchsize automatic bufferpool bp1
=>SQL1139N The total size of the table space is too big. SQLSTATE=54047解决办法:把表空间的大小改小点或者把regular(64G)换成large就ok了 。
6、DB2数据库备份失败,报内存不足,增大了dbheap也没有用 。SQL2009C,没有足够的可用内存来运行此实用程序 。
原因:DB2 UTIL_HEAP_SZ 未设置得足够高以用于备份实用程序 。
解决办法:db2 update db cfg for dbname using UTIL_HEAP_SZ 具体的数字(db2备份使用的内存是UTIL_HEAP_SZ,请使用以上命令调整) 。
7、用JDBC往表批量插入数据时 。报23502错误 。如:
Sql代码
Error for batch element #0: DB2 SQL error: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=2, TABLEID=15, COLNO=2
Error for batch element #0: DB2 SQL error: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=2, TABLEID=15, COLNO=2 原因:往表中有非空约束的字段,插入空值 。
解决办法:查看表定义,去掉非空约束,或加入非空值 。
8、用JDBC往表批量插入数据时 。报22001错误 。如:
Sql代码
DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null
DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null
原因:表中某字段的长度不够,发生字符串截断 。
解决办法:查看表定义,加大字段长度 。
9、用JDBC往表批量插入数据时 。报-4474错误 。如:
Sql代码
非法转换:不能从“java.lang.String”转换到“byte[]” ERRORCODE=-4474, SQLSTATE=null
非法转换:不能从“java.lang.String”转换到“byte[]” ERRORCODE=-4474, SQLSTATE=null原因:表中某字段定义为‘ID CHAR(16) FOR BIT DATA NOT NULL’(这个是使用MTK从MS SQL迁移到DB2数据库时,uniqueidentifier转换成的) 。
解决办法:重新创建表,把字段属性改为VARCHAR类型 。