Share via


REMOVE TABLE Command

Removes a table from the current database.

REMOVE TABLE TableName | ?   [DELETE] [RECYCLE]

Parameters

  • TableName
    Specifies the table to remove from the current database.

  • ?
    Displays the Remove dialog box from which you can choose a table in the current database to remove.

  • DELETE
    Specifies that the table is removed from the database and from disk.

    **Caution   **Any table deleted from disk with this clause cannot be retrieved. Even if SET SAFETY is ON, you are not warned before the table is deleted from disk.

  • RECYCLE
    Specifies that the table isn't immediately deleted from disk and is placed in the Windows Recycle Bin.

Remarks

When a table is removed from the database, it becomes a free table and can be added to another database. Tables are added to a database with ADD TABLE.

When REMOVE TABLE is issued, all primary indexes, default values, and validation rules associated with the table are also removed. If SET SAFETY is ON, Visual FoxPro displays a prompt asking if you are sure you want to remove the table from the database.

Caution   REMOVE TABLE affects other tables in the current database if those tables have rules or relations associated with the table being removed. The rules and relations are no longer valid when the table is removed from the database.

Example

The following example creates two databases named mydbc1 and mydbc2, and a table named table1. The table is added to mydbc1 when it is created. The table is then closed and removed from mydbc1. ADD TABLE is then used to add the table to mydbc2. RENAME TABLE is used to change the name of the table from table1 to table2.

CREATE DATABASE mydbc1
CREATE DATABASE mydbc2
SET DATABASE TO mydbc1
CREATE TABLE table1 (cField1 C(10), n N(10))  && Adds table to mydbc1
CLOSE TABLES     && A table must be closed to remove it from a database
REMOVE TABLE table1
SET DATABASE TO mydbc2
ADD TABLE table1
RENAME TABLE table1 TO table2

See Also

ADD TABLE | CLOSE DATABASES | CREATE DATABASE | DROP TABLE | FREE TABLE | OPEN DATABASE