ALTER session set current_schema

Hello

We have multiple instances of the database (for example, MR01DEP, MR02DEP,...).

Each instance is composed of more than stores (called schemas): for example, for MR01DEP, we have STORE1, Bank 2, 3, to MR02DEP we STORE5, STORE6,... and so on.

Now, using developer PL/SQL, SQL Developer or even SQL Plus, when I connect to these databases, I connect using the user SUP_TMP (who has the privileges necessary for the actions that I have to do), and I have something like this:

Conn SUP_TMP / < password > @STORE1 (I can connect like this and not with @MR01DEP; However, even @MR01DEP is correct).

Today, all the tables are on these patterns (STORE1, STORE2,..), and when I connect with the SUP_TMP user, each time, at each meeting, I have to write:

ALTER session set current_schema = STORE1, or

ALTER session set current_schema = Bank 1

At the beginning of every script that I have to run, I want to write a little routine so that I don't need every time to this «alter session set current_schema» statement

If I connect with SUP_TMP / < password > @STORE1.

so I see in the instance of v$, as the instance_name is (correct) MR01DEP.

But I need to somehow get that banks '1', which I use when I connect to it (although, normally, I connect to a database, such as MR01DEP, but I'm specifying STORE1 in the connection string).

So, in other words, I need that at the beginning of each script, to determine the current connection string I'm specifying after '@', and which is the current_schema.

If I log in as SUP_TMP / < password > @STORE5, then I'll have something like immediate execution "alter session set current_schema = STORE5'."

SUP_TMP user should be the I connect each time, but the current pattern of each script in each session, must come from the connection string.

Is this possible?

Thank you!

I know, I specify the store, and it will automatically connect to the correct database (this is the case).

No - NOT sure that connect you to the right base.

As said ground that alias 'keep' is on the client and can be mapped to ANY DATABASE at all.

Also - what you specify with is the DATABASE - this isn't a pattern.

You're talking about two different things.

You set the current schema - you connect to a database. TWO DIFFERENT THINGS.

It may not even be a schema with the same name as the database.

Do not use the same name for the databases and schemas. Oracle is NOT sql server.

You can create a trigger AFTER the opening of SESSION to define the schema for you, but you must be able to know which schema must be defined.

Tags: Database

Similar Questions

  • 'ALTER SESSION SET CURRENT_SCHEMA' does not work

    Hello

    in my JAVA application, I need to change a user's session so that it gets access to the tables that are created by the user 'myUser' (see code below).

    The code below shows how I tried to implement with JAVA:

    ---------------------------------------------------------------------------------------------------------
    Statement stmtSchema = con.createStatement ();
    String sql = "ALTER SESSION SET CURRENT_SCHEMA = myUser;"
    check int = stmtSchema.executeUpdate (sql);
    ---------------------------------------------------------------------------------------------------------

    There is no exception later when running the program, but it seems that the SQL in JAVA command will have no effect because when the program tries a SELECT statement after the session I get an exception:

    Java.Sql.SqlException ora-00942: table or view does not exist

    This means that the current_schema has not yet changed.

    When I tried the same command with sqlplus, it works fine.

    Why it does not work with JDBC?

    We use 8.1.3 of Oracle and Oracle 10g Release 2.

    Hello
    just a validation test. You guarantee that the alter session command and the select statement is belonging to the same connection object?
    If the connection object is the same you can post a simple test cases for further investigation?
    Ciao,.
    Giovanni

  • Inverse of command 'ALTER SESSION SET.

    Hello

    I have a READER user and when I connected with this user that I can set the current session settings such as

    alter SESSION set smtp_out_server = '123.345.134.123';
    
    

    or

    alter session force parallel query parallel N;
    
    

    If it would be sysdba or any other user with grant on parameter $ v we could use:

    select value from v$parameter where name = 'smtp_out_server'
    
    

    Is it possible that I can get the current session settings without going through subsidies on the parameter $ v?

    PS: it seems strange, that we have the setter (alter session set), but haven't Get accessor.

    Maybe the function dbms_utility.get_parameter_value, assuming that you have the privileges.

  • ALTER session statement when login

    Hello
    on the 11 G R2,.
    I want the util_3 to change user2 session right on the connection. How is that possible?

    I want to avoid the util_3 of issue:
    ALTER SESSION SET CURRENT_SCHEMA =USER2
    at each connection.

    Thanks for help.

    use
    run immediately "ALTER SESSION SET CURRENT_SCHEMA = SCOTT';"

  • Several alter session and SQL * Net message from dblink in APEX

    Hello

    I have Apex 4.2.3 and I use Glassfish more listener of the Apex.

    Database is 11.2.0.4 under linux

    Looking for the session active database, I see that apex run several alter session with a lot of expectation as SQL * Net message from dblink the.

    Ex:

    ALTER session set NLS_TERRITORY = "AMERICA."

    call the query of disc elapsed to cpu count current lines

    ------- ------  -------- ---------- ---------- ---------- ----------  ----------

    Parse 58 0.00 0.00 0 0 0 0

    Run 58 0.06 3.53 267 58 0 0

    Fetch        0      0.00       0.00          0          0          0           0

    ------- ------  -------- ---------- ---------- ---------- ----------  ----------

    Total 116 0.06 3.53 267 58 0 0

    Chess in the library during parsing cache: 0

    The analysis of the user id: 277 (recursive depth: 1).

    Elapsed time are waiting on the following events:

    Event waited on times max wait for the Total WHEREAS

    ----------------------------------------   Waited  ----------  ------------

    SQL * Net message to dblink 174 0.00 0.00

    SQL * Net message from dblink 174 3.47 0.03

    ********************************************************************************


    Why he is doing a lot to change session? Why the wait is SQL * Net message from dblink the?

    We have recently to load a new language, but I'm not sure that this is the main problem.



    I think that you have the link db in the workspace schema and data requested by the Apex of this link. For example, it may be

    report which uses db link. Check dba_db_links or user_db_links for the existing links. Check if this link used by Apex.

  • ALTER session nls_date_format not retained

    Hello guys,.

    Here is the environment:

    Oracle 11.2.0.1 on Linux 64-bit RHEL DB

    Oracle 11 g 2 on Windows 2008 R2 32-bit client

    Our product works service (code generated in c ++) and the service opens 5 sessions of database and alter session set nls_date_format questions to HH24:MI:SS DD/MM/YYYY in each of them.

    But searching through the service logs, I see that select statements (to_char (date)) return date in format other than what has been defined via "alter session" i.e. they do not see the part and just JJ-LUN-AA. But the same select instructions out the date in the format of correct/expected (according to alter session statement).

    The problem is that we do an insert in a table taking the current system time and running to_date (< time system >). It is a failure with: ORA-01843: not one month valid. I understand that it must specify a format for the input string, the date system, but we do not and was not a problem for someone else.

    I'm also no disconnected sessions or reconnects.

    Customer Oracle NLS_LANG is: AMERICAN_AMERICA. UTF8.

    This problem occurs for one of our customers who use this product. All other clients do not encounter this problem, as this has been a long-standing code. I'm not saying that the code is perfect and looking at some of the SQLs, we rely on implicit conversion of data in Oracle instead of editing the SQL code, but this has never caused a problem to any other customer.

    I understand the hierarchy of setting NLS_DATE_FORMAT i.e. the database, register of operating system of the customer, the customer Oracle (alter session) and finally to_date/to_char functions.

    It seems that the session format game becomes overloaded as when they restart the service in our product everything is back to normal until a couple of days, when queries in the service connects begin to show the date incorrect without time portion and just JJ-LUN-AA.

    Any help would be appreciated as I had read a lot on the internet with no evidence outside this site including our customer:

    ttp://StackOverflow.com/questions/15396241/CX-Oracle-ora-01843-not-a-valid-month-with-Unicode-parameter h

    Thank you

    Bharath

    Bharath3 wrote:

    ...

    My question is, why the session loses the settings of NLS_DATE when it doesn't happen to anyone else? I think that the format is getting replaced in the sessions but how do I know that? How to find environmental changes to current public meetings?

    Maybe you have a connection pool if every session is used by different... hmm applications or threads. Even if you issue a command of nls alter at the start of the session, some processes could change this setting later. This is why it is best to not depend on any parameter of session happened when the connection was established.

    Best solution: just use the correct format inside the to_Char conversion. Or issue a command to alter session immediately before running the selection.

  • ALTER session with ADF App statement

    Hello:

    11.1.2.3 Jdev
    RedHat 5.8
    Oracle db 11.2.0.3

    When you use a Web of Fusion ADF application, what are the consequences if we issue the command of database:

    ALTER session set time_zone = - 6; for a particular user

    For example, if the session is passivated? The database session remains with request on passivation module? or weblogic failover?

    Or will be session and users mix?

    Thank you very much.

    Hello

    you don't have a 1:1 data association in web applications. If you need to change the database to a user session you will have to do for each request, which means that you override the method of prepareSession AM ADF BC database alter session statement. So to answer your questions

    The database session remains with request on passivation module?

    N °

    or weblogic failover?

    N °

    Frank

  • ALTER SESSION in sql script produces strange results

    Why "alter session set NLS_DATE_FORMAT" would interfere with the operation of a sql script?

    First of all, the script without the ALTER SESSION:
    SQL> !cat doit1.sql
    --alter session set NLS_DATE_FORMAT = "DD-MON-YYYY"
    set pagesize 99
    set trimspool on
    col BIRTH_MONTH for a11
    break on BIRTH_MONTH skip 1
    spo doit.txt
    prompt My Membership
    set feedback off heading off
    select 'As of ' || sysdate from dual;
    set heading on
    --
    select count(*) from dual;
    --
    spool off
    And its execution:
    SQL> @doit1
    My Membership
    
    As of 14-JAN-10
    
      COUNT(*)
    ----------
     1
    Everything is well with the world. Now let's throw in the ALTER SESSION:
    SQL> !cat doit2.sql
    alter session set NLS_DATE_FORMAT = "DD-MON-YYYY"
    set pagesize 99
    set trimspool on
    col BIRTH_MONTH for a11
    break on BIRTH_MONTH skip 1
    spo doit.txt
    prompt My Membership
    set feedback off heading off
    select 'As of ' || sysdate from dual;
    set heading on
    --
    select count(*) from dual;
    --
    spool off
    And its performance
    SQL> @doit2
    set pagesize 99
    *
    ERROR at line 2:
    ORA-00922: missing or invalid option
    
    
    
      COUNT(*)
    ----------
     1
    not spooling currently
    SQL> 
    Don't like the SET commands (I played a bit with many, he does not like one any of them) and does not take account of the order of the opening COIL

    First of all, I've noticed this with a 10.2.0.1 connected to a 10.2.0.4 (windows) client database (HP - UX). Confirmed on my laboratory portable VM, 10.2.0.4 under OEL5, client and db on the same virtual machine.

    You are missing just the leak ';' at the end of the line to alter session. Add to that, it all works.

  • ALTER session in cfquery statement

    Hello world

    Would it not possible to use the alter session in a query?
    I would like to do something like this:
    < cfquery >
    ALTER SESSION SET NLS_COMP = LINGUISTIC;
    ALTER SESSION SET NLS_SORT = GENERIC_BASELETTER;
    Select geo_indication in the eccgis where country_fk = 'PT' and geo_indication like "% O";
    < / cfquery >
    As good in sqlDeveloper (oracle, without cfquery...), the application gives an error in CF (of semicolumns?).
    Did anyone get an idea?

    Thanks in advance,
    Michel

    Thank you very much.

    It is now fixed:
    The sort order also has implications on the SEARCH mechanism
    Looking for Oxxxxxx you can't find Óbidos
    and now:
    Search do not look upcase and focus more.

    Michel

  • ALTER session isn't wofking

    Hi all

    I created the process to edit the session to control the currency format, in any way the process works fine on the home page, but when you visit another page or return to the home page the session value (currency format) goes back to the previous setting ($). How can I keep this session fixed and consistent across my Web site?

    Also when I change the order of any report that the currency format will be shown in the older framework ($), I use the reports of PPR.

    PS, does not change when moving between pages of session state is same. Also, I tried the application process and process page on new session and the page load.

    Thank you
    Fadi.

    Try to add to the attribute VPD of your application (security settings):

    run immediately "alter session set nls_currency ="? "" ' ;

    .. .adjusted for what you really need.

    To clarify, it is an "equal" sign, followed by two single quotes consecutive, followed by a question mark where you can use the desired currency symbol, followed by three apostrophes, terminated by a semicolon.

    Scott

  • ORA-02248: invalid option for ALTER SESSION during the connection of the customer

    Hello
    I'm a junior dba and I was hoping if someone could help me with a problem I have. I recently installed on the oracle 10g client on my windows machine. I am trying to remote connect to my database on a unix machine, but I get error trying to connect from the client below.

    ERROR:
    ORA-00604: an error has occurred at the SQL level 1 recursive
    ORA-02248: invalid option for ALTER SESSION

    I did some searching on that and I think it might be something to do with the NLS_LANG setting maybe. I do not know if and to be honest, I'm a little lost on this.

    Any help would be greatly appreciated. See you soon.

    RGS,
    Rob

    Hello

    what the SQL you gave?

    Check the run-> regedit NLS_LANG parameter and change it according to env

  • Query on ALTER SYSTEM SET


    Hello

    I was under the impression that

    "PFILE has limitation to change settings for initialization of dynamically. If any initialization parameter must be changed, we can edit the pfile parameter changes take effect with the next restart of the system

    To work around this limitation, Oracle has created the concept of the SPFILE initialization parameter can be changed dynamically using ALTER SYSTEM SET statement. »

    But, today, I started my test using PFILE database and run the following command to change the setting of the memory_target from 300 to 290 M.

    ALTER SYSTEM SET memory_target = 290 M;

    And to my surprise, this statement executed correctly without errors and memory_target parameter has been set to the new value (of course, in memory).

    Isn't it change the init dynamically using PFILE itself?

    Please clarify my doubt and correct my understanding.

    Kind regards

    Bharath

    bharathDBA wrote:

    Hello

    I was under the impression that

    "PFILE has limitation to change settings for initialization of dynamically. If any initialization parameter must be changed, we can edit the pfile parameter changes take effect with the next restart of the system

    To work around this limitation, Oracle has created the concept of the SPFILE initialization parameter can be changed dynamically using ALTER SYSTEM SET statement. »

    But, today, I started my test using PFILE database and run the following command to change the setting of the memory_target from 300 to 290 M.

    ALTER SYSTEM SET memory_target = 290 M;

    And to my surprise, this statement executed correctly without errors and memory_target parameter has been set to the new value (of course, in memory).

    Isn't it change the init dynamically using PFILE itself?

    Please clarify my doubt and correct my understanding.

    Kind regards

    Bharath

    You have a bad mixing on the genesis of the SPFILE. Yes, it is a binary file and all this but remember, isn't the SPFILE which makes a dynamic parameter or a PFILE that makes static, but it is the nature of the setting itself which allows to happen. Yes, the difference in the PFILE and SPFILE parameter would be obvious when you change a dynamic parameter, and would give a rebound to the db. Since the PFILE file has not been updated (it's a text file must be updated manually), with the next restart, the setting would take the same value as it has in the PFILE file. But with the SPFILE, depending on what you have set in SCOPE, the parameter should behave accordingly.

    HTH

    Aman...

  • ALTER session privilege

    Hello
    Is there a reason why a developer may not have the privilege to alter session? My understanding of this privilege is that they will be able to make changes in only their own session, once they are disconnected the changes are cancelled. Is there any changes he could do in their own session that I (dba) will be wary of?

    Thank you.

    user8869798 wrote:
    Hello
    Is there a reason why a developer may not have the privilege to alter session? My understanding of this privilege is that they will be able to make changes in only their own session, once they are disconnected the changes are cancelled. Is there any changes he could do in their own session that I (dba) will be wary of?

    Thank you.

    Yes, your interpretation is correct that they are looged off the coast of changes back its session. But there are a number of reasons when ppl do not like to give developers alter session privilege.
    There are powerfully parameter during their session, developers can change like:

    
    sort_area_size
    optimizer_mode
    statistics_level
    optimizer_dynamic_sampling
    optimizer_use_pending_statistics
    optimizer_capture_sql_plan_baselines
    optimizer_use_sql_plan_baselines
    parallel_min_time_threshold
    parallel_degree_limit
    parallel_force_local
    optimizer_use_invisible_indexes
    parallel_min_percent
    cursor_sharing
    result_cache_mode
    parallel_instance_group
    hash_area_size
    result_cache_remote_expiration
    object_cache_optimal_size
    object_cache_max_size_percent 
    

    So if these parameter is changed into something weird that they can impact any database, specifically they can lower down the performance of the database and features.

    Best practice always review the requirements of developers and then after checking give privilege to alter session.

    Also check that the parameters can be modified using alter session

    Select the name of the parameter $ v where ISSES_MODIFIABLE = 'TRUE '.

    Hope this helps

  • ALTER system set events

    Hi all

    I use a 10.2.0.4 Oracle version.

    My colleague trace active generation using: alter system set events 942 trace name errorstack level 3';

    How will I know if it is active now? And how can I turn it off?

    Kind regards
    dbajug

    How will I know if it is active now?

    For all the events that are defined at the system level, try and check the trace file created in USER_DUMP_DEST directory:

    alter system set events 'immediate trace name events level 4';
    

    And how can I turn it off?

    Try:

    alter system set events '942 trace name errorstack off';
    
  • ALTER SYSTEM SET SGA_TARGET

    Hello
    in 10g R2 should I power of database when I change sGA_TARGET:

    ALTER SYSTEM SET SGA_TARGET = value [SCOPE = {SPFILE |}] MEMORY | BOTH}]

    Thank you.

    user522961 wrote:
    Hello
    in 10g R2 should I power of database when I change sGA_TARGET:

    ALTER SYSTEM SET SGA_TARGET = value [SCOPE = {SPFILE |}] MEMORY | BOTH}]

    Thank you.

    You don't need to restart the database for this change.

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14237/initparams193.htm

