User transaction in table : RollBack « Transaction « SQL / MySQL






User transaction in table

  
/*
mysql> select * from Student;
+-----------+------------+
| StudentID | Name       |
+-----------+------------+
|         1 | JJ Smith   |
|         2 | Joe Wang    |
|         3 | John Lee   |
|         4 | Jacky Chen |
+-----------+------------+
4 rows in set (0.03 sec)


*/

Drop table Student;

CREATE TABLE Student (
   StudentID INT NOT NULL PRIMARY KEY,
   Name      VARCHAR(50) NOT NULL
)TYPE = InnoDB;


INSERT INTO Student (StudentID,Name) VALUES (1,'JJ Smith');
INSERT INTO Student (StudentID,Name) VALUES (2,'Joe Wang');
INSERT INTO Student (StudentID,Name) VALUES (3,'John Lee');
INSERT INTO Student (StudentID,Name) VALUES (4,'Jacky Chen');
  
  
  
BEGIN;

INSERT INTO Student (StudentID, Name) VALUES (98, 'Anne');
INSERT INTO Student (StudentID, Name) VALUES (99, 'Julian');

ROLLBACK;

select * from Student;


           
         
    
  








Related examples in the same category

1.The ROLLBACK Statement
2.Cancel the transaction by issuing a ROLLBACK statement.
3.Rollback work