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

SQL Anywhere 11.0.0 » SQL Anywhere Server - SQL Reference » Using SQL » SQL statements » SQL statements (A-D)



Use this statement to start a diagnostic tracing session. That is, to start 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 required to connect to database receiving the tracing information. This parameter is only required when the database being profiled is different from the database receiving the data.

  • 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 primarily used by the Diagnostic Tracing wizard in Sybase Central. However, you can also run it manually. You must run if from the database you want to profile.

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 Sybase Central, or 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.

In order 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. See Using the TCP/IP protocol.

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. See sa_diagnostic_tracing_level table.

To see where tracing data is being sent to, examine the SendingTracingTo database property. See Database-level properties.


Must be connected to the database being profiled and must have DBA authority.

Side effects


See also
Standards and compatibility
  • SQL/2003   Vendor extension.


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. Note that the ATTACH TRACING statement example is all on one line.

CALL sa_set_tracing_level( 1 );
ATTACH TRACING TO 'uid=DBA;pwd=sql;eng=remotedbsrv11;dbn=mytracingdb;links=tcpip'