On Thu, Dec 13, 2001 at 09:50:11AM +0530, sreedhar wrote: > Hello, > > CREATE TABLE tblTEST(field1 VARCHAR(20) NOT NULL, field2 VARCHAR(20) NOT > NULL); > > INSERT INTO tblTEST (field1) VALUES (NULL); > INSERT INTO tblTEST (field2) VALUES (NULL); > INSERT INTO tblTEST (field1,field2) VALUES (NULL,'HELLO'); > > not accepting NULL values; but > > INSERT INTO tblTEST (field1) VALUES ('HELLO'); > > This statement inserting empty value in 'field2'. > > field1 field2 > HELLO > > so how can we make INSERT statement to fail if value of NOT NULL field is > not supplied.
You don't. MySQL supplies a default value for any field that isn't specified. You should verify that you have a value for field1 before issuing the insert. You'd have to handle an error anyway. > > thanks > > regards, > sreedhar > > > ----- Original Message ----- > From: "Paul DuBois" <[EMAIL PROTECTED]> > To: "sreedhar" <[EMAIL PROTECTED]>; "mysql" <[EMAIL PROTECTED]> > Sent: Wednesday, December 12, 2001 11:25 PM > Subject: Re: NOT NULL field accepting NULL > > > > At 7:12 PM +0530 12/12/01, sreedhar wrote: > > >Hi All, > > > > > >In MySQL, Even i declared a field as NOT NULL it is accepting nulls .What > > >might be the > > >problem. please let me know. > > > > > >regards, > > >sreedhar > > > > That's not enough information. > > > > Let's see the CREATE TABLE statement, a sample INSERT statement, and > > the resulting record. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php