sql-DDL-同义词
可以给数据库对象(表、视图等)起别名。
创建一个test用户,并授权访问scott的emp表
create user test identified by 12345678 ;
grant create session to test ;
grant select on scott.emp to test ;
使用test用户查询scott的emp表
select * from scott.emp;
创建同义词简化访问方式
在test账户下为scott.emp起别名(同义词)
create synonym scottemp for scott.emp; 权限不够
需要sys账户授权
grant create synonym to test;
使用同义词查询
select * from scottemp;
私有同义词:谁创建谁使用。
scott账户下使用同义词scottemp查询 --不存在
删除同义词
drop synonym 同义词 ;
drop synonym scottemp;
公有同义词:无论谁创建,任何人都可以使用。
-
需要先在sys账户中授权 :
grant create public synonym to test;
-
创建公有同义词:
create public synonym scottemp for scott.emp;
本文作者:jiyuchen1
本文链接:https://www.cnblogs.com/jiyuchen1/p/16402223.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南