Invoke an editor from SQL*Plus; create a file called first.sql containing an SQL statement that retrieves data from the COURSE table for courses that cost 1195, and whose descriptions start with 'Intro', sorted by their prerequisites.
Solution:
/* ----------------------------------------------------- File name: first.sql Purpose: Display data from course table Created by: Joe Morris on December 7, 2002 ----------------------------------------------------- */ SELECT * FROM course WHERE cost = 1195 AND description like 'Intro%' ORDER BY prerequisite;
Create another file called second.sql that retrieves data from the STUDENT table for students whose last names begin with 'A','B', or 'C', and who work for 'Competrol Real Estate', sorted by their last names.
Solution:
/* ----------------------------------------------------- File name: second.sql Purpose: Display data from course table Created by: Joe Morris on December 7, 2002 ----------------------------------------------------- */ SELECT * FROM student WHERE (last_name like 'A%' OR last_name like 'B%' OR last_name like 'C%') AND employer = 'Competrol Real Estate';
Create yet another file called third.sql that retrieves all the descriptions from the GRADE_TYPE table, for rows that were modified by the user MCAFFREY.
Solution:
/* ----------------------------------------------------- File name: third.sql Purpose: Display data from course table Created by: Joe Morris on December 7, 2002 Modified by: --- ----------------------------------------------------- */ SELECT description FROM grade_type WHERE modified_by = 'MCAFFREY';
Execute each of the files, in the order they were created.
Solution: Make sure you specify the correct location of the file when you execute it at the SQL*Plus prompt. For example, if you created the files in a directory called c:\guest, you need to execute the files at the SQL*Plus prompt as follows:
@c:\guest\@first @c:\guest\@second @c:\guest\@third
Note, instead of using the @ symbol you can also use the START command. Refer to Appendix C, "SQL*Plus Command Reference," for more SQL*Plus commands.