I have a MySQL table with 4 columns
Column Type Null Default
----------------------------------
id int(11) No None AUTO_INCREMENT
col1 int(11) No None
col2 int(11) No None
col3 varchar(20) Yes Null
I have created a index with col1, col2, col3 since I don’t want duplicate rows. I understand that NULL value is considered distinct so the table accepts duplicate rows.
What is the best alternative so I can have rows with unique values for col1, col2, col3?
You could set
NOT NULLoncol3and set the default value to''.