一、MySQL索引创建与删除

目标:

本案例要求熟悉MySQL索引的类型及操作方法,主要练习以下任务:

  • 普通索引、唯一索引、主键索引的创建/删除
  • 自增主键索引的创建/删除
  • 建立员工表yg、工资表gz,数据内容如下表所示,设置外键实现同步更新与同步删除

步骤:

步骤一:索引的创建与删除

1)创建表的时候指定INDEX索引字段

创建库home:

mysql> create database home;
    Query OK, 1 row affected (0.00 sec)

允许有多个INDEX索引字段。比如,以下操作在home库中创建了tea4表,将其中的id、name作为索引字段:

mysql> USE home;
    Database changed
    mysql> CREATE TABLE tea4(
        -> id char(6) NOT NULL,
        -> name varchar(6) NOT NULL,
        -> age int(3) NOT NULL,
        -> gender ENUM('boy','girl') DEFAULT 'boy',
        -> INDEX(id),INDEX(name)
        -> );
    Query OK, 0 rows affected (0.59 sec)

查看新建tea4表的字段结构,可以发现两个非空索引字段的KEY标志为MUL:

mysql> DESC tea4;
    +--------+--------------------+------+-----+---------+-------+
    | Field  | Type               | Null | Key | Default | Extra |
    +--------+--------------------+------+-----+---------+-------+
    | id     | char(6)            | NO   | MUL | NULL    |       |
    | name   | varchar(6)         | NO   | MUL | NULL    |       |
    | age    | int(3)             | NO   |     | NULL    |       |
    | gender | enum('boy','girl') | YES  |     | boy     |       |
    +--------+--------------------+------+-----+---------+-------+
    4 rows in set (0.00 sec)

2)删除现有表的某个INDEX索引字段

比如,删除tea4表中名称为named的INDEX索引字段:

mysql> drop INDEX name ON tea4;                  //删除name字段的索引
    Query OK, 0 rows affected (0.18 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    mysql> DESC tea4;                                      //确认删除结果
    +--------+--------------------+------+-----+---------+-------+
    | Field  | Type               | Null | Key | Default | Extra |
    +--------+--------------------+------+-----+---------+-------+
    | id     | char(6)            | NO   | MUL | NULL    |       |
    | name   | varchar(6)         | NO   |     | NULL    |       |
    | age    | int(3)             | NO   |     | NULL    |       |
    | gender | enum('boy','girl') | YES  |     | boy     |       |
    +--------+--------------------+------+-----+---------+-------+
    4 rows in set (0.00 sec)

3)在已有的某个表中设置INDEX索引字段

比如,针对tea4表的age字段建立索引,名称为 nianling:

mysql> CREATE INDEX nianling ON tea4(age);      //针对指定字段创建索引
    Query OK, 0 rows affected (0.62 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    mysql> DESC tea4;                                  //确认创建结果
    +--------+--------------------+------+-----+---------+-------+
    | Field  | Type               | Null | Key | Default | Extra |
    +--------+--------------------+------+-----+---------+-------+
    | id     | char(6)            | NO   | MUL | NULL    |       |
    | name   | varchar(6)         | NO   |     | NULL    |       |
    | age    | int(3)             | NO   | MUL | NULL    |       |
    | gender | enum('boy','girl') | YES  |     | boy     |       |
    +--------+--------------------+------+-----+---------+-------+
    4 rows in set (0.00 sec)

4)查看指定表的索引信息

使用SHOW INDEX 指令:

mysql> SHOW INDEX FROM tea4\G
    *************************** 1. row ***************************
            Table: tea4
       Non_unique: 1
         Key_name: id
     Seq_in_index: 1
      Column_name: id
        Collation: A
      Cardinality: 0
         Sub_part: NULL
           Packed: NULL
             Null:
       Index_type: BTREE                          //使用B树算法
          Comment:
    Index_comment:
    *************************** 2. row ***************************
            Table: tea4
       Non_unique: 1
         Key_name: nianling                       //索引名称
     Seq_in_index: 1
      Column_name: age                            //字段名称
        Collation: A
      Cardinality: 0
         Sub_part: NULL
           Packed: NULL
             Null:
       Index_type: BTREE
          Comment:
    Index_comment:
    2 rows in set (0.00 sec)

