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.
Related
I have an Oracle Package with some Global Variables which are initialized and used on all procedures of that package.
When I call the procedures (via jdbc connection and calls) the global variables are correctly initialized and their values persists through all procedures on the database session that was opened, but when I have multiple jdbc connections it seems that the global variables values are mixed between the calls.
Isn't Oracle sessions isolated in terms of packages variables? Is there some configuration that I need to do on the database or user profile to guarantee that isolation?
My DB Instance is in a RAC with 2 nodes.
Each database session has its own set of variables, yes.
I would expect that your Java application is using a connection pool such that your Java application is constantly getting connections from the pool and returning them to the pool. If that's the case, there is no relationship between a Java session and an Oracle session. A particular Java session might use Oracle session A for the first call, Oracle session B for the second call, C for the third call, and B again for the fourth call. And other sessions would be doing the same thing so the state of session B might have changed between the two calls because some other Java session used it in the interim.
Some connection pool implementations explicitly clear out package variables when a session is returned to the pool so that data doesn't leak from one session to another. Other implementations would allow the different Java sessions to see the package variables in whatever state they happen to be from the prior call. In either case, maintaining state in packages as part of an enterprise Java application is a bad idea.
It is possible that you want a global context instead but it's hard to know that for sure since we don't know what problem you're trying to solve with your package variables.
I am exploring use of Oracle EBR in for hot patching of our application database. I have searched in Google regarding EBR. What I understand is that EBR will allow user to have many versions of same DB object like PL/SQL procedure etc. User will be able to access a new version when it is enabled for that particular user and the transition will be seamless for existing user i.e. existing sessions will be unaffected. But I am not able to understand how it will not affect the existing sessions. For example if user "X" is in middle of a transaction that uses a DB session and a new EBR version is enabled for that user, won't it affect the current DB session? or will the current DB session won't see the existing EBR and only new sessions will see the new version. Please let me know your opinion.
An edition is enabled at the session level not at the user level. If user X has a dozen sessions, each of those sessions could be using a different edition.
It really wouldn't make sense to try to change the edition the session is using in the middle of a transaction. I can't imagine why you'd want to try. And I'd wager heavily that it wouldn't work.
If you're using edition-based redefinition, you would realistically enable the new edition for new sessions or between transactions in a particular session. Commonly, you'd do a rolling upgrade where each application server gets rebooted and the connection pool set to use the new edition while the connection pools on the other servers remain using the old edition.
I am using Oracle 11g.
I am looking for a good explanation of Oracle Sessions. I googled for this, but strangely, none of the web sites contain any explanation of what oracles sessions are. My specific questions are
1) What are oracle sessions?
2) Does one connection object always relate to one oracle session.?
3) can one oracle session be shared by another connection started by the same user.?
A logical entity in the database instance memory that represents the state of a current user login to a database.
A single connection can have 0, 1, or more sessions established on it.
I can't imagine that it can
http://docs.oracle.com/cd/E28271_01/server.1111/e25789/glossary.htm
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. ;-)
Is there a tool (that already comes with Oracle) for tracing SQLs that have been executed? In DB2 there is something called an 'event monitor' which I use to track the tables that have been updated. Is there an equivalent tool in Oracle?
I plan to
enable tracing
go on the website (that uses the db) and change an entry
disable tracing
see output file and record which table has been updated.
There is a table I am looking that should be updated when the entry is changed. I do not know what the name of the table is (and there are many tables), and so I need to trace the SQL executed to find out.
I have tried:
ALTER SESSION SET sql_trace = true;
-- go on website and change an entry
ALTER SESSION SET sql_trace = false;
tkprof the_trace_file.trc file.out EXPLAIN=system/manager SYS=no
However when following those steps above, no SQLs were recorded.
Is there a tool that Oracle provides? (I would like to avoid downloading external software)
There is a table I am looking that
should be updated when the entry is
changed. I do not know what the name
of the table is (and there are many
tables), and so I need to trace the
SQL executed to find out.
I'm thinking you are using the word "trace" here with another meaning than what is usually meant in the Oracle world.
You basically hit some button in the app, and by looking at what SQL queries are running, you want to find what table that code was referencing? Did I get it right?
In that case, you could have a look at v$sql, and look at columns SQL_TEXT and SQL_FULLTEXT.
The ALTER SESSION commands work at the session level (ie your current connection).
The website will use a different session (probably from a connection pool).
You can enable tracing for all sessions using the ALTER SYSTEM SET sql_trace = true;
The main reason you didn't get anything in the trace file is because you didn't do anything in the session where trace was enabled.
If you'd have done:
alter system set sql_trace = true;
-- fiddle around with the website
alter system set sql_trace = false;
You'd have gotten one or more trace files, one for each session which had activity while you were fiddling with the website.
The problem is that if the website uses connection pooling, your user activity may have been spread across several connections, and may be intermingled with other concurrent user activity.
Maybe Oracle Audit will help you.
Here is a good explanation: http://www.oracle-base.com/articles/10g/Auditing_10gR2.php
You have to enable audit by setting the parameter AUDIT_TRAIL.
That is at server level. You can audit at client level using a third party sql tracer for OCI:
http://sourceforge.net/projects/ocimonitor/
I find the Enterprise Manager the most useful tool for this. As has already been noted you have to alter the session that the web site is using and not your own. If you set your connection pool limit to 1 connection, you can easily find the session in the enterprise manager and then turn on the tracing. Usually a find the the top queries display in the enterprise manager tells me what queries are taking too long without having to trace anything.