I have a schema, named BILL, and in this schema all the tables have a column named ID. I need a way to delete the row from all the tables, where ID = ‘test’. There are a lot of schemas, so it is important that i only delete them from BILL. There are tables that don’t contain a test row too if it matters. This is an oracle database.
I couldn’t figure out how to do this with sql. Maybe pl/sql? Any thoughts?
I’d go with
execute immediate:This should work if all tables in that schema have a column name named
id(as you indiciated is the case). Otherwise, you should join withdba_tab_columnsto make sure to only select tables that have such a column.It will fail, too, if
idis a primary key that other tables reference. In that case you could embed theexecute immediateinto a