Reputation: 7977
I have column 'colors'
with data type 'ENUM'
in 'profile'
table.
The following values
are used for 'colors' column and this 'profile' table has more than 1K records
.
- Black
- White
- Red
- Orange
enum('Black', 'White', 'Red', 'Orange')
Now I want to set empty value for 'colors' column
for some scenarios while inserting records.
So I just tried to add one record with empty value through phpmyadmin and it is working fine
insert into `profile` (user_id, colors) values ('10000', '');
My question is, I don't have empty value for 'colors' column. However, it is working fine.
So shall I continue without altering schema for 'colors' column
(or)
Should I alter the schema as follows
ALTER TABLE `profile` CHANGE `colors` `method` ENUM( '', 'Black', 'White', 'Red', 'Orange' )
Please suggest the best practice.
Thanks in advance!
Upvotes: 3
Views: 2150
Reputation:
somewhat changing my mind from my comments:
NULL - for data absence
blank - for actively picking that as the colour(if that makes sense)
as to how enum works:
It allows blank by default and NULL when your schema allows it.
Ref:https://dev.mysql.com/doc/refman/5.0/en/enum.html
Upvotes: 2