mysql中如何查询数据库中的表名
作者:Olivia_Vang 时间:2024-01-20 03:07:32
查询数据库中的表名
查询一个数据库中含有某关键词的表名
搜索一个数据库中包含一些关键字,词的表。
SELECT
TABLE_NAME
FROM
information_schema. TABLES
WHERE
table_schema = '数据库名'
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)
查询数据库中所有的表
show tables;
-- use 数据库名
USE sakila;
SHOW TABLES;
同上面,where条件只查数据库名。还可以同时搜索多个数据库中的表。
SELECT
TABLE_NAME
FROM
information_schema. TABLES
WHERE
table_schema = '数据库名';
例:
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)
来源:https://blog.csdn.net/Olivia_Vang/article/details/103172800
标签:mysql,查询,数据库,表名
0
投稿
猜你喜欢
python字典的元素访问实例详解
2023-06-10 10:54:11
利用Python实现普通视频变成动漫视频
2023-02-05 05:13:59
对Python3+gdal 读取tiff格式数据的实例讲解
2023-03-10 10:21:53
IOS中safari下的select下拉菜单文字过长不换行的解决方法
2024-04-25 13:07:58
oracle 分页 很棒的sql语句
2009-07-02 11:44:00
python开发入门——set的使用
2023-09-21 09:39:56
python开发简单的命令行工具简介
2021-01-06 14:39:20
python使用xlrd模块读写Excel文件的方法
2022-02-14 16:54:55
python判断一个对象是否可迭代的例子
2021-01-04 18:19:23
python实现爬取百度图片的方法示例
2021-11-22 00:46:04
浅谈python中的数字类型与处理工具
2022-02-09 01:07:30
Python设计模式中的结构型适配器模式
2023-07-19 11:59:54
Python ini配置文件示例详解
2023-08-24 09:07:36
浅析MySQL数据库授权原则
2009-12-15 09:21:00
Python web框架(django,flask)实现mysql数据库读写分离的示例
2024-01-14 15:46:36
解决Python报错:SyntaxError: invalid character ‘,‘ (U+FF0C)
2023-01-24 06:12:57
Highcharts+NodeJS搭建数据可视化平台示例
2024-05-02 17:38:38
Python实现大数据收集至excel的思路详解
2022-02-03 10:25:25
CentOS7离线安装MySQL的教程详解
2024-01-20 13:07:33
Python中tkinter无法同时显示多个image的解决方法及pack与place解析
2021-05-10 10:23:47