Home  >  Article  >  Database  >  How can I use the IN operator to check a list of MySQL tables in a different database than the one we are currently using and the table types in the result set?

How can I use the IN operator to check a list of MySQL tables in a different database than the one we are currently using and the table types in the result set?

王林
王林forward
2023-08-31 17:53:02780browse

如何使用 IN 运算符检查与我们当前使用的数据库不同的数据库中的 MySQL 表列表以及结果集中的表类型?

This can be done using the SHOW FULL TABLES statement. Its syntax is as follows -

Syntax

SHOW FULL TABLES IN db_name

Here, db_name is the name of the database where we want to view the list of tables.

Example

We are currently using a database named 'query', the following MySQL query will display the list of tables we get from the database named mysql along with the table type.

mysql> SHOW FULL TABLES IN mysql;
+---------------------------+------------+
| Tables_in_mysql           | Table_type |
+---------------------------+------------+
| arena                     | BASE TABLE |
| arena1                    | BASE TABLE |
| columns_priv              | BASE TABLE |
| dates                     | VIEW       |
| dates1                    | VIEW       |
| db                        | BASE TABLE |
| digits                    | VIEW       |
| engine_cost               | BASE TABLE |
| event                     | BASE TABLE |
| func                      | BASE TABLE |
| general_log               | BASE TABLE |
| gtid_executed             | BASE TABLE |
| help_category             | BASE TABLE |
| help_keyword              | BASE TABLE |
| help_relation             | BASE TABLE |
| help_topic                | BASE TABLE |
| innodb_index_stats        | BASE TABLE |
| innodb_table_stats        | BASE TABLE |
| ndb_binlog_index          | BASE TABLE |
| numbers                   | VIEW       |
| plugin                    | BASE TABLE |
| proc                      | BASE TABLE |
| procs_priv                | BASE TABLE |
| proxies_priv              | BASE TABLE |
| server_cost               | BASE TABLE |
| servers                   | BASE TABLE |
| slave_master_info         | BASE TABLE |
| slave_relay_log_info      | BASE TABLE |
| slave_worker_info         | BASE TABLE |
| slow_log                  | BASE TABLE |
| tables_priv               | BASE TABLE |
| test_date                 | BASE TABLE |
| time_zone                 | BASE TABLE |
| time_zone_leap_second     | BASE TABLE |
| time_zone_name            | BASE TABLE |
| time_zone_transition      | BASE TABLE |
| time_zone_transition_type | BASE TABLE |
| user                      | BASE TABLE |
+---------------------------+------------+
38 rows in set (0.01 sec)

The above is the detailed content of How can I use the IN operator to check a list of MySQL tables in a different database than the one we are currently using and the table types in the result set?. 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