Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26034

Update cascade failed

    XMLWordPrintable

    Details

      Description

      create table Dep(
          id INT UNSIGNED AUTO_INCREMENT primary key,
          dep varchar(255) not null unique,
          dep_sjm varchar(255),
          p_dep INT UNSIGNED default NULL
      );
      ALTER TABLE Dep
          ADD FOREIGN KEY (p_dep)
          REFERENCES Dep (id)
          ON UPDATE CASCADE;
       
      insert into Dep(id,dep,dep_sjm) values (209604,"sales department","XSB");
       
      insert into Dep(id, dep, dep_sjm, p_dep) values (203634,"sales department 1","XSB",209604);
      update Dep set id=48615 where id=209604;
      

      output: ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`test`.`Dep`, CONSTRAINT `Dep_ibfk_1` FOREIGN KEY (`p_dep`) REFERENCES `Dep` (`id`) ON UPDATE CASCADE)
      

        Attachments

          Activity

            People

            Assignee:
            serg Sergei Golubchik
            Reporter:
            egegerg grgeehr
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration