<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>数据库 on 🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟</title>
    <link>https://fps.ink/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/</link>
    <description>Recent content from 🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    
    <managingEditor>xxx@example.com (Jarvis)</managingEditor>
    <webMaster>xxx@example.com (Jarvis)</webMaster>
    
    <copyright>本博客所有文章除特别声明外，均采用 BY-NC-SA 许可协议。转载请注明出处！</copyright>
    
    <lastBuildDate>Sat, 11 Sep 2021 22:12:00 +0800</lastBuildDate>
    
    
    <atom:link href="https://fps.ink/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/index.xml" rel="self" type="application/rss&#43;xml" />
    

    
    

    <item>
      <title>SQL 语法大全总结</title>
      <link>https://fps.ink/post/sql-syntax/</link>
      <pubDate>Sat, 11 Sep 2021 22:12:00 &#43;0800</pubDate>
      <author>xxx@example.com (Jarvis)</author>
      <guid>https://fps.ink/post/sql-syntax/</guid>
      <description>
        <![CDATA[<h1>SQL 语法大全总结</h1><p>作者：Jarvis（xxx@example.com）</p>
        
          <p>一份按「DDL → DML → DQL → DCL → TCL」梳理的 SQL 语法速查清单，覆盖建表、查询、连接、子查询、窗口函数、事务、索引与常见方言差异。示例以标准 SQL 为主，方言差异会在对应位置标注。</p>
<h2 id="一sql-分类">
<a class="header-anchor" href="#%e4%b8%80sql-%e5%88%86%e7%b1%bb"></a>
一、SQL 分类
</h2><table>
	<thead>
			<tr>
					<th>分类</th>
					<th>全称</th>
					<th>作用</th>
					<th>代表语句</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>DDL</td>
					<td>Data Definition Language</td>
					<td>定义结构</td>
					<td><code>CREATE</code> <code>ALTER</code> <code>DROP</code> <code>TRUNCATE</code> <code>RENAME</code></td>
			</tr>
			<tr>
					<td>DML</td>
					<td>Data Manipulation Language</td>
					<td>操作数据</td>
					<td><code>INSERT</code> <code>UPDATE</code> <code>DELETE</code> <code>MERGE</code></td>
			</tr>
			<tr>
					<td>DQL</td>
					<td>Data Query Language</td>
					<td>查询数据</td>
					<td><code>SELECT</code></td>
			</tr>
			<tr>
					<td>DCL</td>
					<td>Data Control Language</td>
					<td>权限控制</td>
					<td><code>GRANT</code> <code>REVOKE</code></td>
			</tr>
			<tr>
					<td>TCL</td>
					<td>Transaction Control Language</td>
					<td>事务控制</td>
					<td><code>BEGIN</code> <code>COMMIT</code> <code>ROLLBACK</code> <code>SAVEPOINT</code></td>
			</tr>
	</tbody>
</table>
<h2 id="二常用数据类型">
<a class="header-anchor" href="#%e4%ba%8c%e5%b8%b8%e7%94%a8%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b"></a>
二、常用数据类型
</h2><table>
	<thead>
			<tr>
					<th>类型</th>
					<th>说明</th>
					<th>示例</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>整数</td>
					<td><code>TINYINT</code> <code>SMALLINT</code> <code>INT</code> <code>BIGINT</code></td>
					<td><code>age INT</code></td>
			</tr>
			<tr>
					<td>小数</td>
					<td><code>DECIMAL(p,s)</code> 精确，<code>FLOAT/DOUBLE</code> 近似</td>
					<td><code>price DECIMAL(10,2)</code></td>
			</tr>
			<tr>
					<td>字符串</td>
					<td><code>CHAR(n)</code> 定长，<code>VARCHAR(n)</code> 变长，<code>TEXT</code> 长文本</td>
					<td><code>name VARCHAR(50)</code></td>
			</tr>
			<tr>
					<td>日期时间</td>
					<td><code>DATE</code> <code>TIME</code> <code>DATETIME</code> <code>TIMESTAMP</code></td>
					<td><code>created_at TIMESTAMP</code></td>
			</tr>
			<tr>
					<td>布尔</td>
					<td><code>BOOLEAN</code>（MySQL 用 <code>TINYINT(1)</code>）</td>
					<td><code>enabled BOOLEAN</code></td>
			</tr>
			<tr>
					<td>二进制</td>
					<td><code>BLOB</code> <code>BYTEA</code>（PG）</td>
					<td><code>avatar BLOB</code></td>
			</tr>
			<tr>
					<td>JSON</td>
					<td>MySQL <code>JSON</code>、PG <code>JSONB</code></td>
					<td><code>extra JSON</code></td>
			</tr>
	</tbody>
</table>
<blockquote>
<p>金额一律用 <code>DECIMAL</code>，不要用 <code>FLOAT</code>，否则会出现 <code>0.1 + 0.2 != 0.3</code>。</p>
</blockquote>
        
        <hr><p>本文2021-09-11首发于<a href='https://fps.ink/'>🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟🐟</a>，最后修改于2021-09-11</p>]]>
      </description>
      
        <category>技术</category>
      
    </item>
    
  </channel>
</rss>
