<span class="log-zd"><span class="log-close"><a title="隐藏目录"><i class="be be-cross"></i><strong>目录</strong></a></span></span>

1.1 MySQL用户管理

1.1.1 用户的定义

**  用户名+**主机域

1.1.2 用户的作用

    1、用户登录

    2、用于管理数据库及数据

1.1.3 连接数据库

     定义用户:用户名+主机域,密码

     定义权限:对不同的对象进行权限(角色)定义

命令:

权限

角色

权限范围

用户

1.1.4 【练习题】按照要求创建用户

用户只能通过10.0.0.0/24网段访问,用户名为clsn 密码为123

这个用户只能对clsn数据库下的对象进行增insert create、改update 、查select;

  创建命令:

查看用户权限

查看当前存在的用户:

创建用户语法

示例:

注意这个样创建的用户只有连接权限

企业里创建用户一般是授权一个内网网段登录,最常见的网段写法有两种。

<p class="a" style="text-indent: 21pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">
  <span style="color: #ff6600;"><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">方法</span><span lang="EN-US">2</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">:</span></span><span lang="EN-US">172.16.1.0/255.255.255.0</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">,但是不能使用</span><span lang="EN-US">172.16.1.0/24</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">,是个小遗憾。</span>
</p>

标准的建用户方法:

查看用户对应的权限

1.1.5 用户删除

删除用户语法:

【练习】用户优化:只保留

特殊的删除方法:(慎用,尽量不要直接去修改表)

1.1.6 用户授权

给用户授权

创建用户的同时授权

创建用户然后授权

授权和root一样的权限

授权给用户select,create,insert,update 权限

回收权限

可以授权的用户权限

【示例】博客授权收回示例

   授权博客类的最多权限:select,insert,update,delete

1.2 MySQL 客户端工具

1.2.1 MysQL客户端命令介绍

**  mysql**命令客户端

<p class="a">
  <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">    将</span> <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">用户</span><span lang="EN-US">SQL </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">语句发送到服务器</span>
</p>

**  mysqladmin**命令 :命令行管理工具

**  mysqldump**命令 :备份数据库和表的内容

1.2.2 mysql命令说明

  用于连接数据库

  用于管理数据库通过下列方式进行管理

<p class="a" style="text-indent: 1cm; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">
  <span lang="EN-US">  DDL</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">:数据定义语言</span>
</p>

<p class="a" style="text-indent: 1cm; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">
  <span lang="EN-US">  DCL</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">:数据控制语言</span>
</p>

<p class="a" style="text-indent: 1cm; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">
  <span lang="EN-US">  DML</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">:数据操作语言</span>
</p>

**  mysql**命令接口自带命令说明

    <td style="width: 381.3pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4f81bd; border-right-color: #4f81bd; border-bottom-color: #4f81bd; border-left: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">命令说明</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68;">
        <strong><span lang="EN-US">\h </span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US"> help </span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US"> ?&nbsp; </span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">获取帮助</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4;">
        <strong><span lang="EN-US">\G</span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">格式化输出(行转列)</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68;">
        <strong><span lang="EN-US">\T </span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US"> tee</span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">记录操作日志</span><span lang="EN-US">&nbsp; tee /tmp/mysql.log</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4;">
        <strong><span lang="EN-US">\c </span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US"> CTRL+c </span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">退出</span><span lang="EN-US">mysql</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68;">
        <strong><span lang="EN-US">\s </span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US"> status</span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">查看数据库状态信息</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4;">
        <strong><span lang="EN-US">\. </span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US"> source </span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span lang="EN-US">mysql> source /tmp/world.sql</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68;">
        <strong><span lang="EN-US">\!</span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">使用</span><span lang="EN-US">shell</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">中的命令</span>
      </p>
      
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">&nbsp;<span class="cnblogs_code">mysql<span style="color: #808080;">></span> \! cat <span style="color: #808080;">/</span>etc<span style="color: #808080;">/</span>redhat<span style="color: #808080;">-</span><span style="color: #000000;">release </span></span></span>
      </p>
      
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';"><span class="cnblogs_code"><span style="color: #000000;">CentOS release </span><span style="color: #800000; font-weight: bold;">6.9</span> (Final)</span>&nbsp;</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 4;">
        <strong><span lang="EN-US">\u </span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US">use&nbsp;&nbsp;&nbsp; </span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span lang="EN-US">use&nbsp; world </span>
      </p>
      
      <p class="MsoNormal">
        <span lang="EN-US">show databases&nbsp; </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">看当前所有数据库的名字</span>
      </p>
      
      <p class="MsoNormal">
        <span lang="EN-US">show tables&nbsp;&nbsp; </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">查看当前</span><span lang="EN-US">use</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">到的数据库所有的表</span>
      </p>
      
      <p class="MsoNormal">
        <span lang="EN-US">show&nbsp; tables from world&nbsp;&nbsp; </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">查看目标数据库下的表</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 141.5pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" width="189">
      <p class="MsoNormal" style="text-align: justify; text-justify: inter-ideograph; mso-yfti-cnfc: 68;">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">快捷键</span></strong>
      </p>
    </td>
    
    <td style="width: 381.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="508">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">上下翻页、</span><span lang="EN-US">TAB</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">键、</span><span lang="EN-US">ctrl +C </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">、</span><span lang="EN-US">ctrl +L</span>
      </p>
    </td>
  </tr>
