Laravel db:truncate command

The db:truncate Laravel command lets you easily truncate your database tables!

Zacharias Creutznacher Zacharias Creutznacher

Checkout our latest addition to our laravel-useful-additions package - the db:truncate command!

This command truncates all the tables of your current database connection. Checkout --help to see arguments and options. Here are some examples:

#Default

By default it truncates all existing tables of your database:

Note: in production environment it asks for confirmation

php artisan db:truncate

#Specify tables

You could also only truncate some specific tables:

php artisan db:truncate users details

#Disable foreign key checks

If you need to disable foreign key checks during truncation, this is also possible:

php artisan db:truncate --checks=false