5)创建表的时候指定UNIQUE索引字段

UNIQUE表示唯一性的意思,同一个表中可以有多个字段具有唯一性。

比如,创建tea5表,将id、name字段建立设置UNIQUE索引,age字段设置INDEX索引:

mysql> CREATE TABLE tea5(
        -> id char(6),
        -> name varchar(4) NOT NULL,
        -> age int(3) NOT NULL,
        -> UNIQUE(id),UNIQUE(name),INDEX(age)
        -> );
    Query OK, 0 rows affected (0.30 sec)

查看新建tea5表的字段结构,可发现UNIQUE字段的KEY标志为UNI;另外,由于字段name必须满足“NOT NULL”的非空约束,所以将其设置为UNIQUE后会自动变成了PRIMARY KEY主键字段:

mysql> DESC tea5;                                      //确认设置结果
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | char(6)    | YES  | UNI | NULL    |       |
    | name  | varchar(4) | NO   | PRI | NULL    |       |
    | age   | int(3)     | NO   | MUL | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    3 rows in set (0.03 sec)

6)删除UNIQUE索引、在已有的表中设置UNIQUE索引字段

先删除tea5表name字段的唯一索引(与删除INDEX索引的方法相同):

mysql> DROP INDEX name ON tea5;                     //清除UNIQUE索引
    Query OK, 0 rows affected (0.97 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    mysql> DESC tea5;                                      //确认删除结果
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | char(6)    | YES  | UNI | NULL    |       |
    | name  | varchar(4) | NO   |     | NULL    |       |
    | age   | int(3)     | NO   | MUL | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    3 rows in set (0.00 sec)

重新为tea5表的name字段建立UNIQUE索引,并确认结果:

mysql> CREATE UNIQUE INDEX name ON tea5(name);      //建立UNIQUE索引
    Query OK, 0 rows affected (0.47 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    mysql> DESC tea5;                                      //确认设置结果
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | char(6)    | YES  | UNI | NULL    |       |
    | name  | varchar(4) | NO   | PRI | NULL    |       |
    | age   | int(3)     | NO   | MUL | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    3 rows in set (0.00 sec)

7)建表时设置PRIMARY KEY主键索引

主键索引实际上在前面已经接触过了,建表的时候可以直接指定。如果表内一开始没有主键字段,则新设置的非空UNIQUE字段相当于具有PRIMARY KEY主键约束。

每个表中的主键字段只能有一个。

建表的时候,可以直接在某个字段的“约束条件”部分指定PRIMARY KEY;也可以在最后指定PRIMARY KEY(某个字段名)。比如:

mysql> CREATE TABLE biao01(
        -> id int(4) PRIMARY KEY,                      //直接在字段定义时约束
        -> name varchar(8)
        -> );
    Query OK, 0 rows affected (0.19 sec)

或者:

mysql> CREATE TABLE biao02(
        -> id int(4),
        -> name varchar(8),
        -> PRIMARY KEY(id)                              //所有字段定义完,最后指定
        -> );
    Query OK, 0 rows affected (0.17 sec)

在建表的时候,如果主键字段为int类型,还可以为其设置AUTO_INCREMENT自增属性,这样当添加新的表记录时,此字段的值会自动从1开始逐个增加,无需手动指定。比如,新建一个tea6表,将id列作为自增的主键字段:

mysql> CREATE TABLE tea6(
        -> id int(4) AUTO_INCREMENT,
        -> name varchar(4) NOT NULL,
        -> age int(2) NOT NULL,
        -> PRIMARY KEY(id)
        -> );
    Query OK, 0 rows affected (0.29 sec)

8)删除现有表的PRIMARY KEY主键索引

如果要移除某个表的PRIMARY KEY约束,需要通过ALTER TABLE指令修改。比如,以下操作将清除biao01表的主键索引。

清除前(主键为id):

mysql> DESC biao01;
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | int(4)     | NO   | PRI | NULL    |       |
    | name  | varchar(8) | YES  |     | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    2 rows in set (0.00 sec)

清除操作:

mysql> ALTER TABLE biao01 DROP PRIMARY KEY;
    Query OK, 0 rows affected (0.49 sec)
    Records: 0  Duplicates: 0  Warnings: 0

清除后(无主键):

mysql> DESC biao01;
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | int(4)     | NO   |     | NULL    |       |
    | name  | varchar(8) | YES  |     | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    2 rows in set (0.00 sec)

当尝试删除tea6表的主键时,会出现异常:

mysql> ALTER TABLE tea6 DROP PRIMARY KEY;
    ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

这是因为tea6表的主键字段id具有AUTO_INCREMNET自增属性,提示这种字段必须作为主键存在,因此若要清除此主键必须先清除自增属性——修改id列的字段定义:

mysql> ALTER TABLE tea6 MODIFY id int(4) NOT NULL;
    Query OK, 0 rows affected (0.75 sec)
    Records: 0  Duplicates: 0  Warnings: 0

然后再清除主键属性就OK了:

mysql> ALTER TABLE tea6 DROP PRIMARY KEY;                  //清除主键
    Query OK, 0 rows affected (0.39 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    mysql> desc tea6;                                         //确认清除结果
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | int(4)     | NO   |     | NULL    |       |
    | name  | varchar(4) | NO   |     | NULL    |       |
    | age   | int(2)     | NO   |     | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    3 rows in set (0.01 sec)

9)为现有表添加PRIMARY KEY主键索引

重新为tea6表指定主键字段,仍然使用id列:

mysql> ALTER TABLE tea6 ADD PRIMARY KEY(id);              //设置主键字段
    Query OK, 0 rows affected (0.35 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    mysql> DESC tea6;                                          //确认设置结果
    +-------+------------+------+-----+---------+-------+
    | Field | Type       | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | id    | int(4)     | NO   | PRI | NULL    |       |
    | name  | varchar(4) | NO   |     | NULL    |       |
    | age   | int(2)     | NO   |     | NULL    |       |
    +-------+------------+------+-----+---------+-------+
    3 rows in set (0.00 sec)

步骤二:创建数据库并设置外键实现同步更新与同步删除

根据实验任务要求,两个表格的字段结构如上面表所示。

1)创建yg表,用来记录员工工号、姓名

其中yg_id列作为主键,并设置自增属性

mysql> CREATE TABLE yg(
        -> yg_id int(4) AUTO_INCREMENT,
        -> name char(16) NOT NULL,
        -> PRIMARY KEY(yg_id)
        -> );
    Query OK, 0 rows affected (0.15 sec)

2)创建gz表,用来记录员工的工资信息

其中gz_id需要参考员工工号,即gz表的gz_id字段设为外键,将yg表的yg_id字段作为参考键:

mysql> CREATE TABLE gz(
        -> gz_id int(4) NOT NULL,
        -> name char(16) NOT NULL,
        -> gz float(7,2) NOT NULL DEFAULT 0,
        -> INDEX(name),
        -> FOREIGN KEY(gz_id) REFERENCES yg(yg_id)
        -> ON UPDATE CASCADE ON DELETE CASCADE
        -> );
    Query OK, 0 rows affected (0.23 sec)

3)为yg表添加2条员工信息记录

因yg_id有AUTO_INCREMENT属性,会自动填充,所以只要为name列赋值就可以了。

插入表记录可使用INSERT指令,这里先执行下列操作,具体在下一章学习:

mysql> INSERT INTO yg(name) VALUES('Jerry'),('Tom');
    Query OK, 2 rows affected (0.16 sec)
    Records: 2  Duplicates: 0  Warnings: 0

确认yg表的数据记录:

mysql> SELECT * FROM yg;
    +-------+-------+
    | yg_id | name  |
    +-------+-------+
    |     1 | Jerry |
    |     2 | Tom   |
    +-------+-------+
    2 rows in set (0.00 sec)

4)为gz表添加2条工资信息记录

同上,数据参考图-2,插入相应的工资记录(gz_id字段未指定默认值,也未设置自增属性,所以需要手动赋值):

mysql> INSERT INTO gz(gz_id,name,gz)
        -> VALUES(1,'Jerry',12000),(2,'Tom',8000)
        -> ;
    Query OK, 2 rows affected (0.06 sec)
    Records: 2  Duplicates: 0  Warnings: 0

确认gz表的数据记录:

mysql> SELECT * FROM gz;
    +-------+-------+----------+
    | gz_id | name  | gz       |
    +-------+-------+----------+
    |     1 | Jerry | 12000.00 |
    |     2 | Tom   |  8000.00 |
    +-------+-------+----------+
    2 rows in set (0.05 sec)

5)验证表记录的UPDATE更新联动

将yg表中Jerry用户的yg_id修改为1234:

mysql> update yg SET yg_id=1234 WHERE name='Jerry';
    Query OK, 1 row affected (0.05 sec)
    Rows matched: 1  Changed: 1  Warnings: 0

确认修改结果:

mysql> SELECT * FROM yg;
    +-------+-------+
    | yg_id | name  |
    +-------+-------+
    |     2 | Tom   |
    |  1234 | Jerry |
    +-------+-------+
    2 rows in set (0.00 sec)

同时也会发现,gz表中Jerry用户的gz_id也跟着变了:

mysql> SELECT * FROM gz;
    +-------+-------+----------+
    | gz_id | name  | gz       |
    +-------+-------+----------+
    |  1234 | Jerry | 12000.00 |
    |     2 | Tom   |  8000.00 |
    +-------+-------+----------+
    2 rows in set (0.00 sec)

6)验证表记录的DELETE删除联动

删除yg表中用户Jerry的记录:

mysql> DELETE FROM yg WHERE name='Jerry';
    Query OK, 1 row affected (0.05 sec)

确认删除结果:

mysql> SELECT * FROM yg;
    +-------+------+
    | yg_id | name |
    +-------+------+
    |     2 | Tom  |
    +-------+------+
    1 row in set (0.00 sec)

查看gz表中的变化(Jerry的记录也没了):

mysql> SELECT * FROM gz;
    +-------+------+---------+
    | gz_id | name | gz      |
    +-------+------+---------+
    |     2 | Tom  | 8000.00 |
    +-------+------+---------+
    1 row in set (0.00 sec)

7)删除指定表的外键约束

先通过SHOW指令获取表格的外键约束名称:

mysql> SHOW CREATE TABLE gz\G
    *************************** 1. row ***************************
           Table: gz
    Create Table: CREATE TABLE `gz` (
      `gz_id` int(4) NOT NULL,
      `name` char(16) NOT NULL,
      `gz` float(7,2) NOT NULL DEFAULT '0.00',
      KEY `name` (`name`),
      KEY `gz_id` (`gz_id`),
      CONSTRAINT `gz_ibfk_1` FOREIGN KEY (`gz_id`) REFERENCES `yg` (`yg_id`) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)

其中gz_ibfk_1即删除外键约束时要用到的名称。

删除操作:

