mysql中如何查詢數(shù)據(jù)庫中的表名
查詢數(shù)據(jù)庫中的表名
查詢一個(gè)數(shù)據(jù)庫中含有某關(guān)鍵詞的表名
搜索一個(gè)數(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í)搜索多個(gè)數(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é)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Windows下修改mysql的data文件夾存放位置的方法
這篇文章主要介紹了在Windows下修改mysql的data文件夾存放位置的方法,需要的朋友可以參考下2014-03-03
mysql查詢昨天 一周前 一月前 一年前的數(shù)據(jù)
這篇文章主要介紹了mysql查詢昨天 一周前 一月前 一年前的數(shù)據(jù)的方法,需要的朋友可以參考下2014-05-05
mysql分頁時(shí)offset過大的Sql優(yōu)化經(jīng)驗(yàn)分享
mysql分頁是我們在開發(fā)經(jīng)常遇到的一個(gè)功能,最近在實(shí)現(xiàn)該功能的時(shí)候遇到一個(gè)問題,所以這篇文章主要給大家介紹了關(guān)于mysql分頁時(shí)offset過大的Sql優(yōu)化經(jīng)驗(yàn),文中介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編來一起看看吧。2017-08-08
my.cnf參數(shù)配置實(shí)現(xiàn)InnoDB引擎性能優(yōu)化
目前來說:InnoDB是為Mysql處理巨大數(shù)據(jù)量時(shí)的最大性能設(shè)計(jì)。它的CPU效率可能是任何其它基于磁盤的關(guān)系數(shù)據(jù)庫引擎所不能匹敵的。在數(shù)據(jù)量大的網(wǎng)站或是應(yīng)用中Innodb是倍受青睞的。另一方面,在數(shù)據(jù)庫的復(fù)制操作中Innodb也是能保證master和slave數(shù)據(jù)一致有一定的作用。2017-05-05
MySQL中字段的實(shí)際長度的實(shí)現(xiàn)示例代碼
MySQL字段的存儲長度不僅取決于數(shù)據(jù)類型,還受字符編碼和存儲內(nèi)容的影響,CHAR和VARCHAR字段可以使用LENGTH()和CHAR_LENGTH()函數(shù)獲取長度信息,下面就來具體介紹一下2024-09-09
Mysql按條件計(jì)數(shù)多種實(shí)現(xiàn)方法詳解
這篇文章主要介紹了Mysql按條件計(jì)數(shù)多種實(shí)現(xiàn)方法詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07

