mySQL Triggers – How To

Posted by: Admin  :  Category: Mysql

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

mysql triggers are little programs that run before or after a sql call to then do something else behind the scenes.
Video Rating: 5 / 5

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

7 Responses to “mySQL Triggers – How To”

  1. latlov Says:

    you are the man!

  2. frenchpet Says:

    kirk hammet is that you ?

  3. yp06407012 Says:

    Then through PHP I access the voltagedata_rt table, no need to sort as per time-stamp because _rt table is always the latest……!!!

  4. yp06407012 Says:

    /* note the delete followed by insert in the trigger */
    /* voltagedata is my regular table, voltagedata_rt is my realtime data table filled by triggers */

    DROP TRIGGER IF EXISTS indiacep.catch_voltagedata_insert//
    CREATE TRIGGER indiacep.catch_voltagedata_insert BEFORE INSERT ON indiacep.voltagedata
    FOR EACH ROW
    BEGIN
    DELETE FROM indiacep.voltagedata_rt WHERE voltagedata_rt.busid = new.busid;
    INSERT INTO indiacep.voltagedata_rt VALUES (new.tstamp, new.busid, new.freq, new.voltage);
    END
    //

  5. optikalefxx Says:

    That is a great optimization idea!

    So basically after queries are run you store the values in a trigger table, and instead of querying the latest, you just use whatever is in the trigger table to load?

  6. yp06407012 Says:

    Thanks. Gr8 video on triggers..!!
    I have a continuous flow of data which I want to store as well as display the latest values on a webpage. The refreshing of the webpage was taking long time because I was running query on the full datatable. using trigger, I created a “latestdata” table which replaces (deletes and inserts) records with a newer timestamp, and this is queried by webpage, making the refresh faster.

    So, it took me just 8:51 min to learn and also use triggers. Its working…!!!

  7. Ron8000 Says:

    Great Video! Never really used triggers but when I find a need. This know how will be there Thanks!

Leave a Reply

*