Are the settings of oracle server like , the nls_date_format,.... attributes (I don't know really how many of these kind settings are there) , will be downloaded to the oracle client running on different machine by connecting to the SQL*plus using server host name?
Or the client will maitain its different set , assuming the client is SQL*Plus.
If the client is having its own settings ,is there any way If I can set the same settings as server. like export all settings from server and import those settings to client.
If the client is SQL Developer , is there any way to maintain the sync. between server settings and client's.
You can query the settings (about 20 variables) from the NLS-Views (NLS_DATABASE_PARAMETERS, NLS_INSTANCE_PARAMETERS, NLS_SESSION_PARAMETERS). By show parameter nls you can view the actual settings in SQL*Plus.
These can be altered by sysdba in several ways:
The database parameters are read from (s)pfile while startup. They can be altered via ALTER SYSTEM SCOPE=SPFILE if you use spfile. If you use pfile you have to edit it manually
The instance parameters are set by ALTER SYSTEM SCOPE=MEMORY and will be lost upon shutdown
Both at once can be altered using SCOPE=BOTH. This will be applied immediately and survive the shutdown
The client can override this for his own session in (at least?) two ways:
Set it for your session by ALTER SESSION in SQL*Plus
Set environment variables before client startup via export NLS_...=... in the shell
The latter overrides the earlier ones, so SESSION beats INSTANCE which eats DATABASE.
For your question: you can use a SELECT * FROM NLS_INSTANCE_SETTINGS and apply these to your current session by ALTER SESSION SET ... for each of these variables (maybe via some PL/SQL procedure). Another way would be just to unset all session parameters so that the instance parameters will be used.
If you do not set any NLS variables (especially NLS_LANG) in your environment, your session should be the same as the instance or the database ones. In practice this will never work as expected as you always have some locale settings that produce weired results in SQLP*Plus. ;-)
Related
I have Oracle RAC 10g environment with two nodes.
On connection we set the session TIME_ZONE using ALTER SESSION.
But, on switching the session to another node , RAC lost TIME_SONE settings.
How to keep session parameters upon switching to another RAC node?
Tx
If you're talking about Transparent Application Failover there is probably no easy way to do this:
You must also reexecute any session customizations, in other words,
ALTER SESSION statements, after failover has occurred.
There may be workarounds, depending on how you set the session settings. For example, if all the relevant sessions come from the same application, computer, etc., you can use a logon trigger that sets the same settings. You can find the relevent session using v$session.failed_over = 'YES', and matching other relevant columns in v$session.
Is it possible to alter the session permanently even after i close my oracle sql developer?
An example of the statement that i want to alter:
Alter Session Set Nls_Timestamp_Tz_Format='HH24:MI TZR';
The above statement only allow me to alter the current session and not making it permanently.
Thanks
If you just want to change the default value for SQL Developer, you can do that in the SQL Developer settings. In SQL Developer 3.1 (the same settings exist in earlier versions though the navigation may be slightly different), Tools | Preferences | Database | NLS allows you to specify a Timestamp Format and a Timestamp TZ Format. SQL Developer will then automatically issue the appropriate ALTER SESSION commands for you whenever it creates a new session.
You need to set this in the initialization parameter file to affect the database globally.
Initialization parameters such as Nls_Timestamp_Tz_Format can be set up from three sources:
In a session using the ALTER SESSION SET statement
In client side parameter file init.ora
In server side parameter file spfile
To set default permanently in the db, from the database:-
alter system ... scope=spfile;
then as SYS (so you may need to talk to a DBA), and obviously at an appropriate time! -
shutdown;
startup;
(I know the spfile has been mentioned, but it can all be done from the sqlplus cmdline, at least in 11g.)
We have created a "after logon" trigger to alter the session in order to set the two NLS settings - NLS_SORT and NLS_COMP. NLS_SORT needs to be set to BINARY_CI and NLS_COMP needs to be set to LINGUISTIC. By querying the V$NLS_PARAMETERS view after establishing the connection to verify the values I see that NLS_COMP parameter gets updated but NLS_SORT doesn't.
After researching more I realized that the OCI JDBC driver executes the below query after the connection is established
ALTER SESSION SET NLS_LANGUAGE='AMERICAN' NLS_TERRITORY='AMERICA'
Since NLS_SORT derives its values from NLS_LANGUAGE, NLS_SORT parameter value resets to BINARY instead of BINARY_CI. The NLS_LANGUAGE setting is taken from windows registry.
Does the oci jdbc driver execute these queries to synchronize the NLS settings on the client to that with the database server?
Can the jdbc oci driver be configured to avoid executing the alter session set NLS_LANGUAGE query?
The reason I ask the second question is that it doesn't make sense for application server (e.g glassfish, tomcat, jboss) machine (on which the OCI client is installed) settings to override the database server settings.
I have been wrestling with the exact same problem after introducing a trigger on logon for setting these values.
"The purpose of the NLS_LANGUAGE and NLS_TERRITORY settings are to let the database know locale information. These are derived from the NLS_LANG setting on the client (but can also be changed). These settings allow the database to send data back to the client in the expected format and language." - taken from here
No, it can't be configured to avoid that execution, though it might be a future feature. As it is, it seems the only solution is to have your application always change these parameters after logging in.
It might be of help to know that if you're using the thin connector rather than the OCI-driver and you set an on logon trigger, these values will be set properly after logon. The problem here is with the OCI-driver that will set up these values according to NLS_LANG only after the logon trigger has been executed.
According to chapter 19 Globalization Support from Home / Database / Oracle Database Online Documentation 12c Release 1 (12.1) / Application Development / Database JDBC Developer's Guide:
Starting from Oracle Database 10g, the NLS_LANG variable is no longer
part of the JDBC globalization mechanism. The JDBC driver does not
check NLS environment. So, setting it has no effect.
ALTER SESSION statement which you observed probably comes from the following statement from Globalization Support for JDBC Drivers section of chapter 9 Java Programming in a Global Environment from Oracle9i Database Globalization Support Guide (Release 2 (9.2)):
At database connection time, the JDBC Class Library sets the server
NLS_LANGUAGE and NLS_TERRITORY parameters to correspond to the locale
of the Java VM that runs the JDBC driver. This operation is performed
on the JDBC OCI and JDBC thin drivers only, and ensures that the
server and the Java client communicate in the same language.
I found out my servers, running Oracle 10g, were not initializing with the same NLS_SORT value when using the sqlplus binary.
Is there a way to set the default NLS_SESSION_PARAMETERS for every instance of sqlplus?
PS: The idea is not to do an ALTER SESSION at the beginning of every sql script.
the NLS parameters are specified by the client application. SQL*Plus on windows will have its parameters defined in the registry (same as the ORACLE_HOME where it is installed). On *nix systems the paremeters are defined as environment variable.
You can find additionnal information in the documentation.
Use an ON LOGON trigger to do the ALTER SESSION?
Then you can do it in one place and won't have have to change every client.
i'm developing a 32bit Client-Application with Delphi. From this application I need to connect to databases on two different servers. First databse character set ist WE8MSWIN1252, the other server decodes with WE8PC850. Setting the client NLS_LANG parameter to the correct value solves correct sql-query results.
Unfortunately this (the client character-set) seems only to be recognized on applications startup (first connect to oracle). I need to change the client-characterset at runtime. Oracle client seems to store the character set an application used to connect!
beside: I#m using udl-files to setup the connections (Microsoft OLE DB - driver)
what can I do?
You could use ALTER SESSION calls to change the settings at the session level after connecting to the database.
I need to change the
client-characterset at runtime.
Why ? I would have thought what you want at the client end is a character set that is acceptable to the operating environment and end-user.
Pick out a character set such as UTF-8 and let Oracle handle the conversion between the client character set and the two database character sets.