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?
so i just need to place NULL there in the table where there is no value given?right?
shilps
2010-10-11 10:56:22
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
2010-10-11 10:58:29
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
2010-10-11 11:06:03
Yes, it applies to column with any data type.
codaddict
2010-10-11 11:08:56
+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 NULL
s, and use a NULL
value as @codaddict suggested in the other answer.
Daniel Vassallo
2010-10-11 10:34:44
so i just need to place NULL there in the table where there is no value given?right?
shilps
2010-10-11 10:56:45
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
2010-10-11 11:01:48
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
2010-10-11 11:09:09