MySQL的小对象(索引和事务)外加引擎介绍

数据库索引概念

一,数据库索引

​ 在数据库中,索引使数据库程序无须对整个表进行扫描,就可以在其中找到所有数据,数据库的索引是某个表中一列或者若干列值的集合,以及物理标识这些值的数据页的逻辑指针清单

二,索引的作用

1,设置合适的索引之后,数据库利用各种快速的定位技术,能够加快查询速率,特别是当表很大时,或者查询涉及到多个表时,使用索可使查询加快成千倍。

2,可以降低数据库的IO成本,并且索引还可以降低数据库的排序成本。

3,通过创建唯一性 索引保证数据表数据的唯一性, 可以加快表与表之间的连接。

4,在使用分组和排序时,可大大减少分组和排序时间。

三,索引的分类

1,普通索引

这是最基本的索引类型,而且没有唯一性之类的限制。

2,唯一性索引

与普通索引基本相同,区别在于:索引列的所有值都只能出现一次,即必须唯一,但可为空

3,主键

是一种特殊的唯一索引, 必须指定为“PRIMARY KEY",具有唯一性的同时不能为空

4,全文索引

MySQL从3.23.23版开始支持全文索引和全文检索。在MySQL中,全文索引的类型为FULLTEXT,全文索引可以在VARCHAR或者TEXT类型的列上创建。贴吧的文本内容,和一些小型的网站网页内容,存放在数据库中即为全文索引模式。

5,单列索引与多列索引

索引可以是单列上创建的索引,也可以是多列上创建的索引。

四,创建索引的原则依据

1、表的主键、外键必须有索引
2、数量超过300行的表应该有索引
3、经常与其他表进行连接的表,在连接字段上应该建立索引
4、唯一性太差的字段不适合建立索引
5、更新太频繁的字段不适合创建索引
6、经常出现在where字句中的字段,特别是大表的字段,应该建立索引
7、索引应该建在选择性高的字段上。
8、索引应该建立在小字段上,对于大的文本字段甚至超长字段,不要建立索引

五,创建,查看,删除索引的方法。

​ 根据企业需求选择了合适的索引之后,可以使用CREATE INDEX创建索引,CREATE INDEX加上各个索引关键字便可创建各个类型的索引。

案例:创建公司IT运营部工资数据表

需求描述:为公司建立员工工资数据库imployee_salary,在imployee_salary数据库中,建立IT_salary数据表,以保存IT员工的工资信息,如下表显示。

安装mariadb

[root@localhost ~] yum -y install mariadb mariadb-server
[root@localhost ~] systemctl start mariadb
[root@localhost ~] netstat -anpt | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      17433/mysqld 

建立数据库imployee_salary

[root@localhost ~] vim /etc/my.cnf
[client]
default-character-set=utf8
[root@localhost ~] systemctl start mariadb

[root@localhost ~] mysql
MariaDB [(none)]> create database imployee_salary default charset utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use imployee_salary;
Database changed

建立数据表IT_salary

MariaDB [imployee_salary]> create table IT_salary(岗位类别 char(20) not null, 姓名 char(20) not null, 年龄 int, 员工ID int not null, 学历 char(6),年限 int,薪资 int not null,primary key(员工ID));
Query OK, 0 rows affected (0.03 sec)

//int 数字类型,char 字符串类型, not null 不能为空,char()指定最多字节个数, primary key() 指定索引字段

MariaDB [imployee_salary]> desc IT_salary;
+--------------+----------+------+-----+---------+-------+
| Field        | Type     | Null | Key | Default | Extra |
+--------------+----------+------+-----+---------+-------+
| 岗位类别     | char(20) | NO   |     | NULL    |       |
| 姓名         | char(20) | NO   |     | NULL    |       |
| 年龄         | int(11)  | YES  |     | NULL    |       |
| 员工ID       | int(11)  | NO   | PRI | NULL    |       |
| 学历         | char(6)  | YES  |     | NULL    |       |
| 年限         | int(11)  | YES  |     | NULL    |       |
| 薪资         | int(11)  | NO   |     | NULL    |       |
+--------------+----------+------+-----+---------+-------+
7 rows in set (0.00 sec)

将it运营部的员工工资信息插入到IT_salary

