Re: default
Posted in 1997
>Date: Tue, 08 Jul 1997 08:38:12 -0600
>From: Thuc Nguyen <thucn@email.utcourts.gov>
>X-Informix-List-Id: <list.15347>
>
>alter table nonmon_bond_detl add
> undetermined_value CHAR(1)
> # how to restrict to "Y" or "N" on undetermined_value? I tried default>"Y" or "N".
> note VARCHAR(255)
You can't add a non-null column to a table which contains data, and I assume
the table does contain data. Therefore, you'll need to do something like:
ALTER TABLE nonmon_bond_detl
ADD (undetermined_value CHAR(1) DEFAULT 'Y'
CHECK (undetermined_value IN ('Y', 'N'))
CONSTRAINT c1_nonmon_bond_detl,
note VARCHAR(255)
);UPDATE nonmon_bond_detl
SET undetermined_value = 'Y'
WHERE undetermined_value IS NULL;
ALTER TABLE nonmon_bond_detl
MODIFY (undetermined_value CHAR(1) NOT NULL);
I haven't formally verified that the second ALTER TABLE does not lose the
default information -- you should do so on a trial table before playing
with a production database.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
PS: I decline to respond to messages with anti-spam in the return path.