QUESTION 1                                                                                                                                 [19]     1.1       Write an SQL statement to create a table named riverview_customers, using a subquery based on table f_customers, to include the columns as displayed in the results listed below.                                                                                                                        (4)   SQL> SELECT *   2  FROM riverview_customers;        CUST# CUSTOMER                   JOINDATE ---------- -------------------------- ---------      10006 Johnny Boy Radingoana      17-JUL-18      10008 Gentleman Baloy            13-NOV-18      10012 Lazarus Mashaba            15-APR-19      10015 Louis Malherbe             23-SEP-19      10024 Liberty Nkosi              15-JAN-20      10026 Susan Xaba                 01-FEB-20   6 rows selected.     1.2    Write an SQL statement to create an alternative name rivcusts to be used for table riverview_customers.                                                                                                          (1.5)           1.3    Without re-creating the table of question 1.1, write one SQL statement to answer this question. Change the definition of table riverview_customers to include the customer type, but name this column custtype. Put a restriction on the table to ensure that the customer types will include values of O, L and N only. Name this restriction valid_custtypes.                                                                                                          (4)   1.4   Write one SQL statement to create a comment that refers to the custtype column of the previous question. The comment must read “Only O, L, and N customer types are allowed!”                                                                                                                                                             (2)              1.5    Write an SQL statement to create a sequence named rcust_seq to start at 10100 and end at 10200. When the sequence has reached 10200, it must restart at 10100. The Oracle Server must allocate 25 values for this sequence in memory. The sequence must increase with two everytime a new sequence value is generated.                        (2.5)   1.6    Write two SQL statements to first remove the alternative name you created in your answer to question1.2 and then rename table riverview_customers to rivcusts.  (2)     1.7      Use the sequence you created in your answer to question 1.5 and write one SQL statement to add a new record to table rivcusts. The customer number must be the next available number according to the sequence. The customer type is L and the customer (Johnyboy Mahlangu) joined FoneForFood on the current date (use a system variable for the current date). You are not allowed to name the columns.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question
100%

QUESTION 1                                                                                                                                 [19]

 

 

1.1       Write an SQL statement to create a table named riverview_customers, using a subquery based on table f_customers, to include the columns as displayed in the results listed below.                                                                                                                        (4)

 

SQL> SELECT *

  2  FROM riverview_customers;

 

     CUST# CUSTOMER                   JOINDATE

---------- -------------------------- ---------

     10006 Johnny Boy Radingoana      17-JUL-18

     10008 Gentleman Baloy            13-NOV-18

     10012 Lazarus Mashaba            15-APR-19

     10015 Louis Malherbe             23-SEP-19

     10024 Liberty Nkosi              15-JAN-20

     10026 Susan Xaba                 01-FEB-20

 

6 rows selected.

 

 

1.2    Write an SQL statement to create an alternative name rivcusts to be used for table riverview_customers.                                                                                                          (1.5)

         

1.3    Without re-creating the table of question 1.1, write one SQL statement to answer this question. Change the definition of table riverview_customers to include the customer type, but name this column custtype. Put a restriction on the table to ensure that the customer types will include values of O, L and N only. Name this restriction valid_custtypes.                                                                                                          (4)

 

1.4   Write one SQL statement to create a comment that refers to the custtype column of the previous question. The comment must read

“Only O, L, and N customer types are allowed!”

                                                                                                                                                            (2)

        

 

 

1.5    Write an SQL statement to create a sequence named rcust_seq to start at 10100 and end at 10200. When the sequence has reached 10200, it must restart at 10100. The Oracle Server must allocate 25 values for this sequence in memory. The sequence must increase with two everytime a new sequence value is generated.                        (2.5)

 

1.6    Write two SQL statements to first remove the alternative name you created in your answer to question1.2 and then rename table riverview_customers to rivcusts(2)

 

 

1.7      Use the sequence you created in your answer to question 1.5 and write one SQL statement to add a new record to table rivcusts. The customer number must be the next available number according to the sequence. The customer type is L and the customer (Johnyboy Mahlangu) joined FoneForFood on the current date (use a system variable for the current date). You are not allowed to name the columns.

