database programming - section 13 - oracledatabase programming - section 13 page 15 tell me / show...

64
Database Programming - Section 13 Instructor Guide

Upload: others

Post on 24-Feb-2020

87 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Database Programming - Section 13 Instructor Guide

Page 2: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may
Page 3: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page i

Table of Contents

Database Programming - Section 13..............................................................................................................1 Lesson 1 - Practice Exercises and Review.....................................................................................................1 What Will I Learn? ........................................................................................................................................2 Why Learn It?................................................................................................................................................3 Tell Me / Show Me........................................................................................................................................4 Try It / Solve It ..............................................................................................................................................5 Lesson 2 - Putting It All Together .................................................................................................................11 What Will I Learn? ........................................................................................................................................13 Why Learn It?................................................................................................................................................14 Tell Me / Show Me........................................................................................................................................15 Try It / Solve It ..............................................................................................................................................16 Lesson 3 - Creating and Revoking Object Privileges ....................................................................................18 What Will I Learn? ........................................................................................................................................20 Why Learn It?................................................................................................................................................21 Tell Me / Show Me........................................................................................................................................22 Try It / Solve It ..............................................................................................................................................38 Lesson 4 - Practice Exercises ........................................................................................................................41 What Will I Learn? ........................................................................................................................................42 Why Learn It?................................................................................................................................................43 Tell Me / Show Me........................................................................................................................................44 Try It / Solve It ..............................................................................................................................................45 Lesson 5 - Practice Exercises and Quiz .........................................................................................................55 What Will I Learn? ........................................................................................................................................56 Why Learn It?................................................................................................................................................57 Tell Me / Show Me........................................................................................................................................58 Try It / Solve It ..............................................................................................................................................59

Page 4: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may
Page 5: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 1

Lesson 1 - Practice Exercises and Review

Lesson 1 - Practice Exercises and Review

Lesson Preparation

Use the section Study Guide and Vocabulary to review for the quiz. Students should complete the 10 review questions. Review the answers before students take the quiz.

What to Watch For None.

Connections None.

Page 6: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 2

What Will I Learn?

What Will I Learn?

Page 7: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 3

Why Learn It?

Why Learn It?

Page 8: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 4

Tell Me / Show Me

Tell Me / Show Me

Page 9: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 5

Try It / Solve It

Try It / Solve It

Try It / Solve It

Complete and review the practice exercises. Assign SQL Quiz. A passing score is 7 out of 10. Assessment: You may want to encourage students to retake the quiz until they achieve a passing score. Or you may prefer to allow only one attempt at the quiz. Allow 20 minutes for the quiz and 10 minutes for assessment/discussion afterward. Have students work in pairs to review what they missed on the quiz. Based on the types of questions they missed, have each pair of students choose one question they missed or did not understand to present to the group. Use this discussion to assess student understanding. Answers: 1. b. The value 999 will not be generated by this sequence f. USER_OBJECTS documents this sequence in the data dictionary.

Page 10: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 6

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 2. d. email VARCHAR2(25) CONSTRAINT emp_email_ukUNIQUE, h. CONSTRAINT employee_id_pk PRIMARY KEY(employee_id),

Page 11: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 7

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 3. b. USER_SEQUENCES 4. e. None of the above Indexes cannot be modified -- instead, DROP and re-create.

Page 12: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 8

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 5. c. USER_IND_COLUMNS 6. c. The synonym is not accessible to all users.

Page 13: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 9

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 7. b. 6, 9, 12 8. c. Most queries are expected to return more than 5% of the rows.

Page 14: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 10

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 9. b. FOREIGN KEY c. PRIMARY KEY d. UNIQUE COMPOSITE KEY 10. b. FROM

Page 15: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 11

Lesson 2 - Putting It All Together

Lesson 2 - Putting It All Together

Lesson Preparation

The Internet has extensive resources for each component in this lesson. Use the search-engine keywords: cover letter, resume, follow-up letter. Students should be able to locate samples other than those shown in this lesson.

