-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_db.sql
141 lines (99 loc) · 3.37 KB
/
sample_db.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)
-- Dumped by pg_dump version 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: atm_accounts; Type: TABLE; Schema: public; Owner: atm
--
CREATE TABLE public.atm_accounts (
cpf character(11),
id_account integer NOT NULL,
type character(1) NOT NULL,
balance integer,
CONSTRAINT account_type CHECK (((type = 'C'::bpchar) OR (type = 'P'::bpchar))),
CONSTRAINT positive_balance CHECK ((balance >= 0))
);
ALTER TABLE public.atm_accounts OWNER TO atm;
--
-- Name: atm_accounts_id_account_seq; Type: SEQUENCE; Schema: public; Owner: atm
--
CREATE SEQUENCE public.atm_accounts_id_account_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.atm_accounts_id_account_seq OWNER TO atm;
--
-- Name: atm_accounts_id_account_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: atm
--
ALTER SEQUENCE public.atm_accounts_id_account_seq OWNED BY public.atm_accounts.id_account;
--
-- Name: atm_users; Type: TABLE; Schema: public; Owner: atm
--
CREATE TABLE public.atm_users (
name character varying(50) NOT NULL,
cpf character(11) NOT NULL,
b_date date NOT NULL,
CONSTRAINT cpf_exact_length CHECK ((char_length(cpf) = 11)),
CONSTRAINT non_empty_name CHECK (((name)::text <> ''::text))
);
ALTER TABLE public.atm_users OWNER TO atm;
--
-- Name: atm_accounts id_account; Type: DEFAULT; Schema: public; Owner: atm
--
ALTER TABLE ONLY public.atm_accounts ALTER COLUMN id_account SET DEFAULT nextval('public.atm_accounts_id_account_seq'::regclass);
--
-- Data for Name: atm_accounts; Type: TABLE DATA; Schema: public; Owner: atm
--
COPY public.atm_accounts (cpf, id_account, type, balance) FROM stdin;
22255588813 1 P 160
00011122233 2 P 250
12345678900 3 C 515
00011122233 4 C 18867
\.
--
-- Data for Name: atm_users; Type: TABLE DATA; Schema: public; Owner: atm
--
COPY public.atm_users (name, cpf, b_date) FROM stdin;
Kevin Flynn 00011122233 1984-02-28
Sam Flynn 12345678900 1961-02-28
Maximus Decimus Meridius 22255588813 2000-05-19
Marcus Aurelius 11144477789 1984-02-28
\.
--
-- Name: atm_accounts_id_account_seq; Type: SEQUENCE SET; Schema: public; Owner: atm
--
SELECT pg_catalog.setval('public.atm_accounts_id_account_seq', 15, true);
--
-- Name: atm_accounts atm_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: atm
--
ALTER TABLE ONLY public.atm_accounts
ADD CONSTRAINT atm_accounts_pkey PRIMARY KEY (id_account);
--
-- Name: atm_users atm_users_pkey; Type: CONSTRAINT; Schema: public; Owner: atm
--
ALTER TABLE ONLY public.atm_users
ADD CONSTRAINT atm_users_pkey PRIMARY KEY (cpf);
--
-- Name: atm_accounts atm_accounts_cpf_fkey; Type: FK CONSTRAINT; Schema: public; Owner: atm
--
ALTER TABLE ONLY public.atm_accounts
ADD CONSTRAINT atm_accounts_cpf_fkey FOREIGN KEY (cpf) REFERENCES public.atm_users(cpf) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--