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: Simple SQL quetsion

Re: Simple SQL quetsion

From: Chrysalis <cellis_at_iol.ie>
Date: 1997/06/12
Message-ID: <33A047CB.75CB@iol.ie>#1/1

Bill Bearden wrote:
>
> A true primary key can't be null. If this is truly a primary key, select
> count(*) should be the same as selecting count(distinct primary_key).
>
> Here is one way to check for distinct composite key...
>
> select count(distinct to_char(organization_id) +
> to_char(inventory_item_id)) k
> from inv.mtl_system_items;
>
> Bill Bearden
> Consultant
> Nimrod Oren <orenn_at_inter.net.il> wrote in article
> <339F1A31.3242EF0_at_inter.net.il>...
> > I'm using the rule-based optimizer and I try to get the number of
> > records from a table with a composite primary-key.
> > Select count(*) does a full table scan. Is there a way to count the
> > occurrences of the primary key (hopefully without hints)?
> >
> >

If it's a primary key, you don't need to specify distinct! Also I suspect the "+" in you answer should be the concatenation character. You could also use concat(organization_id,inventory_item_id).

Chrysalis. Received on Thu Jun 12 1997 - 00:00:00 CDT

Original text of this message

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