Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

What is the difference between Empty/Blank , Null and NotNull database field.
how many default memory space occupied by them.

Thanks
Ravik
Posted

1 solution

There is no special empty or blank value. Usually string (char, varchar, nvarchar, text, stb...) fields that contain no characters are called empty or blank. But an empty string is not null. Null is a special value that denotes the field not to be populated with any data. It is "nothing". Thus theoretically null values are not used in aggregate calculations, and if involved in an arithmetical calculation they make the whole formula undefined/null (dbms implementation might treat null values slightly different).
The space occupied is a more complex question. Since any data type can hold null value (concrete fields might be marked as not nullable, sometimes derived types also), the space occupied by a null value in the database itself depends on the data type. In case of a scalar, or a fixed maximum width string (in this case char and varchar behave the same way) field, there is no difference with null value or filled. In case of undefined variable length fields like TEXT (deprecated) or VARCHAR(MAX), a null value will occupy a single block.
In the memory of the dbms and of the program it is even more complicated. I have to say, that it depends on the native data types used, and of course of the coder.
Optimization is used in case of the major dbms providers, but is most cases performance is more important than bytes consumed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900