-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathORACLE_Exercise 14.txt
More file actions
65 lines (56 loc) · 2.62 KB
/
ORACLE_Exercise 14.txt
File metadata and controls
65 lines (56 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
1) Write a command that puts the following values, in their given order, into the salespeople table:
city – San Jose, name – Blanco, comm – NULL, cnum – 1100.
INSERT INTO SALESPEOPLE (CITY, SNAME, COMM, SNUM) VALUES
('SAN JOSE', 'BLANCO', NULL, 1100);
----->
SELECT * FROM SALESPEOPLE;
SNUM SNAME CITY COMM
---------- ---------- ---------- ----------
1001 PEEL LONDON .12
1002 SERRES SAN JOSE .13
1004 MOTIKA LONDON .11
1007 RIFKIN BARCELONA .15
1003 AXERLROD NEW YORK .1
1100 BLANCO SAN JOSE
=======================================================================================================================
2) Write a command that removes all orders from customer Clemens from the Orders table.
DELETE FROM ORDERS
WHERE CNUM=
(SELECT CNUM FROM CUSTOMERS
WHERE CNAME='Clemens');
----->
0 rows deleted.
=======================================================================================================================
3) Write a command that increases the rating of all customers in Rome by 100.
UPDATE CUSTOMERS SET RATING=RATING+100
WHERE CITY='ROME';
----->
SELECT * FROM CUSTOMERS;
CNUM CNAME CITY RATING SNUM
---------- ---------- ---------- ---------- ----------
2001 HOFFMAN LONDON 100 1001
2002 GIOVANNI ROME 300 1003
2003 LIU SAN JOSE 200 1002
2004 GRASS BERLIN 300 1002
2006 CLEMENS LONDON 100 1001
2008 CISNEROS SAN JOSE 300 1007
2007 PEREIRA ROME 200 1004
=======================================================================================================================
4) Salesperson Serres has left the company. Assign her customers to Motika.
UPDATE CUSTOMERS SET SNUM=
(SELECT SNUM FROM SALESPEOPLE
WHERE SNAME='MOTIKA')
WHERE SNUM=
(SELECT SNUM FROM SALESPEOPLE
WHERE SNAME='SERRES');
SELECT * FROM CUSTOMERS;
----->
CNUM CNAME CITY RATING SNUM
---------- ---------- ---------- ---------- ----------
2001 HOFFMAN LONDON 100 1001
2002 GIOVANNI ROME 300 1003
2003 LIU SAN JOSE 200 1004
2004 GRASS BERLIN 300 1004
2006 CLEMENS LONDON 100 1001
2008 CISNEROS SAN JOSE 300 1007
2007 PEREIRA ROME 200 1004