Adds or removes trace events from a session, adds or removes targets from a session, or starts or stops a trace session.
ALTER TRACE EVENT SESSION session-name [ ON SERVER ] { ADD TRACE EVENT trace-event-name [,...] | DROP TRACE EVENT trace-event-name [,...] | ADD TARGET FILE [ ( SET target-parameter-name=target-parameter-value [, ...] ) ] | DROP TARGET target-name [, ...] ] | STATE = { START | STOP } }
target-parameter-name : { filename_prefix | max_size | num_files | flush_on_write | compressed }
Alters a trace event session that is recording trace events from all databases on the database server. If this clause is not specified, then only the trace event session on the current database is altered.
The name of the trace event being added to the session.
The name of the trace event being removed from the session.
The name of the target being added to the session. Information about the trace events that are part of the session is logged to this target (file).
The name of the target being removed from the session.
Adding or dropping trace events or targets from a running trace session causes the session to pause briefly to make the changes and then resume after the changes are made. You do not need to stop a tracing session to add or drop trace events or targets. Adding or removing a trace event from a session that has already started has the side effect that some trace events are missed while a session is temporarily paused.
You must have the MANAGE ANY TRACE SESSION system privilege.
None
Not in the standard.
The following example creates a trace event called my_event, creates a trace event session called my_session, and starts the session:
CREATE TEMPORARY TRACE EVENT my_event( id INTEGER, information LONG VARCHAR ); CREATE TEMPORARY TRACE EVENT SESSION my_session ADD TRACE EVENT my_event, -- user event ADD TRACE EVENT SYS_ConsoleLog_Information -- system event ADD TARGET FILE ( SET filename_prefix='my_trace_file' ); -- add a target ALTER TRACE EVENT SESSION my_session STATE = START;