MySQL for the Internet of Things

(Steven Felgate) #1
ChapTEr 8 ■ DEmonsTraTion of high availabiliTy TEChniquEs

mysql> SELECT * FROM test_trans;
+----+-------+
| id | value |
+----+-------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
+----+-------+
4 rows in set (0.00 sec)


mysql> DELETE FROM test_trans;
Query OK, 4 rows affected (0.00 sec)


mysql> SELECT * FROM test_trans;
Empty set (0.00 sec)


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


mysql> SELECT * FROM test_trans;
+----+-------+
| id | value |
+----+-------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+----+-------+
3 rows in set (0.01 sec)


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


mysql> INSERT INTO test_trans VALUES (NULL,4), (NULL,5);
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0


mysql> DELETE FROM test_trans WHERE id <= 2;
Query OK, 2 rows affected (0.01 sec)


mysql> SELECT * FROM test_trans;
+----+-------+
| id | value |
+----+-------+
| 3 | 3 |
| 5 | 4 |
| 6 | 5 |
+----+-------+
3 rows in set (0.00 sec)

Free download pdf