List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:August 16 1999 6:31pm
Subject:Re: Is there a way to make a column not null AFTER creating it WITHOUT
mysqldump and importing it again
View as plain text  
Jann Linder wrote:
> 
> Is there a way to make a colum not null after the table is created...maybe
> with the alter table command?
> 
> The DB is LIVE and i do not wish to take the chance of corruption by
> exporting all the data, recreating the tables in re-importing the data.
> 
> Just as a side note, the column which ALLOWS NULL at this time, currently
> does NOT have any null entries.
> 
> THX.
> 
> Jann
> 
> Jann Linder

Hi Jann

Just use:
ALTER TABLE yourTable MODIFY column VARCHAR(255) NOT NULL;

You obviously have to give the column definition it really has insted the above :)

If you had some NULL values in, you had to additionally change them to e.g. the default
value with:
UPDATE youTabel SET column = 'default' WHERE column IS NULL;

Tschau
Christian

Thread
Is there a way to make a column not null AFTER creating it WITHOUT mysqldump and importing it againJann Linder16 Aug
  • Re: Is there a way to make a column not null AFTER creating it WITHOUT mysqldump and importing it againMartin Ramsch16 Aug
  • Re: Is there a way to make a column not null AFTER creating it WITHOUT mysqldump and importing it againChristian Mack16 Aug
    • RE: [CGI] Re: Is there a way to make a column not null AFTER creating it WITHOUT mysqldump and importing it againJann Linder16 Aug
      • RE: [CGI] Re: Is there a way to make a column not null AFTER creating it WITHOUT mysqldump and importing it againUlf18 Aug
  • Re: [CGI] Is there a way to make a column not null AFTER creating it WITHOUT mysqldump and importing it againUlf18 Aug