</table>

1.2.2.1  mysql中help命令的使用

  在mysql命令行中输入mysql或 ?都可以查看帮助

  有关特定 SQL 类别或语句的帮助

  查看 grant 的帮助

  有关与状态相关的 SQL 语句的帮助

1.2.2.2  source命令的使用

在 mysql 中处理输入文件:

使用 SOURCE 命令:

  或者使用非交互式:(尽量避免使用mysql 导入数据,会产生大量的无用日志)

1.2.3 mysqladmin命令说明

基本语法

    <td style="width: 182.85pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4f81bd; border-right-color: #4f81bd; border-bottom-color: #4f81bd; border-left: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">说明</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span><span lang="EN-US"> ping</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">&ldquo;强制回应</span><span lang="EN-US"> (Ping)</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">&rdquo;服务器。</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span> <span lang="EN-US">shutdown</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">关闭服务器。</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span> <span lang="EN-US">create databasename</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">创建数据库。</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span><span lang="EN-US">drop databasename</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">删除数据库</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span> <span lang="EN-US">version</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">显示服务器和版本信息</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span> <span lang="EN-US">status</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">显示或重置服务器状态变量</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span> <span lang="EN-US">password</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">设置口令</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span> <span lang="EN-US">flush-privileges</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">重新刷新授权表。</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 339.95pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="453">
      <p class="MsoNormal">
        <strong><span lang="EN-US">mysqladmin -u</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">用户</span><span lang="EN-US"> -p</span></strong><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">密码</span> <span lang="EN-US">flush-logs</span></strong>
      </p>
    </td>
    
    <td style="width: 182.85pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="244">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">刷新日志文件和高速缓存。</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 522.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" colspan="2" valign="top" width="697">
      <p class="MsoNormal">
        <span style="color: #ff6600;"><strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">以上信息通过</span><span lang="EN-US">mysqladmin&nbsp; --help </span></strong></span><strong><span style="font-family: 微软雅黑, sans-serif; color: #ff6600;">获得</span></strong>
      </p>
    </td>
  </tr>
</table>

1.2.4 mysqldump简单说明

  mysqldump是一款数据库备份工具。

命令帮助及基本语法:

1.3 SQL语句入门

1.3.1 DDL语句(数据定义语言)

定义范围:

<p class="a">
  <span lang="EN-US">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">表:表名字、列</span>
</p>

1.3.1.1  数据库查看

查看数据库–查看全部

   查看数据库–模糊匹配

查看你相关的帮助

1.3.1.2  数据库操作

  创建一个数据库

   通过show 命令能够查看创建的数据库的格式

创建数据库时定义字符编码

存在的数据库修改字符编码:

修改数据库编码格式示例

mysql> show create database haha; +——–+————————————————————–+ | Database | Create Database | +——–+————————————————————–+ | haha | CREATE DATABASE haha /!40100 DEFAULT CHARACTER SET gbk / | +——–+————————————————————–+ 1 row in set (0.00 sec)

查看支持的字符集和校对规则.

删除数据库

mysql> show databases; +——————+ | Database |

切库

查看当前所在数据库

查看当前登陆的用户

查看库里面的表

1.3.1.3  DDL语句之管理表

表的属性

<p class="a" style="text-indent: 21pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">
  <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">默认:字符集、引擎</span>
</p>

表定义(列):

<p class="a" style="text-indent: 21pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;">
  <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 宋体; mso-hansi-font-family: 宋体;">列属性(数据类型、列约束)</span>
</p>

创建表

创建更多的表;

查看表结构

查看建表语句

1.3.1.4  修改表的定义

修改表名字

