Question: Hello, I am having problems in section 1-3 and 1-4, which does not allow me to move forward. If someone can look at this and

Hello, I am having problems in section 1-3 and 1-4, which does not allow me to move forward. If someone can look at this and let me know where I am making errors, I would greatly appreciate it. Thank you.

Although we discussed spooling in this chapter, a short-cut way to copy, save and print your SQL output would be to copy and paste your SQL output into a word processor, and then save and print your output from there. We suggest you use the short-cut method the copy and paste method to hand in your exercises. To keep a complete record of your work, it would be good idea to copy/paste your query as well as your query result.

Print a description of the Course table (use DESC Course). Use the SELECT statement to display the actual data. (Just a reminder you will have to use rearp. in front of all the table names, since you are not the owner of these tables. So, you will have to type in rearp.Course instead of just Course in your query).

Create a synonym for the Student table.

Display the table description using the synonym. Display all the data in the Student table using SELECT.DES

1-3. We have supplied a Student-Course database with the following tables (these tables are shown in Appendix 3 of this text):

Student

Course

Section

Prereq (for prerequisite)

Grade_report

Department_to_major

Room

(There are also other tables that will be used later in other exercises [such as Cap and Plants], but they are not tables connected with the Student-Course data). Create synonyms for the tables in the Student- Course database because you will use them extensively. You can shorten the name of the table in your synonym if you like, for example:

CREATE SYNONYM d2m FOR Department_to_major;

Using the synonyms and DESC, show the first few lines of all the tables in the Student-Course data- base. To display the column names and data-types, use DESC. To display the first few lines of the table, use a WHERE on the table name like this:

SELECT * FROM Student WHERE rownum < 5;

Assume you created a synonym, Stu, for the Student table. Rownum is a built-in row counter (also called a pseudo variable). You can also use rownum in the result set of the query like this:

SELECT rownum, sname, major FROM Stu WHERE major = ACCT;

1-4. Using line editing:

Type in and run the statement, SELECT * FROM Prereq;

Use c (the CHANGE command) to edit the statement and display the Course table instead of the Prereq table.

c. Edit and then run the statement by adding a new line that says:

WHERE offering_dept = COSC

So your query should now read:

SELECT *

FROM Course

WHERE offering_dept = COSC;

d. Edit the above query (use a line number and c) to select only course_name in the result set. (Hint: change from * to course_name)

e. Delete the last line (WHERE offering_dept = COSC) of your query and re-run the query.

f. Add a line that says: WHERE offering_dept = MATH to the query, so your query will now read:

SELECT *

FROM Course

WHERE offering_dept = MATH;

Re-run the query.

1-5. You can access system parameters using a dummy table called dual. Run the following statement:

SELECT sysdate, user FROM dual;

Oracle provides Dual as a convenient table guaranteed to return at least one row and one column.

The system also keeps the time and you can show it like this:

SELECT TO_CHAR (sysdate,dd-Mon-yyyy hh24:mm:ss) FROM dual

Other date formats are also available, and will be discussed later in this text.

1-6. Print out a list of the system parameters.

1-7. Print out the options that you have for the SAVE option when you use HELP.

1-8. How would you change your password if you had to?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!