MySQL: ON DELETE

Поділитися
Вставка
  • Опубліковано 17 жов 2024

КОМЕНТАРІ • 22

  • @BroCodez
    @BroCodez  Рік тому +6

    ALTER TABLE transactions
    ADD CONSTRAINT fk_customer_id
    FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
    ON DELETE SET NULL;
    ALTER TABLE transactions
    ADD CONSTRAINT fk_customer_id
    FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
    ON DELETE CASCADE;

    • @paliszarok
      @paliszarok Рік тому +1

      thanks for literally existing

  • @navidrahbar-musicproducers2672
    @navidrahbar-musicproducers2672 4 місяці тому +1

    I love how you explain things in the simplest way.
    Perfectly understandable.
    Many thanks man.

  • @contactdi8426
    @contactdi8426 Рік тому +5

    Bro you made everything so easy peasy to understand. Love you

  • @satriauno3011
    @satriauno3011 10 місяців тому

    Good Explanation thanks

  • @DyanGong
    @DyanGong 6 місяців тому

    so clear for anyone, super cool

  • @benwan4926
    @benwan4926 Рік тому

    This is a really useful tutorial

  • @abdelrhmansayed340
    @abdelrhmansayed340 Рік тому +1

    THX

  • @massivestrokeee_6652
    @massivestrokeee_6652 Рік тому

    thank you for you incredible work bro i luv u

  • @ccgould434
    @ccgould434 2 місяці тому

    I cant thank you enough

  • @acminostgien3038
    @acminostgien3038 11 місяців тому

    question, if the data that has the foreign key is not nullable, does the on delete set null still work?

  • @Ben10isNostalgic
    @Ben10isNostalgic Місяць тому

    Hey Bro, could you please create java spring boot tutorial.

  • @smp219
    @smp219 Рік тому

    ty for python tutorial

  • @maxsquad5801
    @maxsquad5801 Рік тому

    Thx bro

  • @_sumedh_music
    @_sumedh_music Рік тому

    Hi bro, I am following your whole SQL series and I have learnt all the concepts but this ON DELETE concept sucks. I typed the same query as you have shown but still it gives me error "Error Code: 1451. Cannot delete or update a parent row: a foreign key constraint fails (`mydb`.`transactions`, CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`c_id`) REFERENCES `customers` (`c_id`))". Can you please help me with this @BroCode .

    • @_sumedh_music
      @_sumedh_music Рік тому

      The query in my MYSQL WorkBench -> alter table transactions1
      drop foreign key transactions1_ibfk_1;
      alter table transactions1
      add constraint transactions1_ibfk_1
      foreign key transactions1 (customer_id) references customers(c_id)
      ON DELETE cascade;

    • @contactdi8426
      @contactdi8426 Рік тому

      Just because you can't do (despite spoon feeding) doesn't mean his video Sucks! He explained in the best and easiest manner, but the issue is with you that you can't manage a minor error which clearly states the issue which you don't want to read. Dumb***

    • @kin_1997
      @kin_1997 2 місяці тому

      set foreign_key_checks = 0; temporarly and then set it back to 1

    • @_sumedh_music
      @_sumedh_music 2 місяці тому

      @@kin_1997 Thanks for the solution mate, but I think now I am not gonna solve a 1 year old query 🥲

    • @kin_1997
      @kin_1997 2 місяці тому +1

      @@_sumedh_music haha no problem, maybe someone else will see solution and it will help them

  • @nicolewynne4781
    @nicolewynne4781 Рік тому +2

    could you please do full PHP course bro?

  • @funnyoceanofmemes1656
    @funnyoceanofmemes1656 10 місяців тому

    i dont know bro what is your obsession with poppy puff