Puya Sarmidani Puya Sarmidani - 2 months ago 8
MySQL Question

Table empty after restarting mySQL Server

I got a lot of tables inside a database.
Strange thing is that one table always empties after restarting mySQL.
It seems like it's a TEMP table but i doubt that.
Where can i see if it is a TEMP table or is something else triggering this event.

Talking about triggers, I do have a trigger inside another table that updates values but i do not think that this is the cause of it.

[Edit]

My trigger query is

BEGIN
IF NEW.Discount <> OLD.Discount || NEW.Price <> OLD.Price || NEW.FirstYearDiscount <> OLD.FirstYearDiscount
THEN
INSERT INTO InvoiceTotal SET
PriceExcl = (SELECT
SUM((Price - (Price * (IF(Discount > FirstYearDiscount || Discount < 0, Discount, FirstYearDiscount) / 100))) * InvoicePeriod)
FROM InvoiceItem WHERE InvoiceID = NEW.InvoiceID),
InvoiceID = NEW.InvoiceID
ON DUPLICATE KEY UPDATE
PriceExcl = (SELECT
SUM((Price - (Price * (IF(Discount > FirstYearDiscount || Discount < 0, Discount, FirstYearDiscount) / 100))) * InvoicePeriod)
FROM InvoiceItem WHERE InvoiceID = NEW.InvoiceID);
END IF;
END


This trigger wil update values if change.

I also got a cronjob that inserts new values when a order is made.

Answer

I did some digging around and for each Table, clicked on Operations (mixed in with the tabs up top), and noticed a property called Storage Engine. It was initially set to Memory, which seemed off to me. So I checked my other databases and noticed they were all set to MyISAM. So I changed the tables, in the Database I was having problems with, to MyISAM and restarted my server to test check them. The data was now saving with no problems!

Hope it helps other people who has the same problem (Y)

PS. Thanks for the replies guys