mysql> create table actor(id int ,
    ->                          firstname varchar(10),
    ->                          lastname varchar(10)
    -> );
Query OK, 0 rows affected (0.11 sec)mysql> select *from actor where id=201;
Empty set (0.00 sec)mysql> start transaction ;
Query OK, 0 rows affected (0.00 sec)mysql> autocommit=0;
ERROR 1064 (42000): You have an error in your SQL syntax;
mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec)mysql> insert into actor  values(201,'lisa','tom');
Query OK, 1 row affected (0.06 sec)mysql> select *from actor where id=201;
+------+-----------+----------+
| id   | firstname | lastname |
+------+-----------+----------+
|  201 | lisa      | tom      |
+------+-----------+----------+
1 row in set (0.00 sec)为什么我明明没有提交 第二次查询还是可以查到呢  

解决方案 »

  1.   


    你的引擎是什么?
    Innodb吗?MyISAM不支持事务的
      

  2.   


    因为你没有ROLLBACK,一旦ROLLBACK,那个数据就被清除了,我用你给我的例子测试了一下的
      

  3.   

    我用的是innodb   
    不要用rollback 啊 我是想先不commit 第二次查询的时候查不到 然后用commit  在查询就可以查到了  
    但是不知道为什么实现不了这个过程 
    是因为米有用rollback吗????? 
      

  4.   

    mysql> select * from actor where id=203;
    Empty set (0.00 sec)mysql> start transaction ;
    Query OK, 0 rows affected (0.04 sec)mysql> insert into actor  values(203,'dsaf','af');
    Query OK, 1 row affected (0.02 sec)mysql> rollback;
    Query OK, 0 rows affected (0.09 sec)mysql> select * from actor where id=203;
    Empty set (0.00 sec)mysql> commit ;
    Query OK, 0 rows affected (0.00 sec)mysql> select * from actor where id=203;
    Empty set (0.00 sec)用了rollback后就清除了 查询不到了 
      

  5.   


    你在rollback前,那个还在缓存,能查到的,不然你怎么确认你输的数据是否正确