美文网首页
java_sql存储引擎

java_sql存储引擎

作者: 走停2015_iOS开发 | 来源:发表于2021-01-20 09:26 被阅读0次

存储引擎就是mysql的存储方式

mysql> show create table t_student;
+-----------+-----------------------------------------------------------------+
| Table     | Create Table                                                                                                                                                                                                                                                                                                                    |
+-----------+-----------------------------------------------------------------+
| t_student | CREATE TABLE `t_student` (
  `sno` int NOT NULL,
  `sname` varchar(255) DEFAULT NULL,
  `classno` int DEFAULT NULL,
  PRIMARY KEY (`sno`),
  KEY `classno` (`classno`),
  CONSTRAINT `t_student_ibfk_1` FOREIGN KEY (`classno`) REFERENCES `t_class` (`cno`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-----------+--------------------------------------------------
//存储引擎是InnoDB
//字符集是utf8
//完整的建表语句
mysql> create table t_x (
id int(11) default null
)ENGINE = InnoDB DEFAULT CHARSET = utf8;
Query OK, 0 rows affected, 2 warnings (0.02 sec)

mysql> select *from t_x;
Empty set (0.01 sec)
//查看当前mysql支持的存储引擎
mysql> show engines \g;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |

//常见的存储引擎
1.MyISAM采用三个文件组织一张表
xxx.frm   存储格式的文件
xxx.myd   存储数据的文件
xxx.myi   存储表中索引的文件
可以被压缩

2.InnoDB是mysql缺省(默认)引擎 支持事务 外键 行级锁 等 最安全
表结构存储在xxx.frm文件中
数据存储在tablespace这样的表空间中(逻辑概念) 无法被压缩 无法被转化为只读

3.MEMORY 不支持事务 数据容易丢失 数据和索引都是存储在内存当中 优点是查询速度最快

相关文章

网友评论

      本文标题:java_sql存储引擎

      本文链接:https://www.haomeiwen.com/subject/nqhczktx.html