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中對(duì)表連接查詢的簡(jiǎn)單優(yōu)化教程
這篇文章主要介紹了MySQL中對(duì)表連接查詢的簡(jiǎn)單優(yōu)化教程,表連接查詢是MySQL最常用到的基本操作之一,因而其的優(yōu)化也非常值得注意,需要的朋友可以參考下2015-12-12
Windows下修改mysql的data文件夾存放位置的方法
這篇文章主要介紹了在Windows下修改mysql的data文件夾存放位置的方法,需要的朋友可以參考下2014-03-03
mysql查詢昨天 一周前 一月前 一年前的數(shù)據(jù)
這篇文章主要介紹了mysql查詢昨天 一周前 一月前 一年前的數(shù)據(jù)的方法,需要的朋友可以參考下2014-05-05
mysql分頁(yè)時(shí)offset過(guò)大的Sql優(yōu)化經(jīng)驗(yàn)分享
mysql分頁(yè)是我們?cè)陂_發(fā)經(jīng)常遇到的一個(gè)功能,最近在實(shí)現(xiàn)該功能的時(shí)候遇到一個(gè)問(wèn)題,所以這篇文章主要給大家介紹了關(guān)于mysql分頁(yè)時(shí)offset過(guò)大的Sql優(yōu)化經(jīng)驗(yàn),文中介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編來(lái)一起看看吧。2017-08-08
my.cnf參數(shù)配置實(shí)現(xiàn)InnoDB引擎性能優(yōu)化
目前來(lái)說(shuō):InnoDB是為Mysql處理巨大數(shù)據(jù)量時(shí)的最大性能設(shè)計(jì)。它的CPU效率可能是任何其它基于磁盤的關(guān)系數(shù)據(jù)庫(kù)引擎所不能匹敵的。在數(shù)據(jù)量大的網(wǎng)站或是應(yīng)用中Innodb是倍受青睞的。另一方面,在數(shù)據(jù)庫(kù)的復(fù)制操作中Innodb也是能保證master和slave數(shù)據(jù)一致有一定的作用。2017-05-05
MySQL中字段的實(shí)際長(zhǎng)度的實(shí)現(xiàn)示例代碼
MySQL字段的存儲(chǔ)長(zhǎng)度不僅取決于數(shù)據(jù)類型,還受字符編碼和存儲(chǔ)內(nèi)容的影響,CHAR和VARCHAR字段可以使用LENGTH()和CHAR_LENGTH()函數(shù)獲取長(zhǎng)度信息,下面就來(lái)具體介紹一下2024-09-09
MySQL存儲(chǔ)過(guò)程的傳參和流程控制示例講解
這篇文章主要介紹了MySQL存儲(chǔ)過(guò)程的傳參和流程控制示例講解,?repeat和Loop區(qū)別是repeat有自己退出循環(huán)的語(yǔ)句until,Loop使用的是if判斷語(yǔ)句,本文結(jié)合示例代碼詳細(xì)講解,需要的朋友可以參考下2023-02-02
Mysql按條件計(jì)數(shù)多種實(shí)現(xiàn)方法詳解
這篇文章主要介紹了Mysql按條件計(jì)數(shù)多種實(shí)現(xiàn)方法詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07

