Questo è ora supportato a partire da MySQL 8.0.16.
Vedi https://dev.mysql. com/doc/refman/8.0/en/create-table-check-constraints.html
mysql> create table id_parent_table (
-> main_id bigint unsigned not null,
-> parent_id bigint unsigned not null,
-> constraint columns_cannot_equal check (main_id <> parent_id)
-> );
Query OK, 0 rows affected (0.38 sec)
mysql> insert into id_parent_table (main_id, parent_id) values (1, 1);
ERROR 3819 (HY000): Check constraint 'columns_cannot_equal' is violated.