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: ## Primary key issue ##

Re: ## Primary key issue ##

From: Howard J. Rogers <hjr_at_dizwell.com>
Date: Tue, 07 Dec 2004 19:14:37 +1100
Message-ID: <41b5666c$0$20379$afc38c87@news.optusnet.com.au>


M.Senthil Kumar wrote:
> Is it possible to assign 2 primark column in a table....
> I saw a table using TOAD( Front End tool for Oracle ). In that table
> it numbered under the column pk 1 and 2. Clear my doubts...

Create table emp (
empno number,
ename varchar2(20),
sal number,
deptno number);

Alter table emp add constraint (emp_pk primary key (empno, ename));

Of course a combination of columns can be unique and not null (and thus perhaps qualify as a primary key for the table).

You cannot declare such a multi-column constraint "inline" with the column declarations (because which of the multiple columns would you pick to declare it at... either would be wrong). But you can declare the constraint "out of line" as a chunk of SQL at the end of the create table statement, or you can do it as I've just shown you, with an alter table command issued after the create table statement has completed.

Regards
HJR Received on Tue Dec 07 2004 - 02:14:37 CST

Original text of this message

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