Oracle 设置每个用户默认方案(不改变会话)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/283589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 01:37:38  来源:igfitidea点击:

Oracle setting per user default scheme (not altering a session)

oracleloginschemasettingsdefault

提问by Zsolt Botykai

is there a way to change an oracle user's default schema?

有没有办法更改 oracle 用户的默认架构?

I found it in the FAQ that I can alter it in the session, but it's not what I want. E.G. the user at log on always sees another schema as default.

我在 FAQ 中发现我可以在会话中更改它,但这不是我想要的。EG 用户在登录时总是看到另一个默认模式。

Thanks in advance.

提前致谢。

回答by Tony Andrews

I believe a logon trigger should work:

我相信登录触发器应该可以工作:

CREATE OR REPLACE TRIGGER db_logon
AFTER logon ON DATABASE WHEN (USER = 'A')
BEGIN
    execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = B';
END;

回答by Ryan Cook

For some reason Tony's trigger did not work for me. However, a slightly different trigger that I found on the web using the same concept did.

出于某种原因,托尼的触发器对我不起作用。但是,我在网上找到的一个稍微不同的触发器使用了相同的概念。

create or replace trigger set_default_schema
after logon on my_user.schema
begin
  execute immediate 'alter session set current_schema=NEW_SCHEMA';
end;

I just wanted to throw it out there in case someone else has the same issue.

我只是想把它扔在那里,以防其他人有同样的问题。

回答by Greg

create or replace trigger AFTER_LOGON_TSFREL
AFTER LOGON ON "TSFRELEASEAPP".SCHEMA
BEGIN
   EXECUTE IMMEDIATE 'ALTER SESSION SET current_schema=TSF_RELEASE';
END;