List down all the Tables in a MySQL Database


Let us understand how to list down all the tables in a MySQL database −

Once a database is created, we can access and use a specific database, using the following query −

Query

mysql> USE databaseName
Database changed

The ‘USE’ statement doesn’t require a semi-colon. This is similar to the ‘QUIT’ statement. Even if semi-colon is used, it does no harm. We can create and use a database of our own, but before that, MySQL administrator’s permission is required.

The MySQL administrator can execute a command as shown below to provide permissions −

mysql> GRANT ALL ON tableName.* TO ‘your_mysql_name’@’your_client_host’;

Here, ‘your_mysql_name’ refers to the MySQL user name which is assigned to the user.

The ‘your_client_host’ refers to the host from which the user connected to the server.

The below query displays the tables in the database −

mysql> SHOW TABLES;

Note: If the database was newly created, it is obvious that there would be no tables in it. The above query would result in an ‘empty set’. One of the most important part is to decide the structure of the database, the tables that would be needed, the columns in every table and the relationship between these tables.

Once we decide what our database needs to contain, a proper name for it, and tables have been created with proper column names and row values, we can discuss what kind of manipulations can be performed with this database.

Updated on: 09-Mar-2021

496 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements