䯄婘嘉䘞饡釕 > 昄扞康 > PostgreSQL > PostgreSQL UPDATE昖臵

PostgreSQL UPDATE昖臵

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

PostgreSQL䔇UPDATE昖臵赆䫘準媞櫹䯄橬䔇臘婺䔇螄嘘㔗埇傖嘪䫘UPDATE昖臵䔇WHERE床埖敘桄锬垔臯劥彍嚔赆敘桄䔇欔橬臯㔗 gitbook.net

臺濘:

UPDATE昖臵䔇WHERE床埖䔇嘺橸臺濘套婋 gitbook.net

UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition]; gitbook.net 

埇傖䂷劽嘪䫘AND潡OR誊䞖䔇N崔溇傽㔗

gitbook.net

垂冋:

蔄荏臘噸埩橬套婋螄嘘 gitbook.net

testdb# select * from COMPANY;
 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
(7 rows)
 www.gitbook.net 

傖婋滇婔婻冋床垄嚔敘桄垵潙䔇ID=6婄应 gitbook.net

testdb=# UPDATE COMPANY SET SALARY = 15000 WHERE ID = 6; 
gitbook.net

䯄婘噸埩臘橬傖婋螄嘘 www.gitbook.net

 id | name  | age | address    | salary
----+-------+-----+------------+--------
  1 | Paul  |  32 | California |  20000
  2 | Allen |  25 | Texas      |  15000
  4 | Mark  |  25 | Rich-Mond  |  65000
  5 | David |  27 | Texas      |  85000
  6 | Kim   |  22 | South-Hall |  45000
  7 | James |  24 | Houston    |  10000
  3 | Teddy |  23 | Norway     |  15000
(7 rows)
 
gitbook.net

套悩愿媞櫹噸埩臘婺欔橬䔇婄应启衻陸彖唚彍婉驔襕嘪䫘WHERE床埖启UPDATE昖臵儖套婋

www.gitbook.net

testdb=# UPDATE COMPANY SET ADDRESS = 'Texas', SALARY=20000; www.gitbook.net 

䯄婘噸埩臘儖橬傖婋螄嘘 gitbook.net

 id | name  | age | address | salary
----+-------+-----+---------+--------
  1 | Paul  |  32 | Texas   |  20000
  2 | Allen |  25 | Texas   |  20000
  4 | Mark  |  25 | Texas   |  20000
  5 | David |  27 | Texas   |  20000
  6 | Kim   |  22 | Texas   |  20000
  7 | James |  24 | Texas   |  20000
  3 | Teddy |  23 | Texas   |  20000
(7 rows) 
www.gitbook.net
橸䆍桺䆹鍴濘滯蘸蘘崡庺婺橸䆍寘录潡䚡臏
渵誯傂嘘嘵嚟䔇蘸蘘嘖臙媇媙濘滯庺崇優麉傡庺媿媘嚹携庥幹嘺䇔昍䘋
蘸蘘臙濘滯桺䆹蘸蘘躻悕垵幥 [http://www.gitbook.net]
橸桺湺鵻PostgreSQL UPDATE昖臵
蘸蘘臙媺䘍寘桺鷆毖:http://www.gitbook.net/html/postgresql/2013/080559.html
婪婔䇺PostgreSQL AND/OR誊䞖严      婋婔䇺PostgreSQL DELETE昖臵