Vérace
As the subject line says:
Do triggers work on dbfiddle with MySQL 5.6.
I can get it working on my local machine but not on the fiddle site.
Here's what I don't appear to be able to get working.
```
root@localhost [test]> DESC payment_ter;
+-------------+------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------------+------+-----+---------+----------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| price | decimal(10,2) unsigned | NO | | 0.00 | |
| pay_date | int unsigned | NO | | NULL | |
| pt_date_str | char(10) | YES | | NULL | |
+-------------+------------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
root@localhost [test]>
```
and
```
root@localhost [test]> SHOW TRIGGERS;
Empty set (0.00 sec)
root@localhost [test]>
```
My trigger:
```
DROP TRIGGER IF EXISTS tr_ins_dates;
DELIMITER $$
CREATE TRIGGER tr_ins_dates BEFORE INSERT
ON payment_ter
FOR EACH ROW BEGIN
SET NEW.pt_date_str = CONCAT_WS ('-', YEAR(FROM_UNIXTIME(NEW.pay_date)),
LPAD(MONTH(FROM_UNIXTIME(NEW.pay_date)), 2, 0), '01');
END $$
DELIMITER ;
```
and then I do an `INSERT`
```
root@localhost [test]> INSERT INTO payment_ter (price, pay_date) VALUES (56.6, UNIX_TIMESTAMP('2020-03-19 16:42:30'));
Query OK, 1 row affected (0.19 sec)
```
and then:
```
root@localhost [test]> SELECT * FROM payment_ter;
+----+-------+------------+-------------+
| id | price | pay_date | pt_date_str |
+----+-------+------------+-------------+
| 1 | 56.60 | 1584636150 | 2020-03-01 |
+----+-------+------------+-------------+
1 row in set (0.00 sec)
```
So, my pt_date_str field has been updated - my trigger is working.
But, when I perform the same actions on dbfiddle, it won't work.
Here's a [link](https://dbfiddle.uk/?rdbms=mysql_5.6&fiddle=c8dcbb6cdc139b710b18bfdf2f1e2fb6) in case I'm missing something blindingly obvious!
Top Answer
Jack Douglas
Triggers work, but the `DELIMITER` statement does not. It [isn't supported](https://stackoverflow.com/q/5311141/12757754) by the PHP driver, because it is not a mysql database command, but [mysql *client* command](https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html).
<>https://dbfiddle.uk/?rdbms=mysql_5.6&fiddle=ee92c9a178a47f173630e49f8b499172
Your fiddle works [without the delimiter](https://dbfiddle.uk/?rdbms=mysql_5.6&fiddle=13f23506a4c540f7531e1073f5b51529), though you don't need the `DROP TRIGGER IF EXISTS`, and if you do want it, it may be best to put it in a separate batch for clarity given that you can't change the delimiter.