<!DOCTYPE html><html><head>
<base href="https://time.geekbang.org/column/article/69862"><meta charset="utf-8"><meta name="keywords" content="06 | 全局锁和表锁 :给表加个字段怎么有这么多阻碍?" id="metakeywords"><meta name="description" content="今天,我跟你介绍了MySQL的全局锁和表级锁。" id="metadesc"><link rel="apple-touch-icon" sizes="180x180" href="//static001.geekbang.org/static/time/icon/apple-touch-icon.jpg"><link rel="icon" type="image/png" sizes="32x32" data-savepage-href="//static001.geekbang.org/static/time/icon/favicon-32x32.jpg" href="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABkAAD/4QMsaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjYtYzE0MCA3OS4xNjA0NTEsIDIwMTcvMDUvMDYtMDE6MDg6MjEgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDQyAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpCMDg3N0FGOEFEMzkxMUU5OTQwO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odSrk1ktz2d11wl31JkAns+FmvFneIqdkpTTdFKNJIJCqOQpKl40OjBge1WI8b1H2nztj3ZjBt77m4LJrZJlb94RId2yeH5iuYw0iDeFcRyuBuRkIdN+meo+Te7UcetfajppWSa6vpKhfQK2K4zGos1iQ0iuyPOrxRXHrsWax+bJTFWpKG25DT6VfK+9Eb6dX7NYZ2ZnUeP4/iUTXGOzP/AFRAQI7gL+k1zJ/isCxMwQmgDB67naMBA/qRm/UXXxyfJ83nS0ym2Qel5GBaa0Zv3gs4dGe4MyIZACWZGjI2Rxzt4yvjzp6u0FpfX2oqyYbJvDaT6s6zKC0m0vLGZKusis2mVFSo8ewvrKS600pSi00tKCpXr3LJ9d4ba9f4Vx+IWj+xLKDaz/G+V2aSZwPwHld2A1IBAqaV8U7tDOrrsvPuTze7j9TX9xuSOtfXCirFBGT/ALMkMcaswADMC1BWnlzdXTyheChyS4wyd5x41liG2c001m0NtqObmg9sgxO8itLKmGsw11YWEKhyGTBS4sRZaVxprIV6F5bSUtAVdj9YvnKLc8Vyt7w/MoAPZF/WCVR8C4tHZYpSmuySqSKDt3laKDR1R2/F11K9pznC2HPY+5Leqb+NzCxGptr5EeaFXoPZERJE1NwRXJcymgePd9qZMm82NuvYu+9hTY6oa8mzOfMg49SwVrSpyJh2BNWllS42ZgbR9mQXJMx719fmS0fi6lYH19e4puvsg5rked5912+65dlijWuq29qHaOHdQb3q8jUpvC1XyH2X2fxualOOxXH+KxvGI2Df89qivNK4GjXV4Y45Z9tT602xxLWuwuN/hN9EvwR+f//Z"><link rel="icon" type="image/png" sizes="16x16" data-savepage-href="//static001.geekbang.org/static/time/icon/favicon-16x16.jpg" href="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABkAAD/4QMsaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOV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meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover"><meta name="format-detection" content="telephone=no"><title>极客时间 | MySQL实战45讲</title><script data-savepage-src="https://hm.baidu.com/hm.js?022f847c4e3acd44d4a2481d9187f1e6" src=""></script><script async="" data-savepage-src="https://www.google-analytics.com/analytics.js" src=""></script><script type="text/javascript" data-savepage-src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js" src=""></script><script type="text/javascript" data-savepage-src="//at.alicdn.com/t/font_372689_nw1guejwd2q.js" src=""></script><style data-savepage-href="https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css">.prism-player .prism-big-play-btn{background:/*savepage-url=./img/bigplay.png*/url() no-repeat;background-size:contain;width:64px;height:64px}.prism-player .prism-big-play-btn .outter{border:7px solid rgba(255,255,255,.51);width:64px;height:64px;border-radius:100%;position:absolute;box-sizing:border-box;top:0;left:0}