问题描述:
Db2 rename table的时候报错 SQL0750N
inst105@node01:~$ db2 "rename table tb1 to tb1_bak"
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0750N The statement failed because the table or column cannot be renamed.
SQLSTATE=42986
原因分析:
inst105@node01:~$ db2 " ? SQL0750N"
SQL0750N The statement failed because the table or column cannot be
renamed.
Explanation:
The source table in a RENAME statement cannot be renamed for one or more
of the following reasons.
* The table is referenced in one or more existing materialized query
tables.
* The table is involved in one or more referential constraints as a
parent or dependent table.
* The table is a target table for decomposition of one or more XSR
objects.
* The table is a system-period temporal table.
* The table is a history table.
* The database manager configuration parameter auto_reval is set to
DISABLED and one of the following occurred:
* The table is referenced in one or more existing views.
* The table is referenced in one or more existing triggers. This
includes triggers on the table or references in triggered SQL
statements.
* The table is referenced in one or more existing SQL functions or
SQL methods.
* The table has check constraints defined. This includes check
constraints caused by generated columns.
* The table is the latency table, SYSTOOLS.REPL_MQT_LATENCY.
问题解决:
本次问题的原因在于AUTO_REVAL当前值为DISABLED,并且使用db2look查看发现该表上有视图
inst105@node01:~$ db2pd -db sample -dbcfg | grep -i AUTO_REVAL
AUTO_REVAL DISABLED DISABLED
inst105@node01:~$ db2look -d sample -a -e -t tb1 | grep -i create
-- Generate statistics for all creators
-- The db2look utility will consider only the specified tables
-- Creating DDL for table(s)
-- This CLP file was created using DB2LOOK Version "10.5"
CREATE TABLE "INST105 "."TB1" (
create view vtb1 as select * from tb1;