Sample Header Ad - 728x90

When does Oracle still treat empty strings as NULL?

1 vote
1 answer
2157 views
I was looking for the difference between VARCHAR and VARCHAR2 and learned, among other things, that Oracle’s VARCHAR2 treats empty strings as NULL, or the other way round. Also, apparently I should be using VARCHAR2, and that VARCHAR is reserved for the future. In my blissful ignorance, I have a table where I created a column using VARCHAR, and I certainly don’t get the same:
SELECT * FROM customers WHERE state='';
SELECT * FROM customers WHERE IS NULL;		--	not the same
I’m using Version 18.0.0.0.0, so it wouldn’t surprise me to find that the future they were talking about has finally arrived. All the answers I have found mentioning this are pretty old. Here is a fiddle: https://dbfiddle.uk/yeWEbcDF I tested in 11g, 18c and 21c.
Asked by Manngo (3145 rep)
Mar 17, 2023, 11:07 PM
Last activity: Mar 19, 2023, 07:12 AM