mysql> ALTER TABLE gz DROP FOREIGN KEY gz_ibfk_1;
    Query OK, 0 rows affected (0.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0

确认删除结果:

mysql> SHOW CREATE TABLE gz\G
    *************************** 1. row ***************************
           Table: gz
    Create Table: CREATE TABLE `gz` (
      `gz_id` int(4) NOT NULL,
      `name` char(16) NOT NULL,
      `gz` float(7,2) NOT NULL DEFAULT '0.00',
      KEY `name` (`name`),
      KEY `gz_id` (`gz_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)

二、MySQL存储引擎的配置

目标:

本案例要求MySQL数据存储引擎的使用,完成以下任务操作:

  1. 可用的存储引擎类型
  2. 查看默认存储类型
  3. 更改表的存储引擎

步骤:

步骤一:查看存储引擎信息

登入MySQL服务器,查看当前支持哪些存储引擎。

使用mysql命令连接,以root用户登入:

[root@dbsvr1 ~]# mysql -u root –p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 9
    Server version: 5.7.17 MySQL Community Server (GPL)
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql>

执行SHOW ENGINES\G指令可列表查看,MySQL 5.6可用的存储引擎有9种(除最后的FEDERATED以外,其他8种都支持),其中默认采用的存储引擎为InnoDB:

mysql> SHOW ENGINES\G
    *************************** 1. row ***************************
          Engine: InnoDB
         Support: DEFAULT                              //此存储引擎为默认
         Comment: Supports transactions, row-level locking, and foreign keys
    Transactions: YES
              XA: YES
      Savepoints: YES
    *************************** 2. row ***************************
          Engine: MRG_MYISAM
         Support: YES
         Comment: Collection of identical MyISAM tables
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 3. row ***************************
          Engine: MEMORY
         Support: YES
         Comment: Hash based, stored in memory, useful for temporary tables
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 4. row ***************************
          Engine: BLACKHOLE
         Support: YES
         Comment: /dev/null storage engine (anything you write to it disappears)
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 5. row ***************************
          Engine: MyISAM
         Support: YES
         Comment: MyISAM storage engine
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 6. row ***************************
          Engine: CSV
         Support: YES
         Comment: CSV storage engine
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 7. row ***************************
          Engine: ARCHIVE
         Support: YES
         Comment: Archive storage engine
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 8. row ***************************
          Engine: PERFORMANCE_SCHEMA
         Support: YES
         Comment: Performance Schema
    Transactions: NO
              XA: NO
      Savepoints: NO
    *************************** 9. row ***************************
          Engine: FEDERATED
         Support: NO                             //此引擎不被支持
         Comment: Federated MySQL storage engine
    Transactions: NULL
              XA: NULL
      Savepoints: NULL
    9 rows in set (0.01 sec)

或者直接查看系统变量default_storage_engine 的值,也可确认默认采用的存储引擎是InnoDB:

mysql> SHOW VARIABLES LIKE 'default_storage_engine';
    +------------------------+--------+
    | Variable_name          | Value  |
    +------------------------+--------+
    | default_storage_engine | InnoDB |
    +------------------------+--------+
    1 row in set (0.00 sec)

步骤二:修改默认存储引擎

在 mysql> 环境中,可以直接通过SET指令更改默认的存储引擎(只在本次连接会话过程中有效,退出重进即失效) 。比如临时修改为MyISAM,可执行下列操作:

mysql> SET default_storage_engine=MyISAM;              //改用MyISAM引擎
    Query OK, 0 rows affected (0.00 sec)
    mysql> SHOW VARIABLES LIKE 'default_storage_engine';          //确认结果
    +------------------------+--------+
    | Variable_name          | Value  |
    +------------------------+--------+
    | default_storage_engine | MyISAM |
    +------------------------+--------+
    1 row in set (0.00 sec)

若希望直接修改MySQL服务程序所采用的默认存储引擎,应将相关设置写入配置文件/etc/my.cnf,并重启服务后生效。比如:

[root@dbsvr1 ~]# vim /etc/my.cnf
    [mysqld]
    .. ..
    default_storage_engine=MEMORY                              //改用MEMORY引擎
    [root@dbsvr1 ~]# systemctl  restart mysqld.service           //重启服务

重新登入 mysql> 确认修改结果:

[root@dbsvr1 ~]# mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 3
    Server version: 5.7.17 MySQL Community Server (GPL)
    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql> SHOW VARIABLES LIKE 'default_storage_engine';
    +------------------------+--------+
    | Variable_name          | Value  |
    +------------------------+--------+
    | default_storage_engine | MEMORY |                  //默认引擎已修改
    +------------------------+--------+
    1 row in set (0.00 sec)
    mysql> exit
    Bye

为了避免后续实验障碍,测试完后记得恢复原状——移除默认引擎设置,或者将其修改为InnoDB即可:

[root@dbsvr1 ~]# vim /etc/my.cnf
    [mysqld]
    .. ..
    default_storage_engine=InnoDB
    [root@dbsvr1 ~]# systemctl  restart mysqld.service

确认恢复结果(选项 -e 可调用指定的SQL操作后返回Shell命令行):

[root@dbsvr1 ~]# mysql -u root -p -e "SHOW VARIABLES LIKE 'default_storage_engine';"
    Enter password:
    +------------------------+--------+
    | Variable_name          | Value  |
    +------------------------+--------+
    | default_storage_engine | InnoDB |
    +------------------------+--------+

 附加:

1> 创建index 索引:
create  table  表名(
字段名列表,
index(字段名1),   //创建表时 指定索引字段
index(字段名2),
...
index(字段名n)
);

2>

Database基础(二):MySQL索引创建与删除、 MySQL存储引擎的配置的更多相关文章

  1. Mysql索引创建及删除

    1.索引 MySQL索引的建立对于MySQL的高效运行是很重要的,索引可以大大提高MySQL的检索速度. 打个比方,如果合理的设计且使用索引的MySQL是一辆兰博基尼的话,那么没有设计和使用索引的My ...

  2. mysql索引创建&查看&删除

    1.索引作用 在索引列上,除了上面提到的有序查找之外,数据库利用各种各样的快速定位技术,能够大大提高查询效率.特别是当数据量非常大,查询涉及多个表时,使用索引往往能使查询速度加快成千上万倍. 例如,有 ...

  3. MySQL索引创建、删除、查看

    主键索引   PRIMARY KEY索引仅是一个具有名称PRIMARY的UNIQUE索引.这表示一个表只能包含一个PRIMARY KEY,因为一个表中不可能具有两个同名的索引. ALTER TABLE ...

  4. 索引-mysql索引创建、查看、删除及使用示例

    mysql索引创建.查看.删除及使用示例 1.创建索引: ALTER TABLE用来创建普通索引.UNIQUE索引或PRIMARY KEY索引. ALTER TABLE table_name ADD ...

  5. MySQL索引的缺点以及MySQL索引在实际操作中有哪些事项

    以下的文章主要介绍的是MySQL索引的缺点以及MySQL索引在实际操作中有哪些事项是值得我们大家注意的,我们大家可能不知道过多的对索引进行使用将会造成滥用.因此MySQL索引也会有它的缺点: 虽然索引 ...

  6. MySQL索引类型一览 让MySQL高效运行起来(转)

    转自:http://www.php100.com/html/webkaifa/database/Mysql/2010/0409/4279.html 索引是快速搜索的关键.MySQL索引的建立对于MyS ...

  7. MySQL - 常见的三种数据库存储引擎

    原文:MySQL - 常见的三种数据库存储引擎 数据库存储引擎:是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建.查询.更新和删除数据.不同的存储引擎提供不同的存储机制.索引技巧. ...

  8. Mysql 用户 创建与删除(基础1)

    Mysql是最流行的关系型数据库管理系统之一,由瑞典MySQL AB公司开发,目前属于Oracle公司. MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个 ...

  9. mysql索引 ->创建索引、修改索引、删除索引的命令语句

    查看表中已经存在 index:show index from table_name; 创建和删除索引索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或ALTER ...

随机推荐

  1. Codechef BINOMSUM

    题意:(复制sunset的)有\(T\)天,每天有\(K\)个小时,第\(i\)天有\(D+i−1\)道菜,第一个小时你选择\(L\)道菜吃,接下来每个小时你可以选择吃一道菜或者选择\(A\)个活动中 ...

  2. Bugku | Easy_vb

    载入ida,直接搜‘ctf’就有了,坑点是不要交“MCTF{XXX}”,要交“flag{XXXX}”

  3. cordova打包apk流程

    一.打包 条件: 1.java-jdk 2.Android-sdk  ( 安装教程:https://blog.csdn.net/qq_36577136/article/details/80632674 ...

  4. 转载:eclipse中web项目小地球没了

    转载自:{FROM:http://www.cnblogs.com/zhouyalei/archive/2013/01/30/2882651.html} MyEclipse下创建的项目 导入eclips ...

  5. php 封装原生数据导入的方法(csv文件格式)

    //前端---部分代码 <form class="form-inline" style="margin-top: 20px" method="p ...

  6. shell 截取变量的字符串

    假设有变量 var=http://www.linuxidc.com/test.htm一 # 号截取,删除左边字符,保留右边字符.echo ${var#*//}其中 var 是变量名,# 号是运算符,* ...

  7. H5rem

    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1, ...

  8. 微众银行c++选择题后记

    一个类的成员可以有:另一个类的对象,类的自身指针,自身类对象的引用(私有的如何初始化呢,所以不行,换成静态的可以),自身类对象(构造时如何初始化呢?) class A{ public: A(){} A ...

  9. 《单词的减法》state1~state17(第三遍学习记录)

    2016.05.24 state 8 curse/curve dedication 多用于奉献和献身 disastrous disruptive distract state 9 domestic/d ...

  10. Percona XtraDB Cluster集群5.7 开启SSL认证

    mysqldump -uroot -p --ssl-cert=/data/mysql/client-cert.pem --ssl-key=/data/mysql/client-key.pem -h 1 ...