mysql> show tables ; +————–+ | Tables_in_clsn | +————–+ | haha |

   修改表名字,方法二。

   修改表结构

   指定添加年龄列到name列后面的位置,示例如下:

mysql> desc people; +—–+———-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +—–+———-+——+—–+———+——-+ | id | int(11) | YES | | NULL | | | addr | char(40) | NO | | NULL | | | name | int(40) | YES | | NULL | | | age | int(4) | YES | | NULL | | +—–+———-+——+—–+———+——-+ 4 rows in set (0.00 sec)

   通过下面的命令在第一列添加qq字段。

mysql> desc people; +——+———-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +——+———-+——+—–+———+——-+ | telnum | int(11) | YES | | NULL | | | id | int(11) | YES | | NULL | | | addr | char(40) | NO | | NULL | | | name | int(40) | YES | | NULL | | | age | int(4) | YES | | NULL | | +——+———-+——+—–+———+——-+ 5 rows in set (0.00 sec)

   同时添加多个列定义:

mysql> desc people; +——+———-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +——+———-+——+—–+———+——-+ | id1 | int(11) | YES | | NULL | | | telnum | int(11) | YES | | NULL | | | id | int(11) | YES | | NULL | | | addr | char(40) | NO | | NULL | | | name | int(40) | YES | | NULL | | | sex | char(4) | YES | | NULL | | | age | int(4) | YES | | NULL | | +——+———-+——+—–+———+——-+ 7 rows in set (0.00 sec)

mysql> desc people; +——+———-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +——+———-+——+—–+———+——-+ | id1 | int(11) | YES | | NULL | | | telnum | int(11) | YES | | NULL | | | id | int(11) | YES | | NULL | | | addr | char(40) | NO | | NULL | | | name | int(40) | YES | | NULL | | | age | int(4) | YES | | NULL | | +——+———-+——+—–+———+——-+ 6 rows in set (0.00 sec)

修改表定义

mysql> desc people; +——+———-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +——+———-+——+—–+———+——-+ | id1 | int(11) | YES | | NULL | | | telnum | int(11) | YES | | NULL | | | id | int(11) | YES | | NULL | | | addr | char(40) | NO | | NULL | | | name | char(20) | YES | | NULL | | | age | int(4) | YES | | NULL | | +——+———-+——+—–+———+——-+ 6 rows in set (0.00 sec)

   修改列名:

mysql> desc people; +———–+———-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +———–+———-+——+—–+———+——-+ | id1 | int(11) | YES | | NULL | | | telnum | int(11) | YES | | NULL | | | id | int(11) | YES | | NULL | | | addr | char(40) | NO | | NULL | | | people_name | char(30) | YES | | NULL | | | age | int(4) | YES | | NULL | | +———–+———-+——+—–+———+——-+ 6 rows in set (0.00 sec)

1.3.1.5  DDL语句小结

1.3.2 DCL数据库控制语言

**grant:**用户授权

创建用户的同时进行授权

**revoke:**回收权限

   收回权限示例:

1.3.3 DML数据库操作语言

    DML是针对数据行的操作

1.3.3.1  insert 语句

    insert 语法结构

创建表,插入数据

   表的类型

在表中插入第一行数据

mysql> select * from clsn; +—-+——+ | id | name | +—-+——+ | 1 | clsn | +—-+——+ 1 row in set (0.00 sec)

插入两行数据

mysql> select * from clsn; +—-+———-+ | id | name | +—-+———-+ | 1 | clsn | | 2 | yougboy | | 3 | youggilr | +—-+———-+ 3 rows in set (0.00 sec)

仅在name下插入一个名字

mysql> select * from clsn; +—-+———-+ | id | name | +—-+———-+ | 1 | clsn | | 2 | yougboy | | 3 | youggilr | | NULL | xiaoming | +—-+———-+ 4 rows in set (0.00 sec)

一次插入多行数据

mysql> insert into test2 select * from clsn; Query OK, 4 rows affected (0.01 sec) Records: 4 Duplicates: Warnings:

mysql> select * from test2; +—-+———-+ | id | name | +—-+———-+ | 1 | clsn | | 2 | yougboy | | 3 | youggilr | | NULL | xiaoming | +—-+———-+ 4 rows in set (0.00 sec)

1.3.3.2  update更改数据库(一定要加上where条件)

  更新表内容

   将字段中的youggirl改为haha

   更改后

1.3.3.3  delete删除表内容(一定要有where条件)

_  删除语句_

   删除xiaoming的记录

   删除之后

