mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 12:41:20 +08:00
doc: update docs/mysql.md (#941)
Co-authored-by: null <shanhai1204@gmail.com> 0c618e1c01
This commit is contained in:
@ -39,7 +39,7 @@
|
||||
<p>本备忘单旨在快速理解 <a href="https://mysql.com">MySQL</a> 所涉及的主要概念,提供了最常用的SQL语句,供您参考。</p>
|
||||
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
||||
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#介绍">介绍</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#登录mysql">登录MySQL</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#常用的">常用的</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#数据库-database">数据库 Database</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#表-table">表 Table</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#proccess">Proccess</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#查看-mysql-信息">查看 MySQL 信息</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#退出mysql会话">退出MySQL会话</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#备份">备份</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#mysql-示例">MySQL 示例</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理表格">管理表格</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#从表中查询数据">从表中查询数据</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#从多个表查询">从多个表查询</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#使用-sql-约束">使用 SQL 约束</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#修改数据">修改数据</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理视图">管理视图</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理触发器">管理触发器</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#when">WHEN</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#event">EVENT</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#trigger_type">TRIGGER_TYPE</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理索引">管理索引</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#mysql-数据类型">MySQL 数据类型</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#strings">Strings</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#date--time">Date & time</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#numeric">Numeric</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#函数">函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#聚合函数">聚合函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#数学函数">数学函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#日期和时间函数">日期和时间函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串函数">字符串函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#高级函数">高级函数</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#介绍">介绍</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#登录mysql">登录MySQL</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#常用的">常用的</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#数据库-database">数据库 Database</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#表-table">表 Table</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#proccess">Proccess</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#查看-mysql-信息">查看 MySQL 信息</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#退出mysql会话">退出MySQL会话</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#备份">备份</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#错误处理-error-handling">错误处理 Error Handling</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#mysql-示例">MySQL 示例</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理表格">管理表格</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#从表中查询数据">从表中查询数据</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#从多个表查询">从多个表查询</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#使用-sql-约束">使用 SQL 约束</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#修改数据">修改数据</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理视图">管理视图</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理触发器">管理触发器</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#when">WHEN</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#event">EVENT</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#trigger_type">TRIGGER_TYPE</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#管理索引">管理索引</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#mysql-数据类型">MySQL 数据类型</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#strings">Strings</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#date--time">Date & time</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#numeric">Numeric</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#函数">函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#聚合函数">聚合函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#数学函数">数学函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#日期和时间函数">日期和时间函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#字符串函数">字符串函数</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#高级函数">高级函数</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist row-span-3"><div class="wrap-header h3wrap"><h3 id="介绍"><a aria-hidden="true" tabindex="-1" href="#介绍"><span class="icon icon-link"></span></a>介绍</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
<p>MySQL 为关系型数据库(Relational Database Management System),一个关系型数据库由一个或数个表格组成,如下所示的一个表格</p>
|
||||
@ -180,6 +180,41 @@
|
||||
<p>恢复备份</p>
|
||||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">mysql <span class="token parameter variable">-u</span> user <span class="token parameter variable">-p</span> db_name <span class="token operator"><</span> db.sql
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="错误处理-error-handling"><a aria-hidden="true" tabindex="-1" href="#错误处理-error-handling"><span class="icon icon-link"></span></a>错误处理 Error Handling</h3><div class="wrap-body">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table><thead><tr><th align="left">语句</th><th align="left">描述</th></tr></thead><tbody><tr><td align="left"><code>SHOW ERRORS;</code></td><td align="left">显示最近的错误信息</td></tr><tr><td align="left"><code>SHOW WARNINGS;</code></td><td align="left">显示最近的警告信息</td></tr><tr><td align="left"><code>SHOW COUNT(*) ERRORS;</code></td><td align="left">返回最近语句的错误数量</td></tr><tr><td align="left"><code>SHOW COUNT(*) WARNINGS;</code></td><td align="left">返回最近语句的警告数量</td></tr><tr><td align="left"><code>EXPLAIN</code></td><td align="left">分析 SQL 查询的执行计划,排查问题</td></tr><tr><td align="left"><code>SHOW ENGINE INNODB STATUS;</code></td><td align="left">显示 InnoDB 引擎状态,包括死锁等错误信息</td></tr></tbody></table>
|
||||
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="mysql-示例"><a aria-hidden="true" tabindex="-1" href="#mysql-示例"><span class="icon icon-link"></span></a>MySQL 示例</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="管理表格"><a aria-hidden="true" tabindex="-1" href="#管理表格"><span class="icon icon-link"></span></a>管理表格</h3><div class="wrap-body">
|
||||
<p>创建一个包含三列的新表</p>
|
||||
@ -656,7 +691,11 @@
|
||||
|
||||
|
||||
|
||||
<table><thead><tr><th align="left">函数</th><th align="left">解释</th></tr></thead><tbody><tr><td align="left"><code>SUM()</code></td><td align="left">计算一列值的总和</td></tr><tr><td align="left"><code>AVG()</code></td><td align="left">计算一列值的平均值</td></tr><tr><td align="left"><code>COUNT()</code></td><td align="left">计算行数,可选择性地忽略NULL值</td></tr><tr><td align="left"><code>MAX()</code></td><td align="left">找出一列的最大值</td></tr><tr><td align="left"><code>MIN()</code></td><td align="left">找出一列的最小值</td></tr></tbody></table>
|
||||
|
||||
|
||||
|
||||
|
||||
<table><thead><tr><th align="left">函数</th><th align="left">解释</th></tr></thead><tbody><tr><td align="left"><code>SUM()</code></td><td align="left">计算一列值的总和</td></tr><tr><td align="left"><code>AVG()</code></td><td align="left">计算一列值的平均值</td></tr><tr><td align="left"><code>COUNT()</code></td><td align="left">计算行数,可选择性地忽略NULL值</td></tr><tr><td align="left"><code>MAX()</code></td><td align="left">找出一列的最大值</td></tr><tr><td align="left"><code>MIN()</code></td><td align="left">找出一列的最小值</td></tr><tr><td align="left"><code>GROUP_CONCAT()</code></td><td align="left">将一组值连接成单一字符串,可指定分隔符,常用于分组。</td></tr></tbody></table>
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="数学函数"><a aria-hidden="true" tabindex="-1" href="#数学函数"><span class="icon icon-link"></span></a>数学函数</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2 -->
|
||||
|
||||
|
Reference in New Issue
Block a user