Sunday, March 30, 2008

Table SYS.HISTGRM$ owned by SYS

SYS.HISTGRM$ holds statistics for tables. When we used csscan to converte a database to Unicode UTF-8 character set, it reported that SYS.HISTGRM$ had one row of Convertible data. We got "ORA-701 object necessary for warm starting database cannot be altered" from issuing command "truncate table sys.histgrm$".

We did followings to work it out:

1. Find the rowid from the csscan report on the record in SYS.HISTGRM$ that is Convertible.

2. Identify the object in SYS.HISTGRM$ and in the csscan report: SQL> select a.owner, a.object_name, a.object_type
from all_objects a, sys.histgrm$ b
where a.object_id = b.obj# and b.rowid='AAAAD7AABAAANS+ABL'
group by a.owner, a.object_name, a.object_type;
OWNER OBJECT_NAME OBJECT_TYPE
----- ----------- -----------
DSS BIN$P3VMZ66Y4JTgQwoBAoDglA==$0 TABLE
-- It shows that object is in recycle bin.

3. Purge the recyclebin as SYSDBA:
SQL> PURGE TABLE "BIN$P3VMZ66Y4JTgQwoBAoDglA==$0" ;
SQL> purge DBA_RECYCLEBIN;
-- Now, "select * from DBA_RECYCLEBIN;" should got zero rows.
-- Note: If it is a regular table, run a package to delete the satats:
-- exec DBMS_STATS.DELETE_TABLE_STATS ('OWNER','TABLE_NAME');

After those steps, SYS.HISTGRM$ did not show up in the csscan report.

Notes:
Step 1 and Step 2 can be replaced by running script @?/nls/csscan/sql/analyze_histgrm.sql (which uses csmv$errors).
Step 3 is to delete the stats on involved tables in order to have HISTGRM$ contain just the clob records. These clob records can be altered with the csalter.plb script.

No comments: