Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!decwrl!nsc!pyramid!infmx!cortesi From: cortesi@infmx.UUCP (David Cortesi) Newsgroups: comp.databases Subject: Re: Union and Views Message-ID: <4937@infmx.UUCP> Date: 1 Aug 90 22:45:37 GMT References: <27663@netnews.upenn.edu> Reply-To: cortesi@infmx.UUCP (David Cortesi) Distribution: usa Organization: Informix, Menlo Park, Ca. U.S.A. Lines: 39 In article <27663@netnews.upenn.edu> aaron@grad2.cis.upenn.edu.UUCP (Aaron Watters) writes: > >In Informix, for example, Unions are not allowed in the >definitions of Views. Why is this? > >Do other systems have this restriction? Indeed they do. First, from An Introduction To Database Systems by Date (4th ed.1987), Section 8.2 "View Definition," In principle, any derivable table -- i.e. any table that can be retrieved via a SELECT statement -- can theoretically be defined as a view. In practice ... DB2 does not allow a view definition to include the UNION operator; however there is no intrinsic reason for that restriction, it is merely a quirk of DB2 per se... Later, Date wrote The SQL Standard (2nd ed., 1989) in which he cites the ANSI syntax for a view (page 88): CREATE VIEW view [ ( column-commalist) ] AS query-specification [WITH CHECK OPTION] and then on page 95 he explicates the meaning of that nonterminal, the "query-specification": query-expression ::= query-term | query-expression UNION [ALL] query-term query-term ::= query-specification | ( query-expression) The construct "query expression" appears only within a cursor definition (note, therefore, that UNION -- with or without ALL -- is not allowed in ... a view definition). So it would appear that the "quirk" of DB2 has been enshrined in the ANSI standard. Hope you find this informative.