• notice
  • Congratulations on the launch of the Sought Tech site

Laravel - MySQL - Bypass database foreign key conditional constraint, force delete

MySQL under the command SET FOREIGN_KEY_CHECKS=0, can forcibly delete the associated source, sometimes when we just want to test, it will be very useful and will not be stuck.

In Laravel, you can delete records or clear data tables in this way

DB::statement('SET FOREIGN_KEY_CHECKS=0');
WalletDetail::truncate();


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+