暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 想要将架构名称传递为动态模式

ASKTOM 2020-05-20
217

问题描述

我的问题是在这里,我只是想将 'Scott' 模式名称传递为动态,因为模式名称每2个月更改一次,例如 'scott.1 '和 'scott.2' 等。

从产品A中选择prod_id,prod_name,scott.product_details B其中A.prod_id = B.prod'id;

专家解答

您可以研究以下几件事:

使用同义词/视图,所以你不需要指定模式:

grant dba to other_user 
  identified by other_user;
  
create table other_user.t (
  c1 int
);

insert into other_user.t values ( 42 );

select * from other_user.t;

C1   
   42 

create synonym t 
  for other_user.t;
  
select * from t;

C1   
   42 


将current_schema设置为另一个schema:

drop synonym t ;

alter session set current_schema = other_user;

select * from t;

C1   
   42 


尽管如果您使用不同模式的表 (如您的示例所暗示的),则需要为当前用户提供模式。

但是... 为什么需要更改模式name定期?
文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论