Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Unique Index on a view
> 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
![]() |
![]() |