0

Possible Duplicate:
MySQL ignores the NOT NULL constraint

I set a column to be not null but when inserting new row and put this field value with null mysql inserts the row how i prevent that?

Community
  • 1
  • 1
  • Don't make the insert if the value is wrong. You have complete control over that. – John Conde Dec 15 '12 at 00:16
  • 1
    If I understand the question correctly, you are able to insert a new row with one its fields set to null but that field has a non-null constraint. This should not happen; perhaps you can provide the code or MySql command that you used to do the insert? – rlandster Dec 15 '12 at 00:35

1 Answers1

0

did you insert the value on database field like

insert into table
values('');

or

    insert into table 
values(null);

well both will insert a row in database but the field will be with null value. NULL is a keyword which indicates a field value that is null. if you want the field value will be empty then thats not null actually. to do so you have to do

insert into table values(' '); // a space bar in between ' ' so thats not null

user1844626
  • 1,838
  • 7
  • 24
  • 37