同义词Synonym
同义词Synonym
1 同义词Synonym

【用途】:Oracle中,如果一个表名字特别长,可以创建同义词,简化对对象的访问
public:公有同义词
私有同义词只能自己访问
公有同义词只要是任何有权限的用户都可以访问
公有同义词不是模式对象,不能用模式名做前缀
2 创建同义词

【访问公有同义词需要相应的权限】

conn /as sysdba grant create synonym to scott; grant create public synonym to scott;

scott用户为emp表创建公有同义词scott_emp
create public synonym scott_emp for emp;

sys创建test用户并给予创建会话权限
create user test identified by test; grant create session to test;
sys用户把公有同义词scottemp的访问权限给hr
grant select on scott_emp to test;
或者scott把访问emp基表的权限赋予hr
grant select on emp to test;
test用户访问scott_emp同义词
select * from scott_emp;

3 删除同义词

drop public synonym scott_emp;

【注意】:在sys用户下删除公有同义词,删除私有同义词去掉public即可

浙公网安备 33010602011771号