Which user/schema executed query in V$SQLAREA

I am looking on one row/query in view "V$SQLAREA" and want to which user/schema was used to log in to the database when that one query was executed. How i can get that schema name?
Should i look this column maybe:
V$SQLAREA
PARSING_SCHEMA_NAME             VARCHAR2(30)      Schema name that was used to parse this child cursor( http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2129.htm )
I have Java software that uses different database schemas/users to make connections to my database. And i want to know for one query which schema/user was used to connect to database before running the query.
I think i need to join "V$SQLAREA" to view V$SESSION and there the column "USERNAME" tells me the connection user name for the executed query.
V$SESSION
USERNAME      VARCHAR2(30)      Oracle username
( http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2088.htm )Seems like i fail to join "V$SQLAREA" to view V$SESSION:
select q.SQL_TEXT, q.sql_id, q.PARSING_SCHEMA_NAME, q.ADDRESS, q.last_active_time, s.USERNAME, s.SCHEMANAME from v$sqlarea q, v$session s
where q.last_active_time > sysdate - 1
and q.sql_text like 'DELETE FROM casino.lgngameoperationlog WHERE sessionCode%'
and s.sql_address=q.address
order by last_active_time desc
no rows found
select q.SQL_TEXT, q.sql_id, q.PARSING_SCHEMA_NAME, q.ADDRESS, q.last_active_time from v$sqlarea q
where q.last_active_time > sysdate - 1
and q.sql_text like 'DELETE FROM casino.lgngameoperationlog WHERE sessionCode%'
order by last_active_time desc
'DELETE FROM casino.lgngameoperationlog WHERE sessionCode = :1 and sessionType = :2';     51thfgbubkkg6;     JAVA;     0000000392523658;     28.10.2010 18:09:14;
*/

I have Java software that uses different database schemas/users to make connections to my database. And i want to know for one query which schema/user was used to connect to database before running the query.If the SQL-text sits inside your Java code, that is the text does not sit inside some stored pl/sql program unit, then you can use parsing_schema_id, yes.
If the SQL-text sits inside a stored procedure, then depending on how that procedure is defined (invoker rights or definer rights), you could use parsing_schema_id too (in the first case (invoker rights)).

