Subject | Re: [firebird-support] Changing Columns |
---|---|
Author | Ann Harrison |
Post date | 2015-07-03T14:51:11Z |
On Jul 3, 2015, at 8:09 AM, 'checkmail' check_mail@... [firebird-support] <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