At 9:43 +0800 3/4/02, Al Caponi wrote:
>Check out the MySQL website for altering table structure:
>
>http://www.mysql.com/doc/A/L/ALTER_TABLE.html
>
>You could use MODIFY to change the columns definition in your tables. Note
>that specifying NOT NULL on a column will not affect existing rows where
>that field already contains a NULL value.

Where do you see that?  I just took a look at the page and didn't find
this mentioned.

I just tried the operation, and NULL values were converted to the empty
string when I changed the column to NOT NULL.

Even if NULL values were retained, it'd probably be best to change them
anyway, because future insert operations wouldn't be able to create NULL,
and then it might be necessary to look for two special values that signify
"unknown", rather than just one.

>
>Regards,
>Al
>
>>  -----Original Message-----
>>  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>>  Sent: Monday, March 04, 2002 6:00 AM
>>  To: [EMAIL PROTECTED]
>>  Subject: change column to not null in MySQL
>>
>>
>>  Is there any way in mysql to change a column that contains data
>>  from null = yes to be not null.
>>
>>  I want to enforce users to enter some value in column_x that was
>>  not a required field until now, by setting the column to not accept
>>  any record where column_x is null, is there any way to do this
>>  without distorting current data (I guess I will have to give some
>>  bogus value for all the data field's that are now null before I can
>>  change this).?
>>
>>  If the column type cannot be changed what's the recommended
>>  way of doing something like this.
>>
>>  Thanks
>>
>>  Shia
>>  Shia Meisels
>>  B&H Photo Video
>>  212-239-7500 Ext. 2158
>  > http://www.bhphotovideo.com


---------------------------------------------------------------------
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

Reply via email to