Subject | Re: [firebird-support] Computed column for primary key |
---|---|
Author | Alan J Davies |
Post date | 2011-06-09T12:47:52Z |
I've just created a table with the data you show and a PK of dept_id,
build_id and this is the copied and pasted result.
Seems perfect to me, or am I missing the point?
CREATE TABLE NEW_TABLE (
DEPT_ID INTEGER NOT NULL,
BUILD_D INTEGER NOT NULL
);
ALTER TABLE NEW_TABLE ADD CONSTRAINT PK_NEW_TABLE PRIMARY KEY (DEPT_ID,
BUILD_D);
select n.dept_id, n.build_d, n.dept_id||'-'||n.build_d acct_nmbr
from new_table n
DEPT_ID BUILD_D ACCT_NMBR
1 1 1-1
1 21 1-21
12 1 12-1
Alan J Davies
Aldis
build_id and this is the copied and pasted result.
Seems perfect to me, or am I missing the point?
CREATE TABLE NEW_TABLE (
DEPT_ID INTEGER NOT NULL,
BUILD_D INTEGER NOT NULL
);
ALTER TABLE NEW_TABLE ADD CONSTRAINT PK_NEW_TABLE PRIMARY KEY (DEPT_ID,
BUILD_D);
select n.dept_id, n.build_d, n.dept_id||'-'||n.build_d acct_nmbr
from new_table n
DEPT_ID BUILD_D ACCT_NMBR
1 1 1-1
1 21 1-21
12 1 12-1
Alan J Davies
Aldis
On 09/06/2011 13:23, Gordon Niessen wrote:
> On 6/9/2011 3:29 AM, Alan J Davies wrote:
>> If every record has this character "-", it becomes meaningless in an
>> index. All you need is this:
> This might not be true in all cases. Take for example the following
> data set:
> DEPT_ID BUILD_ID ACCOUNT_NBR
> 1 1 1-1
> 1 21 1-21
> 12 1 12-1
>
> Separators can be important.