-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
28 lines (26 loc) · 672 Bytes
/
Copy pathinit.sql
File metadata and controls
28 lines (26 loc) · 672 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
CREATE UNLOGGED TABLE clientes (
id BIGSERIAL PRIMARY KEY NOT NULL,
created_at timestamp with time zone DEFAULT now(),
limite INTEGER NOT NULL,
saldo INTEGER DEFAULT 0
);
CREATE UNLOGGED TABLE transacoes (
id SERIAL PRIMARY KEY NOT NULL,
cliente_id INT NOT NULL,
valor INTEGER NOT NULL,
tipo VARCHAR(1) NOT NULL,
descricao VARCHAR(10) ,
realizada_em timestamp with time zone DEFAULT now(),
CONSTRAINT fk_clientes FOREIGN KEY (cliente_id)
REFERENCES clientes(id)
);
DO $$
BEGIN
INSERT INTO clientes (limite)
VALUES
(1000 * 100),
(800 * 100),
(10000 * 100),
(100000 * 100),
(5000 * 100);
END; $$