#1 Create a simple view named CUST_VIEW using the book_customer table that will dis play the customer

number, first and last name, and the state for every customer currently in the database. Define the view so that it will list the customer last names by asce nding order within the states in descending order. Now insert the following data into the book_customer table using an INSERT statement. CUSTOMER# - 1021, FIRSTNAME – ED WARD, LASTNAME – BLAKE, STATE – TX. Now query your view and display the new record. #2 Create a complex view named CUST_ORDER that will list the customer number, last name, and state from the BOOK_CUSTOMER table and the order number and order date from the BOOK_ORDER table. Insert the following data into this view: CUSTOMER# - 1022, LASTNAME – smith, STATE – Kansas, ORDER# - 1021, and ORDERDATE – 10-OCT-2004. #3 breif summary why the insert statement for the view you created in #2 did not work. #4 Create a sequence that can be used to assign a publisher ID number to a new publ isher. Define the sequence to start with 7, increment by two and stop at 1000. Name the sequence PUBNUM_SEQ. #5 Insert two new publishers into the PUBLISHER table, one named Double Week with a contact name Jennifer Close at 800-959-6321, and the second one named Specific House with a contact name Freddie Farmore at 866-825-3200. Use your new sequence to create the PUBID for each record. Now query your PUBLISHER table to see your two new records. #6 Using a single query, query the PUBNUM_SEQ to determine what both the current sequence number is and the next sequence number will be. #7 Create a unique index on the combined columns ORDER# and CUSTOMER# in the BOOK_O RDER table. Give the index a name of BOO_ORDER_IDX. #8 Determine how many objects you currently own in your schema by querying the USER_OBJECTS view in the Data Dictionary. Your result set should list the diffe rent object types that you find. #9 Using the BOOK_ORDER, ORDERITEMS, and BOOKS tables, create a query using an OUTE R JOIN operation that will list the book title, order date and order number for all books in the BOOKS table.

Give the number purchased column and alias of “Number Purchased”. lastname.customer#.isbn = orderitems. lastname.customer#. state. the custom er’s city and state. state. book_order.customer# = book_order.order# ORDER BY orderitems.orde r#) <= quantity) >2 group by book_order. city.order#) <= QUANTITY then sum(count(book_order.order# having sum(quantity) >= 3 or (select count(book_order.isbn left join book_order on book_order.customer#.order# = orderitems.order# = orderitems.customer# join orderitems on book_order. city. city.customer# = book_order. and the number of books they have purchased.order# having sum(quantity) >= 3 group by book_order. create a query using the JOIN method to display a list ing of all customers who have purchased more than 2 books.customer#. select title. quantity.customer# join orderitems on book_order.Order you output in descending order by book ISBN. select book_order. lastname. sum(quantity) AS "Number Purchased" from book_customer join book_order on book_customer.order#) from book_order having count(book_order. There are three books that h ave never been ordered which should show up at the top of your listing.order# = orderitems. select book_order. . orderdate. state. lastname. #10 Using the correct tables.order# from books left join orderitems on books.isbn DESC.order #)) else sum(quantity) end AS "Number Purchased" from book_customer join book_order on book_customer. case Q wheN count(book_order. List the customer’s last name.

      lastname AS "Customer Name". select books. state. To verify your update. BOOK_ORDER CASCADE CONSTRAINTS PURGE. quantity.05). write a query using the correct Relational Set Operator that will show all of the ISBN numbers in the BOOKS table that have not been ordered. book_order. write a sub query that will return the names of t hose customers who were referred by the same individual who referred Jorge Perez. you can issue a ROLLBACK statement to return the data to the original state. firstname from book_customer where referred is not null and firstname not like JORGE% and referred = 1003.) select customer#. all you have is the publisher “name”. Do not display J orge Perez’s name in the returned results (Hint: you should only have two customers displayed and the exclusion for Jorge Perez must be associated with the upper query. #11 Using only the BOOK table for the upper most statement.city.isbn from books left join orderitems on books. no subquery #13 Using the BOOKS and ORDERITEMS table. DROP DROP DROP DROP DROP TABLE TABLE TABLE TABLE TABLE BOOK_CUSTOMER CASCADE CONSTRAINTS PURGE. Remember . PUBLISHER CASCADE CONSTRAINTS PURGE.order# = orderitems.isbn = orderitems. BOOKS CASCADE CONSTRAINTS PURGE. provide a select statement on the BOOKS table before your update statement. and then a sec ond select on the BOOKS table after the update.order# WHERE orderdate is null ORDER BY books.isbn. cant figure out #12 Using the BOOK_CUSTOMER table. referred   .order#. Use the sub query to find the publisher ID. Once you have verified the results. AUTHOR CASCADE CONSTRAINTS PURGE.isbn left join book_order on book_order. create a sub query that will update the retail price of all books published by PRINTING IS US by 5% (retail * 1.

