MySQL中 如何查询表名中包含某字段的表 ,查询MySql数据库架构信息:数据库,表,表字段...

--查询tablename 数据库中 以"_copy" 结尾的表
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 指具体的表名

--如果本身是在tablename 这个库里新建的查询,可以去掉 table_schema='tablename ' 这一句
select table_name from information_schema.tables where table_type='base table' and table_name like '%_copy';

--在Informix数据库中,如何查询表名中包含某字段的表
select * from systables where tabname like 'saa%'
--此法只对Informix数据库有用 

--查询指定数据库中指定表的所有字段名column_name
select column_name from information_schema.columns where table_schema='csdb' and table_name='xxx' 
SELECT * FROM information_schema.columns WHERE column_name='brand_id';

 --检查数据库'test'中的某一个表'd_ad'是否存在
select count(1) from information_schema.tables where table_schema = 'test' and table_name = 'd_ad'; 

--如何查询mysql数据库中有多少张表
select count(*) TABLES, table_schema from information_schema.tables where table_schema = 'test' group by table_schema;

 

 

-- 查询MySql数据库架构信息:数据库,表,表字段
/*1.查询所有数据库*/
show databases; 

/*2.查询所有数据表*/
select * from information_schema.tables where table_schema='world'

/*3.查询指定表的所有字段*/
select * from information_schema.columns 
where table_schema='world'
and table_name='city' 

 

源文:https://www.cnblogs.com/acm-bingzi/p/mysql-information-schema.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值