insert into IT_salary(岗位类别,姓名,年龄,员工ID,学历,年限,薪资) values ('网络工程师','孙空武',27,011,'本科',3,4800);
insert into IT_salary(岗位类别,姓名,年龄,员工ID,学历,年限,薪资) values ('windows工程师','蓝凌',19,012,'中专',2,3500);
insert into IT_salary(岗位类别,姓名,年龄,员工ID,学历,年限,薪资) values ('Linux工程师','姜纹',32,013,'本科',8,15000);
insert into IT_salary(岗位类别,姓名,年龄,员工ID,学历,年限,薪资) values ('java工程师','关园',38,014,'大专',10,16000);
insert into IT_salary(岗位类别,姓名,年龄,员工ID,学历,年限,薪资) values ('硬件驱动工程师','罗中昆',29,015,'本科',9,16500);
MariaDB [imployee_salary]> select * from IT_salary;
+-----------------------+-----------+--------+----------+--------+--------+--------+
| 岗位类别              | 姓名      | 年龄   | 员工ID   | 学历   | 年限   | 薪资   |
+-----------------------+-----------+--------+----------+--------+--------+--------+
| 网络工程师             | 孙空武    |     27 |       11 | 本科   |      3  |   4800  |
| windows工程师         | 蓝凌      |     19 |       12 | 中专   |      2 |   3500  |
| Linux工程师           | 姜纹      |     32 |       13 | 本科   |      8 |  15000  |
| java工程师            | 关园      |     38 |       14 | 大专   |     10 |  16000  |
| 硬件驱动工程师         | 罗中昆    |     29 |       15 | 本科    |      9  |  16500  |
+-----------------------+-----------+--------+----------+--------+--------+--------+
5 rows in set (0.00 sec)

1,创建普通索引

格式:create index <索引的名字> on 表名(字段)

MariaDB [imployee_salary]> create index salary_index on IT_salary(薪资);
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

查看索引

MariaDB [imployee_salary]> show index from IT_salary \G
*************************** 1. row ***************************
        Table: IT_salary
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: 员工ID
    Collation: A
  Cardinality: 2
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
*************************** 2. row ***************************
        Table: IT_salary
   Non_unique: 1
     Key_name: salary_index
 Seq_in_index: 1
  Column_name: 薪资
    Collation: A
  Cardinality: 5
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
2 rows in set (0.00 sec)

2,创建唯一性索引

格式:create unique index <索引的名字> on 表名(字段);

MariaDB [imployee_salary]> create unique index salary_unique_index on IT_salary(姓名);
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0
MariaDB [imployee_salary]> show index from IT_salary \G
*************************** 1. row ***************************
        Table: IT_salary
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: 员工ID
    Collation: A
  Cardinality: 5
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
*************************** 2. row ***************************
        Table: IT_salary
   Non_unique: 0
     Key_name: salary_unique_index
 Seq_in_index: 1
  Column_name: 姓名
    Collation: A
  Cardinality: 5
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
*************************** 3. row ***************************
        Table: IT_salary
   Non_unique: 1
     Key_name: salary_index
 Seq_in_index: 1
  Column_name: 薪资
    Collation: A
  Cardinality: 5
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
3 rows in set (0.00 sec)

3,创建主键索引

格式 create table 表名 ([…],primary key(字段));

​ alter table 表名 add primary key(字段);

示例:

create table IT_salary(岗位类别 char(20) not null, 姓名 char(20) not null, 年龄 int, 员工ID int not null, 学历 char(6),年限 int,薪资 int not null,primary key(员工ID));

若在新建表时忘记创建主键,可以进行如下操作,

MariaDB [imployee_salary]> alter table IT_salary add primary key(员工ID);

4,查看索引

格式: show index from 表名;

​ show keys from 表名;

MariaDB [imployee_salary]> show index from IT_salary \G;
MariaDB [imployee_salary]> show keys from IT_salary \G;

5,删除索引

格式:drop index <索引的名称> on 表名;

​ alter table 表名 drop index <索引的名称>;

​ alter table 表名 drop primary key;

:前两条命令作用相同,由于每个表只允许有一个primary key 所以不能指定名称。

MariaDB [imployee_salary]> drop index salary_index on IT_salary;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [imployee_salary]> alter table IT_salary drop index salary_unique_index;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [imployee_salary]> alter table IT_salary drop primary key;
Query OK, 5 rows affected (0.01 sec)               
Records: 5  Duplicates: 0  Warnings: 0

MariaDB [imployee_salary]> show keys from IT_salary;
Empty set (0.00 sec)

数据库事务的概念

​ 事务是一种机制、一个操作序列,包含了一组数据库操作命令,并且把所有的命令作为一个整体一起向系统提交或撤销操作请求,即这一组数据库命令要 么都执行,要么不都执行。
​ 事务是一个不可分割的工作逻辑单元,在数据库系统上执行并发操作时,事务是最小的
控制单元。
​ 事务适用于多用户同时操作的数据库系统的场景,如银行、保险公司及证券交易系统等等。通过事务的完整性以保证数据的一致性。

