Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Can I change the primary key on a table?

Re: Can I change the primary key on a table?

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Wed, 19 Jan 2005 20:18:59 +0800
Message-ID: <41EE5032.6A38@yahoo.com>


deanbrown3d_at_yahoo.com wrote:
>
> Ok basic question here. I want to insert a column after the first one
> (which is currently the primary key), and extend the PK to be the first
> TWO comlumns now. I'm using 10g client and 9 server, if this helps. Is
> there a way to do this without creating another intermediate table?
>
> e.g.
>
> Table A = (TRAIN_I, ARR_TIME, DEPT_TIME, etc)
> PK = TRAIN_I
>
> Want now:
> Table A = (TRAIN_I, VERSION_I, ARR_TIME, DEPT_TIME, etc)
> PK = TRAIN_I, VERSION_I
>
> Many thanks
>
> Dean

alter table T drop primary key;

alter table T add primary key ( a,b,c,d );

hth
connor

-- 
Connor McDonald
Co-author: "Mastering Oracle PL/SQL - Practical Solutions"
ISBN: 1590592174

web: http://www.oracledba.co.uk
web: http://www.oaktable.net
email: connor_mcdonald_at_yahoo.com

Coming Soon! "Oracle Insight - Tales of the OakTable"

"GIVE a man a fish and he will eat for a day. But TEACH him how to fish,
and...he will sit in a boat and drink beer all day"

------------------------------------------------------------
Received on Wed Jan 19 2005 - 06:18:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US