Performing a Transaction : COMMIT « Transaction « SQL / MySQL






Performing a Transaction

      
mysql>
mysql> CREATE TABLE Books
    -> (
    ->     BookID SMALLINT NOT NULL PRIMARY KEY,
    ->     BookTitle VARCHAR(60) NOT NULL,
    ->     Copyright YEAR NOT NULL
    -> )
    -> ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> START TRANSACTION;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO Books VALUES (101, 'Notebook', 1934);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO Books VALUES (102, 'C++', 1919);
Query OK, 1 row affected (0.00 sec)

mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> drop table Books;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
    
  








Related examples in the same category

1.Issue a BEGIN statement to suspend auto-commit mode, then issue the queries that make up the transaction.