forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
29 lines (26 loc) · 774 Bytes
/
init.sql
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
CREATE UNLOGGED TABLE IF NOT EXISTS clientes (
id SERIAL PRIMARY KEY NOT NULL
, nome VARCHAR(100) NOT NULL
, limite INT NOT NULL
, saldo INT
);
CREATE UNLOGGED TABLE IF NOT EXISTS transacoes (
id SERIAL PRIMARY KEY NOT NULL
, id_cliente INT NOT NULL
, valor INT NOT NULL
, tipo VARCHAR(1) NOT NULL
, descricao VARCHAR(100) NOT NULL
, realizada_em TIMESTAMP DEFAULT CURRENT_TIMESTAMP
, FOREIGN KEY (id_cliente) REFERENCES clientes(id)
);
-- CREATE INDEX idx_id_cliente ON transacoes (id_cliente);
DO $$
BEGIN
INSERT INTO clientes (nome, limite)
VALUES
('o barato sai caro', 1000 * 100),
('zan corp ltda', 800 * 100),
('les cruders', 10000 * 100),
('padaria joia de cocaia', 100000 * 100),
('kid mais', 5000 * 100);
END; $$