Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements

ATTACH TRACING statement (deprecated)

The diagnostic tracing feature is deprecated. Use the SQL Anywhere Profiler to diagnose issues in your database. The ATTACH TRACING statement starts a diagnostic tracing session (starts sending diagnostic information to the diagnostic tables).

 [ LIMIT { size | history } ]
connect-string : the connection string for the database
size : SIZE nnn { MB | GB }
history : HISTORY nnn { MINUTES | HOURS | DAYS }
nnn : integer
  • connect-string

    The connection string is required to connect to the database receiving the tracing information. This parameter is only required when the database being profiled is different from the database receiving the data.

    The following connection parameters are allowed in connect-string: DBF, DBKEY, DBN, Host, Server, LINKS, PWD, UID.

    Specify the DBF relative to the database server that you want to connect to. If you do not specify a different database server, then the database server to which you are currently connected attempts to start the tracing database identified by the DBF connection parameter.

    An error is returned if you specify the DBF parameter with the LINKS or Server connection parameters.

  • LIMIT clause

    The volume limit of data stored in the tracing database, either by size, or by length of time.


The ATTACH TRACING statement is used to start a tracing session for the database you want to profile. You can only use it once a tracing level has been set. You can set the tracing level using the sa_set_tracing_level system procedure.

Once a session is started, tracing information is generated according to the tracing levels set in the sa_diagnostic_tracing_level table. You can send the tracing data to tracing tables within the same database that is being profiled by specifying LOCAL DATABASE. Alternatively, you can send the tracing data to a separate tracing database by specifying a connection string (connect-string) to that database. The tracing database must already exist, and you must have permissions to access it.

You can limit the amount of tracing data to store using the LIMIT SIZE or LIMIT HISTORY clauses. Use the LIMIT SIZE clause when you want to limit the volume of tracing data to a certain size, as measured in megabytes or gigabytes. Use the LIMIT HISTORY clause to limit the volume of tracing data to a period of time, as measured in minutes, hours, or days. For example, HISTORY 8 DAYS limits the amount of tracing data stored in the tracing database to 8 days' worth.

To start a tracing session, TCP/IP must be running on the database server(s) on which the tracing database and production database are running.

Packets that contain potentially sensitive data are visible on the network interface, even when tracing to a local database. For security purposes, you can specify encryption in the connection string.

To see the current tracing levels set for a database, look in the sa_diagnostic_tracing_level table.

To see where tracing data is being sent to, examine the SendingTracingTo database property.

You must be connected to the database being profiled to execute this statement.


You must have the DIAGNOSTICS system role and the MANAGE PROFILING system privilege.

Side effects


  • ANSI/ISO SQL Standard

    Not in the standard.


The following example sets the tracing level to 1 using the sa_set_tracing_level system procedure. Then it starts a tracing session. Tracing data generated for the local database will be sent to the mytracingdb tracing database on another computer, as shown by the specified connection string. A maximum of two hours of tracing data will be maintained during the tracing session.

CALL sa_set_tracing_level( 1 );
ATTACH TRACING TO 'UID=DBA;PWD=passwd;Server=remotedbsrv;DBN=mytracingdb;Host=mytracing-pc'