随笔分类 -  MYSQL学习

摘要:根据加锁的范围,MySQL 中的锁可分为三类: 全局锁 表级锁 行锁 MySQL 全局锁会关闭所有打开的表,并使用全局读锁锁定所有表。其命令为: FLUSH TABLES WITH READ LOCK; 解锁: UNLOCK TABLES; 老规矩:准备数据 drop table if exists 阅读全文
posted @ 2020-07-29 17:40 |那小子 阅读(263) 评论(0) 推荐(0)
摘要:数据准备: drop table if exists t1; /* 如果表t1存在则删除表t1 */ CREATE TABLE `t1` ( `id` int(11) NOT NULL AUTO_INCREMENT, `a` int(11) DEFAULT NULL, `b` int(11) NOT 阅读全文
posted @ 2020-07-27 18:20 |那小子 阅读(418) 评论(0) 推荐(0)
摘要:数据前提:导入sql,执行一下数据表 CREATE TABLE `t1` ( /* 创建表t1 */ `id` int(11) NOT NULL auto_increment, `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL, `create_t 阅读全文
posted @ 2020-07-27 14:31 |那小子 阅读(228) 评论(0) 推荐(0)
摘要:前提:数据准备 drop table if exists t1; /* 如果表t1存在则删除表t1 */ CREATE TABLE `t1` ( /* 创建表t1 */ `id` int(11) NOT NULL AUTO_INCREMENT, `a` int(20) DEFAULT NULL, ` 阅读全文
posted @ 2020-07-24 16:27 |那小子 阅读(1345) 评论(0) 推荐(0)
摘要:前提:数据准备 drop table if exists t1; /* 如果表t1存在则删除表t1 */ CREATE TABLE `t1` ( /* 创建表t1 */ `id` int(11) NOT NULL AUTO_INCREMENT, `a` varchar(20) DEFAULT NUL 阅读全文
posted @ 2020-07-23 18:27 |那小子 阅读(1122) 评论(0) 推荐(0)
摘要:有时需要确定 SQL 到底慢在哪个环节,此时 explain 可能不好确定。在 MySQL 数据库中,通过 profile,能够更清楚地了解 SQL 执行过程的资源使用情况,能让我们知道到底慢在哪个环节 下面我们来讲一下如何使用 profile 分析慢查询,大致步骤是:确定这个 MySQL 版本是否 阅读全文
posted @ 2020-07-23 16:20 |那小子 阅读(184) 评论(0) 推荐(0)
摘要:1.查看是否开启慢查询日志show variables like "%slow_query_log%"; 2.查看慢查询阈值 show global variables like "long_query_time"; set global long_query_time = 1; 3.确定慢查询日志 阅读全文
posted @ 2020-07-23 16:10 |那小子 阅读(229) 评论(0) 推荐(0)