Icon Deleting Tables

Introduction
Deleting tables is accomplished through the DeleteTable method of the TDBISAMTable component. The properties used by the DeleteTable method include the DatabaseName, TableName, and Exists properties.

Deleting a Table
To delete a table, you must specify the DatabaseName and TableName properties of the TDBISAMTable component and then call the DeleteTable method. The table component must be closed and the Active property must be False. It is usually good practice to also examine the Exists property of the TDBISAMTable component first to make sure that you don't attempt to delete a non-existent table. If you do attempt to delete a non-existent table an EDBISAMEngineError exception will be raised. The error code given when a table delete fails due to the table not existing is 11010 and is defined as DBISAM_OSENOENT in the dbisamcn unit (Delphi) or dbisamcn header file (C++).

The following example shows how to delete the "customer" table using the DeleteTable method:

begin
   with MyTable do
      begin
      DatabaseName:='d:\temp';
      TableName:='customer';
      if Exists then
         DeleteTable;
      end;
end;

Information You should be extremely careful when using this method since deleting a table will remove the table and its contents permanently. Be sure to have a backup of your data before using this method in order to avoid any costly mistakes.

In addition to using the TDBISAMTable DeleteTable method for deleting tables, DBISAM also allows the use of the DROP TABLE SQL statement.
Image