Friday, June 25, 2010

MySql Not Null Property for Varchar

SET @@global.sql_mode= 'STRICT_TRANS_TABLES';
Strict mode is on for MySql,
still I am able to insert empty strings into variables
which are declared as VARCHAR NOT NULL.
Why?
How to avoid it?

Ans : 
Try this... add this to your MySQL's config file if you want to make this permanent( --sql-mode='STRICT_ALL_TABLES')

For time being you can set it from command line

SET GLOBAL sql_mode= 'STRICT_ALL_TABLES';

No comments:

Blog Archive