CIS/336 iLab 5 of 7 - SQL Course
Lab 5 of 7: Retreiving data from Multiple Tables (28 points)
L A B O V E R V I E W
Lab 5 deals with writing queries using multiple tables as covered in the reading and lecture material this week. In some cases, you will be given the option to write a query using either the TRADITIONAL method of joining tables or using the JOIN key word. In some cases, you will be asked to use a specific approach. Using the incorrect process when the process is specified will result in points being taken off for that problem.
The SELECT statement is the primary means of extracting data from database tables, and allows you to determine exactly which data you want to extract by means of different comparison operators used in the WHERE clause. This includes the use of specific "wild card" characters which allow you to search for character or number patterns within the data. You can also perform mathematical expressions within the SELECT statement to create derived output. The ORDER BY clause allows you to sort the output data in either ascending (the default) or descending order. Lab #5 will explore all of these applications of the SELECT statement. General Lab Information and Considerations
This lab will utilize a set of tables found in the script file (LeeBooks.sql) found in the Doc Sharing area of the website. If you have not yet downloaded this file from Doc Sharing then do so now. Once you have downloaded the script file, import and run the script in SQL*Plus. Each query in the script file you will create must be numbered (use --1 comments for numbering) and in order. The SQL for the following exercises should be written using notepad and run in SQL*Plus.
A Clean Script File:
A script file is meant to be like a program. The file can be run every time the code needs to be executed without having to retype the code again each time. For this reason, it is important that there are no errors in the code inside the file. You can go back and forth between Notepad and Oracle when creating your script file to check your queries and verify if they work or not, but you do not want to create your final output file until after you have verified that everything in your script is correct by running it, in its entirety at least once and viewing the output. Once this has been done, you can create your final output file, with echo on to create the document you can turn in with your lab. If using a Spool Session, be sure to type "SPOOL OFF" AT THE SQL> after your Script Stops Spooling!
Lab Do's and Don’t's
Do Not include the LEEBOOKS.SQL as part of your lab script.
Do use Notepad to write your query script file.
Do Not write your queries in Word.
Do test each query before moving on to the next.
Do Not include extra queries for a problem unless the problem explicitly asks for more than one query.
Do test your queries before creating your final output file.
Do Not turn in a script file that has queries with errors.
Do number each query using --1 comment notation.
Do Not start your query on the same line as the comment.
Do remember to check your final output and script file for accuracy.
Do Not turn in your lab without first checking your output file to verify that it is correct.
Things to keep in mind:
If you are not sure of the table names in your user schema, you can use the following select statement to list them.
SELECT * FROM TAB;
If you want to know the name of the columns in a particular table, you can use the following command to list them.
Making a script file containing a series of describe statements for each table and then spooling the output will give you a listing of all the tables with column names. Be sure to review and verify your final output when you are finished. Do Not assume anything. Write queries for each of the stated problems in the steps below that will return a result set of data to...
Please join StudyMode to read the full document