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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to select a primary key?

Re: How to select a primary key?

From: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Fri, 5 Jul 2002 12:52:11 +0100
Message-ID: <3d25886c$0$8511$ed9e5944@reading.news.pipex.net>


If you want a primary key then you need to define one.

alter table coffees add constraint pk_coffees primary key (<key column name>);

will add a primary key named pk_coffees for you.

Expecting INSERT statements to update prexisting rows is just wrong. to update an existing row you use the UPDATE statement.

--
Niall Litchfield
Oracle DBA
Audit Commission UK
*****************************************
Please include version and platform
and SQL where applicable
It makes life easier and increases the
likelihood of a good answer

******************************************
"Konrad Den Ende" <konrad_at_voxway.com> wrote in message
news:ag3rf0$17m$1_at_news.gu.se...

> When i execute the example on Suns website:
> "INSERT INTO COFFEES " +
> "VALUES ('Colombian', 101, 7.99, 0, 0)");
> then everything is fine the first time.
>
> What i expected it to do the next time i execute the
> very same line is to UPDATE row 'Colombian' with
> (the same) values provided.
>
> To my amazment i get more and more rows with the same
> name. I understand that Oracle believs i don't want to
> use any primary key. Why? How to solve this?
> --
>
> Vänligen
> Konrad
> -------------------------------------------------------
> URL: http://konrads.webbsida.com
> E-Mail: konrad_at_voxway.com
> Phone: (+46) 0708 - 70 73 92
> ICQ: 132 250 451
>
>
>
>
>
Received on Fri Jul 05 2002 - 06:52:11 CDT

Original text of this message

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