当前位置: 代码迷 >> Oracle认证考试 >> 表drop掉了,同义词不也drop了吗?这有错吗?该怎么处理
  详细解决方案

表drop掉了,同义词不也drop了吗?这有错吗?该怎么处理

热度:7553   发布时间:2013-02-26 00:00:00.0
表drop掉了,同义词不也drop了吗?这有错吗?
Q: 116 Evaluate the SQL statement
DROP TABLE DEPT;
Which four statements are true of the SQL statement? (Choose four.)

A. You cannot roll back this statement.
B. All pending transactions are committed.
C. All views based on the DEPT table are deleted.
D. All indexes based on the DEPT table are dropped.
E. All data in the table is deleted, and the table structure is also deleted.
F. All data in the table is deleted, but the structure of the table is retained.
G. All synonyms based on the DEPT table are deleted.

Answer: A, B, D, E

这里为什么G是错误的呢?表drop掉了,同义词不也drop了吗?
------解决方案--------------------------------------------------------
不会的。同义词要用drop synonym xxx或drop public synonym xxx
------解决方案--------------------------------------------------------
自己做个试验不就可以了:


SQL> show user;
USER is "SCOTT"
SQL> create table test as select * from emp;

Table created.

SQL> conn sys as sysdba;
Enter password: *****
Connected.
SQL> create synonym ttt for scott.test;

Synonym created.

SQL> select count(*) from ttt;

  COUNT(*)
----------
        14

SQL> drop table scott.test;

Table dropped.

SQL> select count(*) from ttt;
select count(*) from ttt
                     *
ERROR at line 1:
ORA-00980: synonym translation is no longer valid

SQL> select OBJECT_NAME from user_objects where OBJECT_TYPE = 'SYNONYM';

OBJECT_NAME
--------------------------------------------------------------------------------
DEF$_AQCALL
DEF$_CALLDEST
DEF$_SCHEDULE
DEF$_ERROR
DEF$_DEFAULTDEST
DEF$_LOB
XMLDOM
XMLPARSER
XSLPROCESSOR
TTT

10 rows selected.


------解决方案--------------------------------------------------------
同意楼上的,做个实验就都清楚了
  相关解决方案