Similar Messages

  • How to know which user has executed which ddl statement

    Hi All,
    Last week i faced some problem, like some one has truncated the table , so luckily i have the schema backup so i restored it till the last backup taken.
    but i want to know who has executed this ddl statement.
    i know there are some utilities are avaible with oracle, so please describe me the easiest and quickest way to get this.
    Regards
    Asif

    In order of descending simplicity
    - Use the principle of least privilege to restrict the privileges users have in the database to ensure that they cannot do things like truncating a table
    - Enable auditing of potentially problematic statements. This has to be done before the damage is done, though
    - Create a DDL trigger that logs when users issue DDL. This also must be done before the damage is done.
    - Use LogMiner to go through the archived log files that were generated at the time the table was truncated. This assumes that the database is in ARCHIVELOG mode and that you have the archived logs from last week. Using LogMiner to track down the culprit is also likely to be relatively time-intensive
    Justin

  • Problem in execute query?

    hello all,
    table structure:
    create table cor_dept_mst (dept_locn_code varchar2(6) not null,
    dept_code varchar2(2) not null, dept_name varchar2(200), constraint cordeptmst_pk primary key(dept_locn_code,dept_code));
    in form all 3 feilds dispaly.
    when i save new record.. save successfully.
    but when i execute query records not display (do not pass any value)
    records are display after execute if and only if i pass value to dept_code. in this case i pass 01 for dept_code and all records displaying...
    this very silly error.. i use block where clause.
    please help
    thanks
    yash

    oopss.....
    there was a silly code which halt the execute query...

  • How to see the user log of query

    Hi all ,
    Can any body help me about the log of user access to a Bex 3.5 query ? We want to learn which users access to query designer and make changes on queries. The query designer only give us the last user who access to query. Is there a transaction or something that we can see this information.

    Hi Selen,
    Check RSZCHANGES and note down the compid
    and check it in RSZCOMPDIR
    Check these tables in SE11
    check these threads even..
    [Change logs for query...........;
    [Id of logged in user;
    [http://help.sap.com/saphelp_nw04s/helpdata/en/43/5fa1dc3c046e47e10000000a422035/frameset.htm]
    Regards,
    NR
    Assign points if helpful...

  • WRH$** tables, Need to know by which user SQL Query has been executed

    Hi,
    From the AWR data (WRH$) tables , I need to know how many sql code is using some specific indexes, I found that information by using the mentioned code. but I need to find out by which user this code has been executed ( not the PARSING_SCHEMA_NAME). Can someone please help me, how can I get that info?
    select a.operation,a.OBJECT_OWNER,a.OBJECT_NAME ,dbms_lob.substr(b.SQL_TEXT,4000,1) from WRH$_SQL_PLAN a,WRH$_SQLTEXT b
    where a.operation='INDEX' and a.SNAP_ID=b.SNAP_ID and a.SQL_ID=b.SQL_ID and a.OBJECT_NAME in (
    'I_CUSTORDER_STAT_CHG_DTM',
    'I_LINE_ITEM_STAT_CHG_DTM',
    'I_SHOPCART_MODIFIEDDTM',
    'I_VISITOR_CART_UPDATED_DTM',
    'R_ORDER_LOG_EVENT_DTM',
    'I_LI_STATUS_HISTORY_EVENT_DTM',
    'I_SHOPPING_CART_CREATEDDTM',
    'I_VISITOR_CART_CREATED_DTM',
    'I_LINE_ITEM_CREATED_DTM_FTM')

    872903 wrote:
    Hi,
    From the AWR data (WRH$) tables , I need to know how many sql code is using some specific indexes, I found that information by using the mentioned code. but I need to find out by which user this code has been executed ( not the PARSING_SCHEMA_NAME). Can someone please help me, how can I get that info?
    select a.operation,a.OBJECT_OWNER,a.OBJECT_NAME ,dbms_lob.substr(b.SQL_TEXT,4000,1) from WRH$_SQL_PLAN a,WRH$_SQLTEXT b
    where a.operation='INDEX' and a.SNAP_ID=b.SNAP_ID and a.SQL_ID=b.SQL_ID and a.OBJECT_NAME in (
    'I_CUSTORDER_STAT_CHG_DTM',
    'I_LINE_ITEM_STAT_CHG_DTM',
    'I_SHOPCART_MODIFIEDDTM',
    'I_VISITOR_CART_UPDATED_DTM',
    'R_ORDER_LOG_EVENT_DTM',
    'I_LI_STATUS_HISTORY_EVENT_DTM',
    'I_SHOPPING_CART_CREATEDDTM',
    'I_VISITOR_CART_CREATED_DTM',
    'I_LINE_ITEM_CREATED_DTM_FTM')consider enabling AUDIT SELECT FROM TABLE upon which INDEX is based.

  • Query slow in  user schema but fast in sys schema

    Hi,
    DB :10.2.
    OS :Aix
    Tool : Toad
    We executed a query which fast(20 seconds) in sys schema.
    But it's taking slow in user schema(it is taken 10 minutes).
    Yesterday we gathered dictionary stats also.
    Any suggestions.
    Thanks & Regards,
    VN

    You're querying a bunch of USER_<<x>> data dictionary views. Since those views show the objects owned by the current user, the script you generate will be completely different depending on the identity of the current user and the set of objects owned by the current user. If you create a new user and run this script as the new user, it will be even faster because USER_TABLES, USER_SEGMENTS, USER_INDEXES, etc. will all be empty.
    I don't understand why you would issue a MOVE on a table without specifying a new tablespace-- that seems like a pointless exercise. And I would seriously question the architect that wants to use ANALYZE to gather statistics rather than using DBMS_STATS.
    Justin

  • Trace the statements which the user had executed

    Hi all,
    if i want to trace the statements which the user had executed, what should i do?

    Query the v$sqlarea or v$sql view. The sql_text column
    will print out the entire sql string statement.
    SQL > select sql_text from v$sqlarea where parsing_user_id = <input>
    But its length is restricted to 1000 characters. If the query statement exceeds 1000 characters, you can query
    from the v$sqltext view
    The parsing user id is the same as stored in the dba_users table
    SQL > select sql_text from v$sqltext where address = ( select address from v$sqlarea where parsing_user_id = <input> ) order by piece asc;
    Is this what you were looking for ???

  • Which user/credentials does APEX use to execute packages

    Which user does APEX use to execute a function or procedure in the parsing scheme of an application. I am trying to debug an custom authentication scheme which calls a package procedure.

    Mathias Oracle wrote:
    Which user does APEX use to execute a function or procedure in the parsing scheme of an application. I am trying to debug an custom authentication scheme which calls a package procedure.APEX connects to the database using connection pooling as the APEX_PUBLIC_USER or ANONYMOUS schemas, depending on the webserver configuration (except where a DAD has no username/password defined). Code is executed via the <tt>dbms_sys_sql</tt> package using the privileges of the application parsing schema. See:
    {message:id=926724}
    {message:id=1224601}
    Application Express and parsing of SQL

  • How to check which user has the privilege to execute a stored procedure?

    I am using Oracle 7 and I would like to check which user has the privilege to execute a stored procedure. How can I check it? Is there any view I can query for?
    Alex Hung

    Please check DBA_SYS_PRIVS.
    SQL> select * from dba_sys_privs
    2 where grantee='HARY';
    GRANTEE PRIVILEGE ADM
    HARY EXECUTE ANY PROCEDURE NO
    ....

  • To find out which user is schema

    Hi
    All,
    Do you have any idea to find out which user is schema ? (example : any sql query)
    Thanks,
    Vishal

    It's quite unlikely that I would consider an ID that can not connect as being a user. Therefore:
    Schema has objects
    User has CREATE SESSION priv
    Schema & User has objects & CREATE SESSION priv
    Both take use sys.user$.user# so one could view them as different aspects of the same beast. For DBA_USERS the whole key is from sys.user$.user#, whereas for DBA_OBJECTS the sys.user$.user# is a reference for part of the key.
    A schema is simply a collection of objects with a specific namespace. Oracle, for some reason, decided to make the namespace for schemas match the namespace for userids. (I suspect it was to allow us an opportunity to have this kind of discussion.)
    Howard has a discussion that is far superior to the above. I hope we can cajole him to post it.

  • Which view I can query to get the granted objects privilege to a user?

    Hi all,
    which view I can query to get the granted objects privilege to a user?
    for example:
    grant execute on accounting.get_name to scott;
    Which view has above object granted information?
    Thanks

    SQL> select * FROM all_tab_privs where grantor = upper('accounting');
    no rows selected

  • How to find out which user has the permission to execute startsap ?

    Hi All
    How do I find out which user has the permission to execute the startsap and stopsap? Do I control the permission on those script using windows standard authorization? For example: only allow certain user have the read and write permission?
    Thank you.!
    Vincent Lo

    Well to me this is really weird question..
    <b>noone un-authorized should have access to OS on your system</b>
    If this is valid you do not need to solve problems who can and who cannot start/stop SAP, because if you want to prevent some users from shutting down the SAP you have really hard job to do - there are many ways how to kill the SAP (for example killing relevant process from task manager, killing of database, messing with services etc.) - yes, this is harmful way of stopping SAP, but we are talking about attack, right? I would contact some Windows specialist to help you disable all the ways how to harm the running SAP. But still after that - there are many files that can be modified/deleted so SAP will crash after restart - you need to protect them too, etc.
    In case you take the first assumption as granted (and you really limit access to this server) you do not need to worry who can stop or start SAP - at the other hand it may be handy to be able to start/stop SAP from other users - for this you can run the stop/start script "under different user".
    But to answer the question - to me this is question just of access control (but really never tried that myself):
    <a href="http://technet2.microsoft.com/WindowsServer/en/library/c6413717-511e-42bd-bd81-82431afe4b2a1033.mspx">Permit or restrict access to a snap-in for a domain</a> (or see other related links down there on this page)
    Please award points for useful answers.
    Thanks

  • Which user is used to execute command defined in File Adapter?

    Hello,
    in my receiver file adapter I specified a OS command to be executed after message processing. However this command doesn't get executed. After investigation I figure out that it's because the user that is used to executed the command does not have enough authorization to run the program (It's a unix system).
    So anyone knows which user is used to execute the command? Or anyone know how to go around this security issue with OS command in Unix system?
    Thanks
    Eric

    Hi,
    As Bhavesh replied you earlier the OS command is executed by the user <sid>adm in Unix or SAPService<SID> in windows.
    Do check the note 841704 - XI File & JDBC Adapter: Operating system command.
    From Note 841704
    Also note that the command is run as user "<sid>adm" (Unix) / "SAPService<SID>" (Windows).
    Thanks
    SaNv...

  • Which block get effected by save and execute query

    Hello,
    I'm using forms 9i , database oracle 9i.
    Case:
    i made a simple application with 4 stack canvas on each i place data from 4 tables. convention is like every stack canvas get visible when the corresponding button is pressed. once visible i don't set it to invisible i just place other stack canvas over it.
    Although i don't get any error or problem while doing normal work like saving records or Executing query. but i don't understand whether these operation only effect the table which is visible(on stack canvas). and rest of are unaffected.
    if No then how i can do it with only on visible canvas
    and if yes is there any way that i can do execute query on all of them.
    thanks
    Rahul.

    The SAVE (COMMIT_FORM or COMMIT) will affect the whole form if you are using simple blocks based on tables, every block that does have changed or new data it will saved in the database.
    The EXECUTE_QUERY will affect only the current block, the block where the cursor is in currently. If this block is a master block then the EXECUTE_QUERY on the master block will also affect the detail block.
    If it's a standalone (not a master) block, the EXECUTE_QUERY will only affect the block your cursor is in.
    Tony

  • CANT execute query with parameter on user defined tables using query genera

    Dear All,
    I have problem when executing query with parameter on user defined tables using query generator.
    It seems SBO cannot accept parameter to query user defined tables.
    I've tried these:
    SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = [%0] --- this FAIL
    I try to pass the value directly without using parameter and It works
    SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = 2 --- this SUCCESS
    This one works
    SELECT * FROM RDOC T0 WHERE T0.width =[%0]  --- this SUCCESS
    and this one works too
    SELECT * FROM RDOC T0 WHERE T0.width = 595  --- this SUCCESS
    Is there anyone can help me ....???
    Thanks,
    Alfa

    I  generated this code using query wizard ....
    SELECT T0.[U_Status] AS 'Document Status' FROM  [dbo].[@ST_PR_H] T0  WHERE T0.[U_Status] = (N'2' )
    and replaced the (N'2' ) with [%0]
    SELECT T0.[U_Status] AS 'Document Status' FROM  [dbo].[@ST_PR_H] T0  WHERE T0.[U_Status] = [%0]
    and It worked ......
    Thanks 4 all .....

Maybe you are looking for

  • How do I put a Jewish holiday calendar on my iphone calendar?

    I want to insert a Jewish Holiday calendar on my iphone calendar. I already did it with the US calendar but I am having a hard time finding the server address for a Jewish Calendar. Thanks

  • I can't open .CR2 files with elements 11

    I have a canon T5, it records .CR2 files for RAW. Photoshop Elements 11 won't open .CR2 files. I downloaded update 7.40.137 but that doesn't help. What do I do now?                     thanks Ed

  • Why are the wi-fi speeds bad even with my own rout...

    When I connect with an Ethernet, I get amazing speed of 74/76mb download. but soon as i connect via wi-fi with the hub or my own router, speeds dropped till about 20/25mbs.. whats causing the problem, I have tried to change channels but to no effect.

  • Help! Is there anyway to merge documents?

    After recording some vocal overdubs lasts night I realised that somehow all the previous Verse and Chorus vocal takes had VANISHED!!! Dont panic I said and saved to a new project. I then reloaded the previous save i had and thankfully the verse and c

  • Lose audio & external video

    When playing a sequence, audio will suddenly disappear and pix in external monitor will freeze, although pix in canvas continues to play. Have checked ext video, refresh AV, audio playback in View menu and have run FCP Rescue. Seq & Capture presets a