tags:

views:

32

answers:

2

How should we treat the data if they have no values in it. I mean, at some places, they have no value. Should we populate it as it or should we write something at that place?

+2  A: 

You need to use a special value called NULL in such cases.

codaddict
so i just need to place NULL there in the table where there is no value given?right?
shilps
Yes. You can also give the column `NULL` as the default value. Then not inserting any value for that column will automatically insert a `NULL` there.
codaddict
And it is applicable to any data type. Like for strings or INt or both...should I enclosed The "NULL" like this or just simply NULL?
shilps
Yes, it applies to column with any data type.
codaddict
+1  A: 

The concept of the NULL value is a common source of confusion for newcomers to SQL, who often think that NULL is the same as an empty string '', or a value of zero.

This is not the case. Conceptually, NULL means "a missing unknown value" and it is treated somewhat differently from other values. For example, to test for NULL, you cannot use the arithmetic comparison operators such as =, <, or <>.

If you have columns that may contain "a missing unknown value", you have to set them to accept NULLs, and use a NULL value as @codaddict suggested in the other answer.

Daniel Vassallo
so i just need to place NULL there in the table where there is no value given?right?
shilps
@shilps: Yes, that's exactly right :)
Daniel Vassallo
And it is applicable to any data type. Like for strings or INt or both...should I enclosed The "NULL" like this or just simply NULL?
shilps
Yes, it's valid for any data type, except when the column is the primary key... And no, do not wrap it in quotes. Example: `INSERT INTO your_table (id, name, surname) VALUES (1, 'Bob', NULL);`
Daniel Vassallo