2022-07-19 18:47阅读: 36评论: 0推荐: 0

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 中国大陆许可协议进行许可。

posted @   姬雨晨  阅读(36)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起