We need to use ‘mysqlshow’ client program along with the name of the database to get the list of tables in a particular database. Its syntax would be as follows −
Mysqlshow – u root db_name [pat_matching]
Here db_name would be the name of the database from which we want to get the name of tables.
Pat_matching is optional. It is used to get the list of the tables of some specific pattern. If we will not provide any pattern then it will show all the tables stored in that database.
Example
The following command will get all the tables of 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, suppose if we want to get the tables that are having ‘student’ in its name then following query with pattern matching can be used −
C:\mysql\bin>mysqlshow -u root query %student% Database: query Wildcard: %student% +---------------------+ | Tables | +---------------------+ | student | | student_detail | | student_info | | student_marks | | view_student_detail | +---------------------+