How to use T in Oracle

Source: Internet
Author: User
Welcome to the Oracle community forum and interact with 2 million technical staff. 1. Use a script to start and Set Tracing examples. You can learn about the stored procedures involved in tracking using scripts, to understand the specific syntax and parameter meanings of these stored procedures, please query online help ************************************ *

Welcome to the Oracle community forum and interact with 2 million technical staff> go to step 1. Use a script to start and set the tracing example, you can understand the stored procedures involved in tracking with scripts, and understand the specific syntax and parameter meanings of these stored procedures, please query online help /*********************************** **

Welcome to the Oracle community forum and interact with 2 million technical staff> enter

1. Use a script to start and Set Tracing examples

Through this example, you can understand the stored procedures involved in tracking with scripts. To learn the specific syntax and parameter meanings of these stored procedures, please query the online help

       
        /****************************************************//* Created by: SQL Profiler                 *//* Date: 2004/06/19 16:50:05       *//****************************************************/-- Create a Queuedeclare @rc intdeclare @TraceID intdeclare @maxfilesize bigintset @maxfilesize = 5 -- Please replace the text InsertFileNameHere, with an appropriate-- filename prefixed by a path, e.g., c:\MyFolder\MyTrace. The .trc extension-- will be appended to the filename automatically. If you are writing from-- remote server to local drive, please use UNC path and make sure server has-- write access to your network shareexec @rc = sp_trace_create @TraceID output, 0, N'c:\test', @maxfilesize, NULL if (@rc != 0) goto error-- Client side File and Table cannot be scripted-- Writing to a table is not supported through the SP's-- Set the eventsdeclare @on bitset @on = 1exec sp_trace_setevent @TraceID, 12, 1, @onexec sp_trace_setevent @TraceID, 12, 12, @onexec sp_trace_setevent @TraceID, 12, 14, @on-- Set the Filtersdeclare @intfilter intdeclare @bigintfilter bigintexec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'set @intfilter = 100exec sp_trace_setfilter @TraceID, 22, 0, 4, @intfilterset @intfilter = 1exec sp_trace_setfilter @TraceID, 23, 1, 0, @intfilterexec sp_trace_setfilter @TraceID, 35, 1, 6, N'pubs'-- Set the trace status to startexec sp_trace_setstatus @TraceID, 1-- display trace id for future referencesselect TraceID=@TraceIDgoto finisherror: select ErrorCode=@rcfinish: go
       

Ii. Generate the simplest tracking script

The event probe creates a trail and sets various options to run the trail after completion.

Then generate the script:

Event probe -- file -- export the file defined by the trail -- select the appropriate version.

This will generate a tracking script, open the generated script, and modify the following:

Exec @ rc = sp_trace_create

To save the trace results. (The trace results can only be saved to files when the statement is used for tracking)

Then, run this script to start the trail when you need to trace it.

After tracing is started, tracing is automatically performed, so you can disable the query analyzer to do other things.

Iii. Known issues

1. The tracking record is not written to the tracking file in real time. Therefore, it may be written to the tracking file only when you stop tracking.

2. Check that the current trail is available (for more information about the result set, see online help ):

       
        SELECT * FROM ::fn_trace_getinfo(0)
       

3. Stop a trail. You can set the automatic stop time in the sp_trace_create statement or stop the trail manually. Use the following statement:

       
        
EXEC sp_trace_setstatus @ traceid = 1, -- trace id @ status = 0 -- stop, this item may be specified later to enable EXEC sp_trace_setstatus @ traceid = 1, @ status = 2 -- close and release permanently
       

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.