-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel2.sql
More file actions
30 lines (24 loc) · 902 Bytes
/
Copy pathlevel2.sql
File metadata and controls
30 lines (24 loc) · 902 Bytes
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
.headers on
.mode column
-- 1. CREATE a table for Employees
CREATE TABLE employees (
id INTEGER,
name TEXT,
role TEXT,
salary INTEGER
);
-- 2. INSERT some employees
INSERT INTO employees VALUES (1, 'Alice', 'Manager', 80000);
INSERT INTO employees VALUES (2, 'Bob', 'Developer', 60000);
INSERT INTO employees VALUES (3, 'Charlie', 'Developer', 65000);
INSERT INTO employees VALUES (4, 'Diana', 'Designer', 55000);
-- 3. FILTER: Show me ONLY the Developers
SELECT '--- ONLY DEVELOPERS ---' AS '';
SELECT name, salary FROM employees WHERE role = 'Developer';
-- 4. UPDATE: Give Bob a raise! (Change his salary to 75000)
UPDATE employees SET salary = 75000 WHERE name = 'Bob';
-- 5. DELETE: Fire Charlie (Sorry Charlie!)
DELETE FROM employees WHERE name = 'Charlie';
-- 6. FINAL RESULT: Show everyone who is left
SELECT '--- FINAL COMPANY LIST ---' AS '';
SELECT * FROM employees;