为 Oracle 用户设置默认的“alter session”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1419966/
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-18 18:59:31  来源:igfitidea点击:

Set up default "alter session" for an Oracle user

oraclesessionconfiguration

提问by Thilo

For a JDBC application I need to issue a few ALTER SESSION commands. I do not want to put those into the application code itself. Is there a way to specify defaults for the session parameters for the database schema that the application uses (on the database side) ?

对于 JDBC 应用程序,我需要发出一些 ALTER SESSION 命令。我不想将它们放入应用程序代码本身。有没有办法为应用程序使用的数据库模式(在数据库端)指定会话参数的默认值?

回答by Vincent Malgrat

most session parameters are defined by the client application. If you want to override the client settings you could create a DATABASE TRIGGER. For example, this will create a LOGONtrigger on the BARschema:

大多数会话参数由客户端应用程序定义。如果您想覆盖客户端设置,您可以创建一个DATABASE TRIGGER. 例如,这将LOGONBAR架构上创建一个触发器:

CREATE OR REPLACE TRIGGER bar.foo
   AFTER LOGON ON DATABASE WHEN (USER = 'BAR')
BEGIN
   dbms_session.set_nls('NLS_NUMERIC_CHARACTERS', '''.,''');
   EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA=hr';
END foo;

回答by Plasmer

I haven't tested this, but could you make the application call a stored procedure that set the session variables whenever a session is created? Then, you could modify the stored procedure on the server side when needed.

我还没有测试过这个,但是你能不能让应用程序调用一个存储过程来在创建会话时设置会话变量?然后,您可以在需要时修改服务器端的存储过程。