爵士。这是我的代码
@echo off
SET path=C:\Users\neca\Desktop cd C:\wamp\bin\mysql\mysql5.5.24\bin
FOR /F "tokens=*" %%D IN ('mysql -uroot -e "SHOW TABLES from sample"') do echo %%D
pause
但是在我的数据库中我只有2个表(样本和测试)。为什么这样呢? 此代码的输出是
Tables_in_sample
sample
test
其中Tables_in_sample是我没有制作的表。
答案 0 :(得分:3)
Tables_in_sample
只是mysql客户端的标题
mysql> show tables from mysql;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
28 rows in set (0.00 sec)
mysql>
请参阅输出标题为Tables_in_mysql
只需使用-ANe
而非-e
@echo off
SET path=C:\Users\neca\Desktop cd C:\wamp\bin\mysql\mysql5.5.24\bin
FOR /F "tokens=*" %%D IN ('mysql -uroot -ANe "SHOW TABLES from sample"') do echo %%D
pause
答案 1 :(得分:0)
@echo off SET path = C:\ Users \ neca \ Desktop cd C:\ wamp \ bin \ mysql \ mysql5.5.24 \ bin
FOR / F"令牌= *" %% D IN(' mysql -uroot -N -B -e"示例"'中的SHOW TABLES)回显%% D