> Barney Boisvert wrote:
> > Where did you hear that one Jochem? MySQL enforces NOT NULL just fine.
Jochem and Barney - you're both right.. and wrong, it seems.
MySQL absolutely does enforce NOT NULL attributes. You cannot insert a
NULL value into a field specified as NOT NULL.
HOWEVER, it automatically assigns a default value for all fields. So if
you don't include the field in an INSERT Query, the default value will
be used. I *THINK* this behavior differs from other databases that I've
worked with.
For example... let's take a table definition that looks like this:
CREATE TABLE TESTING
(
RecordID int not null,
SomeValue varchar(255) not null
);
MySQL does set defaults for each... so these queries will both work:
INSERT INTO TESTING ( RecordID ) VALUES ( 1 );
INSERT INTO TESTING ( SomeValue ) VALUES ( 'bork' );
But these queries will NOT:
INSERT INTO TESTING VALUES ( NULL, 'bork' );
INSERT INTO TESTING VALUES ( 1, NULL );
INSERT INTO TESTING VALUES ( NULL, NULL )
- Rick
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

