Wednesday 22 May 2019

You Cannot Analyze a Table Through a Synonym


This was tested on an Oracle 12 database. First I created a table and analyzed it: 

$ sqlplus "/as sysdba"

SQL*Plus: Release 12.1.0.2.0 Production on Wed May 22 08:56:23 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> create table wasiq11 (one_col number);

Table created.

SQL> analyze table wasiq11 compute statistics;

Table analyzed.

Then I created a synonym for the table

SQL> create synonym wasiq22 for wasiq11;

Synonym created.

I found that I was able to describe the table via the synonym

SQL> desc wasiq22
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ONE_COL                                            NUMBER

but I could not able to analyze the table through a synonym

SQL> analyze table wasiq22 compute statistics;
analyze table wasiq22 compute statistics
              *
ERROR at line 1:
ORA-00942: table or view does not exist


No comments:

Post a Comment