Project

General

Profile

« Previous | Next » 

Revision 6867

schemas/vegbien.sql: Added materialized view owner_count, generated from owner_count_view

View differences:

schemas/vegbien.my.sql
423 423

  
424 424

  
425 425
--
426
-- Name: sync_owner_count_to_view(); Type: FUNCTION; Schema: public; Owner: -
427
--
428

  
429

  
430

  
431

  
432
--
426 433
-- Name: sync_provider_count_to_view(); Type: FUNCTION; Schema: public; Owner: -
427 434
--
428 435

  
......
2401 2408

  
2402 2409

  
2403 2410
--
2411
-- Name: owner_count; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2412
--
2413

  
2414
CREATE TABLE owner_count (
2415
    owner varchar(255) NOT NULL,
2416
    count varchar(255)
2417
);
2418

  
2419

  
2420
--
2421
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2422
--
2423

  
2424
CREATE TABLE sourcename (
2425
    sourcelist_id int(11) NOT NULL,
2426
    name varchar(255) NOT NULL,
2427
    matched_source_id int(11)
2428
);
2429

  
2430

  
2431
--
2432
-- Name: owner_count_view; Type: VIEW; Schema: public; Owner: -
2433
--
2434

  
2435

  
2436

  
2437

  
2438
--
2404 2439
-- Name: party_party_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2405 2440
--
2406 2441

  
......
2688 2723

  
2689 2724

  
2690 2725
--
2691
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2692
--
2693

  
2694
CREATE TABLE sourcename (
2695
    sourcelist_id int(11) NOT NULL,
2696
    name varchar(255) NOT NULL,
2697
    matched_source_id int(11)
2698
);
2699

  
2700

  
2701
--
2702 2726
-- Name: provider_view; Type: VIEW; Schema: public; Owner: -
2703 2727
--
2704 2728

  
......
4107 4131

  
4108 4132

  
4109 4133
--
4134
-- Data for Name: owner_count; Type: TABLE DATA; Schema: public; Owner: -
4135
--
4136

  
4137

  
4138

  
4139
--
4110 4140
-- Data for Name: party; Type: TABLE DATA; Schema: public; Owner: -
4111 4141
--
4112 4142

  
......
4601 4631

  
4602 4632

  
4603 4633
--
4634
-- Name: owner_count_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4635
--
4636

  
4637
ALTER TABLE owner_count
4638
    ADD CONSTRAINT owner_count_pkey PRIMARY KEY (owner);
4639

  
4640

  
4641
--
4604 4642
-- Name: party_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4605 4643
--
4606 4644

  
......
7015 7053

  
7016 7054

  
7017 7055
--
7018
-- Name: partymember; Type: ACL; Schema: public; Owner: -
7056
-- Name: owner_count; Type: ACL; Schema: public; Owner: -
7019 7057
--
7020 7058

  
7021 7059

  
......
7024 7062

  
7025 7063

  
7026 7064

  
7065

  
7027 7066
--
7028
-- Name: placecorrelation; Type: ACL; Schema: public; Owner: -
7067
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
7029 7068
--
7030 7069

  
7031 7070

  
......
7034 7073

  
7035 7074

  
7036 7075

  
7076

  
7037 7077
--
7038
-- Name: placename; Type: ACL; Schema: public; Owner: -
7078
-- Name: owner_count_view; Type: ACL; Schema: public; Owner: -
7039 7079
--
7040 7080

  
7041 7081

  
......
7044 7084

  
7045 7085

  
7046 7086

  
7087

  
7047 7088
--
7048
-- Name: placename_ancestor; Type: ACL; Schema: public; Owner: -
7089
-- Name: partymember; Type: ACL; Schema: public; Owner: -
7049 7090
--
7050 7091

  
7051 7092

  
......
7055 7096

  
7056 7097

  
7057 7098
--
7058
-- Name: plant; Type: ACL; Schema: public; Owner: -
7099
-- Name: placecorrelation; Type: ACL; Schema: public; Owner: -
7059 7100
--
7060 7101

  
7061 7102

  
......
7065 7106

  
7066 7107

  
7067 7108
--
7068
-- Name: projectcontributor; Type: ACL; Schema: public; Owner: -
7109
-- Name: placename; Type: ACL; Schema: public; Owner: -
7069 7110
--
7070 7111

  
7071 7112

  
......
7075 7116

  
7076 7117

  
7077 7118
--
7078
-- Name: provider_count; Type: ACL; Schema: public; Owner: -
7119
-- Name: placename_ancestor; Type: ACL; Schema: public; Owner: -
7079 7120
--
7080 7121

  
7081 7122

  
......
7084 7125

  
7085 7126

  
7086 7127

  
7128
--
7129
-- Name: plant; Type: ACL; Schema: public; Owner: -
7130
--
7087 7131

  
7132

  
7133

  
7134

  
7135

  
7136

  
7137

  
7088 7138
--
7089
-- Name: provider_count_view; Type: ACL; Schema: public; Owner: -
7139
-- Name: projectcontributor; Type: ACL; Schema: public; Owner: -
7090 7140
--
7091 7141

  
7092 7142

  
......
7095 7145

  
7096 7146

  
7097 7147

  
7148
--
7149
-- Name: provider_count; Type: ACL; Schema: public; Owner: -
7150
--
7098 7151

  
7152

  
7153

  
7154

  
7155

  
7156

  
7157

  
7158

  
7099 7159
--
7100
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
7160
-- Name: provider_count_view; Type: ACL; Schema: public; Owner: -
7101 7161
--
7102 7162

  
7103 7163

  
schemas/vegbien.sql
973 973

  
974 974

  
975 975
--
976
-- Name: sync_owner_count_to_view(); Type: FUNCTION; Schema: public; Owner: -
977
--
978

  
979
CREATE FUNCTION sync_owner_count_to_view() RETURNS void
980
    LANGUAGE sql
