MySQL的SYS视图
MySQL8.0的发展越来越趋同与Oracle,为了更好的监控MySQL的一些相关指标,出现了SYS视图,用于监控。
1.MySQL版本
(root@localhost) [sys]> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.11 |
+-----------+
1 row in set (0.01 sec)
2.数据准备
(root@localhost) [ztest]> show create table zstudent;
| Table | Create Table
+------------------------------------+
| zstudent | CREATE TABLE `zstudent` (
`stu_id` int(11) NOT NULL AUTO_INCREMENT,
`stu_name` varchar(20) DEFAULT NULL,
`sex` char(1) DEFAULT NULL,
PRIMARY KEY (`stu_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 |
+-------------------------------------+
1 row in set (0.00 sec)
创建索引:
(root@localhost) [ztest]> create index idx_stu_name on zstudent (stu_name);
(root@localhost) [ztest]> create unique index idx_stu_name2 on zstudent (stu_name);
sys包含了很多总结performance Schema表的视图,这些视图成对出现,并且有些以x$前缀出现。查看并使用sys的方式:
查看performance Schema表的视图
(root@localhost) [sys]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| ztest |
+--------------------+
5 rows in set (0.01 sec)
(root@localhost) [sys]> use sys
Database changed
(root@localhost) [sys]> show tables;
+---------------------------------------