Checking Database Consistency
Page 4 of 4

Sample Queries

This section provides examples that illustrate using checkTable in queries.

Check the consistency of a single table:

VALUES ConsistencyChecker.checkTable('APP', 'FLIGHTS')

Check the consistency of all of the tables in a schema, stopping at the first failure:

SELECT tablename, ConsistencyChecker.checkTable(
    'APP', tablename)
FROM sys.sysschemas s, sys.systables t
WHERE s.schemaname = 'APP' AND s.schemaid = t.schemaid

Check the consistency of an entire database, stopping at the first failure:

SELECT schemaname, tablename,
ConsistencyChecker.checkTable(schemaname, tablename)
FROM sys.sysschemas s, sys.systables t
WHERE s.schemaid = t.schemaid

NOTE: See the sample program JBMSTours.AdminHelper for an example of running the consistency checker.