1.3.3.4  生产中的伪删除

  为表添加一个state列

_  TINYINT_ ,字段类型,如果设置为UNSIGNED类型,只能存储从0到255的整数,不能用来储存负数。

mysql> desc test2; +—–+————-+——+—–+———+——-+ | Field | Type | Null | Key | Default | Extra | +—–+————-+——+—–+———+——-+ | id | int(11) | YES | | NULL | | | name | varchar(20) | YES | | NULL | | | state | tinyint(2) | NO | | 1 | | +—–+————-+——+—–+———+——-+ 3 rows in set (0.00 sec) mysql> update test set state=1;

   查看当前的state状态

   更新数据,将clsn记录的state改为0

mysql> select * from test2; +—-+———+——-+ | id | name | state | +—-+———+——-+ | 1 | clsn | | | 2 | yougboy | 1 | | 3 | haha | 1 | +—-+———+——-+ 3 rows in set (0.00 sec)

   查询的时候,使用 where 条件只显示 state=1 的记录,效果与删除类似。

1.3.3.5  防止不加条件误删【安全】

备份数据备用

mysql -U 参数实践

   使用update与delete命令的时候不加where 条件不会执行。

在mysql命令加上选项-U后,当发出没有WHERE或LIMIT关键字的UPDATE或DELETE时,mysql程序拒绝执行。

1.3.4 DQL数据查询语言标准语法

1.3.4.1  语法说明

select****命令语法:

1.3.4.2  查看操作

查看用户的连接信息

查看test2表中的所有信息

   查看test表中的id和name

查看id等于2 的信息

查看名字是clsn的记录

查看id大于2的记录

查看id大于2 并且 小于4的记录

查看id大于2或者 小于4的记录

提取记录排序

mysql> select id,name from test2 order by id desc; +—-+———+ | id | name | +—-+———+ | 3 | haha | | 2 | yougboy | | 1 | clsn | +—-+———+ 3 rows in set (0.00 sec)

   显示排错第一行后的三行(需要与排序配合使用)

1.3.5 字符集说明

1.3.5.1  常用的字符集

  MySQL数据库的字符集:字符集(CHARACTER)、校对规则(COLLATION)

  MySQL中常见的字符集:UTF8、LATIN1、GBK

  常见校对规则:ci:大小写不敏感、cs或bin:大小写敏感

  我们可以使用以下命令查看:show charset; 、 show collation;

1.3.5.2  字符集设置

系统字符集说明

客户端字符集说明

  方法1:在编译安装时候就指定如下服务器端字符集。

  方法2:在my.cnf文件中添加上字符参数

数据库中的库级别设置

  获取帮助并查询

  表级别(含字段级别)

1.3.5.3  MySQL客户端级别(连接及返回结果)

  方法1:临时生效单条命令法。

  方法2:通过修改my.cnf实现修改mysql客户端的字符集,配置方法如下

  程序代码级别:生产环境更改数据库(含数据)字符集的方法

1.3.6 常用的查询操作

查看 当前所在的数据库

查看当前的登陆用户

1.4 数据类型说明

1.4.1 ER模型

  ER模型,全称为实体联系模型、实体关系模型或实体联系模式图(ERD)(英语:Entity-relationship model)由美籍华裔计算机科学家陈品山发明,是概念数据模型的高层描述所使用的数据模型或模式图。

  ER模型常用于信息系统设计中;比如它们在概念结构设计阶段用来描述信息需求和/或要存储在数据库中的信息的类型。但是数据建模技术可以用来描述特定论域(就是感兴趣的区域)的任何本体(就是对使用的术语和它们的联系的概述和分类)。在基于数据库的信息系统设计的情况下,在后面的阶段(通常叫做逻辑设计),概念模型要映射到逻辑模型如关系模型上;它依次要在物理设计期间映射到物理模型上。注意,有时这两个阶段被一起称为“物理设计”。

  实体联系模式图(ERD)有一些约定。本文的余下部分描述经典概念,并且主要与概念建模有关。有一些概念更加典型的在逻辑和物理数据库设计中采用,包括信息工程、IDEF1x(ICAM DEFinition Language)和空间建模。

1.4.2 数据类型介绍

**  四种主要类别:**数值类型、字符类型、时间类型、二进制类型

1.4.3 创建带有数据类型的表

  例 1:列声明

  例 2:不允许负值和未知值

