Altering a column to Not Null 
Author Message
 Altering a column to Not Null
I am trying to alter an existing column in a table to change it's
attributes from allow null to not null.

I have looked at the alter table command but it does not seem to allow you
to perform such an operation unless you are adding a new column.

I don't won't to drop the field and re-add it to the end.

Any help on this is appreciated.

Regards Geoff



Mon, 16 Aug 2004 08:26:11 GMT
 Altering a column to Not Null

At least in version 7.x  for DB2 UDB, you cannot change from allow null to
not null, probably because nulls take up space in the record.  Also, you
can't drop or rename a column.  Oh, well...

- Bob

Quote:

>I am trying to alter an existing column in a table to change it's
>attributes from allow null to not null.

>I have looked at the alter table command but it does not seem to allow you
>to perform such an operation unless you are adding a new column.

>I don't won't to drop the field and re-add it to the end.

>Any help on this is appreciated.

>Regards Geoff



Mon, 16 Aug 2004 09:52:22 GMT
 Altering a column to Not Null
Would that help?
ALTER TABLE T ADD CONSTRAINT c1_notnull CHECK (c1 IS NOT NULL);

Cheers
Serge

--
Serge Rielau
DB2 UDB SQL Compiler Development
IBM Software Lab, Canada



Mon, 16 Aug 2004 23:12:02 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. altering the null/not null of an existing column

2. Alter column type - NULL to NOT NULL

3. not null column during CTAS(not null definition did not come across)

4. TSQL : ALTER COLUMN to NOT NULL with DEFAULT syntax error

5. Alter table by adding new column with not null

6. ALTER TABLE Column NOT NULL?

7. ALTER TABLE: adding 2 not null integer columns

8. How to change a NULL column to NOT NULL column

9. How to change the column from NULL to NOT NULL

10. inserting null values into not null column in Server 7.0

11. Default for NULL/NOT NULL column property ?

12. How to change the table column from NULL to NOT NULL


 
Powered by phpBB® Forum Software