I am using a table "media_content" which has columns
id varchar(50) NOT NULL,
shorttitle varchar(200) DEFAULT NULL,
sourceimage blob
Later i modified the sourceimage column to default values as NULL
ALTER TABLE media_content
MODIFY COLUMN sourceimage VARCHAR(250) DEFAULT NULL;
Now i want to make the sourceimage
column default as NONE
, is it possible to do that?
You can specify the default value (of a string-type column) to be a string literal constant, such as 'NONE'
, but be aware that such a value has a very different meaning indeed to NULL
(which indicates no value at all).
As documented under Working with NULL
Values:
The
NULL
value can be surprising until you get used to it. Conceptually,NULL
means “a missing unknown value” and it is treated somewhat differently from other values.
[ deletia ]
A common error when working with
NULL
is to assume that it is not possible to insert a zero or an empty string into a column defined asNOT NULL
, but this is not the case. These are in fact values, whereasNULL
means “not having a value.”
If you merely wish to present NULL
values to your users in some other way, you should handle that at the presentation layer of your application.