Freigeben über


Working with a Database

A database provides a working environment where you can store a collection of tables, establish relationships between the tables, and set properties and data validation rules that control how the related tables work together. A database is stored as a file with a .dbc extension.

Contents of a Database

You can use databases independently or incorporate them into a project by adding them to the Project Manager. To access the tables within a database, the database must be open.

To open a database

  1. In the Project Manager, select the name of the database you want to use.
  2. Choose Modify.

You can also choose Open from the File menu and choose the name of a database.

To look at the structure of a sample database, open the Testdata.dbc file located in the Visual FoxPro ...\Samples\Data directory.

Tables in the Database Designer

When you open a database, the Database Designer appears and displays the tables in the database and the relationships between them. The Database Designer toolbar makes it possible for you to access database-related options quickly. Database commands are available on the Database menu and shortcut menus are available when you right-click the Database Designer.

Finding a Table or View in a Database

If your database contains many tables and views, you might want to quickly locate a specific table in the Database Designer. When the Database Designer is open, you can quickly locate the table or view you want to work using the Find Object command from the Database menu.

To locate a table in a database

  1. From the Database menu, choose Find Object.
  2. In the Find Table or View dialog box, select the table you want to locate.

The located table appears active in the Database Designer.

Displaying Tables or Views

You can choose to display only tables or specific views.

To display only tables or views

  1. From the Database menu, choose Properties.
  2. In the Database Properties dialog box, select the desired display options.

You can expand tables in the Database Designer to see the fields and the indexes they contain or collapses tables to show only the table names, which is helpful if the database contains many tables.

To expand or collapse a table

  • In the Database Designer, right-click a table and select Expand or Collapse.

To expand or collapse all tables

  • Right-click the Database Designer and select Expand All or Collapse All.

Arranging Tables in a Database

You can change the layout of your tables displayed in the Database Designer. For example, after working in the database, you might want to return the tables to the default height and width or you might want to improve the layout by aligning the tables.

To arrange the tables in a database

  • From the Database menu, choose Arrange, and then select the appropriate options in the Find Table or View dialog box.

    In the Database Designer, the title bar of the table you selected is highlighted.

    To Select
    Arrange the tables alphabetically by name By name
    Arrange the tables by type By type
    Align the tables in a row Horizontally
    Align the tables in a column Vertically
    Return the tables to their original size Resize objects to default height and width

See Also

Developing Databases | Adding Tables to a Database | Browse | Removing a Table from a Database | Updating Table and Database Links | Creating a Database | Database Designer | Project Manager