-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_data.sql
More file actions
59 lines (43 loc) · 1.87 KB
/
insert_data.sql
File metadata and controls
59 lines (43 loc) · 1.87 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
-- SQL script to create tables
-- The code to populate the Users table is as follows:
INSERT INTO Users VALUES (1, 'Alice', 'Smith', 'alice@gmail.com','2025-01-15'),
(2,'Bob', 'Johnson', 'Bob@hotmail.com', '2025-02-20'),
(3, 'Charlie', 'Lee', 'Charlie@gmail.com', '2025-03-05');
-- The code to IGNORE or REPLACE in the Users table is as follows:
INSERT OR IGNORE INTO Users (user_id, first_name, last_name, email, signup_date)
VALUES (1,'Alice','Smith','alice@gmail.com','2025-01-15'),
(2,'Bob','Johnson','bob@gmail.com','2025-02-20'),
(3,'Charlie','Lee','charlie@gmail.com','2025-03-05');
INSERT OR REPLACE INTO Users (user_id, first_name, last_name, email, signup_date)
VALUES(1,'Alice','Smith','alice@gmail.com','2025-01-15'),
(2,'Bob','Johnson','bob@gmail.com','2025-02-20'),
(3,'Charlie','Lee','charlie@gmail.com','2025-03-05');
-- The code to see Users table:
SELECT * FROM Users;
-- The code to populate the Products table is as follows:
INSERT INTO Products VALUES (1,'Laptop','Electronics',1200,10),
(2,'Smartphone','Electronics',800,20),
(3,'Coffee Maker','Home Appliances',150,15),
(4,'Headphone','Electronics',200,25);
-- The code to see Products table:
SELECT * FROM Products;
-- The code to populate the Orders table is as follows:
INSERT INTO Orders VALUES (1,1,'2025-04-01',1400),
(2,2,'2025-04-03',950),
(3,1,'2025-04-05',200);
-- The code to see Orders table:
SELECT * FROM Orders;
-- The code to populate the OrderItems table is as follows:
INSERT INTO OrderItems VALUES (1,1,1,1,1200),
(2,1,4,1,200),
(3,2,2,1,800),
(4,2,4,1,150),
(5,3,4,1,200);
-- The code to see OrderItems table:
SELECT * FROM OrderItems;
-- The code to populate the Reviews table is as follows:
INSERT INTO Reviews VALUES (1,1,1,5,'Great laptop','2025-04-02'),
(2,2,2,4,'Good phone','2025-04-04'),
(3,3,3,3,'Average coffee maker','2025-04-06');
-- The code to see Reviews table:
SELECT * FROM Reviews;