|
 |
|
ss
Oracle Tips by Burleson |
Rebuilding and Dropping
Tables
To completely remove a table from the
tablespace, use the DROP TABLE command. This command’s format
follows:
See Code Depot
Oracle will drop the table regardless of its
contents. The only time a drop will fail is when a table’s primary
key is referenced by another table’s foreign key via a restraint
clause. The DBA can check for this situation by looking at the
DBA_CONSTRAINTS and the DBA_CONS_COLUMNS views. A view called
USER_CROSS_ REFS provides this information on a user-by-user basis.
Using the CASCADE CONSTRAINTS clause will force a CASCADE DELETE to
occur in all child tables.
Rebuilding Tables
The DBA may have to rebuild a table or
tables after maintenance, after a physical disk crash, or--the
leading cause--due to operational stupidity. If the application
designers were thoughtful enough to provide a build script, there is
no problem. However, for legacy systems, systems that have been
modified and not redocumented, or systems created on the fly, there
may be no current build scripts, if there were any to begin with. In
this case, the DBA is in trouble. How can this situation be
prevented? Require build scripts for each application and keep them
up to date. For existing, undocumented systems, the script
TAB_RCT9i.sql from the Wiley Web site will create a build script for
simple existing tables. For very complex tables, I suggest
implementing a utility such as TOAD from Quest, Inc. In Oracle9i,
the DBMS_METADATA can also be used to generate the DDL for any
database object. Any rebuild script generator must be run before any
loss has occurred. Due to the added complexity of Oracle9i, it is
doubtful many systems created on the fly will that make use of the
complex options and types. Over time, I will be revising
TAB_RCT9i.SQL to handle the more complex Oracle9i structures, and
newer versions will be made available at the Wiley Web site.

www.oracle-script.com |