According to the documentation:
http://dev.mysql.com/doc/refman/5.0/en/blackhole-storage-engine.html
the blackhole storage engine can be used for things like diagnostics and offloading the binary log to a different machine, without having to store the database on that machine.
What other creative uses for this engine can you come up with?
Found one a using a trigger:
If you have a complicated series of inserts or updates that needs to happen in a transaction, you can do these in application code, or
You can create one 'big' blackhole
table with enough rows to hold all the values.
And create a trigger like:
DELIMITER $$
CREATE TRIGGER ai_bh_table_each AFTER INSERT ON bh_table FOR EACH ROW
BEGIN
DECLARE lastid1 integer;
INSERT INTO table1 VALUES (null, new.field1, new.field2);
SELECT LAST_INSERT_ID() INTO lastid1;
INSERT INTO table2 VALUES (null, new.field3, lastid1);
....
END$$
DELIMITER ;
If you include error checking code you can even simulate transactions on engines that don't support it, like MyISAM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With