1.4.4 数值数据类型

  使用数值数据类型时的注意事项:

  1. 数据类型所表示的值的范围
  2. 列值所需的空间量
  3. 列精度和范围(浮点数和定点数)

  数值数据类型的类:

  1. 整数:整数
  2. 浮点数:小数
  3. 定点数:精确值数值
  4. BIT:位字段值
    <td style="width: 120.45pt; border-top-width: 1pt; border-top-color: #4f81bd; border-left: none; border-bottom-width: 1pt; border-bottom-color: #4f81bd; border-right: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">类型</span></strong>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4f81bd; border-right-color: #4f81bd; border-bottom-color: #4f81bd; border-left: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">说明</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">整数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 64;" align="center">
        <span lang="EN-US">TINYINT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">极小整数数据类型(</span><span lang="EN-US">0-255</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">)</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">整数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center;" align="center">
        <span lang="EN-US">SMALLINT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">较小整数数据类型(</span><span lang="EN-US">-2^15 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">到</span><span lang="EN-US">2^15-1</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">)</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">整数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 64;" align="center">
        <span lang="EN-US">MEDIUMINT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">中型整数数据类型</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">整数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center;" align="center">
        <span lang="EN-US">INT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">常规(平均)大小的整数数据类型(</span><span lang="EN-US">-2^31 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">到</span><span lang="EN-US">2^31-1</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">)</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">整数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 64;" align="center">
        <span lang="EN-US">BIGINT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">较大整数数据类型(</span><span lang="EN-US">-2^63</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">到</span><span lang="EN-US">2^63-1</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">)</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">浮点数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center;" align="center">
        <span lang="EN-US">FLOAT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">小型单精度(四个字节)浮点数</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">浮点数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 64;" align="center">
        <span lang="EN-US">DOUBLE</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">常规双精度(八个字节)浮点数</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">定点数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center;" align="center">
        <span lang="EN-US">DECIMAL</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">包含整数部分、小数部分或同时包括二者的精确值数值</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span lang="EN-US">BIT</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 64;" align="center">
        <span lang="EN-US">BIT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">位字段值</span>
      </p>
    </td>
  </tr>
</table>

1.4.5 字符串数据类型

  表示给定字符集中的一个字母数字字符序列,用于存储文本或二进制数据,几乎在每种编程语言中都有实现,支持字符集和整理。

  属于以下其中一类

    文本:真实的非结构化字符串数据类型

    整数:结构化字符串类型

    <td style="width: 120.45pt; border-top-width: 1pt; border-top-color: #4f81bd; border-left: none; border-bottom-width: 1pt; border-bottom-color: #4f81bd; border-right: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">类型</span></strong>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4f81bd; border-right-color: #4f81bd; border-bottom-color: #4f81bd; border-left: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">说明</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">文本</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">CHAR</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">固定长度字符串,最多为</span><span lang="EN-US">255 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字符</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">文本</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">VARCHAR</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">可变长度字符串,最多为</span><span lang="EN-US">65,535 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字符</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">文本</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">TINYTEXT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">可变长度字符串,最多为</span><span lang="EN-US">255 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字符</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">文本</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">TEXT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">可变长度字符串,最多为</span><span lang="EN-US">65,535 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字符</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">文本</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">MEDIUMTEXT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">可变长度字符串,最多为</span><span lang="EN-US">16,777,215 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字符</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">文本</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">LONGTEXT</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">可变长度字符串,最多为</span><span lang="EN-US">4,294,967,295 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字符</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">整数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">ENUM</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">由一组固定的合法值组成的枚举</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 77.75pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="104">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">整数</span></strong>
      </p>
    </td>
    
    <td style="width: 120.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="161">
      <p class="MsoNormal">
        <span lang="EN-US">SET</span>
      </p>
    </td>
    
    <td style="width: 324.6pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="433">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">由一组固定的合法值组成的集</span>
      </p>
    </td>
  </tr>
</table>

