文章目录
存储引擎
存储引擎是MySQL中特有的一个术语,其它数据库中没有。(Oracle中有,但是不叫这个名字)
存储引擎是一个表存储/组织数据的方式。不同的存储引擎,表存储数据的方式不同。
1 查看表的存储引擎
mysql> show create table t_student;
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t_student | CREATE TABLE `t_student` (
`no` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`cno` int(11) DEFAULT NULL,
PRIMARY KEY (`no`),
KEY `cno` (`cno`),
CONSTRAINT `t_student_ibfk_1` FOREIGN KEY (`cno`) REFERENCES `t_class` (`classno`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 |
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
结论:
- mysql默认的存储引擎是:InnoDB
- mysql默认的字符编码方式是:utf8
2 指定存储引擎和编码
建表时指定存储引擎,以及字符编码方式
create table t_product(
id int primary key,
name varchar(255)
)engine=InnoDB default charset=gbk;
mysql> desc t_product;
+-------+--------------