Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
drPascal
Starting Member
5 Posts |
Posted - 2008-02-21 : 17:13:10
|
In OO programming, data references, such as pointers in C++ or objects in C#. If the reference is null, it points to no object, or to 0x000000, thus the "referenced" object is non existent and the "object" takes up no RAM. I know pointers are not the same as Database values, but what I'm interested in knowing is, on the bits and bytes level, what is a "NULL" and how much space does it take up, as much as is the field? Or just one byte? and when a NULL is replaced does that cause a shifting in the data of the database page or does the new data simply replace the null? |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-02-21 : 17:43:59
|
http://weblogs.sqlteam.com/mladenp/archive/2007/09/06/How_does_SQL_Server_really_store_NULL-s.aspx_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-02-21 : 17:46:19
|
Depends on data type and length of the column. If data page has enough space, sql just put value in same page. Otherwise will move the row to new page. |
 |
|
KenW
Constraint Violating Yak Guru
391 Posts |
Posted - 2008-02-22 : 16:25:46
|
quote: Originally posted by drPascal In OO programming, data references, such as pointers in C++ or objects in C#. If the reference is null, it points to no object, or to 0x000000, thus the "referenced" object is non existent and the "object" takes up no RAM.
Actually, this is incorrect. If you declare a variable to a data reference, whether it is ever assigned something or not, you've allocated SizeOf(pointer) in RAM, and therefore used more than "no RAM".IOW (and in light of your user name ), if in Delphi's Object Pascal you declare a variable of type TObject, you're actually declaring a pointer to a TObject, and that pointer consumes 32 bits of memory in a Win32 application.function MyFunction: Boolean;var Obj: TObject;begin Obj := nilend; In the code segment below, the Obj variable uses 32 bits of RAM* (SizeOf(Pointer) on Win32), even though you've explicitly set it to contain nothing (nil).*Unless, of course, your code is really as simple as that above. In that case, unless you've disabled optimization, Delphi's compiler will eliminate the useless declaration and assignment, and if you don't actually call it, the entire function itself. |
 |
|
drPascal
Starting Member
5 Posts |
Posted - 2008-02-25 : 17:49:45
|
Right, but I was not talking about the pointer variable itself. I was talking about 1) the "object" it points to and 2) what the paradigm is in SQL Server (knowing that it's different, but not quite sure until now). |
 |
|
|
|
|
|
|