Condividi tramite


Removing a Table from a Database

When you add a table to a database, Visual FoxPro modifies the table file's header record to document the path and file name for the database that now owns the table. This path and file name information is called a backlink, because it links the table back to the owning database. The process of removing a table from a database not only removes the table and associated data dictionary information from the database file, but also updates the backlink information to reflect the table's new status as a free table.

You can remove a table from a database through the interface or with the REMOVE TABLE command. As you remove the table from the database, you can also choose to physically delete the table file from the disk.

To remove a table from a database

  • In the Project Manager, select the table name, then choose Remove.

    -or-

  • From the Database Designer, select the table. From the Database menu choose Remove, then in the dialog box, choose Remove.

    -or-

  • Use the REMOVE TABLE command.

For example, the following code opens the testdata database and removes the orditems table:

OPEN DATABASE testdata
REMOVE TABLE orditems

Removing a table from a database does not automatically delete the table file. If you want to both remove the table from the database and delete the table's .dbf file from the disk, use the DELETE clause of the REMOVE TABLE command or the DROP TABLE command. For example, the following code opens the testdata database and deletes the orditems table from disk:

OPEN DATABASE testdata
REMOVE TABLE orditems DELETE

The following code also opens the testdata database, then deletes the orditems table without moving a copy to the Windows Recycle bin:

OPEN DATABASE testdata
DROP TABLE orditems NORECYCLE

See Also

Adding Tables to a Database | Updating Table and Database Links | Creating a Database | Creating Databases | REMOVE TABLE | Designing Databases | Working with a Database