I'm looking for a way to insert records into a 'black hole'; i.e. execute a query for a certain table successfully, but make the records disappear. Something like INSERT INTO NULL
, if you will. MySQL has the BLACKHOLE engine, can Oracle do something similar?
The only thing I could come up with was:
- creating a view with
SELECT NULL FROM DUAL
- creating a trigger with
INSTEAD OF INSERT
andBEGIN NULL; END;
Is this okay?
Obviously, the optimal way is not to execute the insert statement, but I have no control over this – I have to fix this in the DB.
What's the best way to handle this? (the solution with the least impact on performance)
Best Answer
One way you could do something like this on Oracle is to use a
temporary table
withON COMMIT DELETE ROWS
. The rows will "disappear" at the end of the transaction. If you're using a host environment such as JDBC with autocommit, this will make it look like what you describe. If performance is important, this approach will be much faster than the "discarding trigger" approach.Syntax:
Documentation: http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables003.htm#ADMIN11633