I think this is a simple question but I haven't touched in Oracle SQL for a while.
I want to update a table if a certain field value is null.
I'm not sure if I should use the "not exists" clause, and this is what I have so far:
update table_classroom
set cod_classroom = 'unknown'
where exists (select * from table_classroom where cod_classroom is null)
Is this correct?
Even simpler:
update table_classroom
set cod_classroom = 'unknown'
where cod_classroom is null
Perhaps you also want to omit future entries where cod_classroom is null. If this is the case you don't need to update the column manually but you can include this in your alter statement:
ALTER TABLE table_classroom MODIFY (cod_classroom NOT NULL DEFAULT 'unknown')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.