Previous Topic Next topic Print topic


Querying Views

Restriction: This topic applies to Windows environments only.

You may query a view just like a table, provided you have SELECT authority on the view. For example, assume that the redparts view was originally defined as follows:

CREATE VIEW redparts
  AS SELECT *
  FROM part
  WHERE color = 'RED'

The following query retrieves a subset of column values from this view (the view itself being a subset of the original PART table):

SELECT pno, city
  FROM redparts

The query result appears below:

pno city
P1 LONDON
P4 LONDON
P6 LONDON

The next example also queries the redparts view:

SELECT *
  FROM redparts
  WHERE weight < 15

The query results appear below:

pno pname color weight city
P1 NUT RED 12 LONDON
P4 SCREW RED 14 LONDON
Previous Topic Next topic Print topic