docs
docs copied to clipboard
Add more details on what is working / not working
I am trying to create a trigger using the web-console on app.planetscale.com. I have realized that the documentation does not include some details about the supported commands / statements. For example, I am trying to run:
DELIMITER ;;
CREATE TRIGGER `foo_before_insert`
BEFORE INSERT ON `foo` FOR EACH ROW
BEGIN
IF new.id IS NULL THEN
SET new.id = uuid();
END IF;
END;;
DELIMITER ;
I am getting the following error: syntax error at position 10 near 'DELIMITER'
I couldn't find anything on your documents about delimeter or trigger. I assume that PlanetScale currently does not support DELIMETER
or TRIGGER
. I didn't see any piece of documentation that states that whether you support it or not. I would be glad if you can add some documentation, thanks!
Hi! We definitely have this type of doc on our list. I'm going to make sure to include this example.
As for the specific case, we currently do not support Trigger DDL.
@Dogacel For your specific use case though, you might find doing it in the table is useful too:
CREATE TABLE uuid_test (
id BIGINT UNSIGNED NOT NULL,
uuid VARCHAR(36) DEFAULT (UUID()),
name VARCHAR(20),
PRIMARY KEY (id)
);
Which would look like this when actually using the table:
mysql> insert into uuid_test (id) values (1), (2);
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from uuid_test;
+----+--------------------------------------+------+
| id | uuid | name |
+----+--------------------------------------+------+
| 1 | 1f3dc898-7a48-11ec-bc4d-53a33a376454 | NULL |
| 2 | 1f3e04a2-7a48-11ec-bc4d-53a33a376454 | NULL |
+----+--------------------------------------+------+
2 rows in set (0.00 sec)
You can now find this information on the MySQL compatibility page