32306 . SCHELL . BOX 2947 . 83707 . JASMINE . DROP TABLE PROMOTION CASCADE CONSTRAINTS PURGE. BONITA . 82 DIRT ROAD . LastName VARCHAR2(10). THOMPSON . PIERSON . City VARCHAR2(12). NGUYEN . INSERT INTO BOOK_CUSTOMER VALUES (1007. BOX 677 . 32328 . FL . P. CA . CLERMONT . INSERT INTO BOOK_CUSTOMER VALUES (1011. P. NULL). Zip VARCHAR2(5). 3 4711 . State VARCHAR2(2). BOX 651 . 33111 . NULL). 30314 . THOMAS .O. NULL) . CA . 91508 . 114 EAST SAVANNAH . P.O. REESE . MCKENZIE . FL .O. DROP TABLE BOOKAUTHOR CASCADE CONSTRAINTS PURGE. MORALES . NUL L). BURBANK . LUCAS . 12211 . CINDY . BOX 8564 . LEILA . TALLAHASSEE . SEATTLE . Create table Book_customer (Customer# NUMBER(4) CONSTRAINT PK_BOOK_CUSTOMER_CUSTOMER# PRIMARY KEY. LEE . 02110 . 98115 . INSERT INTO BOOK_CUSTOMER VALUES (1014.O. NY . NULL ). INSERT INTO BOOK_CUSTOMER VALUES (1012. BOX 18 . FL . BOISE .O. FirstName VARCHAR2(10). P. . INSERT INTO BOOK_CUSTOMER                                                                                                                                                                                                                                                                                                                                                                                                 . WY . 91510 . P. 69821 SOUTH AVENUE . WA . ID . BOSTON . MESHIA .O. INSERT INTO BOOK_CUSTOMER VALUES (1002. JONES . MCGOVERN . BOX 971 . 9851231 LONG ROAD . FL . RYAN . IL . CODY . INSERT INTO BOOK_CUSTOMER VALUES (1016. BOX 9835 . MA . INSERT INTO BOOK_CUSTOMER VALUES (1013. 1006).O. INSERT INTO BOOK_CUSTOMER VALUES (1008. EASTPOINT . NUL L).O. STEVE .O. MICHELL . ALBANY . Address VARCHAR2(20). GA . ATLANTA . P. KENNETH . INSERT INTO BOOK_CUSTOMER VALUES (1006. GIRARD . P. INSERT INTO BOOK_CUSTOMER VALUES (1010. JAKE . 357 WHITE EAGLE AVE. 90404 . SMITH . NU LL). BOX 851 . AUSTIN . SANTA MONICA . 9153 MAIN STREET . TX . NU LL). WY . NULL). INSERT INTO BOOK_CUSTOMER VALUES (1005. INSERT INTO BOOK_CUSTOMER VALUES (1015. DAUM . WILLIAM . CHEYENNE . INSERT INTO BOOK_CUSTOMER VALUES (1001. BOX 137 . NULL). CRUZ . P.DROP TABLE ORDERITEMS CASCADE CONSTRAINTS PURGE.O. BOX 66 . 82414 . JORGE . CHICAGO . MIAMI . 1010). NULL). INSERT INTO BOOK_CUSTOMER VALUES (1003. CA . P. 1003) . INSERT INTO BOOK_CUSTOMER VALUES (1009. 100 3). P. 82003 . TAMMY . BURBANK . 78710 . INSERT INTO BOOK_CUSTOMER VALUES (1004. NICHOLAS . GIANA . PEREZ . N ULL). 60606 . Referred NUMBER(4)).

60 . ATLANTA . 58 TILA CIRCLE . GA . INSERT INTO BOOK_ORDER VALUES (1005. INSERT INTO BOOK_ORDER VALUES (1003. BOX 563 . ATLANTA . . ShipDate DATE.1005. 1003). .NULL.O. AUSTIN . 08607 . 31-MAR-06 30314 ). SMITH . KENNETH . N . 32307 ). MONTIASA . ID .1003. 02-APR-06 83707 ). GA . OrderDate DATE. INSERT INTO BOOK_CUSTOMER VALUES (1018. SEATTLE . 561 ROUNDABOUT WAY . GA . 01-APR-06 31206 ). NULL ). MI . ShipCity VARCHAR2(15). 30311 ). NULL ). 05-APR-06 . INSERT INTO BOOK_ORDER VALUES (1011.1010. 32328 ). INSERT INTO BOOK_ORDER VALUES (1001.1010. CHICAGO . KALMAZOO .VALUES (1017. 31206 . 1295 WINDY AVENUE . F . BECCA . 9153 MAIN STREET . IL . NJ . INSERT INTO BOOK_ORDER VALUES (1010. 03-APR-06 . BOISE . . 31-MAR-06 605 ). MACON . INSERT INTO BOOK_ORDER VALUES (1004. TRENTON . 114 EAST SAVANNAH . P. 02-APR-06 . MORRISTOWN . NJ . 05-APR-06 . 02-APR-06 . 07960 ). Create Table Book_order (Order# NUMBER(4) CONSTRAINT PF_BOOK_ORDER_ORDER# PRIMARY KEY.1020. BOX 335 . ShipState VARCHAR2(2). EASTPOINT . 03-APR-06 98110 ). P. INSERT INTO BOOK_ORDER VALUES (1012.1004. 04-APR-06 . INSERT INTO BOOK_ORDER VALUES (1006. 01-APR-06 . 05-APR-06 . 9 . BOX 1151 . INSERT INTO BOOK_CUSTOMER VALUES (1019.O.1007. P. 49002                                                                                                                                                                                                                                               INSERT INTO BOOK_ORDER VALUES (1000. 07962 . 49006 . MI . 03-APR-06 . . 958 MAGNOLIA LANE . NJ . 01-APR-06 . 01-APR-06 . WA . N ULL). FALAH . ShipZip VARCHAR2(5)). FL . TALLAHASSEE . . 1008 GRAND AVENUE . GREG . INSERT INTO BOOK_ORDER VALUES (1008. MORRISTOWN . SEATTLE . TRENTON . 31-MAR-06 8114 ). 1008 GRAND AVENUE . TX .1005.1018. NELSON . 384 WRONG WAY HOME . . INSERT INTO BOOK_ORDER VALUES (1002. 1201 ORANGE AVE . WA .O. . 01-APR-06 L . KALMAZOO . 02-APR-06 . 04-APR-06 .1019.1001. 03-APR-06                                                                                                                                                                     . Customer# NUMBER(4). 02-APR-06 78710 ). ShipStreet VARCHAR2(18).1011. 03-APR-06 J . 01-APR-06 08601 ). 102 WEST LAFAYETTE . 69821 SOUTH AVENUE . 01-APR-06 . MACON . INSERT INTO BOOK_ORDER VALUES (1009.1017. INSERT INTO BOOK_ORDER VALUES (1007. 9 LIGHTENING RD. . . 558A CAPITOL HWY. JENNIFER . GA . INSERT INTO BOOK_CUSTOMER VALUES (1020.

FL . TX . . REED-N-RITE . . SEBASTIAN JONES .1007. READING MATERIALS INC. INSERT INTO PUBLISHER VALUES(3. NJ .1001. Lname VARCHAR2(10). Contact VARCHAR2(15).1015.                                                             INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INTO AUTHOR ( S100 . CODY .. 9901 SEMINOLE WAY . PUBLISH OUR WAY . INTO AUTHOR ( K100 . 32 . 9153 MAIN STREET . 1008 GRAND AVENUE . 08606 ). INTO AUTHOR ( A100 . 05-APR-06 ). 82 . MACON . GA . . 800-714-8321 ). 05-APR-06 . 800-555-1211 ). 195 JAMISON LANE . DAVID DAVIDSON .                                                                                                                                                                                               ). SHEILA ). 04-APR-06 78710 ). TALLAHASSEE . JANICE ). 04-APR-06 INSERT INTO BOOK_ORDER VALUES (1016. FL .1008. AMERICAN PUBLISHING . 800-515-2665 ). 557 GLITTER ST. INSERT INTO PUBLISHER VALUES(5. KZOCHSKY .1003. CHEYENNE . JAMES ). INTO AUTHOR ( M100 . WY . 05-APR-06 ). 03-APR-06 414 ). 04-APR-06 307 ).1014. INSERT INTO BOOK_ORDER VALUES (1017. INSERT INTO BOOK_ORDER VALUES (1014. AUSTIN . SAM ). 95812 HIGHWAY 98 . INTO AUTHOR ( J100 . 800-410-0010 ).NULL. INSERT INTO PUBLISHER VALUES(6. INSERT INTO BOOK_ORDER VALUES (1013.1018. INSERT INTO BOOK_ORDER VALUES (1020.NULL. MARTINEZ . INSERT INTO BOOK_ORDER VALUES (1019. INSERT INTO BOOK_ORDER VALUES (1015.NULL. INSERT INTO PUBLISHER VALUES(4. INSERT INTO PUBLISHER VALUES(1. 887 HOT ASPHALT ST . 32328 . EASTPOINT . 7618 MOUNTAIN RD. 05-APR-06 . TAMARA ). SMITH . TRENTON . WY . INSERT INTO BOOK_ORDER VALUES (1018. PRINTING IS US . DOUG COLLINS . 05-APR-06 .NULL. AUSTIN . 04-APR-06 . 800-555-8284 ). RENEE SMITH . 82003 Create Table Publisher (PubID NUMBER(2) CONSTRAINT PK_PUBLISHER_PUBID PRIMARY KEY. 04-APR-06 33112 ).                                                         . Fname VARCHAR2(10)).NULL. LITTLE HOUSE . JONES . INSERT INTO PUBLISHER VALUES(2. MIAMI . Create Table Author (AuthorID Varchar2(4) CONSTRAINT PK_AUTHOR_AUTHORID PRIMARY KEY. TOMMIE SEYMOUR . Phone VARCHAR2(12)). FL . . 31206 ) . Name VarCHAR2(23). .1020. JANE TOMLIN . 800-555-9743 ). .

00.25.4.4.00. INSERT INTO BOOKS VALUES ( 4981341710 CHILDREN ).75.47. INTO AUTHOR ( W105 . INTO AUTHOR ( R100 . 04-JUN-99 .90.95. BODYBUILD IN 10 MINUTES A DAY . PORTER .50.1.2). WILKINSON . E-BUSINESS THE EASY WAY . .25. WILLIAM ). BUILDING A CAR WITH TOOTHPICKS .80.75. ROBINSON .80. . JACK ). DATABASE IMPLEMENTATION . REVENGE OF MICKEY .30.89.18.28. INSERT INTO BOOKS VALUES ( 0401140733 ). INSERT INTO BOOKS VALUES ( 8843172113 TER ). ADAMS .37.19. INSERT INTO BOOKS VALUES ( 0299282519 . OSCAR ).5. LISA ).2.95.00. WHITE . FIELDS . INTO AUTHOR ( F100 . 17-JUL-00 . INTO AUTHOR ( A105 .2.95.55. Category VARCHAR2(12)).3.3.21.                   . JUAN ).14. PAINLESS CHILD-REARING . 14-DEC-01 .40. INSERT INTO BOOKS VALUES ( 9959789321 TER ). PubID NUMBER (2).95. INSERT INTO BOOKS VALUES ( 3437212490 G ). 21-JAN-01 .00. Retail NUMBER (5.95. HOLY GRAIL OF ORACLE . TINA ).37.20. COMPU .48.2). ROBERT ). ANTHONY ). INTO AUTHOR ( B100 .                                                                                                                                     INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INTO AUTHOR ( P100 . 01-MAR-02 . COOKING WITH MUSHROOMS .4. COMPUTER . 31-DEC-01 . INTO AUTHOR ( W100 .22.19. INTO AUTHOR ( P105 . PubDate DATE. INSERT INTO BOOKS VALUES ( 1915762492 R ). COMPU . THE WOK WAY TO COOK . BAKER . 11-SEP-00 . INSERT INTO BOOKS VALUES ( 2491748320 LIFE ). Cost NUMBER (5. COOKIN . 21-JAN-01 . WHITE . HANDCRANKED COMPUTERS . COMPUTE . LISA ).75. INSERT INTO BOOKS VALUES ( 3957136468 ). 18-MAR-02 . COOKING )                                                                                                                       INSERT INTO BOOKS VALUES ( 1059831198 FITNESS ).95. PETERSON .Create table Books (ISBN VARCHAR2(10) CONSTRAINT PK_BOOKS_ISBN PRIMARY KEY.3. INTO AUTHOR ( W110 . FAMILY LIFE . FAMILY . 28-FEB-00 .12.50.59. Title VARCHAR2(30).31.54. .

1. 8843172113 INTO ORDERITEMS (1011.1.1. HOW TO GET FASTER PIZZA . CHILDR . SHORTEST POEMS .1. ISBN VARCHAR2(10).1).                                                   INSERT INTO BOOKS VALUES ( 8117949391 EN ).32. 9959789321 INTO ORDERITEMS (1007.1. 9959789321 INTO ORDERITEMS (1007. 01-MAY-01 .2).1.1).1.1.5.2). . . 2491748320 INTO ORDERITEMS (1005.1).1). INSERT INTO BOOKS VALUES ( 9247381001 INESS ).1).1).2.                                                                                 INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT INTO ORDERITEMS (1000.. INSERT INTO BOOKS VALUES ( 0132149871 HELP ).1).2). 9247381001 INTO ORDERITEMS (1001. . 2491748320 INTO ORDERITEMS (1012. . . 0401140733 INTO ORDERITEMS (1010. 3437212490 INTO ORDERITEMS (1001. SELF . CREATE TABLE ORDERITEMS (ORDER# NUMBER(4) NOT NULL.1.1.2. 3437212490 INTO ORDERITEMS (1004. . constraint pk_orderitems PRIMARY KEY (order#.1).1. 08-NOV-01 .95. . ITEM# NUMBER(2) NOT NULL.15.1). QUANTITY NUMBER(3). BUS .85.17.29.4.1. . 8843172113 INTO ORDERITEMS (1003.2.1).95. 8843172113 INTO ORDERITEMS (1003.5. 8117949391 INTO ORDERITEMS . .3). 09-MAY-99 . 8117949391 INTO ORDERITEMS (1007.3.3.85. INSERT INTO BOOKS VALUES ( 2147428890               . . . .1). 11-NOV-02 . 8843172113 INTO ORDERITEMS (1008. .21.40.31.4. 3437212490 INTO ORDERITEMS (1009. 3957136468 INTO ORDERITEMS (1007.1.5. .95.95. 1059831198 INTO ORDERITEMS (1003. 3437212490 INTO ORDERITEMS (1009.1). .1. . LITERATURE ). .1). item#)).39.2. HOW TO MANAGE THE MANAGER . 2147428890 INTO ORDERITEMS (1006.1). 2491748320 INTO ORDERITEMS (1002.4).8. . .1). BIG BEAR AND LITTLE DOVE .

). 2491748320 INTO ORDERITEMS (1012.2. ). . ).CREATE TABLE BOOKAUTHOR (ISBN VARCHAR2(10). ). P105 INTO BOOKAUTHOR ( 8843172113 .authorid)). 8843172113 INTO ORDERITEMS (1019. 3437212490 INTO ORDERITEMS (1018.1. CONSTRAINT pk_bookauthor PRIMARY KEY (isbn.1). ). A100 INTO BOOKAUTHOR ( 8843172113 . .1. P100 INTO BOOKAUTHOR ( 0401140733 . ).1. S100 INTO BOOKAUTHOR ( 1059831198 .1). . AUTHORid VARCHAR2(4). . . 8843172113 INTO ORDERITEMS (1014.1). 3437212490     . 0401140733 INTO ORDERITEMS (1020.1).2). K100 INTO BOOKAUTHOR ( 8843172113 . A100 INTO BOOKAUTHOR ( 1915762492 . . ).1.1.4. 2491748320 INTO ORDERITEMS (1017. B100 INTO BOOKAUTHOR ( 3957136468 .1). ).1). 0401140733 INTO ORDERITEMS (1013.1). ). . J100 INTO BOOKAUTHOR ( 4981341710 . W100 INTO BOOKAUTHOR ( 1915762492 . B100 INTO BOOKAUTHOR                                             VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES (1012. 8117949391 INTO ORDERITEMS (1018. F100 INTO BOOKAUTHOR ( 2491748320 . J100 INTO BOOKAUTHOR ( 2491748320 . 3437212490 INTO ORDERITEMS (1016. ). ).3. .2). ). . 1915762492 INTO ORDERITEMS (1012.1. W105 INTO BOOKAUTHOR ( 9959789321 . ). ). 0401140733 INTO ORDERITEMS (1015.2.                                                                                                                         INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT INTO BOOKAUTHOR ( 1059831198 . ). A105 INTO BOOKAUTHOR ( 3437212490 .1. .2). . R100 INTO BOOKAUTHOR ( 2491748320 .1). .1.1).

12). S100 INTO BOOKAUTHOR ( 8117949391 . 999. 56).create table promotion (gift varchar2(15).2)). maxretail number(5. 12. insert into promotion values ( BOOK COVER . 56. W105         ).2). ). ).01. . 25. 0.                                                 VALUES INSERT VALUES INSERT VALUES INSERT VALUES INSERT VALUES ( 0299282519 . insert into promotion values ( BOOK LABELS . ). insert into promotion values ( FREE SHIPPING .99).01. Commit.01. 25). R100 INTO BOOKAUTHOR ( 0132149871 . S100 INTO BOOKAUTHOR ( 9247381001 . ). insert into promotion values ( BOOKMARKER . minretail number(5. W100 INTO BOOKAUTHOR ( 2147428890 .

Sign up to vote on this title
UsefulNot useful