-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathextrasql.sql
199 lines (169 loc) · 7.97 KB
/
extrasql.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
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
-- create odm2extra schema, sequences, and views
CREATE SCHEMA odm2extra
AUTHORIZATION postgres;
CREATE SEQUENCE odm2extra."Measurementresultvaluefile_valueFileid_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE odm2extra."Measurementresultvaluefile_valueFileid_seq"
OWNER TO postgres;
CREATE SEQUENCE odm2extra."featureactionNamesid_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 664
CACHE 1;
ALTER TABLE odm2extra."featureactionNamesid_seq"
OWNER TO postgres;
CREATE SEQUENCE odm2extra.processdataloggerfile_id_seq
INCREMENT 1
MINVALUE 0
MAXVALUE 9223372036854775807
START 175
CACHE 1;
ALTER TABLE odm2extra.processdataloggerfile_id_seq
OWNER TO postgres;
CREATE TABLE odm2extra."Measurementresultvaluefile"
(
"valueFileid" serial NOT NULL,
"valueFile" character varying(100) NOT NULL,
resultid bigint NOT NULL,
CONSTRAINT "Measurementresultvaluefile_pkey" PRIMARY KEY ("valueFileid"),
CONSTRAINT "Measurementres_resultid_12190167_fk_measurementresults_resultid" FOREIGN KEY (resultid)
REFERENCES odm2.measurementresults (resultid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED
)
WITH (
OIDS=FALSE
);
ALTER TABLE odm2extra."Measurementresultvaluefile"
OWNER TO postgres;
CREATE TABLE odm2extra."featureactionsNames"
(
featureactionid integer NOT NULL,
name character(500),
"featureactionNamesid" integer NOT NULL DEFAULT nextval('odm2extra."featureactionNamesid_seq"'::regclass),
CONSTRAINT "featureactionNamesid" PRIMARY KEY ("featureactionNamesid"),
CONSTRAINT featureactionid FOREIGN KEY (featureactionid)
REFERENCES odm2.featureactions (featureactionid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE odm2extra."featureactionsNames"
OWNER TO postgres;
CREATE TABLE odm2extra.processdataloggerfile
(
processdataloggerfileid integer NOT NULL DEFAULT nextval('odm2extra.processdataloggerfile_id_seq'::regclass),
dataloggerfileid integer NOT NULL,
"processingCode" character varying(255),
date_processed timestamp with time zone NOT NULL,
databeginson integer,
columnheaderson integer,
CONSTRAINT processdataloggerfile_pkey PRIMARY KEY (processdataloggerfileid),
CONSTRAINT processdataloggerfile_dataloggerfileid_fkey FOREIGN KEY (dataloggerfileid)
REFERENCES odm2.dataloggerfiles (dataloggerfileid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE odm2extra.processdataloggerfile
OWNER TO postgres;
-- Index: odm2extra."Measurementresultvaluefile_7bab5296"
-- DROP INDEX odm2extra."Measurementresultvaluefile_7bab5296";
CREATE INDEX "Measurementresultvaluefile_7bab5296"
ON odm2extra."Measurementresultvaluefile"
USING btree
(resultid);
CREATE OR REPLACE VIEW odm2extra.timeseriesresultvaluesext AS
SELECT timeseriesresultvalues.valueid,
timeseriesresultvalues.datavalue,
timeseriesresultvalues.valuedatetime,
timeseriesresultvalues.valuedatetimeutcoffset,
timeseriesresultvalues.censorcodecv,
timeseriesresultvalues.qualitycodecv,
timeseriesresultvalues.timeaggregationinterval,
timeseriesresultvalues.timeaggregationintervalunitsid,
samplingfeatures.samplingfeaturename,
samplingfeatures.samplingfeaturetypecv,
processinglevels.processinglevelcode,
variables.variablecode,
units.unitsabbreviation,
timeseriesresultvalues.resultid,
cv_aggregationstatistic.name AS aggregationstatisticname
FROM odm2.timeseriesresultvalues,
odm2.timeseriesresults,
odm2.results,
odm2.featureactions,
odm2.samplingfeatures,
odm2.processinglevels,
odm2.variables,
odm2.units,
odm2.cv_aggregationstatistic
WHERE timeseriesresultvalues.resultid = timeseriesresults.resultid AND timeseriesresults.resultid = results.resultid AND timeseriesresults.aggregationstatisticcv::text = cv_aggregationstatistic.name::text AND results.featureactionid = featureactions.featureactionid AND results.processinglevelid = processinglevels.processinglevelid AND results.variableid = variables.variableid AND results.unitsid = units.unitsid AND featureactions.samplingfeatureid = samplingfeatures.samplingfeatureid
ORDER BY timeseriesresultvalues.datavalue DESC;
ALTER TABLE odm2extra.timeseriesresultvaluesext
OWNER TO postgres;
CREATE OR REPLACE VIEW odm2extra.timeseriesresultvaluesextwannotations AS
SELECT timeseriesresultvalues.valueid,
timeseriesresultvalues.datavalue,
timeseriesresultvalues.valuedatetime,
timeseriesresultvalues.valuedatetimeutcoffset,
timeseriesresultvalues.censorcodecv,
timeseriesresultvalues.qualitycodecv,
timeseriesresultvalues.timeaggregationinterval,
timeseriesresultvalues.timeaggregationintervalunitsid,
samplingfeatures.samplingfeaturename,
processinglevels.processinglevelcode,
variables.variablecode,
units.unitsabbreviation,
timeseriesresultvalues.resultid,
cv_aggregationstatistic.name AS aggregationstatisticname,
annotations.annotationtext
FROM odm2.timeseriesresultvalues,
odm2.timeseriesresults,
odm2.results,
odm2.featureactions,
odm2.samplingfeatures,
odm2.processinglevels,
odm2.variables,
odm2.units,
odm2.cv_aggregationstatistic,
odm2.timeseriesresultvalueannotations,
odm2.annotations
WHERE timeseriesresultvalues.resultid = timeseriesresults.resultid AND timeseriesresultvalues.valueid = timeseriesresultvalueannotations.valueid AND timeseriesresults.resultid = results.resultid AND timeseriesresults.aggregationstatisticcv::text = cv_aggregationstatistic.name::text AND results.featureactionid = featureactions.featureactionid AND results.processinglevelid = processinglevels.processinglevelid AND results.variableid = variables.variableid AND results.unitsid = units.unitsid AND featureactions.samplingfeatureid = samplingfeatures.samplingfeatureid AND timeseriesresultvalueannotations.annotationid = annotations.annotationid
ORDER BY timeseriesresultvalues.datavalue DESC;
ALTER TABLE odm2extra.timeseriesresultvaluesextwannotations
OWNER TO postgres;
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 row_security = off;
SET search_path = odm2, pg_catalog;
--
-- TOC entry 4452 (class 0 OID 59969)
-- Dependencies: 385
-- Data for Name: extensionproperties; Type: TABLE DATA; Schema: odm2; Owner: azureadmin
--
INSERT INTO extensionproperties VALUES (1, 'end date', 'The current end date for the result series', 'String', 11);
INSERT INTO extensionproperties VALUES (2, 'start date', 'The start date for the result series', 'String', 11);
INSERT INTO extensionproperties VALUES (4, 'dashboard above upper bound count', 'for time series result dashboard - count of values above upper bound.', 'Integer', 20);
INSERT INTO extensionproperties VALUES (5, 'dashboard below lower bound count', 'for time series result dashboard - count of values below lower bound.', 'Integer', 20);
INSERT INTO extensionproperties VALUES (7, 'dashboard begin date', 'calculated value for the sensor dashboard from sensor dashboard settings using time_series_days', 'String', 11);
INSERT INTO extensionproperties VALUES (6, 'dashboard maximum count', 'maximum count of time series values for dashboard', 'Integer', 20);
INSERT INTO extensionproperties VALUES (3, 'dashboard count', 'a count of time series results for the dashboard', 'Integer', 20);
INSERT INTO extensionproperties VALUES (9, 'dashboard sensor active', 'if the last recorded value is 0 or NaN the sensor does not appear to be active.', 'Boolean', 21);
INSERT INTO extensionproperties VALUES (8, 'dashboard last recorded value', 'last value recorded by sensor', 'Floating point number', 20);
--
-- TOC entry 4458 (class 0 OID 0)
-- Dependencies: 384
-- Name: extensionproperties_propertyid_seq; Type: SEQUENCE SET; Schema: odm2; Owner: azureadmin
--
SELECT pg_catalog.setval('extensionproperties_propertyid_seq', 9, true);