I’m executing a statement like
DELETE FROM USER WHERE USER_ID=1;
In SQLDeveloper.
As the user is referenced in many tables (for example the user has an order, settings, …) we activated ON DELETE CASCADE so that we do not have to delete each and every row manually. However while developing we are interested to know how many rows and and in which tables are “automatically” deleted by cascade delete.
Is there any way to find this out. Either by SQL-Statement, directly in sqldeveloper from a logfile or any other idea?
whilst this is not possible with sql%rowcount, it is possible if you write trigger code, but this means that you need a trigger on all tables you want to monitor. Also triggers would slow down operations a bit.
e.g.:
we want a package spec to hold an array of tables + counts:
we want a trigger on the top level table to reset these counts to zero:
this assumes that you’re only interested in the array with a delete from the top level table. if not, you’d want a trigger on each table with
foo.t_rowcount.delete('TABLE_NAME')instead.now a after for each row trigger on each table of interest to set the arrays:
now when we delete or whatever: