事务:将多条sql操作(增删改) 作为一个操作单元 要么成功 要么失败
MySQL对事务的支持:
被操作的表必须是innoDB类型的表(支持事务)
MySQL常用的表类型:MyISAM (非事务)增删改速度块
InnoDB(事务型) 安全性高
更改表结构类型InnoDB类型
alter table stu engine=innodb;
查看表结构
show create table stu\G;
mysql> create table demo( -> id int(11) unsigned not null auto_increment primary key, -> username char(50), -> ye double -> )ENGINE=InnoDB; Query OK, 0 rows affected (0.05 sec) mysql> insert into demo(username,ye) values('meizi',10000); Query OK, 1 row affected (0.02 sec)
mysql> insert into demo(username,ye) values('feng',1000000); Query OK, 1 row affected (0.00 sec) mysql> select * from demo; +----+----------+---------+ | id | username | ye | +----+----------+---------+ | 1 | meizi | 10000 | | 2 | feng | 1000000 | +----+----------+---------+ 2 rows in set (0.01 sec