前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MySQL中 如何查询表名中包含某字段的表

MySQL中 如何查询表名中包含某字段的表

作者头像
全栈程序员站长
发布2022-02-10 08:27:57
12.5K0
发布2022-02-10 08:27:57
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是全栈君。

查询tablename 数据库中 以”_copy” 结尾的表

代码语言:javascript
复制
select table_name from information_schema.tables where table_schema='tablename' and table_type='base table' and table_name like '%_copy';

information_schema 是MySQL系统自带的数据库,提供了对数据库元数据的访问 information_schema.tables 指数据库中的表(information_schema.columns 指列) table_schema 指数据库的名称 table_type 指是表的类型(base table 指基本表,不包含系统表) table_name 指具体的表名

查询work_ad数据库中是否存在包含”user”关键字的数据表

代码语言:javascript
复制
 select table_name from information_schema.tables where table_schema = 'work_ad' and table_type='base table' and table_name like '%user%';

如果本身是在tablename 这个库里新建的查询,可以去掉 table_schema=’tablename ‘ 这一句

代码语言:javascript
复制
select table_name from information_schema.tables where table_type=’base table’ and table_name like ‘%_copy’;

在Informix数据库中,如何查询表名中包含某字段的表

代码语言:javascript
复制
select * from systables where tabname like 'saa%'

此法只对Informix数据库有用

查询指定数据库中指定表的所有字段名column_name

代码语言:javascript
复制
select column_name from information_schema.columns where table_schema='csdb' and table_name='xxx'

 检查数据库’test’中的某一个表’d_ad’是否存在

代码语言:javascript
复制
select count(1) from information_schema.tables where table_schema = 'test' and table_name = 'd_ad';

如何查询mysql数据库中有多少张表

代码语言:javascript
复制
select count(*) TABLES, table_schema from information_schema.tables where table_schema = ‘test’ group by table_schema;

mysql中查询到包含该字段的所有表名

代码语言:javascript
复制
SELECT  TABLE_NAME FROM  information_schema.COLUMNS  WHERE  COLUMN_NAME='字段名'

如:查询包含status 字段的数据表名

代码语言:javascript
复制
select table_name from information_schema.columns where column_name='status';

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/112142.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 查询tablename 数据库中 以”_copy” 结尾的表
  • 在Informix数据库中,如何查询表名中包含某字段的表
  • 查询指定数据库中指定表的所有字段名column_name
  •  检查数据库’test’中的某一个表’d_ad’是否存在
  • 如何查询mysql数据库中有多少张表
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档