欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

mysql中如何查詢數(shù)據(jù)庫(kù)中的表名

 更新時(shí)間:2022年12月21日 10:05:38   作者:Olivia_Vang  
這篇文章主要介紹了mysql中如何查詢數(shù)據(jù)庫(kù)中的表名問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

查詢數(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)文章

最新評(píng)論