mysqlshow-urootqueryDatab"/> mysqlshow-urootqueryDatab">

Home  >  Article  >  Database  >  How can we get the list of tables in a specific database from MySQL Server command line?

How can we get the list of tables in a specific database from MySQL Server command line?

PHPz
PHPzforward
2023-09-06 23:33:021536browse

我们如何从 MySQL Server 命令行获取特定数据库中的表列表?

We need to use the "mysqlshow" client program along with the database name to get the list of tables in a specific database. Its syntax is as follows -

Mysqlshow – u root db_name [pat_matching]

Here db_name is the name of the database from which we want to get the table name.

Pat_matching is optional. It is used to get a list of tables of a specific schema. If we don't provide any schema then it will display all the tables stored in that database.

Example

The following command will get all tables database "query" -

C:\mysql\bin>mysqlshow -u root query
Database: query
+---------------------+
| Tables              |
+---------------------+
| cars                |
| cars_avgprice       |
| customers           |
| detail_bday         |
| emp                 |
| emp123              |
| emp_t               |
| examination_btech   |
| first_view          |
| info                |
| item_list           |
| item_list1          |
| new_number          |
| reservation         |
| reservations        |
| reserve             |
| student             |
| student_detail      |
| student_info        |
| student_marks       |
| tender              |
| tender1             |
| view_detail         |
| view_student_detail |
| website             |
+---------------------+

Now, assuming we want to get the tables that contain "student" in their name, we can use The following query with pattern matching -

C:\mysql\bin>mysqlshow -u root query %student%
Database: query Wildcard: %student%
+---------------------+
| Tables              |
+---------------------+
| student             |
| student_detail      |
| student_info        |
| student_marks       |
| view_student_detail |
+---------------------+

The above is the detailed content of How can we get the list of tables in a specific database from MySQL Server command line?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete