在orcale資料庫,欲針對單一資料表、多個欄位,確認欄位值是否為NULL進行調整,SQL語法如下:
UPDATE TABLE NAME
SET
TABLE_COLUMN_NAME1 = (CASE WHEN TABLE_COLUMN_NAME1 IS NULL THEN 0 ELSE TABLE_COLUMN_NAME1 END),
TABLE_COLUMN_NAME2 = (CASE WHEN TABLE_COLUMN_NAME2 IS NULL THEN 0 ELSE TABLE_COLUMN_NAME2 END),
TABLE_COLUMN_NAME3 = (CASE WHEN TABLE_COLUMN_NAME3 IS NULL THEN 0 ELSE TABLE_COLUMN_NAME3 END)
WHERE CONDITION XXX....
No comments:
Post a Comment