-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge13-ClothingAlterations.sql
More file actions
48 lines (34 loc) · 1.18 KB
/
challenge13-ClothingAlterations.sql
File metadata and controls
48 lines (34 loc) · 1.18 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
/*Challenge: Clothing alterations*/
CREATE TABLE clothes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
type TEXT,
design TEXT);
INSERT INTO clothes (type, design)
VALUES ("dress", "pink polka dots");
INSERT INTO clothes (type, design)
VALUES ("pants", "rainbow tie-dye");
INSERT INTO clothes (type, design)
VALUES ("blazer", "black sequin");
/*Step 1
Use ALTER to add a 'price' column to the table.
Then select all the columns in each row to see what your table looks like now.
*/
ALTER TABLE clothes ADD price INTEGER;
SELECT * FROM clothes;
/* Step 2
- item 1 should be 10 dollars.
- item 2 should be 20 dollars
- item 3 should be 30 dollars.
When you're done, do another SELECT of all the rows to check that it worked as expected.
*/
UPDATE clothes SET price = 10 WHERE id = 1;
UPDATE clothes SET price = 20 WHERE id = 2;
UPDATE clothes SET price = 30 WHERE id = 3;
SELECT * FROM clothes;
/* Step 3
Now insert a new item into the table that has all three attributes filled in, including 'price'.
Do one final SELECT of all the rows to check it worked.
*/
INSERT INTO clothes (type, design,price)
VALUES ("skirt", "white yellow dots", 25);
SELECT * FROM clothes;