Stefan,
When you insert a row in a table and you do not specify a value
for a field, mySQL (and any other DBMNS?) will do the following:
1. If field accepts null: it will set the value of that field
to null
2. If field DOES NOT accept null - no default value set: it will
set the field's value as per "primitive" data type of field. If CHAR()
it will set it to '', if date/datetime to 0000-00-00, if numeric
to 0. And so on. And this is why you get the '' in your field
when you do your insert.
2. If field DOES NOT accept null - default value set:
it set the field's value to the deafult.
Christopher Lambrou,
CGL Computer Services, Inc.
Empire State Building,
PMB 16J Suite 3304
New York, NY 10118
Tel: (212) 971-9723
Fax: (212) 564-1135
URL: http://www.cglcomputer.com
Email: [EMAIL PROTECTED]
On 5/03/2001 20:59:48, you said:
>hi list,
>
>sorry for posting again, i will learn it.
>
>i have a problem with DEFAULT NULL value in a varchar field.
>mysql is version 3.23.33.
>
>i want to have an user field in a row, to see who has created the row.
>
> create table minidb.tel (
> id int UNSIGNED NOT NULL AUTO_INCREMENT,
> tel char(16) NOT NULL,
> service char(1) BINARY,
> idate timestamp(14) NOT NULL,
> iuser varchar(255) NOT NULL,
> primary key (id, tel, idate)
> );
>
>using DEFAULT USER(), would be nice, but only constants are allowed.
>to prevent inserting rows without iuser, i like to have this field
>with NOT NULL restriction and default value NULL.
>
>when inserting a row with
> insert into tel set tel='+49 174 92932000', service=1;
>
>there will be a record with iuser = ''.
>i thought the meaning of NOT NULL is to reject inserting rows with
>iuser as NULL.
>
>the line
> iuser varchar(255) NOT NULL DEFAULT NULL,
>will rejected with an errormsg.
>
>thx in advance for your help
>
>stefan
>
>
>--
>st3V13h
>
>nach diktat verreist
>
>---------------------------------------------------------------------
>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
>
>
---------------------------------------------------------------------
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