Home > Database > Mysql Tutorial > How to view all tables in the database in mysql

How to view all tables in the database in mysql

下次还敢
Release: 2024-05-01 20:45:43
Original
813 people have browsed it

To view all tables in a MySQL database, you can use the SHOW TABLES; command, which will display a list of all tables, including table name, type, and number of rows (if INFORMATION_SCHEMA is enabled).

How to view all tables in the database in mysql

How to view all tables in the database in MySQL

To view all tables in the MySQL database, you can use Following command:

<code>SHOW TABLES;</code>
Copy after login

After executing this command in the command line, it will display the list of all tables in that database.

Detailed explanation:

  • SHOW TABLES command is a MySQL built-in command used to display all tables in the current database.
  • This command applies to all MySQL versions.
  • It does not take any parameters.
  • It will return a result set with the following information:

    • Table name
    • Table type (e.g. InnoDB, MyISAM)
    • Number of table rows (if INFORMATION_SCHEMA is enabled)
  • The result set is sorted by table name.

Example:

Suppose you have a database named my_database which contains two tables table1 and table2. To view these tables, you can run the following command:

<code>SHOW TABLES FROM my_database;</code>
Copy after login

This will produce the following output:

<code>+----------------------+
| Tables_in_my_database |
+----------------------+
| table1                |
| table2                |
+----------------------+</code>
Copy after login

This output shows that there are table1## in database my_database # and table2 are two tables.

The above is the detailed content of How to view all tables in the database in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template