Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How to modify and extend PRIMARY KEY by SQL
Tue, Jul 10 2007 6:20 PMPermanent Link

Jan Hornstrup
Hi.

Can anybody help me how to modify an existing PRIMARY KEY.

My existing DBISAM v3.x Table looks like this:

Field                 DataType    Size        Primary index
---------------------------------------------------------------
1   Code           Integer                             Yes
2   PortCode     String           5                   Yes
3   Name          String         30                   No
etc......


Now I want to extend the PRIMARY KEY with an aditional field in First position.
The new field is named LbNo and the datatype is AutoInc.


The structure below, should be the new structure:

Field                 DataType    Size        Primary index
---------------------------------------------------------------
1   LbNo            AutoInc                            Yes
2   Code           Integer                             Yes
3   PortCode     String           5                   Yes
4   Name          String         30                   No
etc......

As this gives me "more" gray hair, I am looking forward to any answers !!!


Brgds

Jan Hornstrup
Soft-Team
Denmark
(jhc@soft-team.dk)

Tue, Jul 10 2007 6:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Jan,

<< Can anybody help me how to modify an existing PRIMARY KEY. >>

Do you want to use SQL or code ?  I'm assuming SQL because that's the
newsgroup that you used, but I just want to make sure. Smiley

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Jul 11 2007 1:29 PMPermanent Link

Jan Hornstrup
Hi Tim.

Yes, I want it in SQL-code, as I should provide it for many of our customers !

Brgds Jan Hornstrup




"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Jan,

<< Can anybody help me how to modify an existing PRIMARY KEY. >>

Do you want to use SQL or code ?  I'm assuming SQL because that's the
newsgroup that you used, but I just want to make sure. Smiley

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Jul 11 2007 7:45 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Jan,

<< Yes, I want it in SQL-code, as I should provide it for many of our
customers ! >>

Use something like this:

ALTER MyTable
DROP PRIMARY KEY,
ADD PRIMARY KEY (LbNo, Code, PortCode);

--
Tim Young
Elevate Software
www.elevatesoft.com

Image