Condividi tramite


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 or displays the Remove dialog box so you can choose a table in the current database to remove.

  • [DELETE]
    Removes the table from the database and deletes it permanently from disk.

    Warning

    Tables deleted using the DELETE keyword cannot be retrieved. Visual FoxPro does not confirm deletion or provide a warning even if the SET SAFETY command is set to ON.

  • [RECYCLE]
    Specifies to delay deleting the table from disk and moves it to the Windows Recycle Bin.

Remarks

REMOVE TABLE removes all primary indexes, default values, and validation rules associated with the table. If SET SAFETY is set to ON, Visual FoxPro prompts you to confirm removing the table from the database.

When a table is removed from the database, it becomes a free table and can be added to another database.

Warning

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

Tasks

How to: Remove a Table from a Database

Reference

CLOSE Commands

DROP TABLE Command

INDBC( ) Function

Other Resources

Commands (Visual FoxPro)