I've set my column not to NULL by :

create table myTable 
    Column1 int not null,
    Column2 int not null

I Quickly place empty value to Column2 by :

INSERT INTO `myTable` (
`Column1` ,
'66', ''

Why I still can place empty value not to Null column? Steps to make the column disallow empty entry?

You are placing an empty string, not NULL. The constraint is just against NULL values, and it appears that your database isn't coercing empty strings to NULL if this converts these to INT (which boosts the extra question of why you are placing string literals into INT posts...)


In ORACLE a clear string can be used to represent NULL. In virtually anything else, however, a clear string continues to be a string, and thus not NULL.


Inside your situation you are really placing STRINGS into an INT column. This forces an implicit CAST operation.

Whenever your RDBMS is transforming the string '' for an INT it has to obtain the value . As isn't NULL, this will get placed.

A far more valid test could be:

INSERT INTO `plekz`.`countries` (`Column1 ` , `Column2`)


Sorry, I only half read your question. Additionally you request how you can stop '' being placed.

The first issue is that you are placing STRINGS and also the table is understood to be getting INT fields. Place the constraints around the data that will get placed, however these constraints will apply the the worthiness after an conversion for an INT. Unless of course you need to avoid the value 0 from also being placed, there's nothing that you can do towards the table to avoid this.

Your very best self wager would be to address your reason for placing strings to begin with. You could utilize a saved method that takes, and inspections, the strings before transforming these to INTs after which placing them. Or, better yet, you can result in the inspections inside your client application.

A technically available choice is to create the fields CHAR fields, then put a constraint around the fields, stopping '' from being placed. I'd strongly recommend from this.

As Martin mentions, is dependent in your RDBMS. Oracle goodies empty strings as NULLs while some don't. Check this out SO post.