SQL Anywhere provides a set of system functions that can access information on a per-connection, per-database, or server-wide basis. The kind of information available ranges from static information (such as the database server name) to detailed performance-related statistics (such as disk and memory usage).
The following functions retrieve system information:
PROPERTY function This function provides the value of a given property on a server-wide basis. See PROPERTY function [System].
DB_PROPERTY and DB_EXTENDED_PROPERTY functions These functions provide the value of a given property for a given database, or by default, for the current database. See DB_PROPERTY function [System], and DB_EXTENDED_PROPERTY function [System].
CONNECTION_PROPERTY and CONNECTION_EXTENDED_PROPERTY functions These functions provide the value of a given property for a given connection, or by default, for the current connection. See CONNECTION_PROPERTY function [System], and CONNECTION_EXTENDED_PROPERTY function [String].
Supply as an argument only the name of the property you want to retrieve. The functions return the value for the current server, connection, or database.
For a complete list of the properties available from the system functions, see System functions.
The following statement sets a variable named server_name to the name of the current server:
SET server_name = PROPERTY( 'name' );
The following query returns the user ID for the current connection:
SELECT CONNECTION_PROPERTY( 'UserID' );
The following query returns the file name for the root file of the current database:
SELECT DB_PROPERTY( 'file' );
For better performance, a client application monitoring database activity should use the PROPERTY_NUMBER function to identify a named property, and then use the number to repeatedly retrieve the statistic.
Property names obtained in this way are available for many different database statistics, from the number of transaction log page write operations and the number of checkpoints performed, to the number of reads of index leaf pages from the memory cache.
The following set of statements illustrates the process from Interactive SQL:
CREATE VARIABLE propnum INT; CREATE VARIABLE propval INT; SET propnum = PROPERTY_NUMBER( 'CacheRead' ); SET propval = DB_PROPERTY( propnum );
For more information about the PROPERTY_NUMBER function, see PROPERTY_NUMBER function [System].
You can view many of these statistics in graph form from the Sybase Central Performance Monitor. See Monitoring statistics using Sybase Central Performance Monitor.
|Send feedback about this page via email or DocCommentXchange||Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0|