How to delete all the tables in a database in one shot in laravel.
For Migration we use-
Artisan::call('migrate', ['--force' => true]);
but for deleting all the tables is there any-
Thank You
Select all of the tables in your database in the Schema Browser clicking on the first table, holding Shift, and clicking on the last table. Right-click on the selected tables and select “Drop (n) Tables…” Click on Review SQL, as we will need to add in the foreign key check disable and enable.
Save this question. Show activity on this post. DELETE table1,table2,table3,table4 FROM table1 LEFT JOIN table2 ON table1.pk=table2.pk LEFT JOIN table3 ON table3.pk=table2.pk LEFT JOIN table4 ON table4.pk=table3.pk WHERE table1.pk IN (101,102,106,...)
The syntax also supports deleting rows from multiple tables at once. To delete rows from both tables where there are matching id values, name them both after the DELETE keyword: DELETE t1, t2 FROM t1 INNER JOIN t2 ON t1.id = t2.id; What if you want to delete nonmatching rows?
php artisan db:wipe
It is a quick way to drop all the tables, their types and views if you’re using Laravel 6.x
Full description:
$ php artisan db:wipe {--database=} {--drop-views} {--drop-types} {--force}
database
- The database connection to usedrop-views
- Drop all tables and viewsdrop-types
- Drop all tables and types (Postgres only)force
- Force the operation to run when in productionIt was implemented on Aug 20, 2019
This change has also affected the db:fresh command’s functionality internally. Now it just calls db:wipe
and then migrate
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With