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