What to Watch For Students may not see the value in preparing a cover letter or follow-up letter. Help students think beyond the job application. Let them know that there is competition for every job. They need to stand out from the other candidates and that happens in the details. Students don't always know how to present themselves in a positive light. Help them capitalize on their strengths. Set the standard for what is acceptable in each of the final products. Refuse to accept "It's good enough for me." They are not doing the hiring for these jobs. Students may not know what kind of paper these documents should be printed on. If possible, show them various types of papers that are appropriate. Office supply stores often sell paper by the sheet, and the school office may have stationery to use for demonstration purposes. Ask students why they think the administration uses this kind of paper for correspondence.

Page 16: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 12

Possible answers include: Professionalism and making a good impression; their correspondence is "official.“

Connections Relate other times when a resume, cover letter, and follow-up letter are used -- e.g., applying to a college or university; applying for a college scholarship.

Page 17: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 13

What Will I Learn?

What Will I Learn?

What Will I Learn?

Read the objectives to students. Briefly explain that the purpose of a cover letter is to highlight your skills for a job and the follow-up letter is a "thank you for the interview" response.

Page 18: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 14

Why Learn It?

Why Learn It?

Why Learn It?

Discuss the idea of "first impressions." Show students two assignments you've received -- one hand-written and messy; the other perfectly typed and neat. Ask students which one an employer would read first? Explain that this lesson addresses the details of getting a job. It will demonstrate that the first impression you make when applying for a job will determine whether you'll receive an interview or be called back again.

Page 19: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 15

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

For purposes of this lesson, students may be less intimidated if they think of applying for a job at a fast-food restaurant or a grocery store. They may want to create a resume for a job as baby sitter, retail-store clerk, landscape-maintenance worker, or other job that is attainable for secondary-school students. Ask students to suggest places that they know will hire young adults. The intent of this lesson is to develop writing skills and to learn how to create a "spotless" resume, cover letter, and follow-up letter. Use the sample professional resume as a guide.

Page 20: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 16

Try It / Solve It

Try It / Solve It

Try It / Solve It

Explain that the cover letter is not a rewrite of the resume. The cover letter needs to highlight those skills from the resume that will be of unique interest to the person making the hiring decision. Help students identify which skills the person hiring would be looking for based on the description. Then assist them as they write out how they have related experiences that demonstrate these skills.

Page 21: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 17

Try It / Solve It

Try It / Solve It

Page 22: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 18

Lesson 3 - Creating and Revoking Object Privileges

Lesson 3 - Creating and Revoking Object Privileges

Lesson Preparation

None. What to Watch For

Students granting privileges to other students on their objects can have disastrous results. Begin the practice exercises granting SELECT on a copy of the d_songs table using WITH GRANT OPTION. After students have had a chance to regrant this privilege to others in the class, you can discuss the other privileges (INSERT, DELETE) and what they mean if someone else can access and change your tables. Tell students that they, not the teacher, are in charge of maintaining the integrity of their own tables.

Connections Use the object privileges as a way to reinforce the DML operations that can be performed on a table. Ask students the following questions: - If you granted another user INSERT privileges on one of your tables, what would the user have to know about your tables in order to INSERT new data? What constraints were imposed on your table. - Your friend wants to change the sequence you granted him permission to use. How can she change the START WITH number of the sequence?

Page 23: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 19

Changing the START WITH number of a sequence requires dropping and re-creating it. You must also have given permission to DELETE the sequence. - You want to give your manager the ability to view employee information but don't want the manager changing any data. You also don't want the manager to allow anyone other than a manager to see the data. You also don't want employees to see the salary column. How can you accomplish this? Create a VIEW to include only the columns you want employees to be able to see. Grant only SELECT on the table and don't include WITH GRANT OPTION. - Several tables in your company's database have long, complicated names such as ANTIQUES_PRE1900_PICTURES. You need to refer to this database frequently, as do others in your work group. What options do you have to make querying easier? If you were the only one with SELECT privileges, you could create a synonym for the table and grant privileges just using the synonym. A privilege granted on a synonym is converted to a privilege on the base tables referenced by the synonym. If everyone had SELECT privileges, they could create their own synonyms that make sense to them.

Page 24: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 20

What Will I Learn?

What Will I Learn?

Page 25: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 21

Why Learn It?

Why Learn It?

Page 26: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 22

Tell Me / Show Me

Tell Me / Show Me

