How To Set a NLS Session Parameter At Database Or Schema Level For All Connections?
2018-02-07 11:08
2436 查看
How To Set a NLS Session Parameter At Database Or Schema Level For All Connections? (Doc ID 251044.1) |
APPLIES TO: Oracle Database - Enterprise Edition - Version 8.0.3.0 to 11.2.0.3 [Release 8.0.3 to 11.2] Oracle Database - Enterprise Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2] Information in this document applies to any platform. PURPOSE How to define some NLS session parameters for all clients, regardless of the used NLS_LANG (or other NLS parameter) setting on the client side SCOPE Anyone who want to control NLS settings from the server side. DETAILS Why to set a NLS session parameter at Database or Schema level for all connections? The client side NLS setting will override the instance NLS settings like documented in Note 241047.1 The Priority of NLS Parameters Explained. So you have no "server side" control on the used NLS session settings as they are derived from the client side. However, if you like to overwrite some NLS session parameters for all clients, regardless of the used NLS_LANG (or other NLS parameter) setting on the client side then you can do that, for most environments, in the way described in this note. Please note that: * Oracle recommends you to define always the (correct) NLS_LANG. The <characterset> part of the NLS_LANG is a (very important) client only parameter and cannot be set or defined from server side for a session. Why this is so important is documented in Note 158577.1 and note 179133.1 * This is *not* working for some JDBC drivers , see Note 115001.1 NLS_LANG Client Settings and JDBC Drivers And may also not work for other 3the party connection methods,if the connector issues from the driver itself alter sessions after the logon procedure of Oracle is done then they will override the trigger. * When using a PL/SQL package procedure called by the logon trigger and this has any unhandled exceptions or raises any exceptions, then the logon trigger fails. When the logon trigger fails, the logon fails, that is, the user is denied permission to log in to the database * We do NOT recommend to have several "after logon" triggers, for setting NLS parameters seen the execution order may differ. See Note 121196.1 Fire Sequence of Database Triggers How to set a NLS session parameter at database level for all connections ? Create an event trigger like this: (Example for the NLS_TIMESTAMP_TZ_FORMAT parameter) CREATE OR REPLACE TRIGGER sys.global_nls_session_settings AFTER LOGON ON DATABASE BEGIN execute immediate 'alter session set NLS_TIMESTAMP_TZ_FORMAT =''DD/MM/YYYY HH24:MI:SS TZR TZD'''; END; / How to set a NLS session parameter at schema level for all connections ? You can also create a logon trigger for one schema: (Example for the NLS_DATE_FORMAT and NLS_NUMERIC_CHARACTERS parameter for the scott schema) CREATE OR REPLACE TRIGGER sys.schema_nls_session_settings AFTER LOGON ON SCOTT.SCHEMA BEGIN execute immediate 'alter session set NLS_DATE_FORMAT=''DD/MM/YYYY HH24:MI:SS'''; execute immediate 'alter session set NLS_NUMERIC_CHARACTERS=''.,'''; END; / What NLS parameters can be set using logon triggers? The parameters which can be set like this, are all the NLS parameters you can do an alter session for: 8i and up: NLS_CALENDAR NLS_COMP NLS_CREDIT NLS_CURRENCY NLS_DATE_FORMAT NLS_DATE_LANGUAGE NLS_DEBIT NLS_ISO_CURRENCY NLS_LANGUAGE NLS_LIST_SEPARATOR NLS_MONETARY_CHARACTERS NLS_NUMERIC_CHARACTERS NLS_SORT NLS_TERRITORY NLS_DUAL_CURRENCY NLS_TIMESTAMP_FORMAT NLS_TIMESTAMP_TZ_FORMAT new in 9i/10g: NLS_LENGTH_SEMANTICS NLS_NCHAR_CONV_EXCP note: NLS_TIME_FORMAT and NLS_TIME_TZ_FORMAT are used internally only and should NOT be set or altered Again, the client character set CANNOT be set or defined this way. How to see if there are logon triggers? This select gives you all defined after logon triggers: conn / as sysdba select OWNER, TRIGGER_NAME, TRIGGER_BODY from DBA_TRIGGERS where trim(TRIGGERING_EVENT) = 'LOGON' / select OWNER, TRIGGER_NAME, TRIGGER_BODY from DBA_TRIGGERS where upper(TRIGGER_NAME) = 'LOGON_PROC' / REFERENCES NOTE:115001.1 - NLS_LANG Client Settings and JDBC Drivers NOTE:241047.1 - The Priority of NLS Parameters Explained (Where To Define NLS Parameters) Was this document helpful? Document Details Email link to this documentOpen document in new windowPrintable Page Type: Status: Last Major Update: Last Update: BULLETIN PUBLISHED 16-Jul-2015 06-Dec-2016 Related Products Oracle Database - Enterprise Edition Oracle Database - Enterprise Edition Information Centers Information Center: Overview Database Server/Client Installation and Upgrade/Migration [1351022.2] Index of Oracle Database Information Centers [1568043.2] インフォメーション・センター: データベースおよび Enterprise Manager 日本語ドキュメント [1946305.2] Information Center: Overview of Database Security Products [1548952.2] Document References Recently Viewed How To Set a NLS Session Parameter At Database Or Schema Level For All Connections? [251044.1] NLS_LANG Client Settings and JDBC Drivers [115001.1] IF: High Requests on dc_rollback_segments [1951703.1] WebLogic Server:使用XA Datasource发生 - 获取“XAER_NOTA:XID无效”异常 [2357599.1] How to Validate Network and Name Resolution Setup for the Clusterware and RAC [1054902.1] Show More Didn't find what you are looking for?Ask in Community... Related Products Oracle Database Products > Oracle Database Suite > Oracle Database > Oracle Database - Enterprise Edition > RDBMS Oracle Database Products > Oracle Database Suite > Oracle Database > Oracle Database - Enterprise Edition > RDBMS > NLS Conversion issues, Characterset Conversion, Characterset issues (lossy and truncation data)
相关文章推荐
- How to set trace for others sessions, for your own session and at instance level
- How To List All The Named Events Set For A Database [ID 436036.1]
- 11i - 12 How To Set Email Style Preference For All Users At Once?
- How To List All The Named Events Set For A Database
- How To List All The Named Events Set For A Database [ID 436036.1]
- How to Set Cores-Per-Socket Parameter for a Virtual Machine
- ORA-00604: error occurred at recursive SQL level 1 ORA-12705: invalid or unknown NLS parameter value
- How To Configure Client Failover For Dataguard Connections Using Database Services (Doc ID 1429223.1
- How to Set Cores-Per-Socket Parameter for a Virtual Machine
- How to set Item Level Permission for SharePoint 2007 (MOSS/WSS) List/Document Library Programmatically
- How to configure a Windows RADIUS server for 802.1X Wireless or Wired Connections
- How to Enable SQL_TRACE for Another Session or in MTS Using Oradebug(文档 ID 1058210.6)
- How to Modify the Password for SYSMAN and other Enterprise Manager Users at the OMS Level and Reposi
- How to fix the issue that GEM_HOME and/or GEM_PATH not set issue for rvm in mac version 10.12
- How to set bmp for your UserControl in the toolbox
- hive:For direct MetaStore DB connections, we don't support retries at the client level
- How to point cmake at specific directory for library?
- 5 Tips for creating good code every day; or how to become a good software developer
- How to set network proxy for terminal in Ubuntu
- How To Set An Android Lock Screen PIN, Password or Unlock Pattern