Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: ## Primary key issue ##
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
![]() |
![]() |