-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathempresa.sql
More file actions
398 lines (280 loc) · 8.6 KB
/
empresa.sql
File metadata and controls
398 lines (280 loc) · 8.6 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.1.11
-- Dumped by pg_dump version 9.1.11
-- Started on 2014-02-15 23:38:38 AMST
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- TOC entry 169 (class 3079 OID 11680)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 1938 (class 0 OID 0)
-- Dependencies: 169
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 164 (class 1259 OID 16862)
-- Dependencies: 5
-- Name: Funcionario; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE "Funcionario" (
id bigint NOT NULL,
nome character varying(255),
setor bigint
);
ALTER TABLE public."Funcionario" OWNER TO postgres;
--
-- TOC entry 163 (class 1259 OID 16860)
-- Dependencies: 164 5
-- Name: Funcionario_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE "Funcionario_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public."Funcionario_id_seq" OWNER TO postgres;
--
-- TOC entry 1939 (class 0 OID 0)
-- Dependencies: 163
-- Name: Funcionario_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE "Funcionario_id_seq" OWNED BY "Funcionario".id;
--
-- TOC entry 166 (class 1259 OID 16878)
-- Dependencies: 5 164
-- Name: Gerente; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE "Gerente" (
id bigint,
codigo character varying(32)
)
INHERITS ("Funcionario");
ALTER TABLE public."Gerente" OWNER TO postgres;
--
-- TOC entry 165 (class 1259 OID 16876)
-- Dependencies: 166 5
-- Name: Gerente_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE "Gerente_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public."Gerente_id_seq" OWNER TO postgres;
--
-- TOC entry 1940 (class 0 OID 0)
-- Dependencies: 165
-- Name: Gerente_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE "Gerente_id_seq" OWNED BY "Gerente".id;
--
-- TOC entry 162 (class 1259 OID 16854)
-- Dependencies: 5
-- Name: Setor; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE "Setor" (
id bigint NOT NULL,
nome character varying(128),
unidade bigint,
secretario bigint
);
ALTER TABLE public."Setor" OWNER TO postgres;
--
-- TOC entry 161 (class 1259 OID 16852)
-- Dependencies: 162 5
-- Name: Setor_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE "Setor_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public."Setor_id_seq" OWNER TO postgres;
--
-- TOC entry 1941 (class 0 OID 0)
-- Dependencies: 161
-- Name: Setor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE "Setor_id_seq" OWNED BY "Setor".id;
--
-- TOC entry 168 (class 1259 OID 16892)
-- Dependencies: 5
-- Name: Unidade; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE "Unidade" (
id bigint NOT NULL,
numero bigint
);
ALTER TABLE public."Unidade" OWNER TO postgres;
--
-- TOC entry 167 (class 1259 OID 16890)
-- Dependencies: 5 168
-- Name: Unidade_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE "Unidade_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public."Unidade_id_seq" OWNER TO postgres;
--
-- TOC entry 1942 (class 0 OID 0)
-- Dependencies: 167
-- Name: Unidade_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE "Unidade_id_seq" OWNED BY "Unidade".id;
--
-- TOC entry 1808 (class 2604 OID 16865)
-- Dependencies: 164 163 164
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "Funcionario" ALTER COLUMN id SET DEFAULT nextval('"Funcionario_id_seq"'::regclass);
--
-- TOC entry 1809 (class 2604 OID 16881)
-- Dependencies: 165 166 166
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "Gerente" ALTER COLUMN id SET DEFAULT nextval('"Gerente_id_seq"'::regclass);
--
-- TOC entry 1807 (class 2604 OID 16857)
-- Dependencies: 161 162 162
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "Setor" ALTER COLUMN id SET DEFAULT nextval('"Setor_id_seq"'::regclass);
--
-- TOC entry 1810 (class 2604 OID 16895)
-- Dependencies: 168 167 168
-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "Unidade" ALTER COLUMN id SET DEFAULT nextval('"Unidade_id_seq"'::regclass);
--
-- TOC entry 1926 (class 0 OID 16862)
-- Dependencies: 164 1931
-- Data for Name: Funcionario; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY "Funcionario" (id, nome, setor) FROM stdin;
\.
--
-- TOC entry 1943 (class 0 OID 0)
-- Dependencies: 163
-- Name: Funcionario_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('"Funcionario_id_seq"', 10, true);
--
-- TOC entry 1928 (class 0 OID 16878)
-- Dependencies: 166 1931
-- Data for Name: Gerente; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY "Gerente" (id, nome, codigo, setor) FROM stdin;
\.
--
-- TOC entry 1944 (class 0 OID 0)
-- Dependencies: 165
-- Name: Gerente_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('"Gerente_id_seq"', 58, true);
--
-- TOC entry 1924 (class 0 OID 16854)
-- Dependencies: 162 1931
-- Data for Name: Setor; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY "Setor" (id, nome, unidade, secretario) FROM stdin;
86 UM NOME \N \N
\.
--
-- TOC entry 1945 (class 0 OID 0)
-- Dependencies: 161
-- Name: Setor_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('"Setor_id_seq"', 86, true);
--
-- TOC entry 1930 (class 0 OID 16892)
-- Dependencies: 168 1931
-- Data for Name: Unidade; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY "Unidade" (id, numero) FROM stdin;
\.
--
-- TOC entry 1946 (class 0 OID 0)
-- Dependencies: 167
-- Name: Unidade_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('"Unidade_id_seq"', 6, true);
--
-- TOC entry 1814 (class 2606 OID 16870)
-- Dependencies: 164 164 1932
-- Name: Funcionario_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY "Funcionario"
ADD CONSTRAINT "Funcionario_pkey" PRIMARY KEY (id);
--
-- TOC entry 1816 (class 2606 OID 16886)
-- Dependencies: 166 166 1932
-- Name: Gerente_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY "Gerente"
ADD CONSTRAINT "Gerente_pkey" PRIMARY KEY (id);
--
-- TOC entry 1812 (class 2606 OID 16859)
-- Dependencies: 162 162 1932
-- Name: Setor_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY "Setor"
ADD CONSTRAINT "Setor_pkey" PRIMARY KEY (id);
--
-- TOC entry 1818 (class 2606 OID 16897)
-- Dependencies: 168 168 1932
-- Name: Unidade_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
--
ALTER TABLE ONLY "Unidade"
ADD CONSTRAINT "Unidade_pkey" PRIMARY KEY (id);
--
-- TOC entry 1821 (class 2606 OID 16913)
-- Dependencies: 162 164 1811 1932
-- Name: Funcionario_setor_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "Funcionario"
ADD CONSTRAINT "Funcionario_setor_fkey" FOREIGN KEY (setor) REFERENCES "Setor"(id);
--
-- TOC entry 1820 (class 2606 OID 16908)
-- Dependencies: 1813 162 164 1932
-- Name: Setor_secretario_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "Setor"
ADD CONSTRAINT "Setor_secretario_fkey" FOREIGN KEY (secretario) REFERENCES "Funcionario"(id);
--
-- TOC entry 1819 (class 2606 OID 16903)
-- Dependencies: 162 168 1817 1932
-- Name: Setor_unidade_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY "Setor"
ADD CONSTRAINT "Setor_unidade_fkey" FOREIGN KEY (unidade) REFERENCES "Unidade"(id);
--
-- TOC entry 1937 (class 0 OID 0)
-- Dependencies: 5
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
-- Completed on 2014-02-15 23:38:38 AMST
--
-- PostgreSQL database dump complete
--