1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
   | CREATION DES TABLES
----------------------------
mysql> create table table1 ( id integer not null , libelle varchar(50) , primary key( id) ) Type = InnoDB ;
 
mysql> create table table2 ( id integer not null , libelle varchar(50) , primary key( id) ) Type = InnoDB ;
 
PASSAGE EN MODE TRANSACTION
----------------------------------------
mysql> set autocommit=0 ;
Query OK, 0 rows affected (0.93 sec)
 
POPULATION DES TABLES 2 RECORD
-------------------------------------------
mysql> insert into table1 VALUES (1 , 'Bonjour' );
mysql> insert into table1 VALUES (2 , 'Salut' );
mysql> insert into table2 VALUES (1 , 'Goodmorning' );
mysql> insert into table2 VALUES (2 , 'hello' );
mysql> commit ;
 
 
UN SELECT POUR VERIFIER L'ETAT DES TABLES
-------------------------------------------------------
 
mysql> select * from table1 ;
+----+---------+
| id | libelle |
+----+---------+
|  1 | Bonjour |
|  2 | Salut   |
+----+---------+
2 rows in set (0.05 sec)
 
mysql> select * from table2 ;
+----+-------------+
| id | libelle     |
+----+-------------+
|  1 | Goodmorning |
|  2 | hello       |
+----+-------------+
2 rows in set (0.01 sec)
 
MAINTENANT J'INSERE DES RECORD QUE JE VAIS ROLLBACKer
--------------------------------------------------------------------------
 
mysql> insert into table1 VALUES (3 , 'Au revoir' );
Query OK, 1 row affected (0.01 sec)
 
mysql> insert into table2 VALUES (3 , 'GoodBye' );
Query OK, 1 row affected (0.01 sec)
 
JE VERIFIE QUE LES RECORD SONT DISPO AU SEIN DE LA TRANSACTION
-------------------------------------------------------------------------------------
 
mysql> select * from table1 ;
+----+-----------+
| id | libelle   |
+----+-----------+
|  1 | Bonjour   |
|  2 | Salut     |
|  3 | Au revoir |
+----+-----------+
3 rows in set (0.00 sec)
 
mysql> select * from table2 ;
+----+-------------+
| id | libelle     |
+----+-------------+
|  1 | Goodmorning |
|  2 | hello       |
|  3 | GoodBye     |
+----+-------------+
3 rows in set (0.00 sec)
 
 
OK - TOUT EST LA ; 3 RECORD/TABLE - MAINTENANT UN UNDO
--------------------------------------------------------------------------
 
mysql> ROLLBACK ;
Query OK, 0 rows affected (0.01 sec)
 
PUIS LES MEME SELECT
---------------------------
 
mysql> select * from table1 ;
+----+---------+
| id | libelle |
+----+---------+
|  1 | Bonjour |
|  2 | Salut   |
+----+---------+
2 rows in set (0.12 sec)
 
mysql> select * from table2 ;
+----+-------------+
| id | libelle     |
+----+-------------+
|  1 | Goodmorning |
|  2 | hello       |
+----+-------------+
2 rows in set (0.02 sec)
 
LE ROLLBACK A BIEN FONCTIONNE - PLUS QUE 2 RECORD
--------------------------------------------------------------------  | 
Partager