Database Tutorial

Course Tutorial Site

Site Admin

Rerunnable Script

without comments

A re-runnable script is one that anticipates problems and performs conditionally actions. For example, when a TABLE doesn’t exist, it shouldn’t attempt to drop it because that raises an exception that distracts and potentially misleads those running it to think there’s a meaningfull error. Referential integrity describes the unique relationship between primary and foreign keys. You must drop FOREIGN KEY constraints before you drop the table that holds their referenced PRIMARY KEY when you implement these database level constraints.

The values in rows of a PRIMARY KEY are the list of valid values that may be entered in a FOREIGN KEY. This relationship makes the FOREIGN KEY dependent on the PRIMARY KEY. The deletion of rows from the table holding the PRIMARY KEY abandons the FOREIGN KEY of any dependent rows, which are often called orphaned keys rather than abandoned keys because of the parent-child analogy surrounding referential integrity.

The following drop down segments show you how to write re-runnable scripts with referential integrity restrictions on primary and foreign keys (just click the preceding title).

The balance of examples for creating, modifying, and dropping tables are found in the DDL web pages.

Written by michaelmclaughlin

September 19th, 2017 at 11:34 am

Posted in