community.borland.com

Article #25379: How to add not null to an existing column

Problem:
What is the ALTER TABLE syntax to add a not null constraint to a column?


Solution:
/*******************************************************************************/
Note: The information in this article applies to
            InterBase v5.x
/********************************************************************************/

You could do it  2 different  ways:

        1. Drop the column.    Then add back the same column with NOT NULL listed 
            next to the column data type.  
      
           * If there is data in the column, you will need to use alter table to add a new temporary column 
             and then use an update query to move the data to a temp column before dropping the column.

            
       2. Use the  CHECK constraint  if you do not want to drop the column. But when you define 
            the column, you have to use CHECK constraint for defining the column is nullable or not
             nullable and not using the NOT NULL keyword.

Last Modified: 26-SEP-00