我有以下查询,我只在它们为null时才更新值.
是否可以将所有这些放入单个查询中?
UPDATE test
SET test1 = 'hello'
WHERE test1 IS NULL
Run Code Online (Sandbox Code Playgroud)
和
UPDATE test
SET test2 = 'world'
WHERE test2 IS NULL
Run Code Online (Sandbox Code Playgroud)
你可以尝试:
UPDATE test
SET test1 = NVL(test1, 'hello'),
test2 = NVL(test2, 'world')
WHERE test2 IS NULL
OR test1 IS NULL;
Run Code Online (Sandbox Code Playgroud)
虽然它可能会触发更新触发器,即使对于实际未更改的行也是如此.