在postgresql中,update语句用于修改表中现有的记录。 要更新所选行,您必须使用where子句,否则将更新所有行。
语法:
以下是update
语句的基本语法:
update table_name
set column1 = value1, column2 = value2...., columnn = valuen
where [condition];
看看下面这个例子:
考虑一个名为“employees
”的表,其中包含以下数据。
数据如下所示 -
按照以下步骤更新表
选择表“employees
”,右键单击将看到一个选项脚本,将光标移动到脚本上,您将看到“update脚本”选项,然后点击 -
把值放在“?
”的地方 并完成where条件<condition>
,然后点击“执行”按钮执行查询。
示例
将id
为1
的员工(“employees
”表)记录更新age
的值为29
和salary
的值为9800
。
输出:
您可以看到id为1的记录的已更新:age
和salary
列。