Home >Database >Mysql Tutorial >Oracle一个用户如何访问其它用户的表应用指南

Oracle一个用户如何访问其它用户的表应用指南

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:55:411178browse

本文将详细介绍Oracle一个用户如何访问其它用户的表,需要的朋友可以参考下

假如Oracle中有两个用户A和B,那么如果A要访问B拥有的表,语句应该是:
代码如下:
SELECT * FROM B.TABLENAME。

我要问的是,能否通过修改Oracle的设置,将A访问B拥有表的语也变为跟B用户登录一样的语句:SELECT * FROM TABLENAME?
代码如下:
create synonym tablename for B.TABLENAME;

除了一楼的创建同义词外,还要授予A用户访问改同意词的权限.
代码如下:
drop synonym tablename ;

1 可以使用查询生成sql语句,比如
代码如下:
select 'CREATE SYNONYM '||table_name||' FOR A.'||table_name from dba_tables where owner = 'A'

然后执行这些sql语句。 或者写存储过程实现.
2 select any table 权限可以允许访问所有表
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn