首页 > 数据库 > Oracle > OCP考题解析_007: 同义词
创建同义词的语法:

没有带public的是私有同义词
私有同义词就是普通用户所创建的同义词,之所以说它是私有,是因为只有创建该同义词的用户才能使用此同义词
而公用同义词是指数据库管理员创建的,当然,公用同义词是允许所有的用户来使用的
如果要创建一个远程的数据库上的某张表的同义词,需要先创建一个Database Link,然后再使用@DB_Link_name
当出现同名时、优先级如下:
私有同义词 > 公有同义词
基表 > 公有同义词
存在同名对象和公共同义词时,数据库优先选择对象作为目标
存在同名私有对象和公共对象时,数据库优先选择私有同义词作为目标
基表与私有同义词不能同名、否则会报ORA-00955错误
㈡ 同义词的操作
① 查看同义词
sys@ORCL> select table_name from dict where table_name like \'%SYNONYM%\'; TABLE_NAME ------------------------------ DBA_SYNONYMS USER_SYNONYMS ALL_SYNONYMS
Q: 16 Mary has a view called EMP_DEPT_LOC_VU that was created based on the EMPLOYEES, DEPARTMENTS, and LOCATIONS tables. She granted SELECT privilege to Scott on this view. Which option enables Scott to eliminate the need to qualify the view with the name MARY.EMP_DEPT_LOC_VU each time the view is referenced? A. Scott can create a synonym for the EMP_DEPT_LOC_VU by using the command CREATE PRIVATE SYNONYM EDL_VU FOR mary.EMP_DEPT_LOC_VU; then he can prefix the columns with this synonym. B. Scott can create a synonym for the EMP_DEPT_LOC_VU by using the command CREATE SYNONYM EDL_VU FOR mary.EMP_DEPT_LOC_VU; then he can prefix the columns with this synonym. C. Scott can create a synonym for the EMP_DEPT_LOC_VU by using the command CREATE LOCAL SYNONYM EDL_VU FOR mary.EMP_DEPT_LOC_VU; then he can prefix the columns with this synonym. D. Scott can create a synonym for the EMP_DEPT_LOC_VU by using the command CREATE SYNONYM EDL_VU ON mary(EMP_DEPT_LOC_VU); then he can prefix the columns with this synonym. E. Scott cannot create a synonym because synonyms can be created only for tables. F. Scott cannot create any synonym for Mary\'s view. Mary should create a private synonym for the view and grant SELECT privilege on that synonym to Scott. Answer: B
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26515977/viewspace-1208014/ ,如需转载,请注明出处,否则将追究法律责任。