http://www.oncalldba.com.au/node/37
Compile Invalid Public Synonyms
This article shows how to recompile public synonyms in an Oracle database that are currently invalid
Public synonyms may show as invalid in DBA_OBJECTS even though they are actually valid and working correctly. This often occurs after the target object is modified or dropped and recreated. When this occurs, Oracle flags the public synonym as invalid as a precaution so it knows to re-validate / compile it next time it is used.
To view a list of invalid public synonyms ...
SELECT *
from dba_synonyms
where owner = 'PUBLIC'
and synonym_name in (
SELECT object_name
from dba_objects
where object_type = 'SYNONYM'
and owner = 'PUBLIC'
and status <> 'VALID'
);
Dont worry too much about the invalid public synonyms as the Oracle database will automatically re-validate them and change the status to VALID when they are next accessed. This occurs transparently so your users wont notice anything apart from the slight time delay while Oracle does its thing.
However, if you are a neat freak and dont like invalid objects in your nice clean database, you can run this script to force any invalid public synonyms to be compiled / revalidated.
-- force invalid public synonyms to recompile by "touching" them
-- using this query for each public synonym ...
-- SELECT count(*) temp_count from <OBJECT_NAME> where 1=2
-- note that "1=2" is used to make the queries run very fast while still forcing the public synonyms to be validated
BEGIN FOR c IN (SELECT 'select count(*) temp_count from ' |
-- after the script has completed, the Public Synonyms should now be in a valid state
-- show invalid public synonyms
set linesize 300
set pagesize 5000
column db_link format a30
SELECT *
from dba_synonyms
where owner = 'PUBLIC'
and synonym_name in (
SELECT object_name
from dba_objects
where object_type = 'SYNONYM'
and owner = 'PUBLIC'
and status <> 'VALID'
);
'Database' 카테고리의 다른 글
manual reorg table (0) | 2013.04.08 |
---|---|
How can I create a copy of an Oracle table without copying the data? (0) | 2013.04.08 |
(Oracle) Data Pump Export (expdp) and Data Pump Import(impdp) (0) | 2013.03.08 |
An Introduction to Data Compression in SQL Server 2008 (0) | 2013.02.01 |
(Oracle) alert.log location: bdump (0) | 2013.01.18 |