-
Notifications
You must be signed in to change notification settings - Fork 925
/
script.sql
86 lines (59 loc) · 2 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
--
-- Name: clientes; Type: TABLE; Schema: public; Owner: rinha
--
CREATE TABLE public.clientes (
id smallint NOT NULL,
limite integer,
saldo integer,
CONSTRAINT saldo_check CHECK (((limite + saldo) > 0))
);
ALTER TABLE public.clientes OWNER TO rinha;
--
-- Name: transacoes; Type: TABLE; Schema: public; Owner: rinha
--
CREATE TABLE public.transacoes (
clientes_id integer NOT NULL,
data timestamp with time zone NOT NULL,
tipo character varying(1),
descricao text,
--descricao character varying(10),
valor integer,
CONSTRAINT tipo_check CHECK (tipo in ('c','d')),
CONSTRAINT tipo_descricao CHECK (coalesce(descricao, '') <> ''),
CONSTRAINT length_descricao CHECK (char_length(descricao)<=10)
);
ALTER TABLE public.transacoes OWNER TO rinha;
--
-- Data for Name: clientes; Type: TABLE DATA; Schema: public; Owner: rinha
--
INSERT INTO public.clientes VALUES (3, 1000000, 0);
INSERT INTO public.clientes VALUES (1, 100000, 0);
INSERT INTO public.clientes VALUES (2, 80000, 0);
INSERT INTO public.clientes VALUES (4, 10000000, 0);
INSERT INTO public.clientes VALUES (5, 500000, 0);
--
-- Data for Name: transacoes; Type: TABLE DATA; Schema: public; Owner: rinha
--
--
-- Name: clientes clientes_pkey; Type: CONSTRAINT; Schema: public; Owner: rinha
--
ALTER TABLE ONLY public.clientes
ADD CONSTRAINT clientes_pkey PRIMARY KEY (id);
--
-- Name: transacoes transacoes_pkey; Type: CONSTRAINT; Schema: public; Owner: rinha
--
ALTER TABLE ONLY public.transacoes
ADD CONSTRAINT transacoes_pkey PRIMARY KEY (clientes_id, data, tipo);
--
-- Name: transacoes transacoes_fkey_clientes_id; Type: FK CONSTRAINT; Schema: public; Owner: rinha
--
ALTER TABLE ONLY public.transacoes
ADD CONSTRAINT transacoes_fkey_clientes_id FOREIGN KEY (clientes_id) REFERENCES public.clientes(id);
--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE USAGE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--