Search code examples
sqloracle-databaseoracle11g

Is it possible to store '' (empty string) as a non NULL value in the database?


I am using Oracle DB. At the database level, when you set a column value to either NULL or '' (empty string), the fetched value is NULL in both cases. Is it possible to store '' (empty string) as a non NULL value in the database?

I execute this

UPDATE contacts SET last_name = '' WHERE id = '1001';

commit;

SELECT last_name, ID FROM contacts WHERE id ='1001';

LAST_NAME                  ID
------------               ------
null                       1001

Is it possible to store the last_name as a non-NULL empty string ('')?


Solution

  • The only way to do this in oracle is with some kind of auxiliary flag field, that when set is supposed to represent the fact that the value should be an empty string.