1.4.6 二进制字符串数据类型

  字节序列:二进制位按八位分组

  存储二进制值,例如:编译的计算机程序和应用程序、图像和声音文件

  字符二进制数据类型的类:

    二进制:固定长度和可变长度的二进制字符串

    BLOB:二进制数据的可变长度非结构化集合

    <td style="width: 106.3pt; border-top-width: 1pt; border-top-color: #4f81bd; border-left: none; border-bottom-width: 1pt; border-bottom-color: #4f81bd; border-right: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="142">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">类型</span></strong>
      </p>
    </td>
    
    <td style="width: 352.95pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4f81bd; border-right-color: #4f81bd; border-bottom-color: #4f81bd; border-left: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="471">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">说明</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 63.55pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="85">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">二进制</span></strong>
      </p>
    </td>
    
    <td style="width: 106.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="142">
      <p class="MsoNormal">
        <span lang="EN-US">BINARY</span>
      </p>
    </td>
    
    <td style="width: 352.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="471">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">类似于</span><span lang="EN-US"> CHAR</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">(固定长度)类型,但存储的是二进制字节字符串,而不是非二进制字符串</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 63.55pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="85">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">二进制</span></strong>
      </p>
    </td>
    
    <td style="width: 106.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="142">
      <p class="MsoNormal">
        <span lang="EN-US">VARBINARY</span>
      </p>
    </td>
    
    <td style="width: 352.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="471">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">类似于</span><span lang="EN-US"> VARCHAR</span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">(可变长度)类型,但存储的是二进制字节字符串,而不是非二进制字符串</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 63.55pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="85">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span lang="EN-US">BLOB</span></strong>
      </p>
    </td>
    
    <td style="width: 106.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="142">
      <p class="MsoNormal">
        <span lang="EN-US">TINYBLOB</span>
      </p>
    </td>
    
    <td style="width: 352.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="471">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">最大长度为</span><span lang="EN-US">255 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字节的</span><span lang="EN-US"> BLOB </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">列</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 63.55pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="85">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span lang="EN-US">BLOB</span></strong>
      </p>
    </td>
    
    <td style="width: 106.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="142">
      <p class="MsoNormal">
        <span lang="EN-US">BLOB</span>
      </p>
    </td>
    
    <td style="width: 352.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="471">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">最大长度为</span><span lang="EN-US">65,535 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字节的</span><span lang="EN-US"> BLOB </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">列</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 63.55pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="85">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span lang="EN-US">BLOB</span></strong>
      </p>
    </td>
    
    <td style="width: 106.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="142">
      <p class="MsoNormal">
        <span lang="EN-US">MEDIUDMBLOB</span>
      </p>
    </td>
    
    <td style="width: 352.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="471">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">最大长度为</span><span lang="EN-US">16,777,215 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字节的</span><span lang="EN-US"> BLOB </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">列</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 63.55pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="85">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span lang="EN-US">BLOB</span></strong>
      </p>
    </td>
    
    <td style="width: 106.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="142">
      <p class="MsoNormal">
        <span lang="EN-US">LONGBLOB</span>
      </p>
    </td>
    
    <td style="width: 352.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="471">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">最大长度为</span><span lang="EN-US">4,294,967,295 </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">个字节的</span><span lang="EN-US"> BLOB </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">列</span>
      </p>
    </td>
  </tr>
</table>

1.4.7 时间数据类型

    <td style="width: 219.75pt; border-top-width: 1pt; border-top-color: #4f81bd; border-left: none; border-bottom-width: 1pt; border-bottom-color: #4f81bd; border-right: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="293">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">格式</span></strong>
      </p>
    </td>
    
    <td style="width: 218.25pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4f81bd; border-right-color: #4f81bd; border-bottom-color: #4f81bd; border-left: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="291">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">示例</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span lang="EN-US">DATE</span></strong>
      </p>
    </td>
    
    <td style="width: 219.75pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="293">
      <p class="MsoNormal">
        <span lang="EN-US">YYYY-MM-DD</span>
      </p>
    </td>
    
    <td style="width: 218.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="291">
      <p class="MsoNormal">
        <span lang="EN-US">2017-12-16</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span lang="EN-US">TIME</span></strong>
      </p>
    </td>
    
    <td style="width: 219.75pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="293">
      <p class="MsoNormal">
        <span lang="EN-US">hh:mm:ss[.uuuuuu]</span>
      </p>
    </td>
    
    <td style="width: 218.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="291">
      <p class="MsoNormal">
        <span lang="EN-US">12:59:02.123456</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span lang="EN-US">DATETIME</span></strong>
      </p>
    </td>
    
    <td style="width: 219.75pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="293">
      <p class="MsoNormal">
        <span lang="EN-US">YYYY-MM-DD hh:mm:ss[.uuuuuu]</span>
      </p>
    </td>
    
    <td style="width: 218.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="291">
      <p class="MsoNormal">
        <span lang="EN-US">2017-12-16 12:59:02.123</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span lang="EN-US">TIMESTAMP</span></strong>
      </p>
    </td>
    
    <td style="width: 219.75pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="293">
      <p class="MsoNormal">
        <span lang="EN-US">YYYY-MM-DD hh:mm:ss[.uuuuuu]</span>
      </p>
    </td>
    
    <td style="width: 218.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="291">
      <p class="MsoNormal">
        <span lang="EN-US">2017-12-16 12:59:02.12</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span lang="EN-US">YEAR</span></strong>
      </p>
    </td>
    
    <td style="width: 219.75pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="293">
      <p class="MsoNormal">
        <span lang="EN-US">YYYY</span>
      </p>
    </td>
    
    <td style="width: 218.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="291">
      <p class="MsoNormal">
        <span lang="EN-US">2017</span>
      </p>
    </td>
  </tr>
