Hi Donna,

You have to include the column `type` in the SQL-statement, otherwise the
not specified column will have its indirect null translated to an empty
string or 0 (for strings/numeric).

A bug or a feature? Actually I've used it as a feature sometimes when using
MySQL to move large amount of dirty data between different systems.

Be careful when not including NOT NULL columns in your inserts...

To get around the problem and get more background info, read:

http://dev.mysql.com/doc/mysql/en/constraint_NOT_NULL.html

Regards,
Thomas Lundström, Ongame E-Solutions AB

-----Original Message-----
From: Donna Hinshaw [mailto:[EMAIL PROTECTED] 
Sent: den 21 september 2004 21:07
To: [EMAIL PROTECTED]
Subject: inserting null to not null columns

Hi folks:

I have an InnoDB database, the tables created using MySQL Control Center 
0.9.4-beta (winXP pro platform).
Each table has some columns which I have checked as Nulls Allowed. 

I am building a pure Java GUI to the database. Got the SQL statements 
working fine, but have
discovered that I can successfully insert rows into a table without 
including a value for a column
which should be blocking nulls.

e.g.
Table A
--------
id (PK, auto increment)
name 
type
ssn   ( nulls allowed specified)
==> name and type do not have nulls allowed specified, so I think they 
should be NOT NULL.
  they also have no default specified.

then....
insert into A (id,name,ssn)
values (NULL,"Jane",999999999)

this statement works fine, but I think it should give me an error by 
saying that I'm trying to
insert a row without providing a value for the   type   column (which 
has no default specified).
Looking at the create statement for the tables, MySQL Control Center has 
supplied defaults
of blanks...can I turn off that "preference" ?

using MySQL 4.0.18


Can anyone provide clarification?
thanks...
Donna



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to