Subject Re: [firebird-support] How to change Index Key Name of Primary Key
Author Helen Borrie
At 07:29 PM 24/01/2004 +0800, you wrote:
>Hi there,
>
>I have the following script:
>
>
>CREATE TABLE "AADDRESS" (
> "CUSTOMER_ID" VARCHAR(10) CHARACTER SET ISO8859_1 NOT NULL ,
> "COUNTER" CHAR(5) CHARACTER SET ISO8859_1 NOT NULL PRIMARY KEY ,
> "ADDRESS_ID" VARCHAR(15) CHARACTER SET ISO8859_1 NOT NULL ,
> "ADDRESS_LINE1" VARCHAR(40) CHARACTER SET ISO8859_1 ,
> "ADDRESS_LINE2" VARCHAR(40) CHARACTER SET ISO8859_1 ,
> "ADDRESS_LINE3" VARCHAR(40) CHARACTER SET ISO8859_1 ,
> "ADDRESS_LINE4" VARCHAR(40) CHARACTER SET ISO8859_1 ,
> "ADDRESS_LINE5" VARCHAR(40) CHARACTER SET ISO8859_1 ,
> "APPROVEDBY" VARCHAR(10) CHARACTER SET ISO8859_1 ,
> "LOCKED" INTEGER NOT NULL ,
> "ROLLEDOVER" INTEGER NOT NULL
>)
>
>Instead of having PRIMARYKEY as the Index Key Name , how should to change
>the script to change the default name of the Primary Key?

You can't change the name of the PK, but if you want it to have a custom
name, use the Named Constraint syntax:
CREATE TABLE "AADDRESS" (
"CUSTOMER_ID" VARCHAR(10) CHARACTER SET ISO8859_1 NOT NULL ,
"COUNTER" CHAR(5) CHARACTER SET ISO8859_1 NOT NULL ,
"ADDRESS_ID" VARCHAR(15) CHARACTER SET ISO8859_1 NOT NULL ,
"ADDRESS_LINE1" VARCHAR(40) CHARACTER SET ISO8859_1 ,
"ADDRESS_LINE2" VARCHAR(40) CHARACTER SET ISO8859_1 ,
"ADDRESS_LINE3" VARCHAR(40) CHARACTER SET ISO8859_1 ,
"ADDRESS_LINE4" VARCHAR(40) CHARACTER SET ISO8859_1 ,
"ADDRESS_LINE5" VARCHAR(40) CHARACTER SET ISO8859_1 ,
"APPROVEDBY" VARCHAR(10) CHARACTER SET ISO8859_1 ,
"LOCKED" INTEGER NOT NULL ,
"ROLLEDOVER" INTEGER NOT NULL,
CONSTRAINT PK_AADDRESS PRIMARY KEY(COUNTER)
);

1.5 will name the index the same as the constraint but you can define
custom names for the PK, UK and FK indexes and make them DESC if you want
to. See Release notes...

I'm puzzled about "Instead of having PRIMARYKEY as the Index Key
Name..". Isn't it named RDB$PRIMARYnn (nn being a number)?

/heLen