Mysql-元数据操作

时间:2019-01-16
本文章向大家介绍Mysql-元数据操作,主要包括Mysql-元数据操作使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

记录几个MySql元数据操作的语句,以备后用

安装好mysql之后在实例下默认会有:mysql information_schema performation_schema

  • mysql 配置信息 用户信息 慢日志 server信息
  • information_schema 记录全局 database、table、column 、视图、触发器、事物元数据相关信息
  • performation_schema

操作元数据

# 查看全局 schema
select * from information_schema.SCHEMATA;

# 查看具体 schema 
select * from information_schema.SCHEMATA t where t.`SCHEMA_NAME` = 'risk_management'

# 查看全局 视图
select * from information_schema.VIEWS;

#查看具体某个schema下views
select * from information_schema.VIEWS t where t.`TABLE_SCHEMA` = 'account'

# 查看当前实例全局 table
select * from  information_schema.TABLES;

# 查看具体 table_schema 表信息 行数,数据大小,索引大小,自增最大值,表常见时间
select * from information_schema.TABLES t where t.`TABLE_SCHEMA` = 'risk_management'  and  t.`TABLE_NAME` = 'gps_info';

# 查看 database 下 table 中列名,列备注,列类型,是否为空,编码类型,是否主键,等信息
select * from `information_schema`.`COLUMNS` t where t.`TABLE_SCHEMA`='risk_management' and t.`TABLE_NAME` = 'gps_info';