mysql中如何查詢數(shù)據(jù)庫中的表名
查詢數(shù)據(jù)庫中的表名
查詢一個數(shù)據(jù)庫中含有某關(guān)鍵詞的表名
搜索一個數(shù)據(jù)庫中包含一些關(guān)鍵字,詞的表。
SELECT? ? ? TABLE_NAME? FROM ? ? information_schema. TABLES WHERE ? ? table_schema = '數(shù)據(jù)庫名' ? ? AND TABLE_NAME LIKE '%name%';
例:
mysql> select table_name from information_schema.tables? ? ? -> where table_schema = 'sakila' ? ? -> and table_name like "%film%"; +----------------------------+ | TABLE_NAME ? ? ? ? ? ? ? ? | +----------------------------+ | film ? ? ? ? ? ? ? ? ? ? ? | | film_actor ? ? ? ? ? ? ? ? | | film_category ? ? ? ? ? ? ?| | film_list ? ? ? ? ? ? ? ? ?| | film_text ? ? ? ? ? ? ? ? ?| | nicer_but_slower_film_list | | sales_by_film_category ? ? | +----------------------------+ 7 rows in set (0.00 sec)
查詢數(shù)據(jù)庫中所有的表
show tables; -- use 數(shù)據(jù)庫名 USE sakila; SHOW TABLES;
同上面,where條件只查數(shù)據(jù)庫名。還可以同時搜索多個數(shù)據(jù)庫中的表。
SELECT? ? ? TABLE_NAME? FROM ? ? information_schema. TABLES WHERE ? ? table_schema = '數(shù)據(jù)庫名';
例:
mysql> select table_name from information_schema.tables where table_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 ? ? ? ? ? ? ? ? ? ? ?| +----------------------------+ 23 rows in set (0.00 sec) ? mysql> select table_name from information_schema.tables where table_schema = 'sakila' or table_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 ? ? ? ? ? ? ? ? | +----------------------------+ 25 rows in set (0.01 sec)
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
MySql報錯Table mysql.plugin doesn’t exist的解決方法
一般產(chǎn)生原因是手工更改my.ini的數(shù)據(jù)庫文件存放地址導(dǎo)致的,大家可以參考下下面的方法2013-02-02MySQL中的 inner join 和 left join的區(qū)別解析
這篇文章主要介紹了MySQL中的 inner join 和 left join的區(qū)別解析,本文通過場景描述給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-05-05VS2022連接數(shù)據(jù)庫MySQL并進行基本的表的操作指南
鑒于MySQL數(shù)據(jù)庫的流行與強大,決定多學(xué)習(xí)使用,下面這篇文章主要給大家介紹了關(guān)于VS2022連接數(shù)據(jù)庫MySQL并進行基本的表的操作指南,文中通過圖文介紹的非常詳細,需要的朋友可以參考下2023-05-059種 MySQL數(shù)據(jù)庫優(yōu)化的技巧
這篇文章小編主要給大家介紹的是 MySQL數(shù)據(jù)庫優(yōu)化的正確姿勢,九種方法呢?。。⌒枰男』锇橼s快收藏起來吧2021-09-09Mysql存儲過程循環(huán)內(nèi)嵌套使用游標示例代碼
本節(jié)主要介紹了Mysql存儲過程循環(huán)內(nèi)如何嵌套使用游標,詳細實現(xiàn)如下,需要的朋友不要錯過2014-08-08mybatis+mysql 使用存儲過程生成流水號的實現(xiàn)代碼
這篇文章主要介紹了mybatis+mysql 使用存儲過程生成流水號的實現(xiàn)代碼,需要的朋友可以參考下2018-01-01MySQL中導(dǎo)出用戶權(quán)限設(shè)置的腳本分享
這篇文章主要介紹了MySQL中導(dǎo)出用戶權(quán)限設(shè)置的腳本分享,本文通過導(dǎo)出mysql.user表中數(shù)據(jù)實現(xiàn)導(dǎo)出權(quán)限設(shè)置,需要的朋友可以參考下2014-10-10