</table>

1.4.8 列属性

  列属性的类别:

    数值:适用于数值数据类型(BIT 除外)

    字符串:适用于非二进制字符串数据类型

    常规:适用于所有数据类型

    <td style="width: 155.95pt; border-top-width: 1pt; border-top-color: #4f81bd; border-left: none; border-bottom-width: 1pt; border-bottom-color: #4f81bd; border-right: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">属性</span></strong>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4f81bd; border-right-color: #4f81bd; border-bottom-color: #4f81bd; border-left: none; background: #4f81bd; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 1;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; color: white; mso-themecolor: background1;">说明</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">数值</span></strong>
      </p>
    </td>
    
    <td style="width: 155.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal">
        <span lang="EN-US">UNSIGNED</span>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">禁止使用负值</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">仅整数</span></strong>
      </p>
    </td>
    
    <td style="width: 155.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal">
        <span lang="EN-US">AUTO_INCREMENT</span>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">生成包含连续唯一整数值的序列</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">字符串</span></strong>
      </p>
    </td>
    
    <td style="width: 155.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal">
        <span lang="EN-US">CHARACTER SET</span>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">指定要使用的字符集</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">字符串</span></strong>
      </p>
    </td>
    
    <td style="width: 155.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal">
        <span lang="EN-US">COLLATE</span>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">指定字符集整理</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">字符串</span></strong>
      </p>
    </td>
    
    <td style="width: 155.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal">
        <span lang="EN-US">BINARY</span>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">指定二进制整理</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 4;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">全部</span><span lang="EN-US">*</span></strong>
      </p>
    </td>
    
    <td style="width: 155.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal">
        <span lang="EN-US">NULL </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">或</span><span lang="EN-US"> NOT NULL</span>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">指示列是否可以包含</span><span lang="EN-US"> NULL </span><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">值</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 84.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #95b3d7; border-bottom-color: #95b3d7; border-left-color: #95b3d7; border-top: none; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="113">
      <p class="MsoNormal" style="text-align: center; mso-yfti-cnfc: 68;" align="center">
        <strong><span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">全部</span></strong>
      </p>
    </td>
    
    <td style="width: 155.95pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="208">
      <p class="MsoNormal">
        <span lang="EN-US">DEFAULT</span>
      </p>
    </td>
    
    <td style="width: 282.05pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #95b3d7; border-right-width: 1pt; border-right-color: #95b3d7; background: #dbe5f1; padding: 0cm 5.4pt;" valign="top" width="376">
      <p class="MsoNormal">
        <span style="font-family: '微软雅黑',sans-serif; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New';">如果未为新记录指定值,则为其提供默认值</span>
      </p>
    </td>
  </tr>
</table>

1.4.9 数据类型小结

  使用固定长度数据类型:

    如果存储的所有字符串值的长度相同

  使用可变长度数据类型:

    如果存储的字符串值不同、对于多字节字符集

  对于频繁使用的字符,使用占用空间较少的多字节字符集。

    使用基本多文种平面 (Basic Multilingual Plane, BMP) 之外的其他、Unicode 字符集。

1.5开发人员SQL规范:

  1、合适的数据类型  2、定义合理的数据长度  3、建表时,同时设置字符集、校对规则、存储引擎类型  4、表名、列名必须有意义,每个列要有描述字段(注释字段 COMMENT ‘素材类型’)  5、每个表都,定义无关列,设置为自增长(AUTO_INCREMENT)  6、每个表都有主键列,一般是设置在无关列上 PRIMARY KEY (ID)  7、每个列都是not null ,default。  8、列要加合适的约束条件。  9、插入数据的时候不要有空值

1.6 参考文献

 

