Subject Re: [firebird-support] alter column drop default (firebird 2.x)
Author Maximiliano Robaina
El mar, 17-01-2012 a las 14:27 +0100, Thomas Steinmaurer escribió:
>
> > If I want to drop a column-level default, in firebird 2.x I can do
> >
> > ALTER TABLE tablename ALTER [COLUMN] colname DROP DEFAULT
> >
> > But, if [COLUMN] has not a default value setting, that statement
> raise
> > an error.
> > The question is, How can I to know if a field has set a default
> value?
> >
> > Query against system tables? Which one?
>
> The following gives you all fields for a given relation and a
> separate
> field if the field has a default value. Change the query for your
> needs.
>
> select
> rf.rdb$relation_name
> , rf.rdb$field_name
> , case
> when f.rdb$default_value is not null then 1 else 0
> end has_default
> from
> rdb$fields f join rdb$relation_fields rf on f.rdb$field_name =
> rf.rdb$field_source
> where
> rf.rdb$relation_name = <your_relation>
>
> Hope this helps.

What is the difference between rdb$relation_fields.default_value and rdb
$fields.default_value ?

Regards.
Maxi.