DUE: CD_NUMBER TITLE PRODUCER YEAR 97 Celebrate the Day R & B Inc Holiday Tunes for All Tunes are US 2004

Similar documents
CS 275 Winter 2011 Problem Set 3

Database Programming - Section 7. Instructor Guide

Updating Column Values and Deleting Rows. Copyright 2008, Oracle. All rights reserved.

Database Foundations. 6-4 Data Manipulation Language (DML) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Database Programming - Section 8. Instructor Guide

Additional Practice Solutions

CIS 207 Oracle - Database Programming and SQL HOMEWORK: # 13

ÇALIŞMA TEST SORULARI

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002.

Manipulating Data. Copyright 2004, Oracle. All rights reserved.

Database Programming with SQL

Data Manipulation Language

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved.

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

Database Programming - Section 11. Instructor Guide

Retrieving Data Using the SQL SELECT Statement. Copyright 2009, Oracle. All rights reserved.

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

Working with Columns, Characters and Rows. Copyright 2008, Oracle. All rights reserved.

Oracle Database 10g: SQL Fundamentals II

School of Computing and Information Technology. Examination Paper Autumn Session 2017

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Using DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.

School of Computing and Information Technology Session: Spring CSCI835 Database Systems (Bridging Subject) Sample class test 23 July 2018

Using DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.

Bsc (Hons) Software Engineering. Examinations for / Semester 1. Resit Examinations for BSE/15A/FT & BSE/16A/FT

Táblák tartalmának módosítása. Copyright 2004, Oracle. All rights reserved.

Database Programming - Section 10. Instructor Guide

Database Design - Section 18. Instructor Guide

Appendix A Practices and Solutions

Database Programming with SQL

2. What privilege should a user be given to create tables? The CREATE TABLE privilege

Introduction to Oracle9i: SQL

SELF TEST. List the Capabilities of SQL SELECT Statements

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

A. It executes successfully and displays rows in the descending order of PROMO_CATEGORY.

Oracle Database SQL Basics

HR Database. Sample Output from TechWriter 2007 for Databases

BraindumpsVCE. Best vce braindumps-exam vce pdf free download

Tables From Existing Tables

What Are Group Functions? Reporting Aggregated Data Using the Group Functions. Objectives. Types of Group Functions

Intermediate SQL: Aggregated Data, Joins and Set Operators

Creating Other Schema Objects

RESTRICTING AND SORTING DATA

Using DbVisualizer Variables

Using DDL Statements to Create and Manage Tables. Copyright 2006, Oracle. All rights reserved.

Introduction to Oracle9i: SQL

Database Management Systems,

Assignment Grading Rubric

Course Overview. Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Database Programming - Section 18. Instructor Guide

Testpassport.

Retrieving Data from Multiple Tables

Creating and Managing Tables Schedule: Timing Topic

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

Unit 1 - Chapter 4,5

Institute of Aga. Microsoft SQL Server LECTURER NIYAZ M. SALIH

chapter 2 G ETTING I NFORMATION FROM A TABLE

Objectives. After completing this lesson, you should be able to do the following:

Institute of Aga. Network Database LECTURER NIYAZ M. SALIH

DEFAULT Values, MERGE, and Multi-Table Inserts. Copyright 2009, Oracle. All rights reserved.

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

DBMS_OUTPUT.PUT_LINE('ERROR - max sal should be > MIN SAL'); RAISE sal_error;

Join, Sub queries and set operators

EXISTS NOT EXISTS WITH

Exam: 1Z Title : Introduction to Oracle9i: SQL. Ver :


Database Programming - Section 1. Instructor Guide

RETRIEVING DATA USING THE SQL SELECT STATEMENT

KORA. RDBMS Concepts II

Unit 27 Web Server Scripting Extended Diploma in ICT

SYSTEM CODE COURSE NAME DESCRIPTION SEM

Exam : 1Z Title : Introduction to Oracle9i: SQL

Sun Certified MySQL Associate

Misc. Triggers Views Roles Sequences - Synonyms. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering

Database Management Systems,

Database Programming with PL/SQL

SQL. Char (30) can store ram, ramji007 or 80- b

