Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: What is the difference between UNIQUE and PRIMARY KEY?
Brian Tkatch wrote:
>
> On Wed, 11 Apr 2001 22:17:29 +0100, "Bart" <Bart_at_opcomp.demon.co.uk>
> wrote:
>
> >A primary key is, by definition, the primary key to a table and a table can
> >have only one.
> >
> >A primary key is not an index, although is usually has an associated index.
> Usually? It always has one. If you do not specify one in the clause,
> it will create one of the same name.
> >
> >A table can have any number of unique indexes.
> >
> >A foreign key can only reference a primary key.
> You mean a Foreign Key when not specifiying a column looks for the
> primary key. It can reference either a primary or a unique key.
>
> create table a (a number unique, b number references a(a))
>
> I would guess a Primary Key is the same thing as not null and unique
> index. It just is the default reference for foreign keys, and other
> programs (such as access) which require a key for updating, will look
> for the primary key.
>
> Brian
You can in more recent versions of Oracle have a primary key based on a non-unique index
-- =========================================== Connor McDonald http://www.oracledba.co.uk (mirrored at http://www.oradba.freeserve.co.uk) "Some days you're the pigeon, some days you're the statue"Received on Thu Apr 12 2001 - 05:22:54 CDT