forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.sql
33 lines (29 loc) · 931 Bytes
/
script.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
30
31
32
33
create table public.clientes
(
id integer not null,
limite integer not null,
saldo_atual integer not null,
saldo_inicial
integer not null,
primary key (id)
);
create table public.transacoes
(
id serial not null,
id_cliente integer not null,
valor integer not null,
realizada_em
timestamp(6) not null,
descricao varchar(255) not null,
tipo varchar(255) not null check (tipo in ('c', 'd')),
primary key (id)
);
create sequence public.cliente_seq start with 1 increment by 10;
alter table if exists public.transacoes
add constraint FK_cliente foreign key (id_cliente) references public.clientes;
INSERT INTO public.clientes (id, limite, saldo_inicial, saldo_atual)
VALUES (1, 100000, 0, 0),
(2, 80000, 0, 0),
(3, 1000000, 0, 0),
(4, 10000000, 0, 0),
(5, 500000, 0, 0);