× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Folks:

I've observed something interesting recently.

If you create a table with a field that's specified as 'NOT NULL', the table will be created fine.

CREATE TABLE TEST1 (F1 CHAR (10) NOT NULL)

If you try to ADD a column to that table with a field that's also specified 'NOT NULL', the column WILL NOT be added because it lacks a default value.

ALTER TABLE TEST1 ADD COLUMN F4 CHAR (10) NOT NULL
NOT NULL clause not allowed.

If you specify a implicit or explicit default value for the column, the column will be created fine.

ALTER TABLE TEST1 ADD COLUMN F4 CHAR (10) NOT NULL WITH DEFAULT
ALTER completed for table TEST1.

Any idea why the table can be created without a default value on the column but can't be altered in the same way?

As a side note, at least on 6.1, if you specify a CCSID value on the add column statement, the lack of a default value does not generate an error.

ALTER TABLE TEST1 ADD COLUMN F4 CHAR (10) NOT NULL CCSID 37
ALTER completed for table TEST1

david




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.