Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 18th, 2012  |  syntax: None  |  size: 1.52 KB  |  views: 78  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C>
  2. C>     CREATE TABLE test(
  3.     ->         id integer PRIMARY KEY,
  4.     ->         data varchar(255) not null,
  5.     ->         version integer not null
  6.     ->     );
  7. Query OK, 0 rows affected (0.00 sec)
  8.  
  9. C>     INSERT INTO test(id,data,version) VALUES (1,'fred',0);
  10. Query OK, 1 row affected (0.00 sec)
  11.  
  12. C>     BEGIN;
  13. Query OK, 0 rows affected (0.00 sec)
  14.  
  15. C>     LOCK TABLES test WRITE;
  16. Query OK, 0 rows affected (0.00 sec)
  17.  
  18.  
  19.  
  20. A>     BEGIN;
  21. Query OK, 0 rows affected (0.00 sec)
  22.  
  23. A>     UPDATE test SET data = 'winnerA',
  24.     ->                 version = version + 1
  25.     ->     WHERE id = 1 AND version = 0;
  26. Query OK, 0 rows affected (16.54 sec)
  27.  
  28.  
  29. B>     BEGIN;
  30. Query OK, 0 rows affected (0.00 sec)
  31.  
  32. B>     UPDATE test SET data = 'winnerB',
  33.     ->                 version = version + 1
  34.     ->     WHERE id = 1 AND version = 0;
  35. Query OK, 1 row affected (4.60 sec)
  36.  
  37.  
  38.  
  39. C> UNLOCK TABLES;
  40. Query OK, 0 rows affected (0.00 sec)
  41.  
  42.  
  43.  
  44.  
  45. B>
  46. Rows matched: 1  Changed: 1  Warnings: 0
  47.  
  48. B> SELECT * FROM test;
  49. +----+---------+---------+
  50. | id | data    | version |
  51. +----+---------+---------+
  52. |  1 | winnerB |       1 |
  53. +----+---------+---------+
  54. 1 row in set (0.00 sec)
  55.  
  56. B> COMMIT;
  57. Query OK, 0 rows affected (0.00 sec)
  58.  
  59.  
  60.  
  61. A>
  62. Rows matched: 0  Changed: 0  Warnings: 0
  63.  
  64. A> COMMIT;
  65. Query OK, 0 rows affected (0.00 sec)
  66.  
  67. C> SELECT * FROM test;
  68. +----+---------+---------+
  69. | id | data    | version |
  70. +----+---------+---------+
  71. |  1 | winnerB |       1 |
  72. +----+---------+---------+
  73. 1 row in set (0.00 sec)
clone this paste RAW Paste Data