Subject | Re: [firebird-support] Alter column not null with constraint name FB3 |
---|---|
Author | livius |
Post date | 2018-04-25T19:46:46Z |
Hi Mark,
thank you for your analysis especially about SQL standard.
I have created http://tracker.firebirdsql.org/browse/CORE-5806
regards,
Karol Bieniaszewski
Sent: Wednesday, April 25, 2018 8:27 AM
Subject: Re: [firebird-support] Alter column not null with
constraint name FB3
On 24-4-2018 20:47, 'livius' liviuslivius@...
[firebird-support] wrote:
>Hi,
>
> >
> >
> > I need to add Field not null constraint with my customname.
> > in previous versions of Firebird we can do:ALTER TABLE XXX ADD FIELDX INTEGER CONSTRAINT NK_XXX__FIELDX NOT NULL;
> > 1.
>2.5
> >>Interestingly, that syntax is not documented in the Firebird
> >>language reference.And we use it also in table creation
> it has been available for years.
> Create table AFIELD1 INTEGER CONSTRAINT NK_A_FIELD1 NOT NULL
> (
>
> )is interchangeably between Firebird and Interbase.
> and this syntax
> There is differencein message when null is inserted into not null field.
> In Interbase thereis constraint name in message in Firebird it is not
> included.In Firebird we have “TABLE”.”FieldName” in message.
>
> Will be good ifFirebird will also contain constraint name.
> And this is good if user canname all self created constraint in the
> database like it is for allother PK, FK, UK, CK.
> You can then have in app standardized handlingabout e.g. error messages.
Given named not null constraints are an undocumented feature, you can't
expect too much from it. I suggest you create tickets to get this
documented, and maybe to extend support to allow naming the constraint
when using alter table xxx alter yyy set not null.
I'd suggest something like expanding ALTER TABLE ADD <tconstraint> by
adding the option to tconstraint:
[CONSTRAINT <constraint-name>] NOT NULL (<column-name>)
Or maybe
ALTER TABLE <table name> ALTER <field name> SET [CONSTRAINT
<constraintname>] NOT NULL
Although that might conflict with the oddity of also supporting ALTER
TABLE <table name> ALTER <field name> SET NULL, which is not defined in
the SQL standard and is not a real constraint, and shouldn't get named.
Interestingly, the SQL standard also supports named not null
constraints, but there also naming it using ALTER COLUMN ... SET NOT
NULL is not supported.
Mark
--
Mark Rotteveel