Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all the tables in database in one shot

Tags:

laravel-5

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

like image 830
sujit prasad Avatar asked Feb 29 '16 07:02

sujit prasad


People also ask

How do I DELETE all tables in a database?

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.

How do I DELETE multiple tables in database?

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,...)

Can you DELETE from multiple tables at once SQL Server?

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?


1 Answers

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 use
  • drop-views - Drop all tables and views
  • drop-types - Drop all tables and types (Postgres only)
  • force - Force the operation to run when in production

It 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.

like image 126
Yevgeniy Afanasyev Avatar answered Oct 03 '22 08:10

Yevgeniy Afanasyev