-
Notifications
You must be signed in to change notification settings - Fork 0
/
Homework_8.sql
98 lines (90 loc) · 6.99 KB
/
Homework_8.sql
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
-- Q1: test veritabanınızda employee isimli sütun bilgileri id(INTEGER), name VARCHAR(50), birthday DATE, email VARCHAR(100) olan bir tablo oluşturalım.
-- Q2: Oluşturduğumuz employee tablosuna 'Mockaroo' servisini kullanarak 50 adet veri ekleyelim.
-- Q3: Sütunların her birine göre diğer sütunları güncelleyecek 5 adet UPDATE işlemi yapalım.
-- Q4: Sütunların her birine göre ilgili satırı silecek 5 adet DELETE işlemi yapalım.
-- A1:
CREATE TABLE employee(
id INTEGER PRIMARY KEY,
name VARCHAR(50) NOT NULL,
birthday DATE NOT NULL,
email VARCHAR(100)
);
-- A2:
insert into employee (id, name, birthday, email) values (1, 'Blake Thor', '12/8/2023', '[email protected]');
insert into employee (id, name, birthday, email) values (2, 'Ivett Bendall', '7/22/1986', '[email protected]');
insert into employee (id, name, birthday, email) values (3, 'Englebert Neachell', '10/14/1996', '[email protected]');
insert into employee (id, name, birthday, email) values (4, 'Geoff Urridge', '3/22/2015', '[email protected]');
insert into employee (id, name, birthday, email) values (5, 'Nels Fleming', '3/23/1988', '[email protected]');
insert into employee (id, name, birthday, email) values (6, 'Brittni Vanichev', '9/4/1996', '[email protected]');
insert into employee (id, name, birthday, email) values (7, 'Skipper Neaves', '6/29/1982', '[email protected]');
insert into employee (id, name, birthday, email) values (8, 'Chelsae Gosforth', '11/2/2015', '[email protected]');
insert into employee (id, name, birthday, email) values (9, 'Malina Paxforde', '3/15/1983', '[email protected]');
insert into employee (id, name, birthday, email) values (10, 'Gregg Pottiphar', '4/29/1996', '[email protected]');
insert into employee (id, name, birthday, email) values (11, 'Doy Speeding', '6/23/1989', '[email protected]');
insert into employee (id, name, birthday, email) values (12, 'Christina Bayless', '8/12/2022', '[email protected]');
insert into employee (id, name, birthday, email) values (13, 'Eadmund Dalinder', '2/21/2000', '[email protected]');
insert into employee (id, name, birthday, email) values (14, 'Valentina Fontel', '3/31/1999', '[email protected]');
insert into employee (id, name, birthday, email) values (15, 'Ramona Binton', '6/19/2013', '[email protected]');
insert into employee (id, name, birthday, email) values (16, 'Kippar Nobbs', '7/2/1980', '[email protected]');
insert into employee (id, name, birthday, email) values (17, 'Cindee Sleeman', '3/29/1997', '[email protected]');
insert into employee (id, name, birthday, email) values (18, 'Leoine Duffitt', '3/30/2006', null);
insert into employee (id, name, birthday, email) values (19, 'Mariejeanne Surgood', '2/20/1996', '[email protected]');
insert into employee (id, name, birthday, email) values (20, 'Derrick Larcombe', '9/23/2004', '[email protected]');
insert into employee (id, name, birthday, email) values (21, 'Vicky Sergeaunt', '1/11/1991', '[email protected]');
insert into employee (id, name, birthday, email) values (22, 'Ansel Ormes', '11/5/2001', '[email protected]');
insert into employee (id, name, birthday, email) values (23, 'Jeniffer Reaman', '8/12/1993', '[email protected]');
insert into employee (id, name, birthday, email) values (24, 'Milka Wenden', '12/21/2011', '[email protected]');
insert into employee (id, name, birthday, email) values (25, 'Pauline Senechell', '3/29/1988', '[email protected]');
insert into employee (id, name, birthday, email) values (26, 'Hinda Willerson', '10/6/2000', '[email protected]');
insert into employee (id, name, birthday, email) values (27, 'Bartholomeo Maddick', '11/9/1999', '[email protected]');
insert into employee (id, name, birthday, email) values (28, 'Conchita Anglim', '11/8/2004', '[email protected]');
insert into employee (id, name, birthday, email) values (29, 'Leila Dooler', '3/22/2014', '[email protected]');
insert into employee (id, name, birthday, email) values (30, 'Perl Norvell', '1/29/1980', '[email protected]');
insert into employee (id, name, birthday, email) values (31, 'Pancho Bim', '4/1/2017', '[email protected]');
insert into employee (id, name, birthday, email) values (32, 'Ellene Goodale', '7/6/2012', '[email protected]');
insert into employee (id, name, birthday, email) values (33, 'Clarine Hendriksen', '5/4/1997', '[email protected]');
insert into employee (id, name, birthday, email) values (34, 'Noel Loughlin', '10/5/1998', '[email protected]');
insert into employee (id, name, birthday, email) values (35, 'Lewie Fawcett', '8/29/2010', '[email protected]');
insert into employee (id, name, birthday, email) values (36, 'Alair Escofier', '1/22/1995', '[email protected]');
insert into employee (id, name, birthday, email) values (37, 'Pris Casaro', '2/12/2023', '[email protected]');
insert into employee (id, name, birthday, email) values (38, 'Zonnya Creasey', '3/13/1980', '[email protected]');
insert into employee (id, name, birthday, email) values (39, 'Jo-ann Goretti', '3/26/2024', '[email protected]');
insert into employee (id, name, birthday, email) values (40, 'Cob Danelutti', '5/26/2022', '[email protected]');
insert into employee (id, name, birthday, email) values (41, 'Andrej Edgcumbe', '6/24/1998', '[email protected]');
insert into employee (id, name, birthday, email) values (42, 'Israel Faudrie', '2/6/2015', '[email protected]');
insert into employee (id, name, birthday, email) values (43, 'Loree Howkins', '1/7/2023', '[email protected]');
insert into employee (id, name, birthday, email) values (44, 'Dante Drinkale', '12/14/2011', '[email protected]');
insert into employee (id, name, birthday, email) values (45, 'Ronny McManus', '2/24/2011', '[email protected]');
insert into employee (id, name, birthday, email) values (46, 'Wolfie Fulep', '11/5/1994', '[email protected]');
insert into employee (id, name, birthday, email) values (47, 'Renaud Hysom', '4/9/2012', '[email protected]');
insert into employee (id, name, birthday, email) values (48, 'Aurora Evanson', '5/31/2022', '[email protected]');
insert into employee (id, name, birthday, email) values (49, 'Cristionna Pelling', '3/9/2009', '[email protected]');
insert into employee (id, name, birthday, email) values (50, 'Antonie Bowyer', '3/31/2011', '[email protected]');
-- A3:
UPDATE employee
SET birthday = '2021-10-04'
WHERE name = 'Aurora Evanson'
RETURNING *;
UPDATE employee
SET email = 'null'
WHERE birthday = '2011-31-3'
RETURNING *;
UPDATE employee
SET email = '[email protected]'
WHERE name = 'Israel Faudrie'
RETURNING *;
UPDATE employee
SET name = 'xxxx',
birthday = '1982-6-29'
WHERE email = 'null'
RETURNING *;
UPDATE employee
SET email = null,
WHERE email = '%@adobe.com'
RETURNING *;
-- A4:
DELETE FROM employee WHERE name = 'Noel Loughlin';
DELETE FROM employee WHERE id > 20 AND id < 25 ;
DELETE FROM employee WHERE birthday > '1999-9-11';
DELETE FROM employee WHERE email ILIKE 'i%';
DELETE FROM employee WHERE name LIKE '%b' OR name LIKE 'B%';