Alkérdések II. Copyright 2004, Oracle. All rights reserved.

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved.

Getting Information from a Table

GIFT Department of Computing Science. CS-217/224: Database Systems. Lab-5 Manual. Displaying Data from Multiple Tables - SQL Joins

Using the Set Operators. Copyright 2006, Oracle. All rights reserved.

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

CSC Web Programming. Introduction to SQL

L e a r n S q l select where

Oracle Database 10g: SQL Fundamentals I

Using the Set Operators. Copyright 2004, Oracle. All rights reserved.

Database Management Systems,

DATABASE MANAGEMENT SYSTEMS PREPARED BY: ENGR. MOBEEN NAZAR

1Z0-007 ineroduction to oracle9l:sql

DATA CONSTRAINT. Prepared By: Dr. Vipul Vekariya

Item: 1 (Ref:Cert-1Z )

Oracle MOOC: SQL Fundamentals

1) Introduction to SQL

RMOUG Training Days 2018

Database Programming with SQL

Lab # 4. Data Definition Language (DDL)

Série n 6 Bis : Ateliers SQL Data Modeler (Oracle)

Transcription:

CIS 207 Oracle - Database Programming and SQL HOMEWORK: # 12 DUE: Run the following queries in Oracle Application Express. Paste a copy of each query Into this word document below the questions, save and return via Canvas: Students should execute DESC tablename before doing INSERT to view the data types for each column. VARCHAR2 data-type entries need single quotation marks in the VALUES statement. Complete the following Try It / Solve It Exercises: Section 12, Lesson 1 Exercises 2, 3 2. DJs on Demand just purchased four new CDs. Use an explicit INSERT statement to add each CD to the copy_d_cds table. After completing the entries, execute a SELECT * statement to verify your work. CD_NUMBER TITLE PRODUCER YEAR 97 Celebrate the Day R & B Inc. 2003 98 Holiday Tunes for All Tunes are US 2004 Ages 99 Party Music Old Town Records 2004 100 Best of Rock and Roll Old Town Records 2004 3. DJs on Demand has two new events coming up. One event is a fall football party and the other event is a sixties theme party. The DJs on Demand clients requested the songs shown in the table for their events. Add these songs to the copy_d_songs table using an implicit INSERT statement. ID TITLE DURATION TYPE_CODE 52 Surfing Summer Not known 12 53 Victory Victory 5 min 12

Before doing any of the assigned questions below, remember that you are not to execute the commands on the database table that are currently available in the APEX environment. First you are to make copies of the tables and give the table the same names but with copy_ proceeding the original names. For example for the d_cds table the copied table would be called copy_d_cds. For example you would use the following command to create the copy_d_cds table: CREATE TABLE copy_d_cds AS SELECT * FROM d_cds; If you need to start with a fresh copy of the copy tables, you can remove the table using the following command format: DROP TABLE copy_d_cds; You might want to reference the student resource link on the class website and use the creating a table handout. NOTE: Copy tables in this section do not yet exist; students must create them. If any change is not possible give an explanation as to why it is not possible. Section 12, Lesson 2 Exercise 1, 4, 5 1..Monique Tuttle, the manager of Global Fast Foods, sent a memo requesting an immediate change in prices. The price for a strawberry shake will be raised from $3.59 to $3.75, and the price for fries will increase to $1.20. Make these changes to the copy_f_food_items table. 4. Add the new customers shown below to the copy_f_customers table. You may already have added Katie Hernandez. Will you be able to add all these records successfully? ID FIRST_ NAME LAST_ NAME ADDRESS CITY STATE ZIP PHONE _NUMB ER 145 Katie Hernandez 92 Chico Way Los Angeles CA 98008 8586667 641 225 Daniel Spode 1923 Silverado Denver CO 80219 7193343 523 230 Adam Zurn 5 Admiral Way Seattle WA 4258879 009 5. Sue Doe has been an outstanding Global Foods staff member and has been given a salary raise. She will now be paid the same as Bob Miller. Update her record in copy_f_staffs.

