Database Guide


Deleting tables and databases

You can delete a table or database by sending the delete message to an instance of AbtTable.

Oracle does not allow you to delete a database. Attempting to do so will result in an error.

windows
You cannot use these examples to delete databases under Windows.

The following examples show how to delete the PEOPLE table from the CORPDATA database and then delete the CORPDATA database. These examples do the following:

To use this code, follow these steps:

  1. Substitute database and table names to reflect your database and table.
  2. Evaluate the first block of code using the Execute command.
  3. Evaluate the second block of code using the Display command.

    This expression returns an empty ordered collection, showing that you have deleted the table.

  4. Evaluate the third block of code using the Execute command.
  5. Evaluate the fourth block of code using the Display command.

    This expression returns an ordered collection, showing that you have deleted the table.

"Delete a table"
| connection |
connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'CORPDATA'.
     deleteTableNamed: 'PEOPLE'.
 
"Display all tables"
| connection |
connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'CORPDATA'.
     allUserTableNames.
 
"Delete a database"
| connection |
connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'CORPDATA'.
     deleteDatabaseNamed: 'CORPDATA'.
 
"Display all databases"
| connection |
connection := AbtDbmSystem activeDatabaseConnectionWithAlias: 'CORPDATA'.
     allDatabaseNames.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]