一,事务的ACID特点

事务具有四个属性:ACID

  • 原子性(Atomicity)
  • 一致性(Consistency)
  • 隔离性 (lsolation)
  • 持久性 (Durability)

1,原子性

事务是一个完整的操作,事务的各元素是不可分的(原子的),事务的所有元素必须作为一个整体提交或回滚。如果事务中的任何元素失败,则整个事务将失败。

2,一致性

当事务完成时,数据必须处于一致状态: 在事务开始之前,数据库汇总存储的数据处于一致状态; 在正在进行的事务中,数据可能处于不一致的状态;当事务完成时,数据必须再次回到已知的一致状态。

3,隔离性

对数据进行修改的所有并发事务是彼此隔离的,这表明事务必须是独立的,它不应该以任何方式依赖于或影响其他事务。修改数据的事务可以在另一个使用相同数据的事务开始之前访问这些数据,或者在另一个使用相同数据的事务结束之后访问这些数据。

4,持久性

事务的持久性指不管系统是否发生了故障,事务处理的结果都是永久的,一旦事务被提交,事务的结果会被永久的保留在数据库中。

二,事务的操作

​ 默认情况下mysql的事务是自动提交的,当sql语句提交事务便自动提交。

手动对事务进行控制的方法

  • 事务处理命令控制
  • 使用set试着事务处理方式

事务处理命令控制事务

begin 开始一个事务
commit 提交一个事务
rollback 回滚一个事务(撤销)

事务的操作必须基于lnnodb存储引擎

commit示例

MariaDB [(none)]> create database auth;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> use auth;
Database changed

MariaDB [auth]>  create table users(user_name char(18) not null, user_passwd char(50) default '',primary key (user_name));
Query OK, 0 rows affected (0.02 sec)

MariaDB [auth]> alter table auth.users engine=innodb;
Query OK, 0 rows affected (0.00 sec)               
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [auth]> begin;   //事务开始
Query OK, 0 rows affected (0.00 sec)

MariaDB [auth]> insert into users values ("lisi",password('123123')); 
Query OK, 1 row affected (0.00 sec)

MariaDB [auth]> insert into users values ("wangwu",password('654321')); 
Query OK, 1 row affected (0.00 sec)

MariaDB [auth]> commit;  //提交事务
Query OK, 0 rows affected (0.00 sec)

MariaDB [auth]> select * from users;
+-----------+-------------------------------------------+
| user_name | user_passwd                               |
+-----------+-------------------------------------------+
| lisi      | *E56A114692FE0DE073F9A1DD68A00EEB9703F3F1 |
| wangwu    | *2A032F7C5BA932872F0F045E0CF6B53CF702F2C5 |
+-----------+-------------------------------------------+
2 rows in set (0.00 sec)

rollback实例;

MariaDB [auth]> begin;   //事务开始
Query OK, 0 rows affected (0.00 sec)

MariaDB [auth]> update users set user_passwd=password("") where user_name="lisi";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [auth]> rollback;  //回滚(撤销操作)从begin开始的所有命令都将被撤销
Query OK, 0 rows affected (0.00 sec)

MariaDB [auth]> select * from users;
+-----------+-------------------------------------------+
| user_name | user_passwd                               |
+-----------+-------------------------------------------+
| lisi      | *E56A114692FE0DE073F9A1DD68A00EEB9703F3F1 |
| wangwu    | *2A032F7C5BA932872F0F045E0CF6B53CF702F2C5 |
+-----------+-------------------------------------------+
2 rows in set (0.00 sec)

使用set命令进行控制

set autocommit=0 禁止自动提交;

set autocommit=1 开启自动提交

MariaDB [auth]> set autocommit = 0;
Query OK, 0 rows affected (0.00 sec)

MariaDB [auth]> insert into users values ('zhaoliu',password('123123'));
Query OK, 1 row affected (0.01 sec)

MariaDB [auth]> insert into users values ('lilili',password('111111'));
Query OK, 1 row affected (0.00 sec)

MariaDB [auth]> commit;
Query OK, 0 rows affected (0.01 sec)

MariaDB [auth]> select * from users;
+-----------+-------------------------------------------+
| user_name | user_passwd                               |
+-----------+-------------------------------------------+
| lilili    | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| lisi      | *E56A114692FE0DE073F9A1DD68A00EEB9703F3F1 |
| wangwu    | *2A032F7C5BA932872F0F045E0CF6B53CF702F2C5 |
| zhaoliu   | *E56A114692FE0DE073F9A1DD68A00EEB9703F3F1 |
+-----------+-------------------------------------------+
4 rows in set (0.00 sec)

存储引擎概念

​ MySQL数据库中使用各种不同的技术存储数据到文件系统中,每一种技术都使用不同的存储机制、索引技巧,锁定水平并最终提供不同的功能和能力,这些不同的技术以及配套的功能在MySQL中称为存储引擎。
​ 存储引擎就是MySQL将数据存储在文件系统中的存储方式或者存储格式
​ 目前MySQL常用的两种存储引擎: MyISAM、 InnoDB.
​ MySQL存储引擎是MySQL数据库服务器中的组件,负责为数据库执行实际的数据I/0操作,使用特殊存储引擎的主要优点之一在于仅需提供特殊应用所需的特性,数据库中的系统开销较小,具有更有效和更高的数据库性能。
​ MySQL系统中,存储引擎处于文件系统之上,在数据保存到数据文件之前会传输到存储引擎,之后按照各个存储引擎的存储格式进行文件的物理存储。

mysql日志种类

  • 错误日志:程序运行,启动类的故障
  • 二进制日志:保存数据库变更语句
  • 中继日志:缓存二进制日志数据
  • 查询日志:记录查询语句的(一般不开启)
  • 慢查询日志:记录超时的查询语句
一,MyISAM简介

1,MyISAM概述

​ MyISAM存储引擎是MySQL关系数据库系统5.5版本之前默认的存储引擎,前身是ISAM。
​ ISAM是一个定义明确且经历时间考验的数据表格管理方法,在设计之时就考虑到数据库被查询的次数要远大于更新的次数。。
​ ISAM的特点: ISAM执行读取操作的速度很快,而且占用不大量的内存和存储资源,它不支持事务处理,不能够容错。。
​ MyISAM管理非事务表,是ISAM的扩展格式,提供ISAM里所没有的索引和字段管理的大量功能。。
​ MyISAM使用一种表格锁定的机制,以优化多个并发的读写操作。MyISAM 提供高速存储和检索,以及全文搜索能力,受到web开发的青睐。。

2,MyISAM的特点

(1)不支持事务
(2)表级锁定形式,数据在更新时锁定整个表。
(3)数据库在读写过程中相互阻塞(会在数据写入的过程中阻塞用户数据的读取,也会在数据读取的过程中阻塞用户的数据写入)。
(4)可以通过key buffer. size 来设置缓存索引,提高访问性能,减少磁盘I0的压力,但缓.存只会缓存索引文件,不会缓存数据。
(5)采用MyISAM存储引擎数据单独写入或读取,速度过程较快而且占用资源相对较少。
(6) MyISAM 存储引擎不支持外键約束,只支持全文索引
(7)每个MyISAM在磁盘上存储成三个文件,每- -个文件的名字以表的名字开始,扩展名指出文件类型。

.frm 文件存储表定义

.MYD 文件存储数据(MYData)

.MYI 文件存储索引文件(MYIndex)

3,MyISAM使用的场景

(1)公司业务不需要事务支持。
(2) 一般单方读取数据比较多的业务,或单方面写入数据比较多的业务,如: www.blog,图片信息数据库,用户数据库,商品库等业务,MyISAM存储引擎数据读写都比较频繁的场景不适合。
(3)对数据业务一致性要 求不是非常高的业务。
(4)使用读写并发访问相对较低的业务。
(5)数据修改相对较少的业务。
(6)服务器硬件资源相对比较差,

二,InnoDB的介绍

1,InnoDB的特点

(1) 支持事务:支持4个事务隔离级别.
(2)行级锁定,但是全表扫描仍然会是表级锁定
(3)读写阻塞与事务隔离级别相关
(4)具有非常高效的缓存特性:能缓存索引,也能缓存数据.
(5)表与主键以簇的方式存储。
(6)支持分区、表空间,类似oracle
数据库。
(7)支持外键约束,5.5以前不支持全文索引,5.5版本以后支持全文索引
(8)对硬件资源要求比较高

2,InnoDB使用的生产场景

(1) 业务需要事务的支持。
(2)行级锁定对高并发有很好的适应能力,但需要确保查询是通过索引来完成。
(3) 业务数据更新较为频繁的场景,如:论坛,微博。
(4) 业务数据-致性要求较高,如:银行业务。
(5) 硬件设备内存较大,利用InnoDB较好的缓存能力来提高内存利用率,减少磁盘I0的压力。

三,配置合适的存储引擎

1,查看数据库可配置的存储引擎

方法:登录mysql 使用show engines; 查看系统所支持的引擎。

MariaDB [(none)]> show engines \G
*************************** 1. row ***************************
      Engine: MEMORY
     Support: YES
     Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 2. row ***************************
      Engine: MRG_MYISAM
     Support: YES
     Comment: Collection of identical MyISAM tables
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 3. row ***************************
      Engine: CSV
     Support: YES
     Comment: CSV storage engine
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: InnoDB
     Support: DEFAULT
     Comment: Percona-XtraDB, Supports transactions, row-level locking, and foreign keys
Transactions: YES
          XA: YES
  Savepoints: YES
*************************** 7. row ***************************
      Engine: ARCHIVE
     Support: YES
     Comment: Archive storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 8. row ***************************
      Engine: FEDERATED
     Support: YES
     Comment: FederatedX pluggable storage engine
Transactions: YES
          XA: NO
  Savepoints: YES
*************************** 9. row ***************************
      Engine: PERFORMANCE_SCHEMA
     Support: YES
     Comment: Performance Schema
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 10. row ***************************
      Engine: Aria
     Support: YES
     Comment: Crash-safe tables with MyISAM heritage
Transactions: NO
          XA: NO
  Savepoints: NO
10 rows in set (0.00 sec)

2,查看表正在使用的存储引擎

方法一:show table status from 库名 where name = ‘表名’ \G;

MariaDB [(none)]> show table status from auth where name = 'users' \G
*************************** 1. row ***************************
           Name: users
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 4
 Avg_row_length: 4096
    Data_length: 16384
Max_data_length: 0
   Index_length: 0
      Data_free: 9437184
 Auto_increment: NULL
    Create_time: 2019-11-08 04:50:05
    Update_time: NULL
     Check_time: NULL
      Collation: latin1_swedish_ci
       Checksum: NULL
 Create_options: 
        Comment: 
1 row in set (0.00 sec)

方法二:show create table 表名;

MariaDB [(none)]> show create table auth.users \G
*************************** 1. row ***************************
       Table: users
Create Table: CREATE TABLE `users` (
  `user_name` char(18) NOT NULL,
  `user_passwd` char(50) DEFAULT '',
  PRIMARY KEY (`user_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

3,配置存储引擎为所选择的类型

方法一,alter table 表名 engine=引擎;

MariaDB [(none)]> alter table auth.users engine=myisam;
Query OK, 4 rows affected (0.01 sec)               
Records: 4  Duplicates: 0  Warnings: 0

MariaDB [(none)]> show create table auth.users \G
*************************** 1. row ***************************
       Table: users
Create Table: CREATE TABLE `users` (
  `user_name` char(18) NOT NULL,
  `user_passwd` char(50) DEFAULT '',
  PRIMARY KEY (`user_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

方法二,修改my.conf 的 default-storage-engine为引擎

[root@localhost ~] vim /etc/my.cnf
[mysqld]
default-storage-engine = myisam
[root@localhost ~] systemctl restart mariadb
[root@localhost ~] mysql
MariaDB [(none)]> show engines \G;
*************************** 1. row ***************************
      Engine: MEMORY
     Support: YES
     Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 2. row ***************************
      Engine: MRG_MYISAM
     Support: YES
     Comment: Collection of identical MyISAM tables
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 3. row ***************************
      Engine: CSV
     Support: YES
     Comment: CSV storage engine
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: DEFAULT
     Comment: MyISAM storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 6. row ***************************
      Engine: InnoDB
     Support: YES
     Comment: Percona-XtraDB, Supports transactions, row-level locking, and foreign keys
Transactions: YES
          XA: YES
  Savepoints: YES
*************************** 7. row ***************************
      Engine: ARCHIVE
     Support: YES
     Comment: Archive storage engine
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 8. row ***************************
      Engine: FEDERATED
     Support: YES
     Comment: FederatedX pluggable storage engine
Transactions: YES
          XA: NO
  Savepoints: YES
*************************** 9. row ***************************
      Engine: PERFORMANCE_SCHEMA
     Support: YES
     Comment: Performance Schema
Transactions: NO
          XA: NO
  Savepoints: NO
*************************** 10. row ***************************
      Engine: Aria
     Support: YES
     Comment: Crash-safe tables with MyISAM heritage
Transactions: NO
          XA: NO
  Savepoints: NO
10 rows in set (0.00 sec)

方法三,crete teble 建立表时使用 engine=引擎

MariaDB [auth]> create table id(id int) engine=innodb;
Query OK, 0 rows affected (0.00 sec)

MariaDB [auth]> show create table auth.id \G;
*************************** 1. row ***************************
       Table: id
Create Table: CREATE TABLE `id` (
  `id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值