Page 27: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 23

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Discuss with students the differences between system and object privileges. Students should be able to give examples of each and answer the question, "Why are these different types of privileges used?" Discuss with students why a DBA would want to run periodic reports listing who has access to objects in the database. If a user needs access to an object, the DBA's job is to make sure that this person should have access to the object and then, if appropriate, to grant access. However, how does the DBA know when someone no longer needs access? How does the person in charge of your school's database keep track of students who transfer to another school? When does the account become inactive or when should logon privileges be stopped or the account deleted? Demo SELECT * FROM SESSION_PRIVS to show what privileges students have on the database. A partial list is shown below:

Page 28: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 24

Page 29: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 25

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Discuss with students the differences between system and object privileges. Students should be able to give examples of each and answer the question, "Why are these different types of privileges used?" Discuss with students why a DBA would want to run periodic reports listing who has access to objects in the database. If a user needs access to an object, the DBA's job is to make sure that this person should have access to the object and then, if appropriate, to grant access. However, how does the DBA know when someone no longer needs access? How does the person in charge of your school's database keep track of students who transfer to another school? When does the account become inactive or when should logon privileges be stopped or the account deleted? Demo SELECT * FROM SESSION_PRIVS to show what privileges students have on the database. A partial list is shown below:

Page 30: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 26

Page 31: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 27

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Review the list of privileges associated with the table. It is a good review for each object and how each is altered or deleted and re-created. Warn students that giving privileges other than SELECT can have detrimental effects for their tables. Tell students to grant privileges only on their copy_tablenames.

Page 32: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 28

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Explain the graphic. Assigning privileges for a few people would not be a difficult task, but having to assign privileges for 1,000 employees would be very time consuming. The role of manager makes it easier to assign employee privileges.

Page 33: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 29

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Explain the sequence of steps for creating roles as shown in the graphic.

Page 34: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 30

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Ask students what considerations a DBA must make when granting object privilege. Possible responses: Does the person want the privilege or does he/she require the privilege? How will the DBA know if the privilege should be revoked?

Page 35: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 31

Tell Me / Show Me

Tell Me / Show Me

Page 36: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 32

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

If a statement does not use the full name of an object, the Oracle Server implicitly prefixes the object name with the current user’s name (or schema). If user Scott King( scott_king) queries the Oracle DEPARTMENTS table, for example, the system selects from the scott_king.DEPARTMENTS table. If a statement does not use the full name of an object, and the current user does not own an object of that name, the system prefixes the object name with PUBLIC. For example, if user Scott queries the USER_OBJECTS table, and Scott does not own such a table, the system selects from the data dictionary view by way of the PUBLIC.USER_OBJECTS public synonym. Explain that the WITH GRANT OPTION means that when you invite friends to a party at your house, they can invite others, too. End result: Your house is packed and you're suddenly out of food!

Page 37: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 33

Tell Me / Show Me

Tell Me / Show Me

Page 38: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 34

Tell Me / Show Me

Tell Me / Show Me

Page 39: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 35

Tell Me / Show Me

Tell Me / Show Me

Page 40: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 36

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Let the students know that using distributed databases encompasses much more than what is shown in the graphic.

Page 41: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 37

Tell Me / Show Me

Tell Me / Show Me

Tell Me / Show Me

Let the students know that using distributed databases encompasses much more than what is shown in the graphic.

Page 42: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 38

Try It / Solve It

Try It / Solve It

Try It / Solve It

For practice question 1, create a teacher_d_songs table copied from DJ on Demand d_songs table. Use the following to create the copy: CREATE teacher_d_songs AS SELECT * FROM d_songs; Grant SELECT to one student in the class with: GRANT select ON teacher_d_songs TO uswa.skhs_sql01_s24 WITH GRANT OPTION; This student, in turn, grants SELECT to another student using: GRANT select ON teacher_d_songs TO uswa.skhs_sql01_s24

Page 43: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 39

WITH GRANT OPTION; Answers: 1. GRANT select ON teacher_d_songs TO uswa.skhs_sql01_s24 WITH GRANT OPTION; 2. Use the HTML DB SQL Workshop Data Dictionary Browser to enter the search for USER_TAB_PRIVS_RECD. Click the magnifying glass to view table privileges received. 3. The CREATE SESSION system privilege 4. The CREATE TABLE privilege 5. You grant them the SELECT privilege.

