-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmoke_test.sql
More file actions
50 lines (40 loc) · 1.32 KB
/
smoke_test.sql
File metadata and controls
50 lines (40 loc) · 1.32 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
-- ============================================
-- MuriukiDB Smoke Test SQL Queries
-- Pesapal Junior Dev Challenge '26
-- ============================================
-- 1) Create table with constraints
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE,
age INTEGER,
created_at DATE
);
-- 2) Insert test data
INSERT INTO users (name, email, age, created_at) VALUES
('Alice', 'alice@example.com', 30, '2025-01-01'),
('Bob', 'bob@example.com', 25, '2025-01-03');
-- 3) Verify rows
SELECT * FROM users ORDER BY id;
-- 4) Test unique constraint (should fail)
INSERT INTO users (name, email) VALUES ('Eve', 'alice@example.com');
-- 5) Create and use index
CREATE INDEX idx_users_email ON users (email);
SELECT * FROM users WHERE email = 'bob@example.com';
-- 6) Test JOIN
CREATE TABLE IF NOT EXISTS orders (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
user_id INTEGER,
product TEXT
);
INSERT INTO orders (user_id, product) VALUES (1, 'Tea'), (2, 'Coffee');
SELECT u.name, o.product FROM users u INNER JOIN orders o ON u.id = o.user_id;
-- 7) Update & Delete
UPDATE users SET age = 26 WHERE name = 'Bob';
DELETE FROM users WHERE name = 'Alice';
-- 8) Final verification
SELECT * FROM users;
-- 9) Show all tables
SHOW TABLES;
-- 10) Describe table structure
DESCRIBE users;