<li>
  <a href="#12_MySQL">1.2 MySQL 客户端工具</a><ul>
    <li>
      <a href="#121_MysQL">1.2.1 MysQL客户端命令介绍</a>
    </li>
    <li>
      <a href="#122_mysql">1.2.2 mysql命令说明</a><ul>
        <li>
          <a href="#1221nbsp_mysqlhelp">1.2.2.1&nbsp; mysql中help命令的使用</a>
        </li>
        <li>
          <a href="#1222nbsp_source">1.2.2.2&nbsp; source命令的使用</a>
        </li>
      </ul>
    </li>
    
    <li>
      <a href="#123_mysqladmin">1.2.3 mysqladmin命令说明</a>
    </li>
    <li>
      <a href="#124_mysqldump">1.2.4 mysqldump简单说明</a>
    </li>
  </ul>
</li>

<li>
  <a href="#13_SQL">1.3 SQL语句入门</a>
</li>
<li>
  <a href="#131_DDL">1.3.1 DDL语句(数据定义语言)</a><ul>
    <li>
      <ul>
        <li>
          <a href="#1311nbsp">1.3.1.1&nbsp; 数据库查看</a>
        </li>
        <li>
          <a href="#1312nbsp">1.3.1.2&nbsp; 数据库操作</a>
        </li>
        <li>
          <a href="#1313nbsp_DDL">1.3.1.3&nbsp; DDL语句之管理表</a>
        </li>
        <li>
          <a href="#1314nbsp">1.3.1.4&nbsp; 修改表的定义</a>
        </li>
        <li>
          <a href="#1315nbsp_DDL">1.3.1.5&nbsp; DDL语句小结</a>
        </li>
      </ul>
    </li>
  </ul>
</li>

<li>
  <a href="#132_DCL">1.3.2 DCL数据库控制语言</a>
</li>
<li>
  <a href="#133_DML">1.3.3 DML数据库操作语言</a><ul>
    <li>
      <ul>
        <li>
          <a href="#1331nbsp_insert">1.3.3.1&nbsp; insert 语句</a>
        </li>
        <li>
          <a href="#1332nbsp_updatewhere">1.3.3.2&nbsp; update更改数据库(一定要加上where条件)</a>
        </li>
        <li>
          <a href="#1333nbsp_deletewhere">1.3.3.3&nbsp; delete删除表内容(一定要有where条件)</a>
        </li>
        <li>
          <a href="#1334nbsp">1.3.3.4&nbsp; 生产中的伪删除</a>
        </li>
        <li>
          <a href="#1335nbsp">1.3.3.5&nbsp; 防止不加条件误删【安全】</a>
        </li>
      </ul>
    </li>
  </ul>
</li>

<li>
  <a href="#134_DQL">1.3.4 DQL数据查询语言标准语法</a><ul>
    <li>
      <ul>
        <li>
          <a href="#1341nbsp">1.3.4.1&nbsp; 语法说明</a>
        </li>
        <li>
          <a href="#1342nbsp">1.3.4.2&nbsp; 查看操作</a>
        </li>
      </ul>
    </li>
    
    <li>
      <a href="#135">1.3.5 字符集说明</a><ul>
        <li>
          <a href="#1351nbsp">1.3.5.1&nbsp; 常用的字符集</a>
        </li>
        <li>
          <a href="#1352nbsp">1.3.5.2&nbsp; 字符集设置</a>
        </li>
        <li>
          <a href="#1353nbsp_MySQL">1.3.5.3&nbsp; MySQL客户端级别(连接及返回结果)</a>
        </li>
      </ul>
    </li>
    
    <li>
      <a href="#136">1.3.6 常用的查询操作</a>
    </li>
  </ul>
</li>

<li>
  <a href="#14">1.4 数据类型说明</a><ul>
    <li>
      <a href="#141_ER">1.4.1 ER模型</a>
    </li>
    <li>
      <a href="#142">1.4.2 数据类型介绍</a>
    </li>
    <li>
      <a href="#143">1.4.3 创建带有数据类型的表</a>
    </li>
    <li>
      <a href="#144">1.4.4 数值数据类型</a>
    </li>
    <li>
      <a href="#145">1.4.5 字符串数据类型</a>
    </li>
    <li>
      <a href="#146">1.4.6 二进制字符串数据类型</a>
    </li>
    <li>
      <a href="#147">1.4.7 时间数据类型</a>
    </li>
    <li>
      <a href="#148">1.4.8 列属性</a>
    </li>
    <li>
      <a href="#149">1.4.9 数据类型小结</a>
    </li>
  </ul>
</li>

<li>
  <a href="#15SQL">1.5开发人员SQL规范:</a>
</li>
<li>
  <a href="#16">1.6 参考文献</a>
</li>