Skip to content

Quickly Inspect Database & Tables in Laravel

quickly inspect database and tables in laravel

Let’s say you want to inspect the database to find information such as the number of open connections, the size of the database, the number of tables, and more.

Normally, you would use a database management tool.

But in Laravel, you can quickly do this from the command line with

php artisan db:show

This command gives you a summary of the database, including its type, connection details, port, and more.

🎥 Prefer a video instead?

Now let’s say you want to inspect a table to figure out its structure: columns, indexes, size, and so on.

You can do this with

php artisan db:table {table-name}

The command lists the size of the table, the columns and their data types, and also the indexes.

If you run the command without the name of the table, it will show you a list of the tables you can choose from.

php artisan db:table

That is all!

Happy coding 🎉


Let me know what you think about this article in the comments section below.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.   
  

Comments