Home > Database > Mysql Tutorial > body text

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

PHPz
Release: 2023-09-06 23:33:02
forward
1359 people have browsed it

我们如何从 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]
Copy after login

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             |
+---------------------+
Copy after login

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 |
+---------------------+
Copy after login

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!

source:tutorialspoint.com
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!