On 24-4-2018 15:40, Mark Rotteveel m...@lawinegevaar.nl 
[firebird-support] wrote:
> On 24-4-2018 09:34, liviuslivius liviusliv...@poczta.onet.pl
> [firebird-support] wrote:
>>
>>
>> Hi,
>> I need to add Field not null constraint with my custom name.
>> in previous versions of Firebird we can do:
>> 1. ALTER TABLE XXX ADD FIELDX INTEGER CONSTRAINT NK_XXX__FIELDX NOT NULL;
> 
> Interestingly, that syntax is not documented in the Firebird 2.5
> language reference.
> 
>> 2. UPDATE TABLE XXX SET FIELDX=some calculations;
>> Now in Firebird 3 this is prohibited on table with data.
> 
> It is prohibited, unless you apply a default.
> 
>> Then i do this on FB3.
>> 1. ALTER TABLE XXX ADD FIELDX INTEGER;
>> 2. UPDATE TABLE XXX SET FIELDX=some calculations;
>> 3. Add not null - how? I see only ALTER TABLE XXX ALTER FIELDX SET NOT
>> NULL; there are not place for constraint name
>> i need to add Field not null constraint with my custom name.
> 
> alter table xxx add constraint NK_XXX__FIELDX check (fieldx is NOT NULL)
> 
> Internally, a `not null`-constraint is just a check constraint.

Correction, I was mistaken, and this is not true. It will have 
equivalent behavior, but it is not 100% the same. In any case, the 
option to define a named NOT NULL constraint seems to be an undocumented 
oddity of the alter table syntax.

Mark

-- 
Mark Rotteveel
  • [firebird-supp... liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
    • Re: [fire... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
      • Re: [... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
      • Re: [... 'livius' liviusliv...@poczta.onet.pl [firebird-support]
        • R... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
          • ... 'livius' liviusliv...@poczta.onet.pl [firebird-support]

Reply via email to