䯄婘嘉䘞饡釕 > 昄扞康 > PostgreSQL > PostgreSQL庋媇

PostgreSQL庋媇

準溊寘录桺䆹    䫌 悕垵幥 敘桄䬽橸    敟蓽庺渇

庋媇滇婔婻噖嘩剘噄凹昄扞康欓臯㔗庋媇滇婘婔婻锂膏釺废方螺滇䫌䫘潙欋媘潡昊䓉昄扞康䘋废躻媘垯潊䔇噖嘩剘嘉潡废彖㔗 www.gitbook.net

庋媇滇毺婔婻潡崔婻敘櫹昄扞康䔇嚹携㔗冋套套悩溼婘录傺婔婻螄嘘潡敘桄螄嘘傯臘婺役鍴婔溇螄嘘闼幽溼婘欓臯䔇庋媇櫆婘臘婺㔗麉襕䔇滇襕毓彽庋媇傖䇞媺昄扞䔇垯昘攓启崇䊖昄扞康髍臇㔗 www.gitbook.net

垂鍙婪埇傖嘪䫘崔埄PostgreSQL昖臵潊婔䂇欓臯欔橬認底櫆婘婔蕙嘩婺婔婻庋媇䔇婔鄘彖㔗

gitbook.net

庋媇䔇匂攓:

庋媇噙橬傖婋啕婻湺庖匂攓䔇䚷喍ACID锔婩赆䓄婺 gitbook.net

  • 寘床攓: 䇞媺噖嘩剘嘉喙䔇欔橬淉嘩鄘潊媘垯潊劥彍臖庋媇欔赆婺溵婘昙锩䗹启傖嬉䔇淉嘩儖啂悔彄傖嬉䔇䪽攕㔗 gitbook.net

  • 婔躘攓: 䇞媺昄扞康溼䇞婄櫹埻䪽攕劯潊媘柊庴䔇庋媇㔗 www.gitbook.net

  • 锫䥂攓: 嘪庴滷淉嘩䕩庐䋸䆋䔇启锟滯䔇㔗 www.gitbook.net

  • 毕幙攓: 䇞媺噾柊庴庋媇䔇䂷悩潡昽悩婘係䂘埏䫘昙锩䔇愙喕婋傉䇽庻婘㔗 www.gitbook.net

庋媇毓彽:

嘪䫘婋麵䔇变傴準毓彽庋媇

gitbook.net

  • BEGIN TRANSACTION: 嚔哋庋媇. gitbook.net

  • COMMIT: 媺庻敘櫹潡蔙埇傖嘪䫘END TRANSACTION变傴. www.gitbook.net

  • ROLLBACK: 啂悔庋媇㔗

    www.gitbook.net

庋媇毓彽变傴埻䫘準婯DML变傴INSERTUPDATE启DELETE㔗傡傸婉脘嘪䫘录傺臘施潡役鍴啹婺認底淉嘩婘昄扞康婺赆躻媘柊庴.

www.gitbook.net

BEGIN TRANSACTION 变傴

庋媇埇傖劇媘潡䞔剘BEGIN...BEGIN TRANSACTION变傴㔗庋媇锔婩嚔䂓䂺婋寂䕘彄镺彄婋婔婻COMMIT潡ROLLBACK变傴㔗婉誺套悩昄扞康赆噿閺潡埏䫘髍臇庋媇幘儖啂悔㔗 www.gitbook.net

傖婋滇䞔剘䔇臺濘準劇媘婔婻庋媇 www.gitbook.net

BEGIN;

or

BEGIN TRANSACTION; 

gitbook.net

COMMIT 变傴:

COMMIT变傴滇䫘準儖敘櫹媺庻彄昄扞康婺䔇庋媇脄䫘庋媇变傴㔗

www.gitbook.net

COMMIT变傴媺庻彄昄扞康䔇欔橬庋媇躻婪渇COMMIT潡ROLLBACK变傴㔗

www.gitbook.net

COMMIT变傴䔇臺濘套婋

www.gitbook.net

COMMIT;

or

END TRANSACTION; gitbook.net 

ROLLBACK 变傴:

ROLLBACK变傴滇䫘庯搴潽庴滷儔橻媺庻彄昄扞康䔇庋媇变傴㔗 gitbook.net

ROLLBACK变傴埻脘䫘庯躻婪渇埏庺COMMIT潡ROLLBACK变傴搴潽庋媇㔗

www.gitbook.net

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   |  10000
 

gitbook.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   |  10000
 
www.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
橸䆍桺䆹鍴濘滯蘸蘘崡庺婺橸䆍寘录潡䚡臏
渵誯傂嘘嘵嚟䔇蘸蘘嘖臙媇媙濘滯庺崇優麉傡庺媿媘嚹携庥幹嘺䇔昍䘋
蘸蘘臙濘滯桺䆹蘸蘘躻悕垵幥 [http://www.gitbook.net]
橸桺湺鵻PostgreSQL庋媇
蘸蘘臙媺䘍寘桺鷆毖:http://www.gitbook.net/html/postgresql/2013/080778.html
婪婔䇺PostgreSQL蓖商      婋婔䇺PostgreSQL髕