MySQL关于查找模式对象的语句

在日常工作中,搜索特定的数据库对象,是最常见的一个工作,下面分享几个关于mysql模式查找的语句。

成都创新互联公司成都网站建设按需定制制作,是成都网站推广公司,为iso认证提供网站建设服务,有成熟的网站定制合作流程,提供网站定制设计服务:原型图制作、网站创意设计、前端HTML5制作、后台程序开发等。成都网站营销推广热线:028-86922220

1. 在 MySQL 数据库中查找名称中包含数字的表

select table_schema as database_name,
table_name
from information_schema.tables
where table_type = 'BASE TABLE'
and table_name rlike ('[0-9]')
order by table_schema,
table_name;

说明:

  • database_name - 找到表的数据库(模式)的名称
  • table_name - 找到的表的名称

2. 在 MySQL 数据库中查找关于特定列名的表

select tab.table_schema as database_name,
tab.table_name
from information_schema.tables as tab
inner join information_schema.columns as col
on col.table_schema = tab.table_schema
and col.table_name = tab.table_name
where tab.table_type = 'BASE TABLE'
and column_name = 'idcity'
order by tab.table_schema,
tab.table_name;

说明:

  • database_name - 找到表的数据库(模式)的名称
  • table_name - 找到的表的名称

3. 在 MySQL 数据库中查找没有特定名称的列的表

select tab.table_schema as database_name,
tab.table_name
from information_schema.tables tab
left join information_schema.columns col
on tab.table_schema = col.table_schema
and tab.table_name = col.table_name
and col.column_name = 'id' -- put column name here
where tab.table_schema not in ('information_schema', 'mysql',
'performance_schema', 'sys')
and tab.table_type = 'BASE TABLE'
and col.column_name is null
order by tab.table_schema,
tab.table_name;

说明:

  • database_name - 找到的表的数据库(模式)名称
  • table_name - 找到的表的名称​

当前名称:MySQL关于查找模式对象的语句
转载注明:http://www.hantingmc.com/qtweb/news17/18617.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联