Page 44: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 40

Try It / Solve It

Try It / Solve It

Try It / Solve It

6. Create a ROLE containing the system privileges and grant the role to users. 7. GRANT SELECT ON copy_employees TO username; 8. GRANT INSERT ON copy_employees TO PUBLIC WITH GRANT OPTION; 9. Query the USER_COLS_PRIVS_RECD 10. REVOKE the privileges on that table.

Page 45: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 41

Lesson 4 - Practice Exercises

Lesson 4 - Practice Exercises

Lesson Preparation

Use the section Study Guide and vocabulary to review for the quiz. Students should complete the review questions. Review the answers before students take the quiz.

What to Watch For None.

Connections None.

Page 46: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 42

What Will I Learn?

What Will I Learn?

Page 47: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 43

Why Learn It?

Why Learn It?

Page 48: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 44

Tell Me / Show Me

Tell Me / Show Me

Page 49: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 45

Try It / Solve It

Try It / Solve It

Try It / Solve It

Complete the questions from this lesson in the STUDY GUIDE Answers: 1. a. create a new table without data based on the structure and column names of an existing table. b. create a new table containing the same structure but different column names as an existing table. c. create a new table containing the structure and data of an existing table. 2. c. a column named: Primary_Key$Column

Page 50: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 46

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 3. c. check constraints 4. b. PERSON_NAME, TITLE, PAY

Page 51: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 47

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 5. c. WITH CHECK OPTION 6. b. CLOB 7. c. timestamp

Page 52: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 48

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 8. c. The current date, time (including fractions of seconds), and offset from UTC 9. c. ALTER TABLE set unused

Page 53: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 49

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 10. c. using the COMMENT ON TABLE or COMMENT ON COLUMN 11. b. ON DELETE SET NULL

Page 54: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 50

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 12. False 13. True 14. True

Page 55: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 51

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 15. a. PRIMARY KEY e. UNIQUE 16. a. enabled or disabled b. created or dropped d. viewed in user_constraints 17. False 18. False 19. False

Page 56: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 52

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 20. d. giving the subquery an alias 21. d. ROWNUM in the WHERE clause 22. c. my_SEQ.currval

Page 57: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 53

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 23. b. ensure that numbers will be unique even though gaps may exist c. use a range of numbers and optionally cycle through them again d. set a fixed interval for successive numbers 24. d. change the interval of the sequence 25. False 26. False

Page 58: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 54

Try It / Solve It

Try It / Solve It

Try It / Solve It

Answers: 27. b. a rowid and a function return based on the column key value 28. c. synonym 29. a. GRANT select 30. True

Page 59: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 55

Lesson 5 - Practice Exercises and Quiz

Lesson 5 - Practice Exercises and Quiz

Lesson Preparation

Students can complete any unfinished practice exercises. Ask students for questions they may have. Students take the quiz and review selected questions. Introduce the final project for sections 14-15.

What to Watch For None.

Connections None.

Page 60: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 56

What Will I Learn?

What Will I Learn?

Page 61: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 57

Why Learn It?

Why Learn It?

Page 62: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 58

Tell Me / Show Me

Tell Me / Show Me

Page 63: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 59

Try It / Solve It

Try It / Solve It

Try It / Solve It

Complete and review the practice exercises. Assign the Database Programming Quiz. A passing score is 7 out of 10. Assessment: You may want to encourage students to retake the quiz until they achieve a passing score. Or you may prefer to allow only one attempt at the quiz. Allow 20 minutes for the quiz and 10 minutes for assessment/discussion afterward. Have students work in pairs to review what they missed on the quiz. Based on the types of questions they missed, have each pair of students choose one question they missed or did not understand to present to the group. Use this discussion to assess student understanding.

Page 64: Database Programming - Section 13 - OracleDatabase Programming - Section 13 Page 15 Tell Me / Show Me Tell Me / Show Me Tell Me / Show Me For purposes of this lesson, students may

Copyright © Oracle, 2004. All rights reserved.

Database Programming - Section 13 Page 60