1.借阅一本图书涉及的3张数据表操作：

INSERT INTO t_borrow_record VALUES('180110','101102','978-7-5677-3957-4','2018-08-06');
UPDATE t_reader SET reader_borrowtotal = reader_borrowtotal + 1 WHERE reader_name = '王明峰';
UPDATE t_book SET book_inventory = book_inventory - 1 where book_name = 'MySQL数据库教程';

2.事务回滚涉及的操作语法：

BEGIN;
INSERT INTO t_borrow_record VALUES('180110','101102','978-7-5677-3957-4','2018-08-06');
UPDATE t_reader SET reader_borrowtotal = reader_borrowtotal + 1 WHERE reader_name = '王明峰';
ROLLBACK;

3.存储过程

DELIMITER $
CREATE PROCEDURE proc_commit(IN bId CHAR(6), IN rId char(6),IN bookId CHAR(17), IN bDate DATE,OUT inv1 INT)
BEGIN  
    START TRANSACTION;   
         INSERT INTO t_borrow_record VALUES(bId, rId, bookId, bDate);     
         UPDATE t_reader  
SET reader_borrowtotal = reader_borrowtotal + 1  WHERE reader_id= rId;     
         UPDATE t_book SET book_inventory = book_inventory - 1 WHERE ISBN =bookId;   
         SELECT book_inventory INTO inv1 FROM t_book WHERE ISBN=bookId; 
          IF inv1>0 THEN  
              COMMIT;    
           ELSE    
             ROLLBACK;
 END IF;
END $
DELIMITER;

调用存储过程

CALL proc_commit('180110','101102','978-7-5677-3957-4','2018-08-06')