Subject Re: [firebird-support] Computed column for primary key
Author Kjell Rilbe
Den 2011-06-09 01:14 skrev firebirdsql såhär:
>
>
> CREATE TABLE accounts
> (
> dept_id INT,
> build_id INT,
> account_nbr COMPUTED BY (dept_id || '-' || build_id),
> PRIMARY KEY(account_nbr)
> );
>
> It complains that I cannot use an computed column for the index. How
> would I fix this?

CREATE TABLE accounts
(
dept_id INT,
build_id INT,
account_nbr COMPUTED BY (dept_id || '-' || build_id),
PRIMARY KEY(dept_id, build_id)
);

> Also, is using computed columns slow vs storing the actual value?

Why do you need to store it? I would assume it's faster to store the
concatenated values, but it will take up more disk space. With primary
key as per my suggestion combined with the computed column should
suffice, or am I missing something?

Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64