This is easy to do, and you can try it for yourself as an exercise.Hint: one way to do it is by using a BEFORE DELETE ON clause.
The idea here is to define a trigger on the data table, such that every time a new name is inserted into it, the running total in the chars table is automatically updated with the number of characters in the newly-inserted record.
(See Listing A) The key to understanding this is the CREATE TRIGGER command, used to define a new database trigger.
To see how such an audit trail might work in practice, consider the following table (table name: accounts), which lists balances for a user's three bank accounts.
(Table A) Now, I'd like to set up an audit trail to track changes made to this table.
This command sets up a new trigger, imaginatively named t1, that is activated every time a new record is inserted into the data table.