MySQL Tutorial

MySQL Tutorial MySQL Features MySQL Database Introduction MySQL Environmental Setup MySQL Data Types MySQL variable MySQL Advance table Query MySQL database queries MySQL Entity-Relationship Model MySQL Table Query MySQL Operators MySQL logical conditions MySQL Queries MySQL Clauses Clustered vs Non-Clustered Index MySQL Full text index MySQL Descending Index MySQL Invisible Index MySQL Composite Index MySQL Prefix index MySQL Index MySQL Create index MySQL Drop Index MySQL Show index MySQL Unique index MySQL Table MySQL Variable MySQL View MySQL Constraints MySQL Command Line Client Basic Queries MySQL Stored Procedure MySQL IF Statement MySQL Subquery MySQL Triggers

MySQL Join

MySQL Join MySQL CROSS JOIN MySQL DELETE JOIN MySQL EQUI JOIN MySQL INNER JOIN MySQL Union MySQL NATURAL JOIN MySQL RIGHT JOIN MySQL SELF JOIN MySQL UPDATE JOIN

MySQL Function

MySQL Function MySQL AVG() Function MySQL SUM() Function MySQL String() Function MySQL Advance() Function MySQL Aggregate() Function MySQL COALESCE() Function MySQL Control Flow Function MySQL COUNT() Function MySQL Date And Time Function MySQL GREATEST() Function MySQL ISNULL() Function MySQL LEAST() Function MySQL Math() Function MySQL MAX() Function MySQL MIN() Function MySQL find_in_set() function MySQL ASIN() Function MySQL CEIL() function MySQL CEILING() function MySQL TAN() Function MySQL Truncate() Function MySQL FLOOR() function MySQL LN() function MySQL LOG2() function MySQL LOG10() function MySQL MOD() function MySQL PI() function MySQL POW() function MySQL RADIANS() function MySQL RAND() function MySQL ROUND() function MySQL Character Length Function MySQL Current Date Function MySQL Date Add Function MySQL Date Format Function MySQL Datediff Function MySQL Day Function MySQL Elt Function MySQL Export Set Function MySQL Field Function MySQL Format Function MySQL From Base64 Function MySQL Hex Function MySQL Insert Function MySQL Instr Function MySQL Length Function MySQL CONCAT() function MySQL FIND_IN_SET() function MySQL LIKE() function MySQL LOAD_FILE() function MySQL LOCATE() function MySQL LOG() function MySQL MONTHNAME() function MySQL NOW() function MySQL PERIOD_ADD() function MySQL PERIOD_DIFF() function MySQL POWER() function MySQL QUARTER() function MySQL REVERSE() function MySQL RIGHT() Function MySQL RPAD() function MySQL RTRIM() function MySQL SEC_TO_TIME() function MySQL SOUNDEX() function

Questions

Which Clause is Similar to Having Clause in MySQL

Misc

MySQL Error 1046 - No Database Selected Failed to Start MySQL Service Unit MySQL Service Unit not Found Import MySQL Connector Mudule not Found Error No Module Named MySQL Joins Available in MySQL MySQL Docs MySQL Download For Windows 7 64 Bit MySQL Error Code 1064 MySQL Export MySQL History MySQL Host MySQL Import MySQL Drop All Tables MySQL Drop MySQL Error Code 1175 MySQL Events MySQL Except MYSQL Foreign Key Constraint MySQL If Exists MySQL IndexOf MySQL List All Tables json_extract in MySQL TIMESTAMPDIFF in MySQL MySQL Syntax Checker Sudo MySQL Secure Installation

MySQL List All Tables

Introduction

MySQL is one of the most well-known open-source and cost-free database management software systems (DBMS). It is famous for its quickness and for having an intuitive UI. When working as a database administrator for a large company, you often have to go through many databases and their tables. We will, therefore, discover how to list or display tables in the MySQL shell in this post.

One of the most crucial things to do as a database administrator overseeing a MySQL server is to familiarize yourself with the MYSQL environment.

It is crucial to display or list the MySQL table if your server has several databases, each with multiple tables. You may get details about user accounts and their permissions with this query.

You may list tables in a MySQL database with the MySQL SHOW table's command, which is called.

By the time this post ends, you will know:

  • The meaning of the directive
  • How to make use of it
  • Why it's beneficial initially and
  • An alternate method to the show tables command for listing the tables in a database

Prerequisites

If you wish to follow along with my examples, there are just two requirements. I first assume a basic understanding of MySQL and SQL. Furthermore, a local installation of MySQL ought to be available to you.

Since CoderPad MySQL Sandbox will be your MySQL client for this article, It's a great approach to begin writing SQL quickly and simply.

Why and how do MySQL SHOW tables work?

To list the tables in a database in MySQL, use the show tables command to specify the power that is essentially it. However, what applications does it have? After all, you may simply show the tables inside a database, usually in a tree, using a client with the MySQL GUI (graphical user interface).

First, not every MySQL interaction will allow you to use a graphical user interface. Show tables are helpful if all you have is the command line. Remember that this command is quite versatile as well. You may use WHERE and LIKE clauses to filter the result further while utilizing them.

Lastly, you may use this in scripts since it is a command. Thus, there's a chance to automate specific processes that a graphical user interface (GUI) couldn't handle.

In MySQL, how can I see tables?

CREATE TABLE students (


 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,


    name VARCHAR(250),


    email VARCHAR(100));


CREATE TABLE teachers (


    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,


    name VARCHAR(250),


    email VARCHAR(100));

In the sandbox, display tables. The following tables need to be displayed:

MySQL List All Tables
SHOW [EXTENDED] [FULL] TABLES


    [{FROM | IN} db_name]


    [LIKE 'pattern' | WHERE expr]

In a MySQL database, you take the following actions to list tables:

  • First, log in using a MySQL client, such as MySQL, To access the MySQL database server.
  • Second, use the USE command to change to a particular database.
  • Third, execute the command SHOW TABLES.

The MySQL SHOW TABLES command's syntax is demonstrated by the following:

SHOW TABLES;

You can see how to list the table in the classic model's database by looking at the following example.

  • Step 1: Establish a connection to the MySQL server:
>mysql -u root -p


Enter password: **********


Mysql>
  • Step 2: Use the classic model's database instead.
mysql> use classic models;


Database changed


mysql>
  • Step 3: Display tables from the database for traditional models:
> show tables;
MySQL List All Tables

You may see whether a table is a base table or a view using the SHOW TABLES command. You use the following version of the SHOW TABLES command to include the table type in the result.

SHOW FULL TABLES


WHERE Table_type = 'BASE TABLE';

For the sake of illustration, let's construct a view in the classic model's database called contacts that contain the first name, last name, and phone from the customer and employee tables:

CREATE VIEW contacts


AS


SELECT lastName, firstName, extension as phone


FROM employees


UNION


SELECT contact first name, contact last name, phone


FROM customers;

You now provide the command SHOW FULL TABLES:

> SHOW FULL TABLES
MySQL List All Tables

As you can see, except for the contacts table, which is a view, every table is the base table.

Displaying every table at once may not be natural for a database with many tables.

Thankfully, the SHOW TABLES command gives you the ability to filter the returned tables as follows by using the LIKE operator or an expression in the WHERE clause:

Additionally, SHOW TABLES allows a LIKE clause, which may be used to limit the results to just those tables that fit a certain pattern:

SHOW TABLES


LIKE 'a%';
MySQL List All Tables

Summary

Following this instruction, we learned to show or list tables in the MySQL database. We now know how to use pattern matching to filter the output.