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