Sql 如果字段值为空,则更新字段值

Sql 如果字段值为空,则更新字段值,sql,oracle,sql-update,exists,Sql,Oracle,Sql Update,Exists,我认为这是一个简单的问题,但我已经有一段时间没有接触到Oracle SQL了 如果某个字段值为空,我想更新一个表 我不确定是否应该使用“not exists”子句,这就是我到目前为止所做的: update table_classroom set cod_classroom = 'unknown' where exists (select * from table_classroom where cod_classroom is null) 这是否正确?更简单: update table_cla

我认为这是一个简单的问题,但我已经有一段时间没有接触到Oracle SQL了

如果某个字段值为空,我想更新一个表

我不确定是否应该使用“not exists”子句,这就是我到目前为止所做的:

update table_classroom
set cod_classroom = 'unknown'
where exists (select * from table_classroom where cod_classroom is null)
这是否正确?

更简单:

update table_classroom
set cod_classroom = 'unknown'
where cod_classroom is null
更简单的是:

update table_classroom
set cod_classroom = 'unknown'
where cod_classroom is null

也许您还想省略cod_教室为空的将来条目。如果是这种情况,则不需要手动更新列,但可以将其包含在alter语句中:

ALTER TABLE TABLE\u CLASSORY MODIFY(cod\u CLASSORY NOT NULL默认值“unknown”)

也许您还想省略cod\u教室为空的未来条目。如果是这种情况,则不需要手动更新列,但可以将其包含在alter语句中:

ALTER TABLE TABLE\u CLASSORY MODIFY(cod\u CLASSORY NOT NULL默认值“unknown”)

谢谢:)如果我还想编辑同一行上的修改日期字段值,该怎么办?我应该只使用set cod_chestival='unknown',mod_date=sysdate吗?@madsantos。这是你问的问题。如果你还有其他问题,你应该把它作为一个新问题来问。也就是说,您可以在
set
子句中添加更多的列和值。@madsantos是的,您可以
set cod\u class='unknown',mod\u date=sysdate
。谢谢:)如果我还想编辑同一行上的修改日期字段值呢?我应该只使用set cod_chestival='unknown',mod_date=sysdate吗?@madsantos。这是你问的问题。如果你还有其他问题,你应该把它作为一个新问题来问。也就是说,你可以在
set
子句中添加更多的列和值。@madsantos是的,你可以
set cod\u class='unknown',mod\u date=sysdate
。从12c开始,你可以像默认为null'unknown'那样做。从12c开始,你也可以像默认为null'unknown'那样做。