Trace the SQL by a user

I want to trace the SQL statements sent by a user. I tried V$SQL view and it seems like it traces only the successful statement. I want to trace all the statements from that user including the ones which have sytanx errors.

are you using dbms_system? For example, with SID and Serial# you can do the following,
exec sys.dbms_system.set_sql_trace_in_session( 46, 13217, TRUE );
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:330817260752
HTH - Kevin

Similar Messages

  • How to trace the ip address of user session?

    how to trace the ip address of user client session?

    Hi.
    This should help:
    http://www.oracle-base.com/articles/misc/IdentifyingHostNamesAndAddresses.php
    Cheers
    Tim...

  • How to trace the SQL statements executed in a database

    I am using Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production on a sun server and I am not familiar with Oracle but with MS SQL there is a tool called profiler, it allows you to monitor and see what is going on in a specific databases whether it is SQL statement executins or anything else. I have installed the oracle enterpise manager console at my windows client and I tried to look for a tool similar to the profiler in the MS SQL. I tried the TRACE DATA VIEWER and I inputed the login credentials but I don' t actually know the service name and I am getting an error ORA-12514 The TSN listener can not resolve the service name given in the connect descriptor. Therefore, am I on the right road so i have to look for the service name or are there any other ways i can trace the currently executing SQL statement in a specific database. I am really stuck there. I would appreciate if somebody help me out. Thanks
    Abdel Moalim

    Abdel Moalim wrote:
    I am using Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production on a sun server and I am not familiar with Oracle but with MS SQL there is a tool called profiler, it allows you to monitor and see what is going on in a specific databases whether it is SQL statement executins or anything else. I have installed the oracle enterpise manager console at my windows client and I tried to look for a tool similar to the profiler in the MS SQL. I tried the TRACE DATA VIEWER and I inputed the login credentials but I don' t actually know the service name and I am getting an error ORA-12514 The TSN listener can not resolve the service name given in the connect descriptor. Therefore, am I on the right road so i have to look for the service name or are there any other ways i can trace the currently executing SQL statement in a specific database. I am really stuck there. I would appreciate if somebody help me out. Thanks
    Abdel MoalimHi
    I see others have answered the network connectivity issues, I'll try and address the tracing issue. Your best bet is to review http://www.petefinnigan.com/ramblings/how_to_set_trace.htm for the many ways in which a sessions SQL and indeed other activity can be traced. In version 7 (which I'm guessing is yours from the sid) the only profiler available was tkprof (Trace Kernel Profiler) which will do a good job of analysing your trace file. The trace files themselves are generated on the server in a protected directory so you may need to ask your dba for access to them. There are other profilers around now (I have one which runs in v9 and higher database at http://www.niall.litchfield.dial.pipex.com/SimpleProfiler/SimpleProfiler.html which will analyse your files for example) but tkprof is the start point - or else just reading the trace file in a text editor. There is also a utility written by the Oracle Apps guys trcanalyzer that will do a good job for you. In general the interface is poor compared with the ms utility but the information is deeper and more helpful
    Niall Litchfield
    http://www.orawin.info/

  • How to always hide the SQL statements for users when they run User Queries?

    Hi,
    from the IT dept. position, I don't want users to see and be so curious about the SQL commands.
    How can I always hide the textbox of  Display Query Structure?
    thanks.

    Hi,
    Unfortunately system design has short of this function. If users are allowed to run those queries, you can not hide the query structure.
    You may post a DRQ here: /community [original link is broken]
    Thanks,
    Gordon

  • How to migrate sql server 2000 user defined function returns table

    Hi,
    How do I capture the SQL Server 200 user defined function that returns table? Is this supported in the current version of Oracle Migration Workbench? I am using the latest version - Release 9.2.0.1.0 with SQL SERVER 2000 plug-in.
    I was able to capture the SQL Server 2000 user defined function that returns string and smalldatetime but not the functions return table during the migrate data source stage.
    Thanks in Advance,
    Susan

    Susan,
    This is not currently supported. The next release of the Oracle Migration Workbench (due very soon), will do a better job of catching this mad reporting an error. We are looking into a suitable mapping and have created bug # 2355073 - TABLE DEFINITIONS NOT ACCEPTED FOR TABLE FUNCTIONS to track this issue.
    Once possible solution we are looking into is using the object type to emulate. Here is an example from the bug:
    Original table
    SQL> create table tabela (a number, b number, c number, d number);
    SQL> insert some values...
    SQL> select * from tabela;
    A B C D
    1 1 1 1
    2 2 2 2
    3 3 3 3
    4 4 4 4
    SQL Server 2000 code
    CREATE FUNCTION FUNCRETORNATABELA()
    RETURNS TABLE
    AS
    RETURN SELECT A,B,C,D FROM TABELA
    SELECT A,B,C,D
    FROM FUNCRETORNATABELA()
    ORDER BY A
    Oracle code (workaround)
    SQL> create or replace type MyObjType as object (
    2 a number, b number, c number, d number);
    3 /
    Type created.
    SQL> create or replace type MyTabType as table of MyObjType;
    2 /
    Type created.
    SQL> create or replace function teste return Mytabtype pipelined as
    2 aa MyObjType := MyObjType(null, null, null, null);
    3 cursor c1 is select a,b,c,d from tabela;
    4 begin
    5 open c1;
    6 loop
    7 fetch c1 into aa.a, aa.b, aa.c, aa.d;
    8 exit when c1%NOTFOUND;
    9 pipe row (aa);
    10 end loop;
    11 close c1;
    12 return;
    13 end;
    14 /
    Function created.
    SQL> select * from table(teste);
    A B C D
    1 1 1 1
    2 2 2 2
    3 3 3 3
    4 4 4 4
    SQL> select a, c from table(teste) order by c desc;
    A C
    4 4
    3 3
    2 2
    1 1
    Donal

  • ?How to get the SQL being executed

    Hi, this is a 2 part question, note that I'm using 10.1.0.3:
    1) When running queries against a ROLAP cube (using BI Beans or the Excel addin), how can I trace the SQL that is being executed?
    2) When using a MOLAP cube, its no longer required to "enable" the cube for SQL access. However, my question is, if I want to query it using a standard SQL tool, how do I do this? It doesn't seem like there are any views, etc. that I can query against?
    Thanks!
    Scott

    Hi Scott,
    1) When running queries against a ROLAP cube (using BI Beans or the Excel addin), how can I trace the SQL that is being executed?
    Tracing the SQL that is executed by a session is a fairly well documented process. Basically, you can either enable tracing for your own personal session, or you can enable tracing for someone else's session. See http://www.petefinnigan.com/ramblings/how_to_set_trace.htm for a pretty definitive writeup, or http://www.rittman.net/work_stuff/tracing_owb_mappings_pt1.htm for example of using trace with OWB (similar sort of concept)
    2) When using a MOLAP cube, its no longer required to "enable" the cube for SQL access. However, my question is, if I want to query it using a standard SQL tool, how do I do this? It doesn't seem like there are any views, etc. that I can query against?
    Best to check with Oracle, but my understanding is that 10.1.0.3A upwards enabled the cube for the OLAP API, not SQL access - the difference being that enabling for OLAP API creates the metadata that the OLAP API requires, which used to be ( < 10.1.0.3 ) stored in the OLAPSYS schema, and is now contained within objects in the AW itself. If you want to enable for SQL access, you'll have to create views using the OLAP_TABLE function as before, although I don't think you need to create the ADTs (abstract datatypes, the object definitions previously required) anymore.
    HTH
    Mark

  • 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 ???

  • How to look at the SQL trace in Oracle

    Hi,
    How do we look for the SQL trace in Oracle?
    With SQL trace I mean all the SQL statements being executed in Oracle database ( including select ).
    Thanks........

    Thanks for a quick reply nbellam. I wonder if there is a way to find out the date and time when the sql was executed?

  • SQL 2012 sp2 "The permissions granted to user 'DOMAIN\user' are insufficient ..."

    1st let me set the tone by admitting I am not real familiar with SQL, I'm more of an Operations Admin. So this is not a new question I think, although I am having difficulty finding an applicable solution.  Using SQL Server 2012 sp2 on a Windows
    2012R2 server.  This is configured to be a SCOM DB server; while on the SQL server itself I open IE and attempt to go to the following URL http://scomsql/reportserver_SCOM I get the
    following error.
    Reporting Services Error
    The permissions granted to user 'DOMAIN\user' are insufficient for performing this operation. (rsAccessDenied) Get Online Help
    SQL Server Reporting Services
    I have looked at the Reporting Services Config. Mgr. and it looks like the Report Mgt. URL is set for port 80 and no SSL is configured.  The rsreportserver.config file has the SecureConnectionLevel set to "0"
    My domain account is listed under Security\Logins and holds the 'Server Roles' of public and sysadmin, 'User Mapping' is DBO for the 'ReportServer$SCOM' and 'ReportServer$SCOMTempDB' and the role membership shows db_owner and public for these as well.
    Any assistance with getting this working would be greatly appreciated.
    # When I wrote this script only God and I knew what I was doing. # Now, only God Knows!

    Hi Wasisname,
    The Reporting Services error rsAccessedDenied occurs when a user does not have permission to perform an action. To troubleshooting this issue, please make sure that you have sufficient permission and the report server name is correct.
    In fact, reporting Services uses role-based security to grant user access to a report server, and there are two types of roles: Item-level roles and System-level roles. On a new installation, only local administrators have access to a report server. In order
    to grant access to visit the URL http://server:port/ReportServer to users, a local administrator must create a role assignment to define the tasks a user can perform. To solve this problem, please refer to the
    following steps:
    Start Report Manager by going to URL
    http://scomsql/reportserver_SCOM.
    Click Site Settings at the top right of the page.
    Click Security in the left pane.
    If a role assignment already exists for the user, click Edit.
    Otherwise, click New Role Assignment. In user, enter the user account.
    Select appropriate access, and then click Apply.
    The issue may be caused by the UAC or Internet Explorer security setting, please try to follow this steps:
    1. Open the Internet options of the IE and add the report server URL into trusted site in the Security tab.
    2. Run the IE as administrator.
    Besides, if the user need to have access to reports, folders, models and shared data sources, we can assign Item-level roles on the root node (the Home folder) or on specific folders or items.
    For more information about Configuring a Native Mode Report Server for Local Administration, please refer to the following document:
    http://msdn.microsoft.com/en-us/library/bb630430(v=sql.110).aspx
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.
    Wendy Fu
    TechNet Community Support

  • How user trace the message created in Satellite System

    HI All,
    I'm using Servide Desk in my company. Just wondering how user can trace the progress of the message created where email notification is not configured.
    Remember when user send/save the message, there's a message number created. Just wonder any center/ transaction code user can trace the progress and have a visible view on the message ON THE SATELLITE System, not in SOLMAN.
    Thanks,
    NIcholas Chang

    >
    Nicholas Chang wrote:
    > Hi All,
    >
    > What standard F4 help screen should i modify and from where should i start? Could you please enlighten me on what function or program that this F4 help screen bind to? I need to know the function/program in order for my abaper to work on this.
    >
    > Also, i just wondering is every user able to create message in Satellite System under Help -> Create Message? According to the SOLMAN Security Guide, it mention user with role SAP_SUPPDESK_CREATE are able to create message but i've and created and tested with a restricted profile user without SAP_SUPPDESK_CREATE role, and it still manage to create message.
    >
    > I've completed the SOLMAN SD setup and currently tryin to fine tune it.
    >
    > Your help is very much appreciated.
    >
    > Thanks!
    > Nicholas
    Hi Nicholas
    If you are using a "Named" user instead of the Trusted Relationship in the RFC maintained in BCOS_CUST for entry OSS_MSG then this is quite possible. In this case the "Named" user will be used to call the interface to create message and the calling user ie the end user creating the ticket will only be used as "Reporter" of the message.
    Regards
    Amit

  • Errors while Changing the Database to Mutli User Mode from Single user mode in SQL Server 2012

    Hi,
    Good Afternoon :).  Need your help in resolving one of the issue with SQL Server 2012.
    Today, we kept one of the database in the Single User mode and wanted to bring back to Multi User mode.  But we are getting the below error.  There are no user sessions connected to this database which are blocking each other.  I see multiple
    SYSTEM sessions are in blocked state.  The blocking is not cleared even affter restarting the SQL services.
    Verified the SQL Server Errorlog and couldnt get much useful information to troubleshoot the issue.
    pasted the information from the sys.sysprocesses as well for your kind reference.
    Msg 1205, Level 13, State 68, Line 1
    Transaction (Process ID 55) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
    Msg 5069, Level 16, State 1, Line 1
    ALTER DATABASE statement failed.
    spid
    kpid
    blocked
    waittype
    waittime
    dbid
    login_time
    status
    cmd
    18
    1004
    36
    0x0005
    144
    5
    4/9/2014 13:13
    background                    
    TASK MANAGER    
    35
    1796
    36
    0x0005
    35
    5
    4/9/2014 13:34
    background                    
    TASK MANAGER    
    36
    2464
    37
    0x0005
    363
    5
    4/9/2014 13:34
    background                    
    TASK MANAGER    
    37
    5100
    36
    0x0005
    254
    5
    4/9/2014 13:04
    background                    
    TASK MANAGER    

    Clearly 36 and 37 are causing deadlock.
    see
    https://www.simple-talk.com/sql/database-administration/handling-deadlocks-in-sql-server/
    http://www.mssqltips.com/sqlservertip/1036/finding-and-troubleshooting-sql-server-deadlocks/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"

    How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"?
    I have an install SQL scripts that creates a Linked Server. I want to put some security on the Linked Server and only grant the Agent Job Signon (the "Run As" or "Executed as User") access to the linked server. I need to retrieve the
    Agent Job Signon (something like "NT SERVICE\SQLAgent$FIDEV360BI02").
    I could query certain jobs and SUBSTRING the Message column - using some form of the query below, which would return "Executed as user: NT SERVICE\SQLAgent$SSDEVBI02. The step succeeded." But that is pretty imprecise.
    use msdb
    SELECT [JobName] = JOB.name,
    [Step] = HIST.step_id,
    [StepName] = HIST.step_name,
    [Message] = HIST.message,
    [Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
    WHEN HIST.run_status = 1 THEN 'Succeeded'
    WHEN HIST.run_status = 2 THEN 'Retry'
    WHEN HIST.run_status = 3 THEN 'Canceled'
    END,
    [RunDate] = HIST.run_date,
    [RunTime] = HIST.run_time,
    [Duration] = HIST.run_duration,
    [Retries] = HIST.retries_attempted
    FROM sysjobs JOB
    INNER JOIN sysjobhistory HIST ON HIST.job_id = JOB.job_id
    -- CHANGE THIS
    -- WHERE JOB.name like '%GroupMaster%' or Job.name like '%etlv%'
    ORDER BY HIST.run_date, HIST.run_time

    by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
    you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
    so, if it is null, it ran as sql server agent account.
    so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
    accurate information as the new account will show up though the job really ran as old account, to get this information, you need to  get this from the logmessage column as you mentioned above.
     try this code...
    /*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
    declare @sqlserveragentaccount varchar(2000)
    select @sqlserveragentaccount= service_account
    from sys.dm_server_services
    where servicename like '%sql%server%agent%'
    select message,isnull(name,@sqlserveragentaccount) as AccountName
    from sysjobhistory a inner join sysjobsteps b
    on a.step_id=b.step_id and a.job_id=b.job_id
    left outer join sysproxies c on c.proxy_id=b.proxy_id
    Hope it Helps!!

  • Add multiple users to a certain database in the SQL server in one go

    I wonder if there is any method to add multiple users to a certain database in the SQL server in one go and without using transact code.
    I can add a single user to a certain database “Q” for example by right click on the user “U1” for example then properties then in user mapping tab select
    the database “Q”, so there should be a method to add multiple users ( U1,U2,U3…) to this database?
    Best Regards,
    Ahmad

    Many thanks Visakh16,
    I can do this using the below script, but what I am searching for is do to this without any scripting.
    USE TestDatabase; --Make sure you have the right database
    DECLARE @sql VARCHAR(MAX) = '';
    SELECT @sql = @sql + 'CREATE USER ' + name + ' FOR LOGIN ' + name + ';
    ' +
    'GRANT CREATE TABLE, CREATE PROCEDURE, CREATE VIEW, VIEW DEFINITION TO ' + name + ';
    FROM sys.server_principals p
    WHERE p.type in ('S','U') -- SQL Logins and Windows Login. Do not change!
    and p.name in ('U1','U2','U3'); -- List of names to add. alter to suit
    PRINT @sql; -- Show the statements being executed in the messages pane
    EXEC(@sql); -- Run the statements that have been built
    Thanks,
    Ahmad

  • How to clear the existing names in USER NAME drop down list in Sql Server Management Studion in Sql Server 2008 R2`.

    Hi,
      We have Sql Server 2008R2 clustered instance running in 2 nodes with Windows 2008R2 SP1 operating system. I would like to know how I could clear the existing  names  in the USER NAME drop down list in the Sql Server Management studio.
    Thanking in you advance,
    Binny Mathew,

    SQL Server Management Studio 2008 delete the file:
    C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
    http://dynamicsgpland.blogspot.in/2012/04/clearing-remembered-default-login-for.html

  • Urgent : How to do the SQL trace analysis

    Hi Floks,
    How to do the SQL  Trace analysis and any another tools is there to test abap programming then this tools runtime analysis,extended Programming Checking,Code inspector .How to utilize that tools .please forward me
    thanks
    suresh

    HI,
    <b>SQL Trace Use:</b>
    The SQL Trace function is an on-demand log of selected SQL statements that are issued against the database through the Open SQL Engine. The SQL Trace can be switched on or off dynamically. The log format is database independent. Besides the SQL statement text, each log record contains information about the point in time when the statement was executed, its duration, its input parameters and results (where applicable) as well as context information.
    <b>
    Features</b>
    The SQL Trace is especially useful for:
    Development
    SQL Trace can help JDO, enterprise beans, servlet and JSP developers to learn which kind of database accesses their code produces.
    1.      Performance analysis
    Typically, performance issues are caused by inefficient database accesses. In this case SQL Trace can be used to show the issued SQL statements and their duration, thus helping to identify inefficient SQL statements.
    <b>Activities</b>
    Typically, you should use the SQL Trace when you need to check the behavior of a particular application. This is the following scenario:
    Look at the below links, you will get the idea
    http://help.sap.com/saphelp_erp2005/helpdata/en/d1/801f89454211d189710000e8322d00/content.htm
    Re: Runtime Analysis vs SQL Trace
    http://www.sapbrain.com/TOOLS/SQLTRACE/SQL_TRACE.html

Maybe you are looking for