Maybe you are looking for

  • Satellite L755-M1DU - I deleted Utility of Toshiba Flash Cards

    Hello Satellite L755-M1DUPart number: PSK2YE-0DU02UAR I lost my phone :( And I accidently deleted (utility of Toshiba Flash cards) What can I do? And where and how do I get maps Flash appears when you press the function key? Thank you

  • System error IMAQ using IMAQ Clipboard to Image

    Hello I have a VI that prints screen then use the Cliboard IMAQ to Image function to get the image into something that I can handle in LabVIEW. It works perfectly when I'm in the LabVIEW environment. As soon as I select any other program LabVIEW thro

  • Cannot install XML Core Services 4.0 Service Pack 2 (KB954430)

    Have tried to install the update of security for Microsoft XML Core Services 4.0 Service Pack 2 (KB954430) since Nov 08 and it continues to fail; Microsoft .NET Framework 3.5 Service Pack 1 for .NET Framework 3.5 Family Update (KB951847) x 86 as well

  • E1200 cloning MAC address but not the PC

    My ISP requires MAC authentication on the router for internet access. They provide the router and register for this router to their access list. I'm not very happy with the router, that they provided, so I intend to buy an E1200 and clone the MAC add

  • 'Messages' blackBerry smartphones / CBX_SylVer_Stars

    Is there anyway that I can make missed calls and email will DO NOT the application of messages? I can't in any case to change it.