SQL 如何在postgresql数据库中单独删除特定列值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8725982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:49:29  来源:igfitidea点击:

how to delete particular column value alone in postgresql database?

sqlpostgresql

提问by user007

I have one table. The table name is employee. I used below query.

我有一张桌子。表名是员工。我使用了以下查询。

delete department,name,bloodgroup from employee where employeeid=2;

But I am not able to delete this record alone. It is showing error. And I don't want to use update statement.

但我无法单独删除此记录。它显示错误。而且我不想使用更新语句。

回答by juergen d

You can't delete single column entries with the deleteSQL command. Only complete rows.

您不能使用deleteSQL 命令删除单列条目。只完成行。

You can use the updatecommand for that:

您可以使用该update命令:

update employee 
set department = null, name = null, bloodgroup = null
where employeeid=2;