DB_Statistics Function


Retrieves a list of statistics about a single table and the indexes that are associated with the table. The information is returned as a result set on the statement handle.


hstmnt = DB_Statistics (hdbc, catalog-name, schema-name, table-name, unique, reserved)
Variable Description

The returned handle to the executed SQL statement. This is an input parameter for other DBTester functions, for example DB_FetchNext. HSQL.


The handle to a database as returned by DB_Connect. HDATABASE.


Catalog name. STRING.


String search pattern for schema names. STRING.


String search pattern for table names. STRING.

Type of index.
  • "0" for SQL_INDEX_UNIQUE.
  • "1" for " SQL_INDEX_ALL.
Indicates the importance of the Cardinality and Pages columns in the result set.
  • "0" for SQL_QUICK
  • "1" for " SQL_ENSURE


  • DB_Statistics corresponds to SQLStatistics. For additional information about SQLStatistics, see SQLStatistics Function.
  • The table-name argument is required. It cannot be an empty string or contain a wildcard.
  • The following wildcard characters are supported for arguments:
    Wildcard character Matches
    % The percent sign matches any character sequence.
    _ The underscore matches any single character.
  • To omit a variable argument, which is not a required argument, specify the argument as an empty string ("").

  • The reserved argument can have one of the following values:
    Value Meaning Description
    "0" SQL_QUICK The Cardinality and Page columns are retrieved only if they are readily available from the server.
    "1" SQL_ENSURE The statistics are retrieved unconditionally.
  • When you receive a valid statement handle, you can call DB_FetchNext or DB_FetchPrevious to manipulate the information.


[ ] STRING cat, sch, tab-name, ignore 
[ ] INTEGER i 
[ ] hstmnt = DB_Statistics (hdbc, cat, sch, "", "1", "0") 
[ ] // retrieve name of table to which stats apply and whether ix is unique; // ignore the rest.
[-] while (DB_FetchNext (hstmt, ignore, ignore, tab-name, i) == TRUE) {
	[ ] //print table names and index info ... 
[ ] }