DEV Community

Carlos Estrada
Carlos Estrada

Posted on

Get list of tables in mysql

In this post I will share how to get the list of tables in mysql using 2 methods, the first one with the show sentence and the second with the information_schema

1. Using Show sentence

This is pretty straight forward just do the next sql query

-- Select your database
SHOW TABLES;
Enter fullscreen mode Exit fullscreen mode

And then you will get the list of tables.

2. Using the information_schema

For this one we will use the information_schema.

SELECT
  TABLE_NAME
FROM information_schema.tables
WHERE
    TABLE_SCHEMA = 'our_db'
Enter fullscreen mode Exit fullscreen mode

Here the our_db after the TABLE_SCHEMA is the name of our database where we want to get the list of tables.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more