MySQL常用查询Databases和Tables
发布时间:2025-11-03 21:07:16 作者:玩站小弟
我要评论
分享一下工作中常见的mysql脚本,此次分享的内容如下:Databasestables一、Databases and schemas列出了 MySQL 实例上的用户数据库(模式):复制select s
。
分享一下工作中常见的用查mysql脚本,此次分享的用查内容如下:
Databasestables
一、Databases and 用查schemas
列出了 MySQL 实例上的用户数据库(模式):
复制select schema_name as database_namefrom information_schema.schematawhere schema_name not in(mysql,information_schema,
performance_schema,sys)
order by schema_name1.2.3.4.5.说明:database_name - 数据库(模式)名称。
二、用查Tables
1. 列出 MySQL 数据库中的用查表下面的查询列出了当前或提供的数据库中的表。站群服务器要列出所有用户数据库中的用查表
(1) 当前数据库
复制select table_schema as database_name,
table_namefrom information_schema.tableswhere table_type = BASE TABLE and table_schema = database()
order by database_name, table_name;1.2.3.4.5.6.说明:
table_schema - 数据库(模式)名称table_name - 表名(2) 指定数据库
复制select table_schema as database_name,
table_namefrom information_schema.tableswhere table_type = BASE TABLE and table_schema = database_name -- enter your database name hereorder by database_name, table_name;1.2.3.4.5.6.说明:
table_schema - 数据库(模式)名称table_name - 表名2. 列出 MySQL 中所有数据库的表下面的查询列出了所有用户数据库中的所有表:
复制select table_schema as database_name,
table_namefrom information_schema.tableswhere table_type = BASE TABLE and table_schema not in (information_schema,mysql,
performance_schema,sys)
order by database_name, table_name;1.2.3.4.5.6.7.说明:
table_schema - 数据库(模式)名称table_name - 表名
,
table_namefrom information_schema.tables tabwhere engine = MyISAM and table_type = BASE TABLE and table_schema not in (information_schema, sys,
performance_schema,mysql)
-- and table_schema = your database nameorder by table_schema,
table_name;1.2.3.4.5.6.7.8.9.10.说明:
database_name - 数据库(模式)名称table_name - 表名
,
table_namefrom information_schema.tables tabwhere engine = InnoDB and table_type = BASE TABLE and table_schema not in (information_schema, sys,
performance_schema,mysql)
-- and table_schema = your database nameorder by table_schema,
table_name;1.2.3.4.5.6.7.8.9.10.说明:
database_name - 数据库(模式)名称table_name - 表名5. 识别 MySQL 数据库中的表存储引擎(模式) 复制select table_schema as database_name,
table_name,
enginefrom information_schema.tableswhere table_type = BASE TABLE and table_schema not in (information_schema,mysql,
performance_schema,sys)
-- and table_schema = your database nameorder by table_schema,
table_name;1.2.3.4.5.6.7.8.9.10.说明:
(1)table_schema - 数据库(模式)名称
(2)table_name - 表名
(3)engine- 表存储引擎。可能的用查值:
CSVInnoDB记忆MyISAM档案黑洞MRG_MyISAM联合的6. 在 MySQL 数据库中查找最近创建的WordPress模板表 复制select table_schema as database_name,
table_name,
create_timefrom information_schema.tableswhere create_time > adddate(current_date,INTERVAL -60 DAY)
and table_schema not in(information_schema, mysql,
performance_schema,sys)
and table_type =BASE TABLE -- and table_schema = your database nameorder by create_time desc,
table_schema;1.2.3.4.5.6.7.8.9.10.11.MySQL 数据库中最近 60 天内创建的所有表,按表的创建日期(降序)和数据库名称排序
说明:
database_name - 表所有者,模式名称table_name - 表名create_time - 表的用查创建日期7. 在 MySQL 数据库中查找最近修改的表 复制select table_schema as database_name,
table_name,
update_timefrom information_schema.tables tabwhere update_time > (current_timestamp() - interval 30 day)
and table_type = BASE TABLE and table_schema not in (information_schema, sys,
performance_schema,mysql)
-- and table_schema = your database nameorder by update_time desc;1.2.3.4.5.6.7.8.9.10.所有数据库(模式)中最近 30 天内最后修改的所有表,按更新时间降序排列
说明:
database_name - 数据库(模式)名称table_name - 表名update_time - 表的用查最后更新时间(UPDATE、INSERT 或 DELETE 操作或 MVCC 的用查 COMMIT)源码库相关文章
电脑赛博朋克素材教程(探索赛博朋克风格的电脑设计与创作技巧)
摘要:赛博朋克是一种充满未来主义和科技感的艺术风格,它通常以电脑为媒介,通过使用各种数字化工具和素材来表达一种高科技、高度网络化的未来世界。本文将带领读者进入电脑赛博朋克的世界,探索其中...2025-11-03
为了应对众多业务部门千变万化的数据需求和高时效性的要求,阿里巴巴首次提出了数据中台的概念,经过众多项目的实践已经沉淀出了标准化的流程和方法论。如何构建一个数据中台?一个好的数据中台需要具备哪些功能?原2025-11-03
以下是我收集的一些宝藏网站,现在分享给你们~喜欢的话可以点个赞哦!1.烧屏网:显示器diy爱好者的论坛,可以在线屏幕检测,非常方便的检查屏幕是否有缺陷、质量和水平。2.装备前线:一个为发烧友服务的极客2025-11-03
在很多城市都是有许多的大型商场,商场内各个分区也是琳琅满目,小的商场两三层,大的商场则可能会有五六层,这使得很多想买特定商品的顾客无法精准知道自己需要的在哪里,即使是百度地图等大型导航软件也不能很好的2025-11-03用U盘快速装机,轻松解决电脑重装问题(U盘快速装机教程,操作简单高效,让电脑恢复如新)
摘要:随着电脑使用时间的增长,系统逐渐变得缓慢,运行不稳定,甚至出现崩溃的情况。此时,我们通常会选择重装系统来解决这些问题。然而,传统的光盘安装方式耗时长且麻烦,而使用U盘进行快速装机则...2025-11-03
年中的时候作为评委参加了公司设计通道晋升评审,完整的听了10位同学的工作汇报和个人总结,果然不出所料,每个同学汇报里都或多或少涉及到“设计规范”或“组件库”的这么一个模块。本想着平静的听完打个酱油就完2025-11-03

最新评论