Subject Re: [firebird-support] Changing Columns
Author Alan J Davies
I tried this in a test database before replying.
Changed a domain from 4 to 8 char. This is used by various tables as a
PK and got this error message. I then changed other domains to check and
had no problems (done this many times before but possibly not with a PK,
can't remember)

This operation is not defined for system tables.
unsuccessful metadata update.
MODIFY RDB$FIELDS failed.
action cancelled by trigger (1) to preserve data integrity.
Cannot update index segment used by an Integrity Constraint.

So it does seem there is an issue here.

Alan J Davies
Aldis


On 03/07/2015 15:51, Ann Harrison aharrison@...
[firebird-support] wrote:
>
> On Jul 3, 2015, at 8:09 AM, 'checkmail' check_mail@...
> <mailto:check_mail@...> [firebird-support]
> <firebird-support@yahoogroups.com
> <mailto:firebird-support@yahoogroups.com>> wrote:
>
>> I would like to change a primary column in my database from 8 to 16
>> characters. Over 100 Tables are constrained, foreign key reference.
>> Now I can change the DDL from the Database and create this again, but
>> I must import all Data-Tables. An other Option is the changing
>> manually, delete all references, changing and create.
>>
>> Is there another option? Can I change it R 20;offlineā€¯ without the
>> necessity to import all data or change it manually?
>>
>>
>
> If you defined a domain, just change the domain, using a SQL ALTER
> DOMAIN statement. If not, use ALTER TABLE. Firebird will do all the
> necessary magic. Indexes on strings are independent of the length of
> the string - up to a limit and at 16 characters you're nowhere near the
> limit. Strings are comparable regardless of length.
>
> As for the actual data, after you've changed the columns, Firebird will
> return those columns as 16 characters and accept up to 16 characters
> when you store or update the records. That completely hides the fact
> that the previously stored data doesn't change. New records and
> records that have been modified will use the 16 character format. Old
> records will continue to use the 8 character format.
>
> The source of the magic is the "format version number" which every
> record carries. When a table is createed or altered in a way that
> changes its stored form, Firebird generates a format version that
> describes the physical structure of the record. During compilation,
> every statement picks up the current format version for the tables it
> uses. When Firebird reads a record with an older format version, it
> performs the necessary transformations.
>
> Cheers,
>
> Ann
>
>