51. Which statement is true regarding synonyms?
A. Synonyms can be created only for a table. 不只是表,schema object
B. Synonyms are used to reference only those tables that are owned by another user.
C. A public synonym and a private synonym can exist with the same name for the same table. 共有和私有可以共同存在
D. The DROP SYNONYM statement removes the synonym, and the table on which the synonym has
been created becomes invalid.
Answer: C
答案解析:
A错误,不只是表,是数据库所有的对象,如表、视图、序列、过程等。
B错误,由数据库管理员创建的公共的同义词,可以所有的用户都可以访问,而由用户自己创建的同义词,只能自己访问。
C正确,共有同义词和私有同义词的名字在一张表中可以相同。
实验验证:
sys@TEST0924> create public synonym semp for scott.emp;
Synonym created.
sys@TEST0924> conn scott/tiger
Connected.
scott@TEST0924> create synonym semp for emp;-------------必须有创建同义词权限,否则报错
create synonym semp for emp
*
ERROR at line 1:
ORA-01031: insufficient privileges
scott@TEST0924> conn /as sysdba
Connected.
sys@TEST0924> grant CREATE synonym to scott;-------------赋予创建同义词权限
Grant succeeded.
sys@TEST0924> conn scott/tiger
Connected.
scott@TEST0924> create synonym semp for emp;------------创建一个和共有同义词的一样名称的同义词,执行成功。
Synonym created.
D错误,删除了同义词,但是表不会被变为无效的。