Condividi tramite


How to: Test Databases

Use this function to test a database, for example, before you make a backup. It is a good idea to test your database frequently.

To test a database

  1. In the development environment, on the File menu, choose Database, and then choose Test. The Test Database window opens.

    Note

    If the Test menu item is not available, then you must open a database.

  2. In the Test Database window, you can specify the extent of the test by selecting one of these options: Minimum, Normal, Maximum, or Custom.

Most of the tests involve running the SQL Server database consistency checker (DBCC). The following table lists the features that are tested during the different tests. It also lists the SQL Server DBCC tests that are carried out.

Level Test Fields Features Checked

Minimum

Test primary keys and data

All records in all tables can be read.

Records are sorted in ascending order according to the primary key.

All fields are correct in relation to the field type.

DBCC CHECKTABLE (<Table>,NOINDEX)

Test BLOBs

All BLOBs (fields for pictures, for example, on an item card,) can be read.

DBCC CHECKTABLE (<Table>,NOINDEX)

Normal

All the fields included in the Minimum test, plus:

Test secondary keys

All secondary keys in all tables can be read.

Sorting is performed correctly according to the secondary key.

All fields in the sorting have the correct field type.

DBCC CHECKTABLE (<Table>)

Test space allocation

All space in the database is either used by a sorting key or is available.

DBCC CHECKALLOC (<Current Database>)

Maximum

All the fields included in the Normal test, plus:

Test field relationships

All fields that have relationships to other fields can be accessed from the field that they are related to.

Custom

The same fields as the Maximum test. The difference is that you can cancel the tests that you do not want to run.

Whatever you select. However, some of these tests correspond to SQL Server tests and must run concurrently.

Primary and secondary keys are sometimes described as indexes and are used, for example, when you sort information. The keys determine how information in a table is ordered. You switch keys to sort the information in a table in a different way.

Choose the Options tab to specify how the output from the database test is managed. The output from the database test consist of the errors messages that are generated. These can be handled as follows:

  • Screen: The error messages are displayed on the screen. Each time an error message is displayed you must choose the OK button before the test continues. This can be quite troublesome if the test generates a large number of messages.

  • Event Log: The error messages are written in the operating system’s event log. For more information about the event log, see the operating system’s documentation.

  • File: The error messages are written to a text file. Use the AssistEdit button to select the name and location of the text file.

If you select Event Log or File, then the database test is not interrupted and will not take so long. You can then review any error messages that were generated and repair the things that caused them.

After you start the test, a window opens containing information about the test status.

Important

Make sure that you create periodic backups of your database and that you can restore from a backup.

See Also

Tasks

How to: Create Backups
How to: Restore Database Backups

Concepts

Table Keys
Setting Relationships Between Tables