第一种: mysql> create table zhang(id int)type=INNODB; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type= INNODB' at line 1第二种: mysql> create table zhang(id int)engine=INNODB; Query OK, 0 rows affected (0.08 sec)mysql> insert into zhang values(1); Query OK, 1 row affected (0.06 sec)mysql> insert into zhang values(2); Query OK, 1 row affected (0.06 sec)mysql> delete from zhang where id=2; Query OK, 1 row affected (0.03 sec)mysql> rollback; Query OK, 0 rows affected (0.00 sec)mysql> select * from zhang; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.00 sec)用type=INNODB;直接就错误,而用engine=INNODB;没有错,但是还是用不了事务啊。 请知道的朋友 回答下,谢谢了。
去掉TYPE=InnoDB;就没问题了,但是不管是insert还是delete之后都不能rollback。现在mysql数据库中要用到事务,请问该怎么建表啊?
create table (...) engine = innodb
mysql> create table zhang(id int)type=INNODB;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'type=
INNODB' at line 1第二种:
mysql> create table zhang(id int)engine=INNODB;
Query OK, 0 rows affected (0.08 sec)mysql> insert into zhang values(1);
Query OK, 1 row affected (0.06 sec)mysql> insert into zhang values(2);
Query OK, 1 row affected (0.06 sec)mysql> delete from zhang where id=2;
Query OK, 1 row affected (0.03 sec)mysql> rollback;
Query OK, 0 rows affected (0.00 sec)mysql> select * from zhang;
+------+
| id |
+------+
| 1 |
+------+
1 row in set (0.00 sec)用type=INNODB;直接就错误,而用engine=INNODB;没有错,但是还是用不了事务啊。
请知道的朋友 回答下,谢谢了。
select @@AUTOCOMMIT;