-
Notifications
You must be signed in to change notification settings - Fork 923
/
Copy pathscript.sql
31 lines (30 loc) · 962 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
alter table if exists transaction
drop constraint if exists FK_transaction_client_id;
drop table if exists client cascade;
drop table if exists transaction cascade;
create unlogged table client
(
id bigserial not null,
name varchar(255),
balance numeric(38, 0) default 0,
limite numeric(38, 0) default 0,
primary key (id)
);
create unlogged table transaction
(
id bigserial not null,
client_id bigint,
description varchar(255),
type char(1),
value numeric(38, 0),
created_at timestamp(6) default now(),
primary key (id)
);
alter table if exists transaction
add constraint FK_transaction_client_id foreign key (client_id) references client;
INSERT INTO client (name, 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);