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 determine uniqueness in PL/SQL

Re: How to determine uniqueness in PL/SQL

From: Dianna Whitt <dwhitt_at_csihq.com>
Date: Thu, 13 May 1999 11:58:58 GMT
Message-ID: <7heeq2$379$1@nnrp1.deja.com>


In article <373A5B87.D6D2A087_at_dpiwe.tas.gov.au>,   Ruiping Gao <ruiping_at_dpiwe.tas.gov.au> wrote:
> I have a table which has combination of columns as the table's primary
> key. When ever people want to insert records into table, I would like
> create a trigger to check if it is duplicated records according to my
> combination primary key. If it's duplicated records, the system will
> refuse to accept the records, otherwise the new records can be in. But
I
> don't know how to do it? Please help.
>
> Thanks in advance
>
> Ruiping
>
> e_mail:ruiping_at_dpiwe.tas.gov.au
>
>

How can I eliminate duplicates values in a table?

Method 1:

   SQL DELETE FROM table_name A WHERE ROWID (

     2    SELECT min(rowid) FROM table_name B
     3    WHERE A.key_values = B.key_values);

Method 2:

   SQL create table table_name2 as select distinct * from table_name1;    SQL drop table_name1;
   SQL rename table_name2 to table_name1;

Method 3: (DGW)

  SQL> delete from table_name

            where stuff-You_what-to-delete-values and
            rowid <> (select max(rowid) from ditest where
            stuff-You_what-to-delete-values)
--

Dianna G. Whitt Principal Engineer
dwhitt_at_csihq.com 407-676-2923,x413
http://www.csi.cc Computer Science Innovations

--== Sent via Deja.com http://www.deja.com/ ==-- ---Share what you know. Learn what you don't.--- Received on Thu May 13 1999 - 06:58:58 CDT

Original text of this message

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