SQL> select * from f_customer;
CNO
MEMBEROF SURNAME
FNAME
STRADDR
SUBURB
CELLNO
C JOINDATE
0835447676L 12/DEC/17
0845668231L 18/DEC/17
0713358234 L 23/MAR/18
0823358876P 15/APR/18
0836672323 0 15/JUN/18
0722245897 0 17/JUL/18
10001
NKOSI
15 Wattle Street
Model Park
Наpрy
Benjamin
Thabo
2362 Poplar Street
3562 Els Street
1435 Rachel Street
10002
MALHERBE
Model Park
10003
PHUDI
Die Heuwel
10004
NKOSI
Milton
Die Heuwel
10005
10002 MALHERBE
Susanna
Johnny Boy
Pretty
Gentleman
10006
RADINGOANA
12 Dora Street
Riverview
10007
MAGAGULA
877 Frans Street
Fransville
0713447233 L 09/0CT/18
Riverview
O 13/NOV/18
082394592
0838568922 L 08/JAN/19
0719985642 o 09/JAN/19
0719982443 0 28/FEB/19
10008
BALOY
756 Dora Street
Reyno Ridge
Die Heuwel
10009
DICKSON
Master
599 Dixon Street
10010
BOTHA
Rachel
2233 Rachel Street
10011
DE WET
Klaas
123 Loraine Street
Del Judor
CNO
MEMBEROF SURNAME
FNAME
STRADDR
SUBURB
CELLNO
C JOINDATE
0847782312 L 15/APR/19
0723667244 P 15/JUN/19
0736658989 C 23/AUG/19
0848892323 L 23/SEP/19
10012
MASHABA
Lazarus
99 Dreyer Street
Riverview
10013
10007 MAGAGULA
Innocent
10014
MANGWALE
Innocent
13 Acacia Street
Die Heuwel
10015
MALHERBE
Louis
2323 Louis Street
Riverview
Herman
Lucinda
10016
10012 MASHABA
345 Orion Street
Reyno Ridge 0928892323
09/0СT/19
Reyno Ridge 0712339675 O 29/0CT/19
0729987676 C 16/DEC/19
0838897755 P 25/DEC/19
0843448778 0 31/DEC/19
0926565788 C 01/JAN/20
0823889766 0 01/JAN/20
10017
STRYDOM
2233 Leo Street
10018
ХАВА
Xolisi
2333 Ursula Street
Del Judor
10019
10012 MASHABA
Sarah
10020
ZITHA
Sibongile
1001 Judy Street
Fransville
10021
MONARENG
Cora
1212 Cora Street
Fransville
10022
10009 DIXON
Marianne
CNO
MEMBEROF SURNAME
FNAME
STRADDR
SUBURB
CELLNO
C JOINDATE
Reyno Ridge 0836778334 o 09/JAN/20
Riverview
Emmanuelle
99 Liberty Street
2323 Louis Street
10023
MTHETHWA
Liberty
Nicky
0723447823N 15/JAN/20
0846775289 o 18/JAN/20
0712338723 0 01/FEB/20
0723889423 0 02/FEB/20
10024
NKOSI
10025
BARLOW
23 Pentalin Street
Marelden
10026
ХАВА
Susan
879 Barlow Street
Riverview
10027
VENTER
Danie
99 Susanna Street
Fransville
27 rows selected.
Transcribed Image Text:SQL> select * from f_customer; CNO MEMBEROF SURNAME FNAME STRADDR SUBURB CELLNO C JOINDATE 0835447676L 12/DEC/17 0845668231L 18/DEC/17 0713358234 L 23/MAR/18 0823358876P 15/APR/18 0836672323 0 15/JUN/18 0722245897 0 17/JUL/18 10001 NKOSI 15 Wattle Street Model Park Наpрy Benjamin Thabo 2362 Poplar Street 3562 Els Street 1435 Rachel Street 10002 MALHERBE Model Park 10003 PHUDI Die Heuwel 10004 NKOSI Milton Die Heuwel 10005 10002 MALHERBE Susanna Johnny Boy Pretty Gentleman 10006 RADINGOANA 12 Dora Street Riverview 10007 MAGAGULA 877 Frans Street Fransville 0713447233 L 09/0CT/18 Riverview O 13/NOV/18 082394592 0838568922 L 08/JAN/19 0719985642 o 09/JAN/19 0719982443 0 28/FEB/19 10008 BALOY 756 Dora Street Reyno Ridge Die Heuwel 10009 DICKSON Master 599 Dixon Street 10010 BOTHA Rachel 2233 Rachel Street 10011 DE WET Klaas 123 Loraine Street Del Judor CNO MEMBEROF SURNAME FNAME STRADDR SUBURB CELLNO C JOINDATE 0847782312 L 15/APR/19 0723667244 P 15/JUN/19 0736658989 C 23/AUG/19 0848892323 L 23/SEP/19 10012 MASHABA Lazarus 99 Dreyer Street Riverview 10013 10007 MAGAGULA Innocent 10014 MANGWALE Innocent 13 Acacia Street Die Heuwel 10015 MALHERBE Louis 2323 Louis Street Riverview Herman Lucinda 10016 10012 MASHABA 345 Orion Street Reyno Ridge 0928892323 09/0СT/19 Reyno Ridge 0712339675 O 29/0CT/19 0729987676 C 16/DEC/19 0838897755 P 25/DEC/19 0843448778 0 31/DEC/19 0926565788 C 01/JAN/20 0823889766 0 01/JAN/20 10017 STRYDOM 2233 Leo Street 10018 ХАВА Xolisi 2333 Ursula Street Del Judor 10019 10012 MASHABA Sarah 10020 ZITHA Sibongile 1001 Judy Street Fransville 10021 MONARENG Cora 1212 Cora Street Fransville 10022 10009 DIXON Marianne CNO MEMBEROF SURNAME FNAME STRADDR SUBURB CELLNO C JOINDATE Reyno Ridge 0836778334 o 09/JAN/20 Riverview Emmanuelle 99 Liberty Street 2323 Louis Street 10023 MTHETHWA Liberty Nicky 0723447823N 15/JAN/20 0846775289 o 18/JAN/20 0712338723 0 01/FEB/20 0723889423 0 02/FEB/20 10024 NKOSI 10025 BARLOW 23 Pentalin Street Marelden 10026 ХАВА Susan 879 Barlow Street Riverview 10027 VENTER Danie 99 Susanna Street Fransville 27 rows selected.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education