981
    AS $$
982
DROP TABLE IF EXISTS owner_count;
983
CREATE TABLE owner_count AS SELECT * FROM owner_count_view LIMIT 0;
984

  
985
GRANT SELECT ON TABLE owner_count TO bien_read;
986
GRANT SELECT ON TABLE owner_count TO public_;
987
GRANT SELECT ON TABLE owner_count_view TO bien_read;
988
GRANT SELECT ON TABLE owner_count_view TO public_;
989

  
990
ALTER TABLE owner_count ADD PRIMARY KEY (owner);
991
$$;
992

  
993

  
994
--
976 995
-- Name: sync_provider_count_to_view(); Type: FUNCTION; Schema: public; Owner: -
977 996
--
978 997

  
......
3332 3351

  
3333 3352

  
3334 3353
--
3354
-- Name: owner_count; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3355
--
3356

  
3357
CREATE TABLE owner_count (
3358
    owner text NOT NULL,
3359
    count bigint
3360
);
3361

  
3362

  
3363
--
3364
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3365
--
3366

  
3367
CREATE TABLE sourcename (
3368
    sourcelist_id integer NOT NULL,
3369
    name text NOT NULL,
3370
    matched_source_id integer
3371
);
3372

  
3373

  
3374
--
3375
-- Name: owner_count_view; Type: VIEW; Schema: public; Owner: -
3376
--
3377

  
3378
CREATE VIEW owner_count_view AS
3379
    SELECT sourcename.name AS owner, count(*) AS count FROM ((sourcename JOIN sourcelist USING (sourcelist_id)) JOIN specimenreplicate ON ((specimenreplicate.institution_id = sourcelist.sourcelist_id))) GROUP BY sourcename.name;
3380

  
3381

  
3382
--
3335 3383
-- Name: party_party_id_seq; Type: SEQUENCE; Schema: public; Owner: -
3336 3384
--
3337 3385

  
......
3667 3715

  
3668 3716

  
3669 3717
--
3670
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3671
--
3672

  
3673
CREATE TABLE sourcename (
3674
    sourcelist_id integer NOT NULL,
3675
    name text NOT NULL,
3676
    matched_source_id integer
3677
);
3678

  
3679

  
3680
--
3681 3718
-- Name: provider_view; Type: VIEW; Schema: public; Owner: -
3682 3719
--
3683 3720

  
......
5206 5243

  
5207 5244

  
5208 5245
--
5246
-- Data for Name: owner_count; Type: TABLE DATA; Schema: public; Owner: -
5247
--
5248

  
5249

  
5250

  
5251
--
5209 5252
-- Data for Name: party; Type: TABLE DATA; Schema: public; Owner: -
5210 5253
--
5211 5254

  
......
5700 5743

  
5701 5744

  
5702 5745
--
5746
-- Name: owner_count_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
5747
--
5748

  
5749
ALTER TABLE ONLY owner_count
5750
    ADD CONSTRAINT owner_count_pkey PRIMARY KEY (owner);
5751

  
5752

  
5753
--
5703 5754
-- Name: party_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
5704 5755
--
5705 5756

  
......
8162 8213

  
8163 8214

  
8164 8215
--
8216
-- Name: owner_count; Type: ACL; Schema: public; Owner: -
8217
--
8218

  
8219
REVOKE ALL ON TABLE owner_count FROM PUBLIC;
8220
REVOKE ALL ON TABLE owner_count FROM bien;
8221
GRANT ALL ON TABLE owner_count TO bien;
8222
GRANT SELECT ON TABLE owner_count TO bien_read;
8223
GRANT SELECT ON TABLE owner_count TO public_;
8224

  
8225

  
8226
--
8227
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
8228
--
8229

  
8230
REVOKE ALL ON TABLE sourcename FROM PUBLIC;
8231
REVOKE ALL ON TABLE sourcename FROM bien;
8232
GRANT ALL ON TABLE sourcename TO bien;
8233
GRANT SELECT ON TABLE sourcename TO bien_read;
8234
GRANT SELECT ON TABLE sourcename TO public_;
8235

  
8236

  
8237
--
8238
-- Name: owner_count_view; Type: ACL; Schema: public; Owner: -
8239
--
8240

  
8241
REVOKE ALL ON TABLE owner_count_view FROM PUBLIC;
8242
REVOKE ALL ON TABLE owner_count_view FROM bien;
8243
GRANT ALL ON TABLE owner_count_view TO bien;
8244
GRANT SELECT ON TABLE owner_count_view TO bien_read;
8245
GRANT SELECT ON TABLE owner_count_view TO public_;
8246

  
8247

  
8248
--
8165 8249
-- Name: partymember; Type: ACL; Schema: public; Owner: -
8166 8250
--
8167 8251

  
......
8244 8328

  
8245 8329

  
8246 8330
--
8247
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
8248
--
8249

  
8250
REVOKE ALL ON TABLE sourcename FROM PUBLIC;
8251
REVOKE ALL ON TABLE sourcename FROM bien;
8252
GRANT ALL ON TABLE sourcename TO bien;
8253
GRANT SELECT ON TABLE sourcename TO bien_read;
8254
GRANT SELECT ON TABLE sourcename TO public_;
8255

  
8256

  
8257
--
8258 8331
-- Name: provider_view; Type: ACL; Schema: public; Owner: -
8259 8332
--
8260 8333

  

Also available in: Unified diff