Click here to Skip to main content
13,090,299 members (76,161 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi guys,

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

Posted 11-Dec-12 6:13am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100