Starting Over

With every creation comes at least one deletion. You’ll probably find that you need to clear out your database and re-create it from time to time. In an effort to make this easy for you, the scripts to perform this action are presented below. Just be careful; the data in your database will be completely wiped out by these SQL scripts, with no warning. The following scripts are database-specific analogs to Example 3-6 in the text.

Cloudscape

The SQL script shown in Example A-16 deletes all of the tables and constraints for Cloudscape databases.

Example A-16.  SQL Script for Deleting All Tables on Cloudscape Databases

-- Drop all tables
DROP TABLE INVESTMENTS;
DROP TABLE FUNDS;
DROP TABLE TRANSACTIONS;
DROP TABLE ACCOUNTS;
DROP TABLE ACCOUNT_TYPES;
DROP TABLE USERS;
DROP TABLE USER_TYPES;
DROP TABLE OFFICES;

InstantDB

Example A-17 is an SQL script that deletes the user and accounts storage on InstantDB databases.

Example A-17. SQL Script for Deleting All Tables on InstantDB Databases

; Load InstantDB JDBC drivers
d org.enhydra.instantdb.jdbc.idbDriver;
o jdbc:idb=forethought.prp;

; Drop all tables
e DROP TABLE INVESTMENTS;
e DROP TABLE FUNDS;
e DROP TABLE TRANSACTIONS;
e DROP TABLE ACCOUNTS;
e DROP TABLE ACCOUNT_TYPES;
e DROP TABLE USERS;
e DROP TABLE USER_TYPES;
e DROP TABLE OFFICES;

; Close up
c close;

MySQL

Example A-18 is an SQL script that deletes the Forethought data store on MySQL databases.

Example A-18. SQL Script for Deleting All Tables on MySQL Databases ...

Get Building Java Enterprise Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.