- 查询数据库中的表名查询一个数据库中含有某关键词的表名
搜索一个数据库中包含一些关键字,词的表。
SELECTTABLE_NAMEFROMinformation_schema.TABLESWHEREtable_schema='数据库名'ANDTABLE_NAMELIKE'%name%';
例:
mysql>selecttable_namefrominformation_schema.tables->wheretable_schema='sakila'->andtable_namelike"%film%";+----------------------------+|TABLE_NAME|+----------------------------+|film||film_actor||film_category||film_list||film_text||nicer_but_slower_film_list||sales_by_film_category|+----------------------------+7rowsinset(0.00sec)查询数据库中所有的表
showtables;--use数据库名USEsakila;SHOWTABLES;
同上面,where条件只查数据库名。还可以同时搜索多个数据库中的表。
SELECTTABLE_NAMEFROMinformation_schema.TABLESWHEREtable_schema='数据库名';
例:
mysql>selecttable_namefrominformation_schema.tableswheretable_schema='sakila';+----------------------------+|TABLE_NAME|+----------------------------+|actor||actor_info||address||category||city||country||customer||customer_list||film||film_actor||film_category||film_list||film_text||inventory||language||nicer_but_slower_film_list||payment||rental||sales_by_film_category||sales_by_store||staff||staff_list||store|+----------------------------+23rowsinset(0.00sec)mysql>selecttable_namefrominformation_schema.tableswheretable_schema='sakila'ortable_schema='test';+----------------------------+|TABLE_NAME|+----------------------------+|actor||address||category||city||country||customer||film||film_actor||film_category||film_text||inventory||language||payment||rental||staff||store||customer_list||film_list||nicer_but_slower_film_list||staff_list||sales_by_store||sales_by_film_category||actor_info||employee||test_alter|+----------------------------+25rowsinset(0.01sec)
上一篇:MySQL查询语句执行流程是什么
下一篇:SQL如何遍历数据行
mysql 数据库









