-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sql
More file actions
35 lines (29 loc) · 898 Bytes
/
setup.sql
File metadata and controls
35 lines (29 loc) · 898 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
31
32
33
34
35
CREATE EXTENSION IF NOT EXISTS pg_trgm;
DROP TABLE IF EXISTS products;
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
keywords TEXT,
price DECIMAL(10,2),
stock_qty INTEGER
);
DROP TABLE IF EXISTS customers;
CREATE TABLE customers (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
balance DECIMAL(10,2) DEFAULT 0.0
);
DROP TABLE IF EXISTS transactions;
CREATE TABLE transactions (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP DEFAULT NOW(),
total_amount DECIMAL(10,2),
summary TEXT
);
INSERT INTO products (name, keywords, price, stock_qty) VALUES
('Tata Salt', 'namak salt', 20.0, 50),
('Maggi', 'noodles magi snack', 14.0, 100),
('Coke', 'cola drink soda thanda', 40.0, 24),
('Lux Soap', 'soap sabun body', 35.0, 30);
INSERT INTO customers (name, balance) VALUES ('Rahul', 500.00), ('Amit', 0.00);
SELECT * FROM products;