Subject Re: [ib-support] Adding a default value for a field
Author Claudio Valderrama C.
""Stevio"" <redeagle@...> wrote in message
news:000501c1d0ec$6d378960$0200a8c0@......
> Hi all,
>
> How can I specify a default value for a field that already exists in a
> table?
>
> The field is called IS_DELETED and is specified as follows:
>
> IS_DELETED VARCHAR(1),
>
> I want it to have a default value of F (for false).

create domain d_is_deleted varchar(1) default 'F';
alter yourtable alter is_deleted type d_is_delete;

Otherwise, locate the RDB$NN implicit domain that your field is_deleted use:

select rdb$field_source from rdb$relation_fields
where rdb$field_name = 'IS_DELETED'
and rdb$relation_name = <yourtable>;
=> this gives a <dom_name> as the result

then use
alter domain <dom_name> set default 'F';

I think we need to make this facility available without tricks, directly in
DDL:
alter tbl alter col set default <something>;
alter tbl alter col drop default;
Sean, would you log this feature request? Thank you.

C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing