Ich habe eine sehr ungewöhnliche Situation, von der ich hoffe, dass jemand etwas Licht in sie bringen kann. Nach meinem Verständnis ist ein Orakel-Synonym im Grunde ein Alias für eine Tabelle in einem anderen Schema.
Wenn ich eine Zählung anhand des Synonyms durchführe, erhalte ich null Zeilen. Wenn ich dasselbe von der zugrunde liegenden Tabelle aus tue, erhalte ich 12 Tausend Zeilen.
Ich kann mir diese Diskrepanz nicht erklären. Kann mir jemand helfen?
select * from dba_synonyms
where synonym_name = 'CS_INCIDENTS_B_SEC';
OWNER SYNONYM_NAME TABLE_OWNER TABLE_NAME DB_LINK
------ ------------------- ------------ ------------------- -------
APPS CS_INCIDENTS_B_SEC CS CS_INCIDENTS_ALL_B
select count(*) from CS.CS_INCIDENTS_ALL_B;
COUNT(*)
----------------------
12549
select count(*) from APPS.CS_INCIDENTS_B_SEC;
COUNT(*)
----------------------
0
Erläutern Sie die Pläne:
Direkt auf dem Tisch...
EXPLAIN PLAN FOR
SELECT *
FROM CS.CS_INCIDENTS_ALL_B
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes| Cost(%CPU)|
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6056 | 1549K| 122 (3)|
| 1 | TABLE ACCESS FULL| CS_INCIDENTS_ALL_B | 6056 | 1549K| 122 (3)|
--------------------------------------------------------------------------
Durch das Synonym...
EXPLAIN PLAN FOR
SELECT *
FROM APPS.CS_INCIDENTS_B_SEC
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes| Cost(%CPU)|
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 262 | 0 (0)|
|* 1 | FILTER | | | | |
| 2 | TABLE ACCESS FULL| CS_INCIDENTS_ALL_B | 6056 | 1549K| 122 (3)|
---------------------------------------------------------------------------
1 - filter(NULL IS NOT NULL)
Synonym Kette...
SQL> SELECT *
2 FROM dba_synonyms
3 START WITH
4 owner = 'CS'
5 AND synonym_name = 'CS_INCIDENTS_ALL_B'
6 CONNECT BY
7 owner = PRIOR table_owner
8 AND synonym_name = PRIOR table_name
9 /
no rows selected
SQL> SELECT *
2 FROM dba_synonyms
3 START WITH
4 owner = 'APPS'
5 AND synonym_name = 'CS_INCIDENTS_B_SEC'
6 CONNECT BY
7 owner = PRIOR table_owner
8 AND synonym_name = PRIOR table_name
9 /
Überprüfung der Richtlinien in der Datenbank...
SQL> SELECT *
2 FROM dba_policies
3 WHERE OBJECT_NAME = 'CS_INCIDENTS_B_SEC'
4 /
OBJECT_OWNER OBJECT_NAME POLICY_GROUP POLICY_NAME
------------- ------------------- ------------- --------------------
APPS CS_INCIDENTS_B_SEC SYS_DEFAULT CS_SR_SEC_SR_ACCESS
PF_OWNER PACKAGE FUNCTION SEL INS UPD DEL IDX CHK
--------- ------------------ -------------- --- --- --- --- --- ---
APPS FND_GENERIC_POLICY GET_PREDICATE YES NO NO NO NO NO
ENABLE STATIC_POLICY POLICY_TYPE LONG_PREDICATE
------ ------------- ------------ --------------
YES NO DYNAMIC YES