5.25 Exercises 159
STUDENTS ADDR CHAR STUDENTS CITY CHAR STUDENTS STATE CHAR STUDENTS ZIP CHAR
A more complete list of objects that belong to the current user can be found in the view USER OBJECTS which lists all objects created by the user, including those mentioned in USER CATALOG, as well as other useful information (such as the date of creation, the last time when the object was affected by a data definition statement, the status of the object, etc.) The definition of views can be accessed by the USER VIEWS catalog view. Example 5.24.1 The meta-view (view about views) USER VIEWS has the structure described below:
Name Null? Type ------------------------------- -------- -------------VIEW_NAME NOT NULL VARCHAR2(30) TEXT_LENGTH NUMBER TEXT LONG TYPE_TEXT_LENGTH NUMBER TYPE_TEXT VARCHAR2(4000) OID_TEXT_LENGTH NUMBER OID_TEXT VARCHAR2(4000) VIEW_TYPE_OWNER VARCHAR2(30) VIEW_TYPE VARCHAR2(30) SUPERVIEW_NAME VARCHAR2(30)
The last six attributes are important for object views discussed in Chapter 7. To extract the definition of the view UPPERGR defined above we write:
select text from user_views where view_name=’UPPERGR’; This query returns the result:
TEXT -----------------------------------------------------------select "STNO","EMPNO","CNO","SEM","YEAR","GRADE" from GRADES where grade > 75
5.25 Exercises
1. Solve the following queries in SQL: (a) Find all students who live in Malden or Newton. (b) Find all students whose name starts with ’F’; (c) Find all students whose name contains the letter ’f’; 2. A select phrase equivalent to the union-computing select
select stno from grades where cno = ’cs210’ union select stno from grades where cno = ’cs240’;