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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Unique Index on a view

Re: Unique Index on a view

From: Brian Peasland <peasland_at_edcmail.cr.usgs.gov>
Date: Wed, 22 Nov 2000 14:05:44 GMT
Message-ID: <3A1BD2B8.D08A9EB3@edcmail.cr.usgs.gov>

> The point is not to have a contraint on a view, or even to limit its
> output. I was trying to accomplish uniqueness in one row for two
> tables. Just curious if it is in someway possible.

It's always possible, just not with an index.

As has already been stated, you can not put an index (or constraint) on a view. A view is nothing more than a stored SELECT statement. For instance, given "SELECT a FROM a WHERE b=c", how would you put an index on that? You can't.

So now the question is, are you trying to select unique values to be returned from a query, or are you trying to ensure uniqueness between the two tables, i.e. ensuring that no one value exists in both tables?

If you are trying to select unique values to be returned from a query and you didn't like the previous answers, try:

   SELECT DISTINCT c FROM (

      SELECT a FROM a
      UNION (ALL)
      SELECT b FROM b);

If you are trying to ensure uniqueness between the two tables, then you'll need to use triggers.

HTH,
Brian

-- 
========================================
Brian Peasland
Raytheons Systems at
  USGS EROS Data Center
These opinions are my own and do not
necessarily reflect the opinions of my 
company!
========================================
Received on Wed Nov 22 2000 - 08:05:44 CST

Original text of this message

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