Section 12, Lesson 3 Exercise 1, 4 1. When would you want a DEFAULT value? 4. Run the following 3 statements to create 3 new tables for use in a Multi-table insert statement. All 3 tables should be empty on creation, hence the WHERE 1=2 condition in the WHERE clause. CREATE TABLE sal_history (employee_id, hire_date, salary) AS SELECT employee_id, hire_date, salary FROM employees WHERE 1=2; CREATE TABLE mgr_history (employee_id, manager_id, salary) AS SELECT employee_id, manager_id, salary FROM employees WHERE 1=2; CREATE TABLE special_sal (employee_id, salary) AS SELECT employee_id, salary FROM employees WHERE 1=2; Once the tables exist in your account, write a Multi-Table insert statement to first select the employee_id, hire_date, salary and manager_id of all employees. If the salary is more than 20,000 insert the employee_id and salary into the special-sal table. Insert the details of employee_id, hire_date and salary into the sal_history table. Insert the employee_id, manager_id and salary into the mgr_history table. You should get a message back saying 39 rows were inserted. Verify you get this message and verify you have the following number of rows in each table: Sal_history: 19 rows Mgr_history: 19 rows Special_sal: 1

Complete the following Try It / Solve It Exercises: Section 13, Lesson 1 Exercise 1, 2, 3 1. Complete the GRADUATE CANDIDATE table instance chart. Credits is a foreign-key column referencing the requirements table. 2. Write the syntax to create the grad_candidates table. 3. Confirm creation of the table using DESCRIBE.

Section 13 Lesson 2, Exercise 1 Using the examples provided in Tell Me/Show Me, create each of the three time-zone tables. TIMESTAMP WITH LOCAL TIME ZONE INTERVAL YEAR TO MONTH INTERVAL DAY TO SECOND LONDON NEW YORK TOKYO SHANGHAI

Section 13, Lesson 3 Exercise 3, 4, 5, 6, 8, 10 Before beginning the practice exercises, execute a DESCRIBE for each of the following tables: o_employees and o_jobs. These tables will be used in the exercises. You will need to know which columns do not allow null values. NOTE: If students have not already created the o_employees, o_departments, and o_jobs tables they should create them using the four steps outlined in the practice. a. Create the three o_tables jobs, employees, and departments using the syntax: CREATE TABLE o_jobs AS (SELECT * FROM jobs); CREATE TABLE o_employees AS (SELECT * FROM employees); CREATE TABLE o_departments AS (SELECT * FROM departments); b. Add the Human Resources job to the jobs table: INSERT INTO o_jobs (job_id, job_title, min_salary, max_salary) VALUES('HR_MAN', 'Human Resources Manager', 4500, 5500); c. Add the three new employees to the employees table: INSERT INTO o_employees (employee_id, first_name, last_name, email, hire_date, job_id) VALUES(210, 'Ramon', 'Sanchez', 'RSANCHEZ', SYSDATE, 'HR_MAN'); d. Add Human Resources to the departments table: INSERT INTO o_departments(department_id, department_name) VALUES (210,'Human Resources'); 3. In your o_employees table, enter a new column called Termination. The datatype for the new column should be VARCHAR2. Set the DEFAULT for this column as SYSDATE to appear as character data in the format: February 20th, 2003.

4.Create a new column in the o_employees table called start_date. Use the TIMESTAMP WITH LOCAL TIME ZONE as the datatype. 5. Truncate the o_job_description table. Then do a SELECT * statement. Are the columns still there? Is the data still there? 6. What is the distinction between TRUNCATE, DELETE and DROP for tables? 8. Add the following comment to the o_jobs table: "New job description added" View the data dictionary to view your comments. 10. F_staffs table exercises: a. Create a copy of the f_staffs table called copy_f_staffs and use this copy table for the remaining labs in this lesson. b. Describe the new table to make sure it exists. c. Drop the table. d. Try to select from the table. e. Investigate your recyclebin to see where the table went.

f. Try to select from the dropped table by using the value stored in the OBJECT_NAME column. You will need to copy and paste the name as it is exactly, and enclose the new name in (double quotes). So if the dropped name returned to you is BIN$Q+x1nJdcUnngQESYELVIdQ==$0, you need to write a query that refers to BIN$Q+x1nJdcUnngQESYELVIdQ==$0. g. Undrop the table. h. Describe the table.