Home Database Mysql Tutorial Oracle中如何用T

Oracle中如何用T

Jun 07, 2016 pm 03:07 PM
oracle Community Enter

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 一、用脚本启动并设置跟踪的示例 通过这个示例,你可以了解用脚本进行跟踪所涉及到的存储过程,要了解这些存储过程的具体语法和参数的含义,请查询联机帮助 /*************************************

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

一、用脚本启动并设置跟踪的示例

通过这个示例,你可以了解用脚本进行跟踪所涉及到的存储过程,要了解这些存储过程的具体语法和参数的含义,请查询联机帮助

<ccid_code>/****************************************************/
/* Created by: SQL Profiler                 */
/* Date: 2004/06/19 16:50:05       */
/****************************************************/
-- Create a Queue
declare @rc int
declare @TraceID int
declare @maxfilesize bigint
set @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 share

exec @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 events
declare @on bit
set @on = 1
exec sp_trace_setevent @TraceID, 12, 1, @on
exec sp_trace_setevent @TraceID, 12, 12, @on
exec sp_trace_setevent @TraceID, 12, 14, @on

-- Set the Filters
declare @intfilter int
declare @bigintfilter bigint
exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'
set @intfilter = 100
exec sp_trace_setfilter @TraceID, 22, 0, 4, @intfilter
set @intfilter = 1
exec sp_trace_setfilter @TraceID, 23, 1, 0, @intfilter
exec sp_trace_setfilter @TraceID, 35, 1, 6, N'pubs'

-- Set the trace status to start
exec sp_trace_setstatus @TraceID, 1
-- display trace id for future references
select TraceID=@TraceID
goto finish

error: 
select ErrorCode=@rc
finish: 
go</ccid_code>
Copy after login

二、生成跟踪脚本的最简式

事件探查器建立跟踪, 并设置好各种选项, 完成后运行跟踪

然后生成脚本:

事件探查器--文件--导出跟踪定义的文件--选择合适的版本.

这样就会生成一个跟踪的脚本, 打开生成的脚本, 修改里面的:

exec @rc = sp_trace_create

部分, 设置跟踪结果的保存文件(用语句跟踪的时候, 跟踪结果只能保存到文件)

然后, 在需要跟踪的时候, 运行这个脚本来启动跟踪

启动跟踪后, 跟踪自动进行, 所以你可以关闭查询分析器做其他事情去了.

三、已知的问题

1.跟踪记录不是实时写入跟踪文件的, 因此, 可能会到你停止跟踪的时候, 跟踪信息才写入跟踪文件

2.查看当前已经进行的跟踪可以用(关于结果集的解释, 请看联机帮助):

<ccid_code>SELECT * FROM ::fn_trace_getinfo(0)</ccid_code>
Copy after login

3. 停止某个跟踪, 可以在sp_trace_create 语句中设置自动停止时间, 也可以手动停止跟踪, 用下面的语句:

<ccid_code>EXEC sp_trace_setstatus 
  @traceid = 1 ,   -- 跟踪的id
  @status = 0     -- 停止, 这样以后还可能指定此项为来启用
EXEC sp_trace_setstatus 
  @traceid = 1 , 
  @status = 2     -- 关闭, 彻底释放</ccid_code>
Copy after login

Oracle中如何用T

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to check tablespace size of oracle How to check tablespace size of oracle Apr 11, 2025 pm 08:15 PM

To query the Oracle tablespace size, follow the following steps: Determine the tablespace name by running the query: SELECT tablespace_name FROM dba_tablespaces; Query the tablespace size by running the query: SELECT sum(bytes) AS total_size, sum(bytes_free) AS available_space, sum(bytes) - sum(bytes_free) AS used_space FROM dba_data_files WHERE tablespace_

How to encrypt oracle view How to encrypt oracle view Apr 11, 2025 pm 08:30 PM

Oracle View Encryption allows you to encrypt data in the view, thereby enhancing the security of sensitive information. The steps include: 1) creating the master encryption key (MEk); 2) creating an encrypted view, specifying the view and MEk to be encrypted; 3) authorizing users to access the encrypted view. How encrypted views work: When a user querys for an encrypted view, Oracle uses MEk to decrypt data, ensuring that only authorized users can access readable data.

How to view instance name of oracle How to view instance name of oracle Apr 11, 2025 pm 08:18 PM

There are three ways to view instance names in Oracle: use the "sqlplus" and "select instance_name from v$instance;" commands on the command line. Use the "show instance_name;" command in SQL*Plus. Check environment variables (ORACLE_SID on Linux) through the operating system's Task Manager, Oracle Enterprise Manager, or through the operating system.

How to uninstall Oracle installation failed How to uninstall Oracle installation failed Apr 11, 2025 pm 08:24 PM

Uninstall method for Oracle installation failure: Close Oracle service, delete Oracle program files and registry keys, uninstall Oracle environment variables, and restart the computer. If the uninstall fails, you can uninstall manually using the Oracle Universal Uninstall Tool.

How to check invalid numbers of oracle How to check invalid numbers of oracle Apr 11, 2025 pm 08:27 PM

Oracle Invalid numeric errors may be caused by data type mismatch, numeric overflow, data conversion errors, or data corruption. Troubleshooting steps include checking data types, detecting digital overflows, checking data conversions, checking data corruption, and exploring other possible solutions such as configuring the NLS_NUMERIC_CHARACTERS parameter and enabling data verification logging.

How to set up users of oracle How to set up users of oracle Apr 11, 2025 pm 08:21 PM

To create a user in Oracle, follow these steps: Create a new user using the CREATE USER statement. Grant the necessary permissions using the GRANT statement. Optional: Use the RESOURCE statement to set the quota. Configure other options such as default roles and temporary tablespaces.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

How to create oracle dynamic sql How to create oracle dynamic sql Apr 12, 2025 am 06:06 AM

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values ​​to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

See all articles