Skip to content

Instantly share code, notes, and snippets.

@chanmix51
Created April 30, 2015 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanmix51/a15b1c7c1d069f5a9e5d to your computer and use it in GitHub Desktop.
Save chanmix51/a15b1c7c1d069f5a9e5d to your computer and use it in GitHub Desktop.
Table dump for articles about joins.
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
--
CREATE TABLE sale (
sale_id integer NOT NULL,
seller_id integer NOT NULL,
sale_ts timestamp with time zone DEFAULT now() NOT NULL,
quantity smallint NOT NULL,
total_price_ct integer NOT NULL,
CONSTRAINT sale_quantity_check CHECK ((quantity > 0)),
CONSTRAINT sale_total_price_ct_check CHECK ((total_price_ct > 0))
);
--
--
CREATE SEQUENCE sale_sale_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
--
ALTER SEQUENCE sale_sale_id_seq OWNED BY sale.sale_id;
--
--
CREATE TABLE seller (
seller_id integer NOT NULL,
name character varying NOT NULL
);
--
--
CREATE SEQUENCE seller_seller_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
--
ALTER SEQUENCE seller_seller_id_seq OWNED BY seller.seller_id;
--
--
ALTER TABLE ONLY sale ALTER COLUMN sale_id SET DEFAULT nextval('sale_sale_id_seq'::regclass);
--
--
ALTER TABLE ONLY seller ALTER COLUMN seller_id SET DEFAULT nextval('seller_seller_id_seq'::regclass);
--
--
COPY sale (sale_id, seller_id, sale_ts, quantity, total_price_ct) FROM stdin;
1 1 2015-04-14 00:30:35+00 7 5210
2 1 2015-04-18 05:49:56+00 6 3940
3 1 2015-04-15 14:10:15+00 9 680
4 1 2015-04-19 08:41:20+00 4 5210
5 1 2015-04-14 02:21:47+00 9 2220
6 1 2015-04-15 18:54:13+00 4 6490
7 1 2015-04-19 08:32:43+00 7 8370
8 1 2015-04-19 10:29:03+00 9 6550
9 1 2015-04-13 19:34:07+00 1 1460
10 1 2015-04-14 13:31:34+00 1 6680
11 1 2015-04-14 07:28:31+00 1 8900
12 1 2015-04-13 13:31:10+00 2 8520
13 1 2015-04-16 11:03:44+00 7 5450
14 1 2015-04-18 21:53:47+00 5 1900
15 1 2015-04-16 16:15:13+00 2 7550
16 1 2015-04-17 16:26:34+00 6 9700
17 1 2015-04-14 19:02:38+00 2 4130
18 1 2015-04-14 16:48:16+00 2 1720
19 1 2015-04-14 15:23:26+00 1 6930
20 1 2015-04-18 21:52:53+00 7 6660
21 1 2015-04-16 05:03:32+00 3 9740
22 1 2015-04-18 22:47:01+00 8 4800
23 1 2015-04-13 18:13:11+00 4 6640
24 1 2015-04-16 15:55:00+00 2 3840
25 1 2015-04-17 15:05:40+00 5 5750
26 1 2015-04-15 12:48:46+00 3 8720
27 1 2015-04-16 17:16:27+00 8 9600
28 1 2015-04-19 15:07:15+00 8 1610
29 1 2015-04-19 20:00:00+00 5 2160
30 1 2015-04-18 19:57:03+00 8 2240
31 2 2015-04-18 20:22:42+00 3 7860
32 2 2015-04-13 08:25:48+00 6 2690
33 2 2015-04-15 16:02:52+00 5 2320
34 2 2015-04-13 14:03:43+00 2 7090
35 2 2015-04-19 13:09:55+00 6 3910
36 2 2015-04-16 20:33:46+00 4 7830
37 2 2015-04-16 22:30:25+00 5 6790
38 2 2015-04-13 03:30:31+00 7 680
39 2 2015-04-14 15:03:10+00 1 9300
40 2 2015-04-18 01:05:55+00 6 5930
41 2 2015-04-14 21:51:51+00 2 5250
42 2 2015-04-14 00:21:28+00 3 4260
43 2 2015-04-19 21:38:14+00 9 5460
44 2 2015-04-13 10:31:19+00 6 1700
45 2 2015-04-13 12:24:27+00 2 4310
46 2 2015-04-17 05:46:05+00 8 8290
47 2 2015-04-14 04:16:17+00 3 340
48 2 2015-04-17 23:36:09+00 6 1980
49 2 2015-04-13 20:17:19+00 8 9880
50 2 2015-04-14 17:58:43+00 8 3480
51 2 2015-04-15 10:17:23+00 4 6480
52 2 2015-04-15 12:33:29+00 6 5990
53 2 2015-04-18 02:39:55+00 9 8820
54 2 2015-04-18 15:05:23+00 1 5370
55 2 2015-04-19 00:17:00+00 5 6090
56 2 2015-04-16 03:32:29+00 7 8660
57 2 2015-04-13 06:12:12+00 8 6720
58 2 2015-04-17 15:23:27+00 9 9420
59 2 2015-04-16 15:47:52+00 8 3230
60 2 2015-04-13 10:54:04+00 5 4070
61 2 2015-04-13 06:00:37+00 6 6160
62 2 2015-04-13 10:26:01+00 8 5470
63 2 2015-04-17 06:11:49+00 6 6800
64 3 2015-04-15 02:26:24+00 4 5420
65 3 2015-04-15 15:52:02+00 6 3210
66 3 2015-04-13 22:08:55+00 8 2510
67 3 2015-04-14 08:44:40+00 5 6780
68 3 2015-04-16 12:10:15+00 2 2640
69 3 2015-04-13 01:16:52+00 9 280
70 3 2015-04-18 19:00:14+00 7 130
71 3 2015-04-15 23:08:48+00 8 6180
72 3 2015-04-15 16:16:29+00 5 8580
73 3 2015-04-13 12:54:32+00 6 160
74 4 2015-04-15 20:51:06+00 3 9640
75 4 2015-04-19 11:17:58+00 6 7930
76 4 2015-04-13 16:08:25+00 2 680
77 4 2015-04-19 19:31:50+00 6 5120
78 4 2015-04-16 04:35:06+00 9 7340
79 4 2015-04-14 05:12:28+00 4 5900
80 4 2015-04-13 09:03:50+00 7 9110
81 4 2015-04-15 21:49:48+00 7 2490
82 4 2015-04-17 23:19:30+00 3 9880
83 4 2015-04-14 09:18:02+00 2 2320
84 4 2015-04-16 20:41:38+00 3 8120
85 4 2015-04-14 17:02:45+00 3 9650
86 4 2015-04-14 22:31:16+00 3 1580
87 4 2015-04-13 19:46:38+00 8 7750
\.
--
--
SELECT pg_catalog.setval('sale_sale_id_seq', 87, true);
--
--
COPY seller (seller_id, name) FROM stdin;
1 Delphia Kozey
2 Dr. Ernie Kilback Sr.
3 Prof. Angelo Parker DVM
4 Mr. Johnson Kiehn
\.
--
--
SELECT pg_catalog.setval('seller_seller_id_seq', 4, true);
--
--
ALTER TABLE ONLY sale
ADD CONSTRAINT sale_pkey PRIMARY KEY (sale_id);
--
--
ALTER TABLE ONLY seller
ADD CONSTRAINT seller_pkey PRIMARY KEY (seller_id);
--
--
ALTER TABLE ONLY sale
ADD CONSTRAINT sale_seller_id_fkey FOREIGN KEY (seller_id) REFERENCES seller(seller_id);
--
-- PostgreSQL database dump complete
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment