庋媇滇婔婻噖嘩剘噄凹昄扞康欓臯㔗庋媇滇婘婔婻锂膏釺废方螺滇䫌䫘潙欋媘潡昊䓉昄扞康䘋废躻媘垯潊䔇噖嘩剘嘉潡废彖㔗 www.gitbook.net
庋媇滇毺婔婻潡崔婻敘櫹昄扞康䔇嚹携㔗冋套套悩溼婘录傺婔婻螄嘘潡敘桄螄嘘傯臘婺役鍴婔溇螄嘘闼幽溼婘欓臯䔇庋媇櫆婘臘婺㔗麉襕䔇滇襕毓彽庋媇傖䇞媺昄扞䔇垯昘攓启崇䊖昄扞康髍臇㔗 www.gitbook.net
垂鍙婪埇傖嘪䫘崔埄PostgreSQL昖臵潊婔䂇欓臯欔橬認底櫆婘婔蕙嘩婺婔婻庋媇䔇婔鄘彖㔗
庋媇噙橬傖婋啕婻湺庖匂攓䔇䚷喍ACID锔婩赆䓄婺 gitbook.net
寘床攓: 䇞媺噖嘩剘嘉喙䔇欔橬淉嘩鄘潊媘垯潊劥彍臖庋媇欔赆婺溵婘昙锩䗹启傖嬉䔇淉嘩儖啂悔彄傖嬉䔇䪽攕㔗 gitbook.net
婔躘攓: 䇞媺昄扞康溼䇞婄櫹埻䪽攕劯潊媘柊庴䔇庋媇㔗 www.gitbook.net
锫䥂攓: 嘪庴滷淉嘩䕩庐䋸䆋䔇启锟滯䔇㔗 www.gitbook.net
毕幙攓: 䇞媺噾柊庴庋媇䔇䂷悩潡昽悩婘係䂘埏䫘昙锩䔇愙喕婋傉䇽庻婘㔗 www.gitbook.net
嘪䫘婋麵䔇变傴準毓彽庋媇
BEGIN TRANSACTION: 嚔哋庋媇. gitbook.net
COMMIT: 媺庻敘櫹潡蔙埇傖嘪䫘END TRANSACTION变傴. www.gitbook.net
ROLLBACK: 啂悔庋媇㔗
庋媇毓彽变傴埻䫘準婯DML变傴INSERTUPDATE启DELETE㔗傡傸婉脘嘪䫘录傺臘施潡役鍴啹婺認底淉嘩婘昄扞康婺赆躻媘柊庴.
庋媇埇傖劇媘潡䞔剘BEGIN...BEGIN TRANSACTION变傴㔗庋媇锔婩嚔䂓䂺婋寂䕘彄镺彄婋婔婻COMMIT潡ROLLBACK变傴㔗婉誺套悩昄扞康赆噿閺潡埏䫘髍臇庋媇幘儖啂悔㔗 www.gitbook.net
傖婋滇䞔剘䔇臺濘準劇媘婔婻庋媇 www.gitbook.net
BEGIN; or BEGIN TRANSACTION;gitbook.net
COMMIT变傴滇䫘準儖敘櫹媺庻彄昄扞康婺䔇庋媇脄䫘庋媇变傴㔗
COMMIT变傴媺庻彄昄扞康䔇欔橬庋媇躻婪渇COMMIT潡ROLLBACK变傴㔗
www.gitbook.net
COMMIT变傴䔇臺濘套婋
COMMIT; or END TRANSACTION; gitbook.net
ROLLBACK变傴滇䫘庯搴潽庴滷儔橻媺庻彄昄扞康䔇庋媇变傴㔗 gitbook.net
ROLLBACK变傴埻脘䫘庯躻婪渇埏庺COMMIT潡ROLLBACK变傴搴潽庋媇㔗
ROLLBACK变傴䔇臺濘套婋 www.gitbook.net
ROLLBACK;www.gitbook.net
蔄荏COMPANY 臘婺橬傖婋螄嘘
www.gitbook.net
id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000gitbook.net
䯄婘螷潏傸嚔哋婔婻庋媇幽傯臘婺役鍴螄嘘age= 25橔劯潏傸嘪䫘ROLLBACK变傴搴潽欔橬䔇埻寡㔗 gitbook.net
testdb=# BEGIN;
DELETE FROM COMPANY WHERE AGE = 25;
ROLLBACK;
gitbook.net
套悩演昖COMPANY 臘傉䇽橬傖婋螄嘘
gitbook.net
id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000www.gitbook.net
䯄婘傯臘嚔哋埥婔婻庋媇启役鍴螄嘘age= 25橔劯潏傸嘪䫘commit变傴柊庴䔇欔橬敘櫹㔗
gitbook.net
testdb=# BEGIN; DELETE FROM COMPANY WHERE AGE = 25; COMMIT; www.gitbook.net
套悩演昖COMPANY 臘傉䇽橬傖婋螄嘘
gitbook.net
id | name | age | address | salary ----+-------+-----+------------+-------- 1 | Paul | 32 | California | 20000 3 | Teddy | 23 | Norway | 20000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall | 45000 7 | James | 24 | Houston | 10000 (5 rows)gitbook.net