SELECT 1 FROM dual where trim('X ') = 'X'
Gives 1.
SELECT 1 FROM dual where trim(' ') = ''
Gives no rows.
Is there an easy way to select all rows where field is whitespace short of regex?
Is there a way to “trick” TRIM into TRIMming ' ' and giving ''?
In Oracle, the empty string is NULL. So the conventional approach would be something like
That will also, of course, return results where the column is
NULL. If you want cases where the column is non-NULL and is solely composed of spacesJust to round out the answer, if you want to use a simple
regexp_likeas well