执行analyze table t1 validate structure时报如下错误(t1为分区表):
SQL> !oerr ora 14508
14508, 00000, "specified VALIDATE INTO table not found"
// *Cause: The specified table either does not exist or user does not have
// the proper privleges.
// *Action: Specify the correct table to use.
官方文档对analyze命令的一段说明:
The ANALYZE Command• Performs a logical block check
• Does not mark blocks as soft corrupt; only reports them
• Validates index and table entries
Use the ANALYZE command to validate the structure of a table or table partitions, and index or index partitions. The object to be analyzed must be local and it must be in your own schema or you must have the ANALYZE ANY system privilege. The cascade option validates an object, including all related objects. The advantage of this option is that you can run it in a SQL*Plus session on a specific object, to do an integrity check and to determine if an error is persistent, by running the same analyze command a number of times.
For partitioned tables, ANALYZE also verifies that the row belongs to the correct partition. If the row does not collate correctly, the rowid is inserted into the INVALID_ROWS table.
解决方法:
调用$ORACLE_HOME/rdbms/admin/utlvalid.sql脚本,创建invalid_rows表。
utlvalid.sql的内容如下:
$ cat utlvalid.sql
rem
Rem Copyright (c) 1990, 1995, 1996, 1998 by Oracle Corporation
Rem NAME
REM UTLVALID.SQL
Rem FUNCTION
Rem Creates the default table for storing the output of the
Rem analyze validate command on a partitioned table
Rem NOTES
Rem MODIFIED
Rem syeung 06/17/98 - add subpartition_name
Rem mmonajje 05/21/96 - Replace timestamp col name with analyze_timestamp
Rem sbasu 05/07/96 - Remove echo setting
Rem ssamu 01/09/96 - new file utlvalid.sql
Rem
create table INVALID_ROWS (
owner_name varchar2(30),
table_name varchar2(30),
partition_name varchar2(30),
subpartition_name varchar2(30),
head_rowid rowid,
analyze_timestamp date
);
SQL> @?/rdbms/admin/utlvalid.sql
表已创建。
SQL> analyze table t1 validate structure;
表已分析。