<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 創建索引 #### 建表時: ~~~ mysql> create table 表名( -> id int primary key, //主鍵索引 -> name varchar(20) unique key, //唯一索引 -> age tinyint, -> intro varchar(20), -> index(age), //普通索引 -> fulltext index(intro), //全文索引 -> index(name,age) //復合索引 ); ~~~ **注意**: **索引可以起名字,但是主索引不能起名字**,因為一個表僅僅可以有一個主鍵索引,其他索引可以出現多個。名字可以省略,mysql會默認生成,通常使用字段名來充當。 #### 更新表結構 ~~~ alter table 表名 add primary key(id),add unique key(name),add index(age),add fulltext index(intro),add index(name,age) ; ~~~ **注意:** 1. 如果表中存在數據,數據符合唯一或主鍵約束才可能創建成功. 2. auto_increment屬性,依賴于一個KEY(主鍵或唯一). ### 刪除索引 修改表結構時完成: **刪除主鍵索引:** ~~~ alter table 表名 drop primary key; ~~~ 如果在刪除主鍵索引時,該字段中有auto_increment則先去掉該屬性再刪除。 ~~~ alter table 表名 modify 主鍵字段名 字段屬性; ~~~ **刪除其他索引** ~~~ alter table t1 drop index 索引名稱; ~~~ 可以通過show create table 表名; 查看索引名稱. ~~~ | t1 | CREATE TABLE `t1` ( `id` int(11) NOT NULL, `name` varchar(20) DEFAULT NULL, `age` tinyint(4) DEFAULT NULL, `intro` varchar(50) DEFAULT NULL, UNIQUE KEY `name` (`name`), KEY `age` (`age`), KEY `name_2` (`name`,`age`), FULLTEXT KEY `intro` (`intro`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | ~~~ ### 查看索引 ~~~ show index from 表名; ~~~ 結果 ~~~ +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | t1 | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | | | t1 | 0 | name | 1 | name | A | 0 | NULL | NULL | YES | BTREE | | | | t1 | 1 | age | 1 | age | A | 0 | NULL | NULL | YES | BTREE | | | | t1 | 1 | name_2 | 1 | name | A | 0 | NULL | NULL | YES | BTREE | | | | t1 | 1 | name_2 | 2 | age | A | 0 | NULL | NULL | YES | BTREE | | | | t1 | 1 | intro | 1 | intro | NULL | 0 | NULL | NULL | YES | FULLTEXT | | | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ ~~~ * * * * * ~~~ show create table 表名; ~~~ * * * * * ~~~ desc 表名; ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看