sql stringlengths 6 1.05M |
|---|
<reponame>pribtech/nodete
update Y2004_2
set txdate = 4
where txdate = 7;
select * from Y2004_2; |
<gh_stars>0
create table ACT_RU_JOB (
ID_ varchar(64) NOT NULL,
REV_ integer,
CATEGORY_ varchar(255),
TYPE_ varchar(255) NOT NULL,
LOCK_EXP_TIME_ timestamp,
LOCK_OWNER_ varchar(255),
EXCLUSIVE_ boolean,
EXECUTION_ID_ varchar(64),
PROCESS_INSTANCE_ID_ varchar(64),
PROC_DEF_ID_ varchar(64),
ELEMENT_ID_ varchar(255),
ELEMENT_NAME_ varchar(255),
SCOPE_ID_ varchar(255),
SUB_SCOPE_ID_ varchar(255),
SCOPE_TYPE_ varchar(255),
SCOPE_DEFINITION_ID_ varchar(255),
CORRELATION_ID_ varchar(255),
RETRIES_ integer,
EXCEPTION_STACK_ID_ varchar(64),
EXCEPTION_MSG_ varchar(4000),
DUEDATE_ timestamp,
REPEAT_ varchar(255),
HANDLER_TYPE_ varchar(255),
HANDLER_CFG_ varchar(4000),
CUSTOM_VALUES_ID_ varchar(64),
CREATE_TIME_ timestamp,
TENANT_ID_ varchar(255) default '',
primary key (ID_)
);
create table ACT_RU_TIMER_JOB (
ID_ varchar(64) NOT NULL,
REV_ integer,
CATEGORY_ varchar(255),
TYPE_ varchar(255) NOT NULL,
LOCK_EXP_TIME_ timestamp,
LOCK_OWNER_ varchar(255),
EXCLUSIVE_ boolean,
EXECUTION_ID_ varchar(64),
PROCESS_INSTANCE_ID_ varchar(64),
PROC_DEF_ID_ varchar(64),
ELEMENT_ID_ varchar(255),
ELEMENT_NAME_ varchar(255),
SCOPE_ID_ varchar(255),
SUB_SCOPE_ID_ varchar(255),
SCOPE_TYPE_ varchar(255),
SCOPE_DEFINITION_ID_ varchar(255),
CORRELATION_ID_ varchar(255),
RETRIES_ integer,
EXCEPTION_STACK_ID_ varchar(64),
EXCEPTION_MSG_ varchar(4000),
DUEDATE_ timestamp,
REPEAT_ varchar(255),
HANDLER_TYPE_ varchar(255),
HANDLER_CFG_ varchar(4000),
CUSTOM_VALUES_ID_ varchar(64),
CREATE_TIME_ timestamp,
TENANT_ID_ varchar(255) default '',
primary key (ID_)
);
create table ACT_RU_SUSPENDED_JOB (
ID_ varchar(64) NOT NULL,
REV_ integer,
CATEGORY_ varchar(255),
TYPE_ varchar(255) NOT NULL,
EXCLUSIVE_ boolean,
EXECUTION_ID_ varchar(64),
PROCESS_INSTANCE_ID_ varchar(64),
PROC_DEF_ID_ varchar(64),
ELEMENT_ID_ varchar(255),
ELEMENT_NAME_ varchar(255),
SCOPE_ID_ varchar(255),
SUB_SCOPE_ID_ varchar(255),
SCOPE_TYPE_ varchar(255),
SCOPE_DEFINITION_ID_ varchar(255),
CORRELATION_ID_ varchar(255),
RETRIES_ integer,
EXCEPTION_STACK_ID_ varchar(64),
EXCEPTION_MSG_ varchar(4000),
DUEDATE_ timestamp,
REPEAT_ varchar(255),
HANDLER_TYPE_ varchar(255),
HANDLER_CFG_ varchar(4000),
CUSTOM_VALUES_ID_ varchar(64),
CREATE_TIME_ timestamp,
TENANT_ID_ varchar(255) default '',
primary key (ID_)
);
create table ACT_RU_DEADLETTER_JOB (
ID_ varchar(64) NOT NULL,
REV_ integer,
CATEGORY_ varchar(255),
TYPE_ varchar(255) NOT NULL,
EXCLUSIVE_ boolean,
EXECUTION_ID_ varchar(64),
PROCESS_INSTANCE_ID_ varchar(64),
PROC_DEF_ID_ varchar(64),
ELEMENT_ID_ varchar(255),
ELEMENT_NAME_ varchar(255),
SCOPE_ID_ varchar(255),
SUB_SCOPE_ID_ varchar(255),
SCOPE_TYPE_ varchar(255),
SCOPE_DEFINITION_ID_ varchar(255),
CORRELATION_ID_ varchar(255),
EXCEPTION_STACK_ID_ varchar(64),
EXCEPTION_MSG_ varchar(4000),
DUEDATE_ timestamp,
REPEAT_ varchar(255),
HANDLER_TYPE_ varchar(255),
HANDLER_CFG_ varchar(4000),
CUSTOM_VALUES_ID_ varchar(64),
CREATE_TIME_ timestamp,
TENANT_ID_ varchar(255) default '',
primary key (ID_)
);
create table ACT_RU_HISTORY_JOB (
ID_ varchar(64) NOT NULL,
REV_ integer,
LOCK_EXP_TIME_ timestamp,
LOCK_OWNER_ varchar(255),
RETRIES_ integer,
EXCEPTION_STACK_ID_ varchar(64),
EXCEPTION_MSG_ varchar(4000),
HANDLER_TYPE_ varchar(255),
HANDLER_CFG_ varchar(4000),
CUSTOM_VALUES_ID_ varchar(64),
ADV_HANDLER_CFG_ID_ varchar(64),
CREATE_TIME_ timestamp,
SCOPE_TYPE_ varchar(255),
TENANT_ID_ varchar(255) default '',
primary key (ID_)
);
create table ACT_RU_EXTERNAL_JOB (
ID_ varchar(64) NOT NULL,
REV_ integer,
CATEGORY_ varchar(255),
TYPE_ varchar(255) NOT NULL,
LOCK_EXP_TIME_ timestamp,
LOCK_OWNER_ varchar(255),
EXCLUSIVE_ boolean,
EXECUTION_ID_ varchar(64),
PROCESS_INSTANCE_ID_ varchar(64),
PROC_DEF_ID_ varchar(64),
ELEMENT_ID_ varchar(255),
ELEMENT_NAME_ varchar(255),
SCOPE_ID_ varchar(255),
SUB_SCOPE_ID_ varchar(255),
SCOPE_TYPE_ varchar(255),
SCOPE_DEFINITION_ID_ varchar(255),
CORRELATION_ID_ varchar(255),
RETRIES_ integer,
EXCEPTION_STACK_ID_ varchar(64),
EXCEPTION_MSG_ varchar(4000),
DUEDATE_ timestamp,
REPEAT_ varchar(255),
HANDLER_TYPE_ varchar(255),
HANDLER_CFG_ varchar(4000),
CUSTOM_VALUES_ID_ varchar(64),
CREATE_TIME_ timestamp,
TENANT_ID_ varchar(255) default '',
primary key (ID_)
);
create index ACT_IDX_JOB_EXCEPTION_STACK_ID on ACT_RU_JOB(EXCEPTION_STACK_ID_);
create index ACT_IDX_JOB_CUSTOM_VALUES_ID on ACT_RU_JOB(CUSTOM_VALUES_ID_);
create index ACT_IDX_JOB_CORRELATION_ID on ACT_RU_JOB(CORRELATION_ID_);
create index ACT_IDX_TIMER_JOB_EXCEPTION_STACK_ID on ACT_RU_TIMER_JOB(EXCEPTION_STACK_ID_);
create index ACT_IDX_TIMER_JOB_CUSTOM_VALUES_ID on ACT_RU_TIMER_JOB(CUSTOM_VALUES_ID_);
create index ACT_IDX_TIMER_JOB_CORRELATION_ID on ACT_RU_TIMER_JOB(CORRELATION_ID_);
create index ACT_IDX_TIMER_JOB_DUEDATE on ACT_RU_TIMER_JOB(DUEDATE_);
create index ACT_IDX_SUSPENDED_JOB_EXCEPTION_STACK_ID on ACT_RU_SUSPENDED_JOB(EXCEPTION_STACK_ID_);
create index ACT_IDX_SUSPENDED_JOB_CUSTOM_VALUES_ID on ACT_RU_SUSPENDED_JOB(CUSTOM_VALUES_ID_);
create index ACT_IDX_SUSPENDED_JOB_CORRELATION_ID on ACT_RU_SUSPENDED_JOB(CORRELATION_ID_);
create index ACT_IDX_DEADLETTER_JOB_EXCEPTION_STACK_ID on ACT_RU_DEADLETTER_JOB(EXCEPTION_STACK_ID_);
create index ACT_IDX_DEADLETTER_JOB_CUSTOM_VALUES_ID on ACT_RU_DEADLETTER_JOB(CUSTOM_VALUES_ID_);
create index ACT_IDX_DEADLETTER_JOB_CORRELATION_ID on ACT_RU_DEADLETTER_JOB(CORRELATION_ID_);
create index ACT_IDX_EXTERNAL_JOB_EXCEPTION_STACK_ID on ACT_RU_EXTERNAL_JOB(EXCEPTION_STACK_ID_);
create index ACT_IDX_EXTERNAL_JOB_CUSTOM_VALUES_ID on ACT_RU_EXTERNAL_JOB(CUSTOM_VALUES_ID_);
create index ACT_IDX_EXTERNAL_JOB_CORRELATION_ID on ACT_RU_EXTERNAL_JOB(CORRELATION_ID_);
alter table ACT_RU_JOB
add constraint ACT_FK_JOB_EXCEPTION
foreign key (EXCEPTION_STACK_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_JOB
add constraint ACT_FK_JOB_CUSTOM_VALUES
foreign key (CUSTOM_VALUES_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_TIMER_JOB
add constraint ACT_FK_TIMER_JOB_EXCEPTION
foreign key (EXCEPTION_STACK_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_TIMER_JOB
add constraint ACT_FK_TIMER_JOB_CUSTOM_VALUES
foreign key (CUSTOM_VALUES_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_SUSPENDED_JOB
add constraint ACT_FK_SUSPENDED_JOB_EXCEPTION
foreign key (EXCEPTION_STACK_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_SUSPENDED_JOB
add constraint ACT_FK_SUSPENDED_JOB_CUSTOM_VALUES
foreign key (CUSTOM_VALUES_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_DEADLETTER_JOB
add constraint ACT_FK_DEADLETTER_JOB_EXCEPTION
foreign key (EXCEPTION_STACK_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_DEADLETTER_JOB
add constraint ACT_FK_DEADLETTER_JOB_CUSTOM_VALUES
foreign key (CUSTOM_VALUES_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_EXTERNAL_JOB
add constraint ACT_FK_EXTERNAL_JOB_EXCEPTION
foreign key (EXCEPTION_STACK_ID_)
references ACT_GE_BYTEARRAY (ID_);
alter table ACT_RU_EXTERNAL_JOB
add constraint ACT_FK_EXTERNAL_JOB_CUSTOM_VALUES
foreign key (CUSTOM_VALUES_ID_)
references ACT_GE_BYTEARRAY (ID_);
create index ACT_IDX_JOB_SCOPE on ACT_RU_JOB(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_JOB_SUB_SCOPE on ACT_RU_JOB(SUB_SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_JOB_SCOPE_DEF on ACT_RU_JOB(SCOPE_DEFINITION_ID_, SCOPE_TYPE_);
create index ACT_IDX_TJOB_SCOPE on ACT_RU_TIMER_JOB(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_TJOB_SUB_SCOPE on ACT_RU_TIMER_JOB(SUB_SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_TJOB_SCOPE_DEF on ACT_RU_TIMER_JOB(SCOPE_DEFINITION_ID_, SCOPE_TYPE_);
create index ACT_IDX_SJOB_SCOPE on ACT_RU_SUSPENDED_JOB(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_SJOB_SUB_SCOPE on ACT_RU_SUSPENDED_JOB(SUB_SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_SJOB_SCOPE_DEF on ACT_RU_SUSPENDED_JOB(SCOPE_DEFINITION_ID_, SCOPE_TYPE_);
create index ACT_IDX_DJOB_SCOPE on ACT_RU_DEADLETTER_JOB(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_DJOB_SUB_SCOPE on ACT_RU_DEADLETTER_JOB(SUB_SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_DJOB_SCOPE_DEF on ACT_RU_DEADLETTER_JOB(SCOPE_DEFINITION_ID_, SCOPE_TYPE_);
create index ACT_IDX_EJOB_SCOPE on ACT_RU_EXTERNAL_JOB(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_EJOB_SUB_SCOPE on ACT_RU_EXTERNAL_JOB(SUB_SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_EJOB_SCOPE_DEF on ACT_RU_EXTERNAL_JOB(SCOPE_DEFINITION_ID_, SCOPE_TYPE_);
insert into ACT_GE_PROPERTY values ('job.schema.version', '6.6.2.0', 1); |
<filename>posda/posdatools/queries/sql/SubprocessesByUser.sql
-- Name: SubprocessesByUser
-- Schema: posda_queries
-- Columns: ['subprocess_invocation_id', 'when_script_started', 'when_background_entered', 'when_script_ended', 'user_to_notify', 'button_name', 'operation_name', 'num_reports']
-- Args: ['invoking_user']
-- Tags: ['AllCollections', 'queries', 'activity_support']
-- Description: Get a list of available queries
select
distinct subprocess_invocation_id,
when_script_started, when_background_entered, when_script_ended, user_to_notify,
button_name, operation_name, count(distinct background_subprocess_report_id) as num_reports
from
subprocess_invocation natural left join background_subprocess natural left join
background_subprocess_report
where invoking_user = ?
group by
subprocess_invocation_id, when_script_started, when_background_entered,
when_script_ended, user_to_notify, button_name, operation_name
order by subprocess_invocation_id desc |
--
-- PostgreSQL database dump
--
SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- Name: another_triggers; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA another_triggers;
ALTER SCHEMA another_triggers OWNER TO postgres;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
--CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
--COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = pg_catalog;
--
-- Name: test_table_trigger_another(); Type: FUNCTION; Schema: another_triggers; Owner: postgres
--
CREATE FUNCTION another_triggers.test_table_trigger_another() RETURNS trigger
LANGUAGE plpgsql
AS $$
begin
return NEW;
end;
$$;
ALTER FUNCTION another_triggers.test_table_trigger_another() OWNER TO postgres;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: test_table; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
--
CREATE TABLE public.test_table (
id integer NOT NULL
);
ALTER TABLE public.test_table OWNER TO postgres;
--
-- Name: test_table_trigger; Type: TRIGGER; Schema: public; Owner: postgres
--
CREATE TRIGGER test_table_trigger BEFORE INSERT OR UPDATE ON public.test_table FOR EACH ROW EXECUTE PROCEDURE another_triggers.test_table_trigger_another();
--
-- 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;
--
-- PostgreSQL database dump complete
--
|
--
-- JOIN
-- Test JOIN clauses
--
CREATE TABLE J1_TBL (
i integer,
j integer,
t text
);
CREATE TABLE J2_TBL (
i integer,
k integer
);
INSERT INTO J1_TBL VALUES (1, 4, 'one');
INSERT INTO J1_TBL VALUES (2, 3, 'two');
INSERT INTO J1_TBL VALUES (3, 2, 'three');
INSERT INTO J1_TBL VALUES (4, 1, 'four');
INSERT INTO J1_TBL VALUES (5, 0, 'five');
INSERT INTO J1_TBL VALUES (6, 6, 'six');
INSERT INTO J1_TBL VALUES (7, 7, 'seven');
INSERT INTO J1_TBL VALUES (8, 8, 'eight');
INSERT INTO J1_TBL VALUES (0, NULL, 'zero');
INSERT INTO J1_TBL VALUES (NULL, NULL, 'null');
INSERT INTO J1_TBL VALUES (NULL, 0, 'zero');
INSERT INTO J2_TBL VALUES (1, -1);
INSERT INTO J2_TBL VALUES (2, 2);
INSERT INTO J2_TBL VALUES (3, -3);
INSERT INTO J2_TBL VALUES (2, 4);
INSERT INTO J2_TBL VALUES (5, -5);
INSERT INTO J2_TBL VALUES (5, -5);
INSERT INTO J2_TBL VALUES (0, NULL);
INSERT INTO J2_TBL VALUES (NULL, NULL);
INSERT INTO J2_TBL VALUES (NULL, 0);
--
-- CORRELATION NAMES
-- Make sure that table/column aliases are supported
-- before diving into more complex join syntax.
--
SELECT '' AS "xxx", *
FROM J1_TBL AS tx
ORDER BY i, j, t;
SELECT '' AS "xxx", *
FROM J1_TBL tx
ORDER BY i, j, t;
SELECT '' AS "xxx", *
FROM J1_TBL AS t1 (a, b, c)
ORDER BY a, b, c;
SELECT '' AS "xxx", *
FROM J1_TBL t1 (a, b, c)
ORDER BY a, b, c;
SELECT '' AS "xxx", *
FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e)
ORDER BY a, b, c, d, e;
SELECT '' AS "xxx", t1.a, t2.e
FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e)
WHERE t1.a = t2.d
ORDER BY a, e;
--
-- CROSS JOIN
-- Qualifications are not allowed on cross joins,
-- which degenerate into a standard unqualified inner join.
--
SELECT '' AS "xxx", *
FROM J1_TBL CROSS JOIN J2_TBL
ORDER BY J1_TBL.i, J1_TBL.j, J1_TBL.t, J2_TBL.i, J2_TBL.k;
-- ambiguous column
SELECT '' AS "xxx", i, k, t
FROM J1_TBL CROSS JOIN J2_TBL;
-- resolve previous ambiguity by specifying the table name
SELECT '' AS "xxx", t1.i, k, t
FROM J1_TBL t1 CROSS JOIN J2_TBL t2
ORDER BY i, k, t;
SELECT '' AS "xxx", ii, tt, kk
FROM (J1_TBL CROSS JOIN J2_TBL)
AS tx (ii, jj, tt, ii2, kk)
ORDER BY ii, tt, kk;
SELECT '' AS "xxx", tx.ii, tx.jj, tx.kk
FROM (J1_TBL t1 (a, b, c) CROSS JOIN J2_TBL t2 (d, e))
AS tx (ii, jj, tt, ii2, kk)
ORDER BY ii, jj, kk;
SELECT '' AS "xxx", *
FROM J1_TBL CROSS JOIN J2_TBL a CROSS JOIN J2_TBL b
ORDER BY J1_TBL.i,J1_TBL.j,J1_TBL.t,a.i,a.k,b.i,b.k;
--
--
-- Inner joins (equi-joins)
--
--
--
-- Inner joins (equi-joins) with USING clause
-- The USING syntax changes the shape of the resulting table
-- by including a column in the USING clause only once in the result.
--
-- Inner equi-join on specified column
SELECT '' AS "xxx", *
FROM J1_TBL INNER JOIN J2_TBL USING (i)
ORDER BY i, j, k, t;
-- Same as above, slightly different syntax
SELECT '' AS "xxx", *
FROM J1_TBL JOIN J2_TBL USING (i)
ORDER BY i, j, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, d) USING (a)
ORDER BY a, d;
SELECT '' AS "xxx", *
FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, b) USING (b)
ORDER BY b, t1.a;
--
-- NATURAL JOIN
-- Inner equi-join on all columns with the same name
--
SELECT '' AS "xxx", *
FROM J1_TBL NATURAL JOIN J2_TBL
ORDER BY i, j, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (a, d)
ORDER BY a, b, c, d;
SELECT '' AS "xxx", *
FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (d, a)
ORDER BY a, b, c, d;
-- mismatch number of columns
-- currently, Postgres will fill in with underlying names
SELECT '' AS "xxx", *
FROM J1_TBL t1 (a, b) NATURAL JOIN J2_TBL t2 (a)
ORDER BY a, b, t, k;
--
-- Inner joins (equi-joins)
--
SELECT '' AS "xxx", *
FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.i)
ORDER BY J1_TBL.i, J1_TBL.j, J1_TBL.t, J2_TBL.i, J2_TBL.k;
SELECT '' AS "xxx", *
FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.k)
ORDER BY J1_TBL.i, J1_TBL.j, J1_TBL.t, J2_TBL.i, J2_TBL.k;
--
-- Non-equi-joins
--
SELECT '' AS "xxx", *
FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i <= J2_TBL.k) order by J1_TBL.i,j,k;
--
-- Outer joins
-- Note that OUTER is a noise word
--
SELECT '' AS "xxx", *
FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i)
ORDER BY i, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL LEFT JOIN J2_TBL USING (i)
ORDER BY i, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL RIGHT OUTER JOIN J2_TBL USING (i)
ORDER BY i, j, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL RIGHT JOIN J2_TBL USING (i)
ORDER BY i, j, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL FULL OUTER JOIN J2_TBL USING (i)
ORDER BY i, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL FULL JOIN J2_TBL USING (i)
ORDER BY i, k, t;
SELECT '' AS "xxx", *
FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (k = 1);
SELECT '' AS "xxx", *
FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1);
--
-- More complicated constructs
--
--
-- Multiway full join
--
CREATE TABLE t1 (name TEXT, n INTEGER);
CREATE TABLE t2 (name TEXT, n INTEGER);
CREATE TABLE t3 (name TEXT, n INTEGER);
INSERT INTO t1 VALUES ( 'bb', 11 );
INSERT INTO t2 VALUES ( 'bb', 12 );
INSERT INTO t2 VALUES ( 'cc', 22 );
INSERT INTO t2 VALUES ( 'ee', 42 );
INSERT INTO t3 VALUES ( 'bb', 13 );
INSERT INTO t3 VALUES ( 'cc', 23 );
INSERT INTO t3 VALUES ( 'dd', 33 );
SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name)
ORDER BY name,t1.n, t2.n, t3.n;
--
-- Test interactions of join syntax and subqueries
--
-- Basic cases (we expect planner to pull up the subquery here)
SELECT * FROM
(SELECT * FROM t2) as s2
INNER JOIN
(SELECT * FROM t3) s3
USING (name)
ORDER BY name, s2.n, s3.n;
SELECT * FROM
(SELECT * FROM t2) as s2
LEFT JOIN
(SELECT * FROM t3) s3
USING (name)
ORDER BY name, s2.n, s3.n;
SELECT * FROM
(SELECT * FROM t2) as s2
FULL JOIN
(SELECT * FROM t3) s3
USING (name)
ORDER BY name, s2.n, s3.n;
-- Cases with non-nullable expressions in subquery results;
-- make sure these go to null as expected
SELECT * FROM
(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
NATURAL INNER JOIN
(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3
ORDER BY name, s2_n, s3_n;
SELECT * FROM
(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
NATURAL LEFT JOIN
(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3
ORDER BY name, s2_n, s3_n;
SELECT * FROM
(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
NATURAL FULL JOIN
(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3
ORDER BY name, s2_n, s3_n;
SELECT * FROM
(SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1
NATURAL INNER JOIN
(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
NATURAL INNER JOIN
(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
SELECT * FROM
(SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1
NATURAL FULL JOIN
(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
NATURAL FULL JOIN
(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3
ORDER BY name, s1_n, s2_n, s3_n;
SELECT * FROM
(SELECT name, n as s1_n FROM t1) as s1
NATURAL FULL JOIN
(SELECT * FROM
(SELECT name, n as s2_n FROM t2) as s2
NATURAL FULL JOIN
(SELECT name, n as s3_n FROM t3) as s3
) ss2
ORDER BY name, s1_n, s2_n, s3_n;
SELECT * FROM
(SELECT name, n as s1_n FROM t1) as s1
NATURAL FULL JOIN
(SELECT * FROM
(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
NATURAL FULL JOIN
(SELECT name, n as s3_n FROM t3) as s3
) ss2
ORDER BY name, s1_n, s2_n, s3_n;
-- Test for propagation of nullability constraints into sub-joins
create temp table x (x1 int, x2 int);
insert into x values (1,11);
insert into x values (2,22);
insert into x values (3,null);
insert into x values (4,44);
insert into x values (5,null);
create temp table y (y1 int, y2 int);
insert into y values (1,111);
insert into y values (2,222);
insert into y values (3,333);
insert into y values (4,null);
select * from x ORDER BY x1;
select * from y ORDER BY y1;
select * from x left join y on (x1 = y1 and x2 is not null) ORDER BY x1, x2, y1, y2;
select * from x left join y on (x1 = y1 and y2 is not null) ORDER BY x1, x2, y1, y2;
select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
on (x1 = xx1) ORDER BY x1, x2, y1, y2;
select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
on (x1 = xx1 and x2 is not null) ORDER BY x1, x2, y1, y2;
select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
on (x1 = xx1 and y2 is not null) ORDER BY x1, x2, y1, y2;
select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
on (x1 = xx1 and xx2 is not null) ORDER BY x1, x2, y1, y2;
-- these should NOT give the same answers as above
select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
on (x1 = xx1) where (x2 is not null)
ORDER BY x1, x2, y1, y2;
select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
on (x1 = xx1) where (y2 is not null)
ORDER BY x1, x2, y1, y2;
select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
on (x1 = xx1) where (xx2 is not null)
ORDER BY x1, x2, y1, y2;
--
-- regression test: check for bug with propagation of implied equality
-- to outside an IN
--
select count(*) from tenk1 a where unique1 in
(select unique1 from tenk1 b join tenk1 c using (unique1)
where b.unique2 = 42);
--
-- regression test: check for failure to generate a plan with multiple
-- degenerate IN clauses
--
select count(*) from tenk1 x where
x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and
x.unique1 = 0 and
x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
-- try that with GEQO too
begin;
set geqo = on;
set geqo_threshold = 2;
select count(*) from tenk1 x where
x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and
x.unique1 = 0 and
x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
rollback;
--
-- regression test: be sure we cope with proven-dummy append rels
--
explain (costs off)
select aa, bb, unique1, unique1
from tenk1 right join b on aa = unique1
where bb < bb and bb is null;
select aa, bb, unique1, unique1
from tenk1 right join b on aa = unique1
where bb < bb and bb is null;
--
-- regression test: check handling of empty-FROM subquery underneath outer join
--
explain (costs off)
select * from int8_tbl i1 left join (int8_tbl i2 join
(select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2
order by 1, 2;
select * from int8_tbl i1 left join (int8_tbl i2 join
(select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2
order by 1, 2;
--
-- regression test: check a case where join_clause_is_movable_into() gives
-- an imprecise result, causing an assertion failure
--
select count(*)
from
(select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2
from tenk1 t1
left join tenk1 t2 on t1.unique1 = t2.unique1
join tenk1 t3 on t1.unique2 = t3.unique2) ss,
tenk1 t4,
tenk1 t5
where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1;
--
-- regression test: check a case where we formerly missed including an EC
-- enforcement clause because it was expected to be handled at scan level
--
explain (costs off)
select a.f1, b.f1, t.thousand, t.tenthous from
tenk1 t,
(select sum(f1)+1 as f1 from int4_tbl i4a) a,
(select sum(f1) as f1 from int4_tbl i4b) b
where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous;
select a.f1, b.f1, t.thousand, t.tenthous from
tenk1 t,
(select sum(f1)+1 as f1 from int4_tbl i4a) a,
(select sum(f1) as f1 from int4_tbl i4b) b
where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous;
--
-- check a case where we formerly got confused by conflicting sort orders
-- in redundant merge join path keys
--
explain (costs off)
select * from
j1_tbl full join
(select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl
on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k;
select * from
j1_tbl full join
(select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl
on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k;
--
-- a different check for handling of redundant sort keys in merge joins
--
explain (costs off)
select count(*) from
(select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x
left join
(select * from tenk1 y order by y.unique2) y
on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2;
select count(*) from
(select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x
left join
(select * from tenk1 y order by y.unique2) y
on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2;
--
-- Clean up
--
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE J1_TBL;
DROP TABLE J2_TBL;
-- Both DELETE and UPDATE allow the specification of additional tables
-- to "join" against to determine which rows should be modified.
CREATE TEMP TABLE t1 (a int, b int);
CREATE TEMP TABLE t2 (a int, b int);
CREATE TEMP TABLE t3 (x int, y int);
INSERT INTO t1 VALUES (5, 10);
INSERT INTO t1 VALUES (15, 20);
INSERT INTO t1 VALUES (100, 100);
INSERT INTO t1 VALUES (200, 1000);
INSERT INTO t2 VALUES (200, 2000);
INSERT INTO t3 VALUES (5, 20);
INSERT INTO t3 VALUES (6, 7);
INSERT INTO t3 VALUES (7, 8);
INSERT INTO t3 VALUES (500, 100);
DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a;
SELECT * FROM t3 ORDER By x, y;
DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a;
SELECT * FROM t3 ORDER By x, y;
DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y;
SELECT * FROM t3 ORDER By x, y;
-- Test join against inheritance tree
create temp table t2a () inherits (t2);
insert into t2a values (200, 2001);
select * from t1 left join t2 on (t1.a = t2.a) order by 1,2,3,4;
-- Test matching of column name with wrong alias
select t1.x from t1 join t3 on (t1.a = t3.x);
--
-- regression test for 8.1 merge right join bug
--
CREATE TEMP TABLE tt1 ( tt1_id int4, joincol int4 );
INSERT INTO tt1 VALUES (1, 11);
INSERT INTO tt1 VALUES (2, NULL);
CREATE TEMP TABLE tt2 ( tt2_id int4, joincol int4 );
INSERT INTO tt2 VALUES (21, 11);
INSERT INTO tt2 VALUES (22, 11);
set enable_hashjoin to off;
set enable_nestloop to off;
-- these should give the same results
select tt1.*, tt2.* from tt1 left join tt2 on tt1.joincol = tt2.joincol
ORDER BY tt1_id, tt2_id;
select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol
ORDER BY tt1_id, tt2_id;
reset enable_hashjoin;
reset enable_nestloop;
--
-- regression test for bug #13908 (hash join with skew tuples & nbatch increase)
--
set work_mem to '64kB';
set enable_mergejoin to off;
explain (costs off)
select count(*) from tenk1 a, tenk1 b
where a.hundred = b.thousand and (b.fivethous % 10) < 10;
select count(*) from tenk1 a, tenk1 b
where a.hundred = b.thousand and (b.fivethous % 10) < 10;
reset work_mem;
reset enable_mergejoin;
--
-- regression test for 8.2 bug with improper re-ordering of left joins
--
create temp table tt3(f1 int, f2 text);
insert into tt3 select x, repeat('xyzzy', 100) from generate_series(1,10000) x;
create index tt3i on tt3(f1);
analyze tt3;
create temp table tt4(f1 int);
insert into tt4 values (0),(1),(9999);
analyze tt4;
SELECT a.f1
FROM tt4 a
LEFT JOIN (
SELECT b.f1
FROM tt3 b LEFT JOIN tt3 c ON (b.f1 = c.f1)
WHERE c.f1 IS NULL
) AS d ON (a.f1 = d.f1)
WHERE d.f1 IS NULL ORDER BY f1;
--
-- regression test for proper handling of outer joins within antijoins
--
create temp table tt4x(c1 int, c2 int, c3 int);
explain (costs off)
select * from tt4x t1
where not exists (
select 1 from tt4x t2
left join tt4x t3 on t2.c3 = t3.c1
left join ( select t5.c1 as c1
from tt4x t4 left join tt4x t5 on t4.c2 = t5.c1
) a1 on t3.c2 = a1.c1
where t1.c1 = t2.c2
);
--
-- regression test for problems of the sort depicted in bug #3494
--
create temp table tt5(f1 int, f2 int);
create temp table tt6(f1 int, f2 int);
insert into tt5 values(1, 10);
insert into tt5 values(1, 11);
insert into tt6 values(1, 9);
insert into tt6 values(1, 2);
insert into tt6 values(2, 9);
select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2
ORDER BY tt5.f1, tt5.f2, tt6.f1, tt6.f2;
--
-- regression test for problems of the sort depicted in bug #3588
--
create temp table xx (pkxx int);
create temp table yy (pkyy int, pkxx int);
insert into xx values (1);
insert into xx values (2);
insert into xx values (3);
insert into yy values (101, 1);
insert into yy values (201, 2);
insert into yy values (301, NULL);
select yy.pkyy as yy_pkyy, yy.pkxx as yy_pkxx, yya.pkyy as yya_pkyy,
xxa.pkxx as xxa_pkxx, xxb.pkxx as xxb_pkxx
from yy
left join (SELECT * FROM yy where pkyy = 101) as yya ON yy.pkyy = yya.pkyy
left join xx xxa on yya.pkxx = xxa.pkxx
left join xx xxb on coalesce (xxa.pkxx, 1) = xxb.pkxx
ORDER BY yy_pkyy, yy_pkxx, yya_pkyy, xxa_pkxx, xxb_pkxx;
--
-- regression test for improper pushing of constants across outer-join clauses
-- (as seen in early 8.2.x releases)
--
create temp table zt1 (f1 int primary key);
create temp table zt2 (f2 int primary key);
create temp table zt3 (f3 int primary key);
insert into zt1 values(53);
insert into zt2 values(53);
select * from
zt2 left join zt3 on (f2 = f3)
left join zt1 on (f3 = f1)
where f2 = 53
ORDER BY f1, f2, f3;
create temp view zv1 as select *,'dummy'::text AS junk from zt1;
select * from
zt2 left join zt3 on (f2 = f3)
left join zv1 on (f3 = f1)
where f2 = 53
ORDER BY f1, f2, f3;
--
-- regression test for improper extraction of OR indexqual conditions
-- (as seen in early 8.3.x releases)
--
select a.unique2, a.ten, b.tenthous, b.unique2, b.hundred
from tenk1 a left join tenk1 b on a.unique2 = b.tenthous
where a.unique1 = 42 and
((b.unique2 is null and a.ten = 2) or b.hundred = 3);
--
-- test proper positioning of one-time quals in EXISTS (8.4devel bug)
--
prepare foo(bool) as
select count(*) from tenk1 a left join tenk1 b
on (a.unique2 = b.unique1 and exists
(select 1 from tenk1 c where c.thousand = b.unique2 and $1));
execute foo(true);
execute foo(false);
--
-- test for sane behavior with noncanonical merge clauses, per bug #4926
--
begin;
set enable_mergejoin = 1;
set enable_hashjoin = 0;
set enable_nestloop = 0;
create temp table a (i integer);
create temp table b (x integer, y integer);
select * from a left join b on i = x and i = y and x = i;
rollback;
--
-- test handling of merge clauses using record_ops
--
begin;
create type mycomptype as (id int, v bigint);
create temp table tidv (idv mycomptype);
create index on tidv (idv);
explain (costs off)
select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv;
set enable_mergejoin = 0;
explain (costs off)
select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv;
rollback;
--
-- test NULL behavior of whole-row Vars, per bug #5025
--
select t1.q2, count(t2.*)
from int8_tbl t1 left join int8_tbl t2 on (t1.q2 = t2.q1)
group by t1.q2 order by 1;
select t1.q2, count(t2.*)
from int8_tbl t1 left join (select * from int8_tbl) t2 on (t1.q2 = t2.q1)
group by t1.q2 order by 1;
select t1.q2, count(t2.*)
from int8_tbl t1 left join (select * from int8_tbl offset 0) t2 on (t1.q2 = t2.q1)
group by t1.q2 order by 1;
select t1.q2, count(t2.*)
from int8_tbl t1 left join
(select q1, case when q2=1 then 1 else q2 end as q2 from int8_tbl) t2
on (t1.q2 = t2.q1)
group by t1.q2 order by 1;
--
-- test incorrect failure to NULL pulled-up subexpressions
--
begin;
create temp table a (
code char not null,
constraint a_pk primary key (code)
);
create temp table b (
a char not null,
num integer not null,
constraint b_pk primary key (a, num)
);
create temp table c (
name char not null,
a char,
constraint c_pk primary key (name)
);
insert into a (code) values ('p');
insert into a (code) values ('q');
insert into b (a, num) values ('p', 1);
insert into b (a, num) values ('p', 2);
insert into c (name, a) values ('A', 'p');
insert into c (name, a) values ('B', 'q');
insert into c (name, a) values ('C', null);
select c.name, ss.code, ss.b_cnt, ss.const
from c left join
(select a.code, coalesce(b_grp.cnt, 0) as b_cnt, -1 as const
from a left join
(select count(1) as cnt, b.a from b group by b.a) as b_grp
on a.code = b_grp.a
) as ss
on (c.a = ss.code)
order by c.name;
rollback;
--
-- test incorrect handling of placeholders that only appear in targetlists,
-- per bug #6154
--
SELECT * FROM
( SELECT 1 as key1 ) sub1
LEFT JOIN
( SELECT sub3.key3, sub4.value2, COALESCE(sub4.value2, 66) as value3 FROM
( SELECT 1 as key3 ) sub3
LEFT JOIN
( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM
( SELECT 1 as key5 ) sub5
LEFT JOIN
( SELECT 2 as key6, 42 as value1 ) sub6
ON sub5.key5 = sub6.key6
) sub4
ON sub4.key5 = sub3.key3
) sub2
ON sub1.key1 = sub2.key3;
-- test the path using join aliases, too
SELECT * FROM
( SELECT 1 as key1 ) sub1
LEFT JOIN
( SELECT sub3.key3, value2, COALESCE(value2, 66) as value3 FROM
( SELECT 1 as key3 ) sub3
LEFT JOIN
( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM
( SELECT 1 as key5 ) sub5
LEFT JOIN
( SELECT 2 as key6, 42 as value1 ) sub6
ON sub5.key5 = sub6.key6
) sub4
ON sub4.key5 = sub3.key3
) sub2
ON sub1.key1 = sub2.key3;
--
-- test case where a PlaceHolderVar is used as a nestloop parameter
--
EXPLAIN (COSTS OFF)
SELECT qq, unique1
FROM
( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1
FULL OUTER JOIN
( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2
USING (qq)
INNER JOIN tenk1 c ON qq = unique2;
SELECT qq, unique1
FROM
( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1
FULL OUTER JOIN
( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2
USING (qq)
INNER JOIN tenk1 c ON qq = unique2;
--
-- nested nestloops can require nested PlaceHolderVars
--
create temp table nt1 (
id int primary key,
a1 boolean,
a2 boolean
)
distribute by replication;
create temp table nt2 (
id int primary key,
nt1_id int,
b1 boolean,
b2 boolean,
foreign key (nt1_id) references nt1(id)
)
distribute by replication;
create temp table nt3 (
id int primary key,
nt2_id int,
c1 boolean,
foreign key (nt2_id) references nt2(id)
)
distribute by replication;
insert into nt1 values (1,true,true);
insert into nt1 values (2,true,false);
insert into nt1 values (3,false,false);
insert into nt2 values (1,1,true,true);
insert into nt2 values (2,2,true,false);
insert into nt2 values (3,3,false,false);
insert into nt3 values (1,1,true);
insert into nt3 values (2,2,false);
insert into nt3 values (3,3,true);
explain (costs off)
select nt3.id
from nt3 as nt3
left join
(select nt2.*, (nt2.b1 and ss1.a3) AS b3
from nt2 as nt2
left join
(select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1
on ss1.id = nt2.nt1_id
) as ss2
on ss2.id = nt3.nt2_id
where nt3.id = 1 and ss2.b3;
select nt3.id
from nt3 as nt3
left join
(select nt2.*, (nt2.b1 and ss1.a3) AS b3
from nt2 as nt2
left join
(select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1
on ss1.id = nt2.nt1_id
) as ss2
on ss2.id = nt3.nt2_id
where nt3.id = 1 and ss2.b3;
--
-- test case where a PlaceHolderVar is propagated into a subquery
--
explain (costs off)
select * from
int8_tbl t1 left join
(select q1 as x, 42 as y from int8_tbl t2) ss
on t1.q2 = ss.x
where
1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1)
order by 1,2;
select * from
int8_tbl t1 left join
(select q1 as x, 42 as y from int8_tbl t2) ss
on t1.q2 = ss.x
where
1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1)
order by 1,2;
--
-- test the corner cases FULL JOIN ON TRUE and FULL JOIN ON FALSE
--
select * from int4_tbl a full join int4_tbl b on true order by 1,2;
select * from int4_tbl a full join int4_tbl b on false order by 1,2;
--
-- test for ability to use a cartesian join when necessary
--
explain (costs off)
select * from
tenk1 join int4_tbl on f1 = twothousand,
int4(sin(1)) q1,
int4(sin(0)) q2
where q1 = thousand or q2 = thousand;
explain (costs off)
select * from
tenk1 join int4_tbl on f1 = twothousand,
int4(sin(1)) q1,
int4(sin(0)) q2
where thousand = (q1 + q2);
--
-- test ability to generate a suitable plan for a star-schema query
--
explain (costs off)
select * from
tenk1, int8_tbl a, int8_tbl b
where thousand = a.q1 and tenthous = b.q1 and a.q2 = 1 and b.q2 = 2;
--
-- test a corner case in which we shouldn't apply the star-schema optimization
--
explain (costs off)
select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from
tenk1 t1
inner join int4_tbl i1
left join (select v1.x2, v2.y1, 11 AS d1
from (values(1,0)) v1(x1,x2)
left join (values(3,1)) v2(y1,y2)
on v1.x1 = v2.y2) subq1
on (i1.f1 = subq1.x2)
on (t1.unique2 = subq1.d1)
left join tenk1 t2
on (subq1.y1 = t2.unique1)
where t1.unique2 < 42 and t1.stringu1 > t2.stringu2;
select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from
tenk1 t1
inner join int4_tbl i1
left join (select v1.x2, v2.y1, 11 AS d1
from (values(1,0)) v1(x1,x2)
left join (values(3,1)) v2(y1,y2)
on v1.x1 = v2.y2) subq1
on (i1.f1 = subq1.x2)
on (t1.unique2 = subq1.d1)
left join tenk1 t2
on (subq1.y1 = t2.unique1)
where t1.unique2 < 42 and t1.stringu1 > t2.stringu2;
-- variant that isn't quite a star-schema case
select ss1.d1 from
tenk1 as t1
inner join tenk1 as t2
on t1.tenthous = t2.ten
inner join
int8_tbl as i8
left join int4_tbl as i4
inner join (select 64::information_schema.cardinal_number as d1
from tenk1 t3,
lateral (select abs(t3.unique1) + random()) ss0(x)
where t3.fivethous < 0) as ss1
on i4.f1 = ss1.d1
on i8.q1 = i4.f1
on t1.tenthous = ss1.d1
where t1.unique1 < i4.f1;
--
-- test extraction of restriction OR clauses from join OR clause
-- (we used to only do this for indexable clauses)
--
explain (costs off)
select * from tenk1 a join tenk1 b on
(a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.hundred = 4);
explain (costs off)
select * from tenk1 a join tenk1 b on
(a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.ten = 4);
explain (costs off)
select * from tenk1 a join tenk1 b on
(a.unique1 = 1 and b.unique1 = 2) or
((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4);
--
-- test placement of movable quals in a parameterized join tree
--
explain (costs off)
select * from tenk1 t1 left join
(tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2)
on t1.hundred = t2.hundred and t1.ten = t3.ten
where t1.unique1 = 1;
explain (costs off)
select * from tenk1 t1 left join
(tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2)
on t1.hundred = t2.hundred and t1.ten + t2.ten = t3.ten
where t1.unique1 = 1;
explain (costs off)
select count(*) from
tenk1 a join tenk1 b on a.unique1 = b.unique2
left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand
join int4_tbl on b.thousand = f1;
select count(*) from
tenk1 a join tenk1 b on a.unique1 = b.unique2
left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand
join int4_tbl on b.thousand = f1;
explain (costs off)
select b.unique1 from
tenk1 a join tenk1 b on a.unique1 = b.unique2
left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand
join int4_tbl i1 on b.thousand = f1
right join int4_tbl i2 on i2.f1 = b.tenthous
order by 1;
select b.unique1 from
tenk1 a join tenk1 b on a.unique1 = b.unique2
left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand
join int4_tbl i1 on b.thousand = f1
right join int4_tbl i2 on i2.f1 = b.tenthous
order by 1;
explain (costs off)
select * from
(
select unique1, q1, coalesce(unique1, -1) + q1 as fault
from int8_tbl left join tenk1 on (q2 = unique2)
) ss
where fault = 122
order by fault;
select * from
(
select unique1, q1, coalesce(unique1, -1) + q1 as fault
from int8_tbl left join tenk1 on (q2 = unique2)
) ss
where fault = 122
order by fault;
explain (costs off)
select * from
(values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys)
left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x
left join unnest(v1ys) as u1(u1y) on u1y = v2y;
select * from
(values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys)
left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x
left join unnest(v1ys) as u1(u1y) on u1y = v2y;
--
-- test handling of potential equivalence clauses above outer joins
--
explain (costs off)
select q1, unique2, thousand, hundred
from int8_tbl a left join tenk1 b on q1 = unique2
where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123);
select q1, unique2, thousand, hundred
from int8_tbl a left join tenk1 b on q1 = unique2
where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123);
explain (costs off)
select f1, unique2, case when unique2 is null then f1 else 0 end
from int4_tbl a left join tenk1 b on f1 = unique2
where (case when unique2 is null then f1 else 0 end) = 0;
select f1, unique2, case when unique2 is null then f1 else 0 end
from int4_tbl a left join tenk1 b on f1 = unique2
where (case when unique2 is null then f1 else 0 end) = 0;
--
-- another case with equivalence clauses above outer joins (bug #8591)
--
explain (costs off)
select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand)
where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44;
select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand)
where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44;
--
-- check handling of join aliases when flattening multiple levels of subquery
--
explain (verbose, costs off)
select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from
(values (0),(1)) foo1(join_key)
left join
(select join_key, bug_field from
(select ss1.join_key, ss1.bug_field from
(select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1
) foo2
left join
(select unique2 as join_key from tenk1 i2) ss2
using (join_key)
) foo3
using (join_key);
select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from
(values (0),(1)) foo1(join_key)
left join
(select join_key, bug_field from
(select ss1.join_key, ss1.bug_field from
(select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1
) foo2
left join
(select unique2 as join_key from tenk1 i2) ss2
using (join_key)
) foo3
using (join_key);
--
-- test successful handling of nested outer joins with degenerate join quals
--
explain (verbose, costs off)
select t1.* from
text_tbl t1
left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
left join int8_tbl i8
left join (select *, null::int as d2 from int8_tbl i8b2) b2
on (i8.q1 = b2.q1)
on (b2.d2 = b1.q2)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
select t1.* from
text_tbl t1
left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
left join int8_tbl i8
left join (select *, null::int as d2 from int8_tbl i8b2) b2
on (i8.q1 = b2.q1)
on (b2.d2 = b1.q2)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1) order by f1;
explain (verbose, costs off)
select t1.* from
text_tbl t1
left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
left join int8_tbl i8
left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2
on (i8.q1 = b2.q1)
on (b2.d2 = b1.q2)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
select t1.* from
text_tbl t1
left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
left join int8_tbl i8
left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2
on (i8.q1 = b2.q1)
on (b2.d2 = b1.q2)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1) order by f1;
explain (verbose, costs off)
select t1.* from
text_tbl t1
left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
left join int8_tbl i8
left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2
where q1 = f1) b2
on (i8.q1 = b2.q1)
on (b2.d2 = b1.q2)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
select t1.* from
text_tbl t1
left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
left join int8_tbl i8
left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2
where q1 = f1) b2
on (i8.q1 = b2.q1)
on (b2.d2 = b1.q2)
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1) order by f1;
explain (verbose, costs off)
select * from
text_tbl t1
inner join int8_tbl i8
on i8.q2 = 456
right join text_tbl t2
on t1.f1 = 'doh!'
left join int4_tbl i4
on i8.q1 = i4.f1;
select * from
text_tbl t1
inner join int8_tbl i8
on i8.q2 = 456
right join text_tbl t2
on t1.f1 = 'doh!'
left join int4_tbl i4
on i8.q1 = i4.f1 order by 1,2,3,4;
--
-- test for appropriate join order in the presence of lateral references
--
explain (verbose, costs off)
select * from
text_tbl t1
left join int8_tbl i8
on i8.q2 = 123,
lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss
where t1.f1 = ss.f1;
select * from
text_tbl t1
left join int8_tbl i8
on i8.q2 = 123,
lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss
where t1.f1 = ss.f1;
explain (verbose, costs off)
select * from
text_tbl t1
left join int8_tbl i8
on i8.q2 = 123,
lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1,
lateral (select ss1.* from text_tbl t3 limit 1) as ss2
where t1.f1 = ss2.f1;
select * from
text_tbl t1
left join int8_tbl i8
on i8.q2 = 123,
lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1,
lateral (select ss1.* from text_tbl t3 limit 1) as ss2
where t1.f1 = ss2.f1;
explain (verbose, costs off)
select 1 from
text_tbl as tt1
inner join text_tbl as tt2 on (tt1.f1 = 'foo')
left join text_tbl as tt3 on (tt3.f1 = 'foo')
left join text_tbl as tt4 on (tt3.f1 = tt4.f1),
lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1
where tt1.f1 = ss1.c0;
select 1 from
text_tbl as tt1
inner join text_tbl as tt2 on (tt1.f1 = 'foo')
left join text_tbl as tt3 on (tt3.f1 = 'foo')
left join text_tbl as tt4 on (tt3.f1 = tt4.f1),
lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1
where tt1.f1 = ss1.c0;
--
-- check a case in which a PlaceHolderVar forces join order
--
explain (verbose, costs off)
select ss2.* from
int4_tbl i41
left join int8_tbl i8
join (select i42.f1 as c1, i43.f1 as c2, 42 as c3
from int4_tbl i42, int4_tbl i43) ss1
on i8.q1 = ss1.c2
on i41.f1 = ss1.c1,
lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2
where ss1.c2 = 0;
select ss2.* from
int4_tbl i41
left join int8_tbl i8
join (select i42.f1 as c1, i43.f1 as c2, 42 as c3
from int4_tbl i42, int4_tbl i43) ss1
on i8.q1 = ss1.c2
on i41.f1 = ss1.c1,
lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2
where ss1.c2 = 0;
--
-- test successful handling of full join underneath left join (bug #14105)
--
explain (costs off)
select * from
(select 1 as id) as xx
left join
(tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id))
on (xx.id = coalesce(yy.id));
select * from
(select 1 as id) as xx
left join
(tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id))
on (xx.id = coalesce(yy.id));
--
-- test ability to push constants through outer join clauses
--
explain (costs off)
select * from int4_tbl a left join tenk1 b on f1 = unique2 where f1 = 0;
explain (costs off)
select * from tenk1 a full join tenk1 b using(unique2) where unique2 = 42;
--
-- test that quals attached to an outer join have correct semantics,
-- specifically that they don't re-use expressions computed below the join;
-- we force a mergejoin so that coalesce(b.q1, 1) appears as a join input
--
set enable_hashjoin to off;
set enable_nestloop to off;
explain (verbose, costs off)
select a.q2, b.q1
from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1)
where coalesce(b.q1, 1) > 0;
select a.q2, b.q1
from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1)
where coalesce(b.q1, 1) > 0;
reset enable_hashjoin;
reset enable_nestloop;
--
-- test join removal
--
begin;
CREATE TEMP TABLE a (id int PRIMARY KEY, b_id int);
CREATE TEMP TABLE b (id int PRIMARY KEY, c_id int);
CREATE TEMP TABLE c (id int PRIMARY KEY);
CREATE TEMP TABLE d (a int, b int);
INSERT INTO a VALUES (0, 0), (1, NULL);
INSERT INTO b VALUES (0, 0), (1, NULL);
INSERT INTO c VALUES (0), (1);
INSERT INTO d VALUES (1,3), (2,2), (3,1);
-- all three cases should be optimizable into a simple seqscan
explain (costs off) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id;
explain (costs off) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id;
explain (costs off)
SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id)
ON (a.b_id = b.id);
-- check optimization of outer join within another special join
explain (costs off)
select id from a where id in (
select b.id from b left join c on b.id = c.id
);
-- check that join removal works for a left join when joining a subquery
-- that is guaranteed to be unique by its GROUP BY clause
explain (costs off)
select d.* from d left join (select * from b group by b.id, b.c_id) s
on d.a = s.id and d.b = s.c_id;
-- similarly, but keying off a DISTINCT clause
explain (costs off)
select d.* from d left join (select distinct * from b) s
on d.a = s.id and d.b = s.c_id;
-- join removal is not possible when the GROUP BY contains a column that is
-- not in the join condition. (Note: as of 9.6, we notice that b.id is a
-- primary key and so drop b.c_id from the GROUP BY of the resulting plan;
-- but this happens too late for join removal in the outer plan level.)
explain (costs off)
select d.* from d left join (select * from b group by b.id, b.c_id) s
on d.a = s.id;
-- similarly, but keying off a DISTINCT clause
explain (costs off)
select d.* from d left join (select distinct * from b) s
on d.a = s.id;
-- check join removal works when uniqueness of the join condition is enforced
-- by a UNION
explain (costs off)
select d.* from d left join (select id from a union select id from b) s
on d.a = s.id;
-- check join removal with a cross-type comparison operator
explain (costs off)
select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
on i8.q1 = i4.f1;
rollback;
create temp table parent (k int primary key, pd int);
create temp table child (k int unique, cd int);
insert into parent values (1, 10), (2, 20), (3, 30);
insert into child values (1, 100), (4, 400);
-- this case is optimizable
select p.* from parent p left join child c on (p.k = c.k);
explain (costs off)
select p.* from parent p left join child c on (p.k = c.k);
-- this case is not
select p.*, linked from parent p
left join (select c.*, true as linked from child c) as ss
on (p.k = ss.k);
explain (costs off)
select p.*, linked from parent p
left join (select c.*, true as linked from child c) as ss
on (p.k = ss.k);
-- check for a 9.0rc1 bug: join removal breaks pseudoconstant qual handling
select p.* from
parent p left join child c on (p.k = c.k)
where p.k = 1 and p.k = 2;
explain (costs off)
select p.* from
parent p left join child c on (p.k = c.k)
where p.k = 1 and p.k = 2;
select p.* from
(parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k
where p.k = 1 and p.k = 2;
explain (costs off)
select p.* from
(parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k
where p.k = 1 and p.k = 2;
-- bug 5255: this is not optimizable by join removal
begin;
CREATE TEMP TABLE a (id int PRIMARY KEY);
CREATE TEMP TABLE b (id int PRIMARY KEY, a_id int);
INSERT INTO a VALUES (0), (1);
INSERT INTO b VALUES (0, 0), (1, NULL);
SELECT * FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
SELECT b.* FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
rollback;
-- another join removal bug: this is not optimizable, either
begin;
create temp table innertab (id int8 primary key, dat1 int8);
insert into innertab values(123, 42);
SELECT * FROM
(SELECT 1 AS x) ss1
LEFT JOIN
(SELECT q1, q2, COALESCE(dat1, q1) AS y
FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss2
ON true order by q1, q2;
rollback;
-- another join removal bug: we must clean up correctly when removing a PHV
begin;
create temp table uniquetbl (f1 text unique);
explain (costs off)
select t1.* from
uniquetbl as t1
left join (select *, '***'::text as d1 from uniquetbl) t2
on t1.f1 = t2.f1
left join uniquetbl t3
on t2.d1 = t3.f1;
explain (costs off)
select t0.*
from
text_tbl t0
left join
(select case t1.ten when 0 then 'doh!'::text else null::text end as case1,
t1.stringu2
from tenk1 t1
join int4_tbl i4 ON i4.f1 = t1.unique2
left join uniquetbl u1 ON u1.f1 = t1.string4) ss
on t0.f1 = ss.case1
where ss.stringu2 !~* ss.case1;
select t0.*
from
text_tbl t0
left join
(select case t1.ten when 0 then 'doh!'::text else null::text end as case1,
t1.stringu2
from tenk1 t1
join int4_tbl i4 ON i4.f1 = t1.unique2
left join uniquetbl u1 ON u1.f1 = t1.string4) ss
on t0.f1 = ss.case1
where ss.stringu2 !~* ss.case1;
rollback;
-- bug #8444: we've historically allowed duplicate aliases within aliased JOINs
select * from
int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = f1; -- error
select * from
int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = y.f1; -- error
select * from
int8_tbl x join (int4_tbl x cross join int4_tbl y(ff)) j on q1 = f1; -- ok
--
-- Test hints given on incorrect column references are useful
--
select t1.uunique1 from
tenk1 t1 join tenk2 t2 on t1.two = t2.two; -- error, prefer "t1" suggestion
select t2.uunique1 from
tenk1 t1 join tenk2 t2 on t1.two = t2.two; -- error, prefer "t2" suggestion
select uunique1 from
tenk1 t1 join tenk2 t2 on t1.two = t2.two; -- error, suggest both at once
--
-- Take care to reference the correct RTE
--
select atts.relid::regclass, s.* from pg_stats s join
pg_attribute a on s.attname = a.attname and s.tablename =
a.attrelid::regclass::text join (select unnest(indkey) attnum,
indexrelid from pg_index i) atts on atts.attnum = a.attnum where
schemaname != 'pg_catalog';
--
-- Test LATERAL
--
select unique2, x.*
from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x;
explain (costs off)
select unique2, x.*
from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x;
select unique2, x.*
from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss;
explain (costs off)
select unique2, x.*
from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss;
explain (costs off)
select unique2, x.*
from int4_tbl x cross join lateral (select unique2 from tenk1 where f1 = unique1) ss;
select unique2, x.*
from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true;
explain (costs off)
select unique2, x.*
from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true;
-- check scoping of lateral versus parent references
-- the first of these should return int8_tbl.q2, the second int8_tbl.q1
select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl;
select *, (select r from (select q1 as q2) x, lateral (select q2 as r) y) from int8_tbl;
-- lateral with function in FROM
select count(*) from tenk1 a, lateral generate_series(1,two) g;
explain (costs off)
select count(*) from tenk1 a, lateral generate_series(1,two) g;
explain (costs off)
select count(*) from tenk1 a cross join lateral generate_series(1,two) g;
-- don't need the explicit LATERAL keyword for functions
explain (costs off)
select count(*) from tenk1 a, generate_series(1,two) g;
-- lateral with UNION ALL subselect
explain (costs off)
select * from generate_series(100,200) g,
lateral (select * from int8_tbl a where g = q1 union all
select * from int8_tbl b where g = q2) ss;
select * from generate_series(100,200) g,
lateral (select * from int8_tbl a where g = q1 union all
select * from int8_tbl b where g = q2) ss;
-- lateral with VALUES
explain (costs off)
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
-- lateral with VALUES, no flattening possible
explain (costs off)
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x;
select count(*) from tenk1 a,
tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x;
-- lateral injecting a strange outer join condition
explain (costs off)
select * from int8_tbl a,
int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z)
on x.q2 = ss.z
order by a.q1, a.q2, x.q1, x.q2, ss.z;
select * from int8_tbl a,
int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z)
on x.q2 = ss.z
order by a.q1, a.q2, x.q1, x.q2, ss.z;
-- lateral reference to a join alias variable
select * from (select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1,
lateral (select x) ss2(y);
select * from (select f1 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1,
lateral (values(x)) ss2(y);
select * from ((select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1) j,
lateral (select x) ss2(y);
-- lateral references requiring pullup
select * from (values(1)) x(lb),
lateral generate_series(lb,4) x4;
select * from (select f1/1000000000 from int4_tbl) x(lb),
lateral generate_series(lb,4) x4 order by lb, x4;
select * from (values(1)) x(lb),
lateral (values(lb)) y(lbcopy);
select * from (values(1)) x(lb),
lateral (select lb from int4_tbl) y(lbcopy);
select * from
int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1,
lateral (values(x.q1,y.q1,y.q2)) v(xq1,yq1,yq2);
select * from
int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1,
lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2);
select x.* from
int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1,
lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2);
select v.* from
(int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1)
left join int4_tbl z on z.f1 = x.q2,
lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy);
select v.* from
(int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1)
left join int4_tbl z on z.f1 = x.q2,
lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy);
create temp table dual();
insert into dual default values;
analyze dual;
select v.* from
(int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1)
left join int4_tbl z on z.f1 = x.q2,
lateral (select x.q1,y.q1 from dual union all select x.q2,y.q2 from dual) v(vx,vy);
explain (verbose, costs off)
select * from
int8_tbl a left join
lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1;
select * from
int8_tbl a left join
lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1;
explain (verbose, costs off)
select * from
int8_tbl a left join
lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1;
select * from
int8_tbl a left join
lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1;
-- lateral can result in join conditions appearing below their
-- real semantic level
explain (verbose, costs off)
select * from int4_tbl i left join
lateral (select * from int2_tbl j where i.f1 = j.f1) k on true;
select * from int4_tbl i left join
lateral (select * from int2_tbl j where i.f1 = j.f1) k on true;
explain (verbose, costs off)
select * from int4_tbl i left join
lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true;
select * from int4_tbl i left join
lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true;
explain (verbose, costs off)
select * from int4_tbl a,
lateral (
select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2)
) ss;
select * from int4_tbl a,
lateral (
select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2)
) ss;
-- lateral reference in a PlaceHolderVar evaluated at join level
explain (verbose, costs off)
select * from
int8_tbl a left join lateral
(select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from
int8_tbl b cross join int8_tbl c) ss
on a.q2 = ss.bq1;
select * from
int8_tbl a left join lateral
(select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from
int8_tbl b cross join int8_tbl c) ss
on a.q2 = ss.bq1;
-- case requiring nested PlaceHolderVars
explain (verbose, costs off)
select * from
int8_tbl c left join (
int8_tbl a left join (select q1, coalesce(q2,42) as x from int8_tbl b) ss1
on a.q2 = ss1.q1
cross join
lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2
) on c.q2 = ss2.q1,
lateral (select ss2.y offset 0) ss3;
-- case that breaks the old ph_may_need optimization
explain (verbose, costs off)
select c.*,a.*,ss1.q1,ss2.q1,ss3.* from
int8_tbl c left join (
int8_tbl a left join
(select q1, coalesce(q2,f1) as x from int8_tbl b, int4_tbl b2
where q1 < f1) ss1
on a.q2 = ss1.q1
cross join
lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2
) on c.q2 = ss2.q1,
lateral (select * from int4_tbl i where ss2.y > f1) ss3;
-- check processing of postponed quals (bug #9041)
explain (verbose, costs off)
select * from
(select 1 as x offset 0) x cross join (select 2 as y offset 0) y
left join lateral (
select * from (select 3 as z offset 0) z where z.z = x.x
) zz on zz.z = y.y;
-- check handling of nested appendrels inside LATERAL
select * from
((select 2 as v) union all (select 3 as v)) as q1
cross join lateral
((select * from
((select 4 as v) union all (select 5 as v)) as q3)
union all
(select q1.v)
) as q2;
-- check we don't try to do a unique-ified semijoin with LATERAL
explain (verbose, costs off)
select * from
(values (0,9998), (1,1000)) v(id,x),
lateral (select f1 from int4_tbl
where f1 = any (select unique1 from tenk1
where unique2 = v.x offset 0)) ss;
select * from
(values (0,9998), (1,1000)) v(id,x),
lateral (select f1 from int4_tbl
where f1 = any (select unique1 from tenk1
where unique2 = v.x offset 0)) ss;
-- check proper extParam/allParam handling (this isn't exactly a LATERAL issue,
-- but we can make the test case much more compact with LATERAL)
explain (verbose, costs off)
select * from (values (0), (1)) v(id),
lateral (select * from int8_tbl t1,
lateral (select * from
(select * from int8_tbl t2
where q1 = any (select q2 from int8_tbl t3
where q2 = (select greatest(t1.q1,t2.q2))
and (select v.id=0)) offset 0) ss2) ss
where t1.q1 = ss.q2) ss0;
select * from (values (0), (1)) v(id),
lateral (select * from int8_tbl t1,
lateral (select * from
(select * from int8_tbl t2
where q1 = any (select q2 from int8_tbl t3
where q2 = (select greatest(t1.q1,t2.q2))
and (select v.id=0)) offset 0) ss2) ss
where t1.q1 = ss.q2) ss0;
-- test some error cases where LATERAL should have been used but wasn't
select f1,g from int4_tbl a, (select f1 as g) ss;
select f1,g from int4_tbl a, (select a.f1 as g) ss;
select f1,g from int4_tbl a cross join (select f1 as g) ss;
select f1,g from int4_tbl a cross join (select a.f1 as g) ss;
-- SQL:2008 says the left table is in scope but illegal to access here
select f1,g from int4_tbl a right join lateral generate_series(0, a.f1) g on true;
select f1,g from int4_tbl a full join lateral generate_series(0, a.f1) g on true;
-- check we complain about ambiguous table references
select * from
int8_tbl x cross join (int4_tbl x cross join lateral (select x.f1) ss);
-- LATERAL can be used to put an aggregate into the FROM clause of its query
select 1 from tenk1 a, lateral (select max(a.unique1) from int4_tbl b) ss;
-- check behavior of LATERAL in UPDATE/DELETE
create temp table xx1 as select f1 as x1, -f1 as x2 from int4_tbl;
-- error, can't do this:
update xx1 set x2 = f1 from (select * from int4_tbl where f1 = x1) ss;
update xx1 set x2 = f1 from (select * from int4_tbl where f1 = xx1.x1) ss;
-- can't do it even with LATERAL:
update xx1 set x2 = f1 from lateral (select * from int4_tbl where f1 = x1) ss;
-- we might in future allow something like this, but for now it's an error:
update xx1 set x2 = f1 from xx1, lateral (select * from int4_tbl where f1 = x1) ss;
-- also errors:
delete from xx1 using (select * from int4_tbl where f1 = x1) ss;
delete from xx1 using (select * from int4_tbl where f1 = xx1.x1) ss;
delete from xx1 using lateral (select * from int4_tbl where f1 = x1) ss;
--
-- test that foreign key join estimation performs sanely for outer joins
--
begin;
create table fkest (a int, b int, c int unique, primary key(a,b));
create table fkest1 (a int, b int, primary key(a,b));
insert into fkest select x/10, x%10, x from generate_series(1,1000) x;
insert into fkest1 select x/10, x%10 from generate_series(1,1000) x;
alter table fkest1
add constraint fkest1_a_b_fkey foreign key (a,b) references fkest;
analyze fkest;
analyze fkest1;
explain (costs off)
select *
from fkest f
left join fkest1 f1 on f.a = f1.a and f.b = f1.b
left join fkest1 f2 on f.a = f2.a and f.b = f2.b
left join fkest1 f3 on f.a = f3.a and f.b = f3.b
where f.c = 1;
rollback;
--
-- test planner's ability to mark joins as unique
--
create table j1 (id int primary key);
create table j2 (id int primary key);
create table j3 (id int);
insert into j1 values(1),(2),(3);
insert into j2 values(1),(2),(3);
insert into j3 values(1),(1);
analyze j1;
analyze j2;
analyze j3;
-- ensure join is properly marked as unique
explain (verbose, costs off)
select * from j1 inner join j2 on j1.id = j2.id;
-- ensure join is not unique when not an equi-join
explain (verbose, costs off)
select * from j1 inner join j2 on j1.id > j2.id;
-- ensure non-unique rel is not chosen as inner
explain (verbose, costs off)
select * from j1 inner join j3 on j1.id = j3.id;
-- ensure left join is marked as unique
explain (verbose, costs off)
select * from j1 left join j2 on j1.id = j2.id;
-- ensure right join is marked as unique
explain (verbose, costs off)
select * from j1 right join j2 on j1.id = j2.id;
-- ensure full join is marked as unique
explain (verbose, costs off)
select * from j1 full join j2 on j1.id = j2.id;
-- a clauseless (cross) join can't be unique
explain (verbose, costs off)
select * from j1 cross join j2;
-- ensure a natural join is marked as unique
explain (verbose, costs off)
select * from j1 natural join j2;
-- ensure a distinct clause allows the inner to become unique
explain (verbose, costs off)
select * from j1
inner join (select distinct id from j3) j3 on j1.id = j3.id;
-- ensure group by clause allows the inner to become unique
explain (verbose, costs off)
select * from j1
inner join (select id from j3 group by id) j3 on j1.id = j3.id;
drop table j1;
drop table j2;
drop table j3;
-- test more complex permutations of unique joins
create table j1 (id1 int, id2 int, primary key(id1,id2));
create table j2 (id1 int, id2 int, primary key(id1,id2));
create table j3 (id1 int, id2 int, primary key(id1,id2));
insert into j1 values(1,1),(1,2);
insert into j2 values(1,1);
insert into j3 values(1,1);
analyze j1;
analyze j2;
analyze j3;
-- ensure there's no unique join when not all columns which are part of the
-- unique index are seen in the join clause
explain (verbose, costs off)
select * from j1
inner join j2 on j1.id1 = j2.id1;
-- ensure proper unique detection with multiple join quals
explain (verbose, costs off)
select * from j1
inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2;
-- ensure we don't detect the join to be unique when quals are not part of the
-- join condition
explain (verbose, costs off)
select * from j1
inner join j2 on j1.id1 = j2.id1 where j1.id2 = 1;
-- as above, but for left joins.
explain (verbose, costs off)
select * from j1
left join j2 on j1.id1 = j2.id1 where j1.id2 = 1;
-- validate logic in merge joins which skips mark and restore.
-- it should only do this if all quals which were used to detect the unique
-- are present as join quals, and not plain quals.
set enable_nestloop to 0;
set enable_hashjoin to 0;
set enable_sort to 0;
-- create an index that will be preferred over the PK to perform the join
create index j1_id1_idx on j1 (id1) where id1 % 1000 = 1;
explain (costs off) select * from j1 j1
inner join j1 j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
select * from j1 j1
inner join j1 j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
reset enable_nestloop;
reset enable_hashjoin;
reset enable_sort;
drop table j1;
drop table j2;
drop table j3;
-- check that semijoin inner is not seen as unique for a portion of the outerrel
explain (verbose, costs off)
select t1.unique1, t2.hundred
from onek t1, tenk1 t2
where exists (select 1 from tenk1 t3
where t3.thousand = t1.unique1 and t3.tenthous = t2.hundred)
and t1.unique1 < 1;
-- ... unless it actually is unique
create table j3 as select unique1, tenthous from onek;
vacuum analyze j3;
create unique index on j3(unique1, tenthous);
explain (verbose, costs off)
select t1.unique1, t2.hundred
from onek t1, tenk1 t2
where exists (select 1 from j3
where j3.unique1 = t1.unique1 and j3.tenthous = t2.hundred)
and t1.unique1 < 1;
drop table j3;
|
--
-- File generated with SQLiteStudio v3.2.1 on seg mai 4 08:47:27 2020
--
-- Text encoding used: UTF-8
--
PRAGMA foreign_keys = off;
BEGIN TRANSACTION;
-- Table: gene
CREATE TABLE gene (
organism TEXT NOT NULL,
locus_tag TEXT NOT NULL,
name TEXT NOT NULL,
is_tf INTEGER DEFAULT 0,
PRIMARY KEY (
organism,
locus_tag
)
);
-- Table: network_node
CREATE TABLE network_node (
organism TEXT NOT NULL,
tf_locus_tag TEXT NOT NULL,
tf_name TEXT NOT NULL,
tf_ortho_names TEXT (20),
tg_locus_tag TEXT NOT NULL,
tg_name TEXT NOT NULL,
tg_ortho_names TEXT (20),
interaction TEXT,
ortho_pox INTEGER,
ortho_ani INTEGER,
ortho_ncr INTEGER,
ortho_sce INTEGER,
tfbs_count INTEGER,
PRIMARY KEY (
organism,
tf_locus_tag,
tg_locus_tag
),
FOREIGN KEY (
organism
)
REFERENCES regulation (src_organism) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
tf_locus_tag
)
REFERENCES regulation (src_tf_locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
tg_locus_tag
)
REFERENCES regulation (src_tg_locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION
);
-- Table: ortho
CREATE TABLE ortho (
src_organism TEXT NOT NULL,
src_locus_tag TEXT NOT NULL,
ortho_organism TEXT NOT NULL,
ortho_locus_tag TEXT NOT NULL,
PRIMARY KEY (
src_organism,
src_locus_tag,
ortho_organism,
ortho_locus_tag
),
FOREIGN KEY (
src_organism
)
REFERENCES gene (organism) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
src_locus_tag
)
REFERENCES gene (locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
ortho_organism
)
REFERENCES gene (organism) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
ortho_locus_tag
)
REFERENCES gene (locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION
);
-- Table: pwm
CREATE TABLE pwm (
organism TEXT NOT NULL,
locus_tag TEXT NOT NULL,
motif_id TEXT NOT NULL,
tf_status TEXT,
family_name TEXT,
motif_type TEXT,
msource_author TEXT,
msource_year TEXT,
pmid TEXT,
PRIMARY KEY (
organism,
locus_tag,
motif_id
),
FOREIGN KEY (
organism
)
REFERENCES gene (organism) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
locus_tag
)
REFERENCES gene (locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION
);
-- Table: regulation
CREATE TABLE regulation (
src_organism TEXT NOT NULL,
src_tf_locus_tag TEXT NOT NULL,
src_tg_locus_tag TEXT NOT NULL,
interaction TEXT,
ortho_organism TEXT NOT NULL,
ortho_tf_locus_tag TEXT NOT NULL,
ortho_tg_locus_tag TEXT NOT NULL,
PRIMARY KEY (
src_organism,
src_tf_locus_tag,
src_tg_locus_tag,
ortho_organism,
ortho_tf_locus_tag,
ortho_tg_locus_tag
),
FOREIGN KEY (
src_organism
)
REFERENCES ortho (src_organism) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
src_tf_locus_tag
)
REFERENCES ortho (src_tf_locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
src_tg_locus_tag
)
REFERENCES ortho (src_tg_locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
ortho_organism
)
REFERENCES ortho (src_organism) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
ortho_tf_locus_tag
)
REFERENCES ortho (src_tf_locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION,
FOREIGN KEY (
ortho_tg_locus_tag
)
REFERENCES ortho (src_tg_locus_tag) ON DELETE RESTRICT
ON UPDATE NO ACTION
);
-- Table: tfbs_prediction
CREATE TABLE tfbs_prediction (
tfbs_id INTEGER UNIQUE
PRIMARY KEY ASC AUTOINCREMENT,
src_organism TEXT NOT NULL,
src_tf_locus_tag TEXT NOT NULL,
src_tg_locus_tag TEXT NOT NULL,
ortho_organism TEXT NOT NULL,
ortho_tf_locus_tag TEXT NOT NULL,
motif_id TEXT,
strand TEXT,
start INTEGER,
[end] INTEGER,
sequence TEXT,
weight NUMBER,
pval TEXT,
ln_pval NUMBER,
sig NUMBER,
FOREIGN KEY (
src_organism
)
REFERENCES regulation (src_organism) ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (
src_organism
)
REFERENCES pwm (organism) ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (
src_tf_locus_tag
)
REFERENCES regulation (src_tf_locus_tag) ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (
src_tg_locus_tag
)
REFERENCES regulation (src_tg_locus_tag) ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (
src_tf_locus_tag
)
REFERENCES pwm (locus_tag) ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (
ortho_organism
)
REFERENCES regulation (ortho_organism) ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (
ortho_tf_locus_tag
)
REFERENCES regulation (ortho_tf_locus_tag) ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (
motif_id
)
REFERENCES pwm (motif_id) ON DELETE NO ACTION
ON UPDATE NO ACTION
);
COMMIT TRANSACTION;
PRAGMA foreign_keys = on;
|
Nestloop
-> Index Scan using comp_manufidx on computer
-> Index Scan using soft_hostidx on software
|
-- @testpoint:opengauss关键字union(保留),作为角色名
--关键字不带引号-失败
drop role if exists union;
create role union with password '<PASSWORD>' valid until '2020-12-31';
--关键字带双引号-成功
drop role if exists "union";
create role "union" with password '<PASSWORD>' valid until '2020-12-31';
drop role "union";
--关键字带单引号-合理报错
drop role if exists 'union';
create role 'union' with password '<PASSWORD>' valid until '2020-12-31';
--关键字带反引号-合理报错
drop role if exists `union`;
create role `union` with password '<PASSWORD>' valid until '2020-12-31'; |
<filename>StarTrek/StarTrekData/dbo/Tables/XMLwithOpenXML.sql<gh_stars>0
CREATE TABLE [dbo].[XMLwithOpenXML] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[XMLData] XML NULL,
[LoadedDateTime] DATETIME NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
|
prompt Importing table t_migraciones...
set feedback off
set define off
insert into t_migraciones (ID_MIGRACION, DESCRIPCION)
values ('mig_000035', 'Mejoras en Plantilla de Notificación General.');
prompt Done.
|
<filename>EasyWrapper/Assets/ILR/1718/Reporting/Stored Procedures/PopulatePFRSummaryReport.sql<gh_stars>0
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Report].[PopulatePFRSummaryReport]') AND type in (N'P', N'PC'))
DROP PROCEDURE [Report].[PopulatePFRSummaryReport]
GO
CREATE PROCEDURE [Report].[PopulatePFRSummaryReport]
AS
BEGIN
DECLARE @CollectionPeriod DATE = (SELECT
CASE '${dcft.runmode}'
WHEN 'DS' THEN
(SELECT TOP 1 ISNULL([FilePreparationDate], CONVERT(DATE, GETDATE())) FROM [Valid].[CollectionDetails])
ELSE CONVERT(DATE, GETDATE()) END);
DECLARE @CollectionPeriodInt INT = (SELECT ISNULL((SELECT CAST(RIGHT(CollectionReturnCode, LEN(CollectionReturnCode)-1) AS INT)
FROM [Reference].[CollectionCalendar] WHERE @CollectionPeriod BETWEEN [ProposedOpenDate] AND [ProposedClosedDate]),12));
-- Clear previous report data - needed by FIS
TRUNCATE TABLE [Report].[FundingSummary_1618]
TRUNCATE TABLE [Report].[FundingSummary_Total1618]
TRUNCATE TABLE [Report].[FundingSummary_1618Traineeships]
TRUNCATE TABLE [Report].[FundingSummary_Total1618Traineeships]
TRUNCATE TABLE [Report].[FundingSummary_1923]
TRUNCATE TABLE [Report].[FundingSummary_Total1923]
TRUNCATE TABLE [Report].[FundingSummary_24Plus]
TRUNCATE TABLE [Report].[FundingSummary_Total24Plus]
TRUNCATE TABLE [Report].[FundingSummary_1924Traineeships]
TRUNCATE TABLE [Report].[FundingSummary_Total1924Traineeships]
TRUNCATE TABLE [Report].[FundingSummary_AebOther]
TRUNCATE TABLE [Report].[FundingSummary_TotalAebOther]
TRUNCATE TABLE [Report].[FundingSummary_24PlusAdvLoansBursary]
TRUNCATE TABLE [Report].[FundingSummary_Total24PlusAdvLoansBursary]
TRUNCATE TABLE [Report].[FundingSummary_AdultOLASS]
TRUNCATE TABLE [Report].[FundingSummary_TotalAdultOLASS]
TRUNCATE TABLE [Report].[FundingSummary_1618Trailblazers]
TRUNCATE TABLE [Report].[FundingSummary_Total1618Trailblazers]
TRUNCATE TABLE [Report].[FundingSummary_1923Trailblazers]
TRUNCATE TABLE [Report].[FundingSummary_Total1923Trailblazers]
TRUNCATE TABLE [Report].[FundingSummary_24PlusTrailblazers]
TRUNCATE TABLE [Report].[FundingSummary_Total24PlusTrailblazers]
TRUNCATE TABLE [Report].[FundingSummary_Total1618Budget]
TRUNCATE TABLE [Report].[FundingSummary_TotalAdultAppBudget]
TRUNCATE TABLE [Report].[FundingSummary_TotalNonAppBudget]
TRUNCATE TABLE [Report].[FundingSummary_TotalAdultBudget]
TRUNCATE TABLE [Report].[FundingSummary_ExceptionalLearningSupport]
TRUNCATE TABLE [Report].[FundingSummary_LineTotalsOLASSEASCancellationCosts]
TRUNCATE TABLE [REPORT].[FundingSummary_1618LevyContractedApprenticeships]
TRUNCATE TABLE [REPORT].[FundingSummary_AdultLevyContractedApprenticeships]
TRUNCATE TABLE [REPORT].[FundingSummary_Total1618LevyContractedApprenticeships]
TRUNCATE TABLE [REPORT].[FundingSummary_TotalAdultLevyContractedApprenticeships]
TRUNCATE TABLE [Report].[FundingSummary_TotalLevyBudget]
TRUNCATE TABLE [REPORT].[FundingSummary_1618NonLevyContractedApprenticeships]
TRUNCATE TABLE [REPORT].[FundingSummary_AdultNonLevyContractedApprenticeships]
TRUNCATE TABLE [REPORT].[FundingSummary_Total1618NonLevyContractedApprenticeships]
TRUNCATE TABLE [REPORT].[FundingSummary_TotalAdultNonLevyContractedApprenticeships]
TRUNCATE TABLE [Report].[FundingSummary_TotalNonLevyBudget]
-- Populate [Report] schema tables
INSERT INTO [Report].[FundingSummary_1618]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 16-18 Apprenticeship Frameworks Programme Funding' as SubGroupHeader,1 as SortOrder,'LineTotals1618Apprenticeship' as DataSetName, * FROM dbo.GetSFAFundingForType('16-18 Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 16-18 Apprenticeship Frameworks Learning Support' as SubGroupHeader,2 as SortOrder,'LineTotals1618Apprenticeship' as DataSetName, * FROM dbo.GetLSFFundingForType('16-18 Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Apprenticeship Frameworks Audit Adjustments' as SubGroupHeader,4 as SortOrder,'LineTotals1618Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Apprenticeship Frameworks Authorised Claims' as SubGroupHeader,5 as SortOrder,'LineTotals1618Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Apprenticeship Frameworks Excess Learning Support' as SubGroupHeader,6 as SortOrder,'LineTotals1618Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 16-18 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Apprenticeship Frameworks Learner Support' as SubGroupHeader,7 as SortOrder,'LineTotals1618Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Learner Support: 16-18 Apprenticeships', @CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_Total1618]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 16-18 Apprenticeship Frameworks for starts before 1 May 2017' as SubGroupHeader,9 as SortOrder,'LineTotals1618Apprenticeship' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_1618) TOTAL
INSERT INTO [Report].[FundingSummary_1618Traineeships]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 16-18 Traineeships Programme Funding' as SubGroupHeader,1 as SortOrder,'LineTotals1618Traineeships' as DataSetName, * FROM dbo.GetEFAFundingForType('16-18 Traineeships (Non-EFA)', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Traineeships Audit Adjustments' as SubGroupHeader,3 as SortOrder,'LineTotals1618Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Traineeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Traineeships Authorised Claims' as SubGroupHeader,4 as SortOrder,'LineTotals1618Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Traineeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Traineeships Excess Learning Support' as SubGroupHeader,5 as SortOrder,'LineTotals1618Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 16-18 Traineeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-19 Traineeships Bursary Vulnerable Student Bursary' as SubGroupHeader,6 as SortOrder,'LineTotals1618Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Vulnerable Bursary: 16-19 Traineeships Bursary', @CollectionPeriodInt) UNION
SELECT 'EAS 16-19 Traineeships Bursary Free Meals' as SubGroupHeader,7 as SortOrder,'LineTotals1618Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Free Meals: 16-19 Traineeships Bursary', @CollectionPeriodInt) UNION
SELECT 'EAS 16-19 Traineeships Bursary Discretionary Bursary' as SubGroupHeader,8 as SortOrder,'LineTotals1618Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Discretionary Bursary: 16-19 Traineeships Bursary', @CollectionPeriodInt)) A
INSERT INTO [Report].[FundingSummary_Total1618Traineeships]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 16-18 Traineeships' as SubGroupHeader,10 as SortOrder,'LineTotals1618Traineeships' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_1618Traineeships) TOTAL
INSERT INTO [Report].[FundingSummary_1923]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 19-23 Apprenticeship Frameworks Programme Funding' as SubGroupHeader,1 as SortOrder,'LineTotals1923Apprenticeship' as DataSetName, * FROM dbo.GetSFAFundingForType('19-23 Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 19-23 Apprenticeship Frameworks Learning Support' as SubGroupHeader,2 as SortOrder,'LineTotals1923Apprenticeship' as DataSetName, * FROM dbo.GetLSFFundingForType('19-23 Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Apprenticeship Frameworks Audit Adjustments' as SubGroupHeader,4 as SortOrder,'LineTotals1923Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 19-23 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Apprenticeship Frameworks Authorised Claims' as SubGroupHeader,5 as SortOrder,'LineTotals1923Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 19-23 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Apprenticeship Frameworks Excess Learning Support' as SubGroupHeader,6 as SortOrder,'LineTotals1923Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 19-23 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Apprenticeship Frameworks Learner Support' as SubGroupHeader,7 as SortOrder,'LineTotals1923Apprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Learner Support: 19-23 Apprenticeships', @CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_Total1923]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 19-23 Apprenticeship Frameworks' as SubGroupHeader,9 as SortOrder,'LineTotals1923Apprenticeship' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_1923) TOTAL
INSERT INTO [Report].[FundingSummary_24Plus]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 24+ Apprenticeship Frameworks Programme Funding' as SubGroupHeader,1 as SortOrder,'LineTotals24PlusApprenticeship' as DataSetName, * FROM dbo.GetSFAFundingForType('24+ Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 24+ Apprenticeship Frameworks Learning Support' as SubGroupHeader,2 as SortOrder,'LineTotals24PlusApprenticeship' as DataSetName, * FROM dbo.GetLSFFundingForType('24+ Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Apprenticeship Frameworks Audit Adjustments' as SubGroupHeader,4 as SortOrder,'LineTotals24PlusApprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 24+ Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Apprenticeship Frameworks Authorised Claims' as SubGroupHeader,5 as SortOrder,'LineTotals24PlusApprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 24+ Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Apprenticeship Frameworks Excess Learning Support' as SubGroupHeader,6 as SortOrder,'LineTotals24PlusApprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 24+ Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Apprenticeship Frameworks Learner Support' as SubGroupHeader,7 as SortOrder,'LineTotals24PlusApprenticeship' as DataSetName, * FROM dbo.GetEASFunding('Learner Support: 24+ Apprenticeships', @CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_Total24Plus]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 24+ Apprenticeship Frameworks' as SubGroupHeader,9 as SortOrder,'LineTotals24PlusApprenticeship' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_24Plus) TOTAL
INSERT INTO [Report].[FundingSummary_1924Traineeships]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 19-24 Traineeships Programme Funding' as SubGroupHeader,1 as SortOrder,'LineTotals1924Traineeships' as DataSetName, * FROM dbo.GetSFAFundingForType('19-24 Traineeship', @CollectionPeriodInt) UNION
SELECT 'ILR 19-24 Traineeships (EFA Model) Programme Funding' as SubGroupHeader,2 as SortOrder,'LineTotals1924Traineeships' as DataSetName, * FROM dbo.GetEFAFundingForType('19+ Traineeships (Non-EFA)', @CollectionPeriodInt) UNION
SELECT 'ILR 19-24 Traineeships Learning Support' as SubGroupHeader,3 as SortOrder,'LineTotals1924Traineeships' as DataSetName, * FROM dbo.GetLSFFundingForType('19-24 Traineeship', @CollectionPeriodInt) UNION
SELECT 'EAS 19-24 Traineeships Audit Adjustments' as SubGroupHeader,5 as SortOrder,'LineTotals1924Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 19-24 Traineeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-24 Traineeships Authorised Claims' as SubGroupHeader,6 as SortOrder,'LineTotals1924Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 19-24 Traineeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-24 Traineeships Excess Learning Support' as SubGroupHeader,7 as SortOrder,'LineTotals1924Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 19-24 Traineeships', @CollectionPeriodInt)UNION
SELECT 'EAS 19-24 Traineeships Learner Support' as SubGroupHeader,8 as SortOrder,'LineTotals1924Traineeships' as DataSetName, * FROM dbo.GetEASFunding('Learner Support: 19-24 Traineeships', @CollectionPeriodInt) ) AS a
INSERT INTO [Report].[FundingSummary_Total1924Traineeships]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 19-24 Traineeships' as SubGroupHeader,10 as SortOrder,'LineTotals1924Traineeships' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_1924Traineeships) TOTAL
/********************************************************************************************************************************************************************/
--Levy Contracted Apprenticeships Budget for starts on or after 1 May 2017
/********************************************************************************************************************************************************************/
--16-18 Levy Contracted Apprenticeships
INSERT INTO [Report].[FundingSummary_1618LevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'ILR 16-18 Levy Contracted Apprenticeships Programme Aim Indicative Earnings'as SubGroupHeader,1 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'ProgrammeAimOnProgPayment,ProgrammeAimBalPayment,ProgrammeAimCompletionPayment') UNION
SELECT 'ILR 16-18 Levy Contracted Apprenticeships Maths and English Programme Funding'as SubGroupHeader,2 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'MathEngOnProgPayment,MathEngBalPayment') UNION
SELECT 'ILR 16-18 Levy Contracted Apprenticeships Framework Uplift'as SubGroupHeader,3 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LDApplic1618FrameworkUpliftBalancingPayment,LDApplic1618FrameworkUpliftCompletionPayment,LDApplic1618FrameworkUpliftOnProgPayment') UNION
SELECT 'ILR 16-18 Levy Contracted Apprenticeships Disadvantage Payments'as SubGroupHeader,4 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'DisadvFirstPayment,DisadvSecondPayment') UNION
SELECT 'ILR 16-18 Levy Contracted Apprenticeships Additional Payments for Providers'as SubGroupHeader,5 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LearnDelFirstProv1618Pay,LearnDelSecondProv1618Pay') UNION
SELECT 'ILR 16-18 Levy Contracted Apprenticeships Additional Payments for Employers'as SubGroupHeader,6 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LearnDelFirstEmp1618Pay,LearnDelSecondEmp1618Pay') UNION
SELECT 'ILR 16-18 Levy Contracted Apprenticeships Learning Support'as SubGroupHeader,7 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LearnSuppFundCash')
UNION
SELECT 'EAS 16-18 Levy Contracted Apprenticeships Training Audit Adjustments' as SubGroupHeader,9 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Levy Contracted Apprenticeships Training Authorised Claims' as SubGroupHeader,10 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Levy Contracted Apprenticeships Additional Payments for Providers Audit Adjustments' as SubGroupHeader,11 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Levy Contracted Apprenticeships Additional Payments for Providers Authorised Claims ' as SubGroupHeader,12 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Levy Contracted Apprenticeships Additional Payments for Providers Learner Support' as SubGroupHeader,13 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 16-18 Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Levy Contracted Apprenticeships Additional Payments for Employers Audit Adjustments ' as SubGroupHeader,14 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Levy Apprenticeships - Employer', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Levy Contracted Apprenticeships Additional Payments for Employers Authorised Claims' as SubGroupHeader,15 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Levy Apprenticeships - Employer', @CollectionPeriodInt)
) AS [1618LevyContractedApprenticeships]
--16-18 Levy Contracted Apprenticeships Totals
INSERT INTO [Report].[FundingSummary_Total1618LevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'Total 16-18 Levy Contracted Apprenticeships' as SubGroupHeader,17 as SortOrder,'LineTotals1618LevyContractedApprenticeships' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From [Report].[FundingSummary_1618LevyContractedApprenticeships]) TOTAL
--Adult Levy Contracted Apprenticeships
INSERT INTO [Report].[FundingSummary_AdultLevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'ILR Adult Levy Contracted Apprenticeships Programme Aim Indicative Earnings'as SubGroupHeader,1 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'ProgrammeAimOnProgPayment,ProgrammeAimBalPayment,ProgrammeAimCompletionPayment') UNION
SELECT 'ILR Adult Levy Contracted Apprenticeships Maths and English Programme Funding'as SubGroupHeader,2 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'MathEngOnProgPayment,MathEngBalPayment') UNION
SELECT 'ILR Adult Levy Contracted Apprenticeships Framework Uplift'as SubGroupHeader,3 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LDApplic1618FrameworkUpliftBalancingPayment,LDApplic1618FrameworkUpliftCompletionPayment,LDApplic1618FrameworkUpliftOnProgPayment') UNION
SELECT 'ILR Adult Levy Contracted Apprenticeships Disadvantage Payments'as SubGroupHeader,4 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'DisadvFirstPayment,DisadvSecondPayment') UNION
SELECT 'ILR Adult Levy Contracted Apprenticeships Additional Payments for Providers'as SubGroupHeader,5 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LearnDelFirstProv1618Pay,LearnDelSecondProv1618Pay') UNION
SELECT 'ILR Adult Levy Contracted Apprenticeships Additional Payments for Employers'as SubGroupHeader,6 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LearnDelFirstEmp1618Pay,LearnDelSecondEmp1618Pay') UNION
SELECT 'ILR Adult Levy Contracted Apprenticeships Learning Support'as SubGroupHeader,7 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Levy Contract',@CollectionPeriodInt,'LearnSuppFundCash')
UNION
SELECT 'EAS Adult Levy Contracted Apprenticeships Training Audit Adjustments' as SubGroupHeader,9 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: Adult Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Levy Contracted Apprenticeships Training Authorised Claims' as SubGroupHeader,10 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: Adult Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Levy Contracted Apprenticeships Additional Payments for Providers Audit Adjustments' as SubGroupHeader,11 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: Adult Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Levy Contracted Apprenticeships Additional Payments for Providers Authorised Claims ' as SubGroupHeader,12 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: Adult Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Levy Contracted Apprenticeships Additional Payments for Providers Learner Support' as SubGroupHeader,13 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: Adult Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Levy Contracted Apprenticeships Additional Payments for Employers Audit Adjustments ' as SubGroupHeader,14 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: Adult Levy Apprenticeships - Employer', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Levy Contracted Apprenticeships Additional Payments for Employers Authorised Claims' as SubGroupHeader,15 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: Adult Levy Apprenticeships - Employer', @CollectionPeriodInt)
) AS [AdultLevyContractedApprenticeships]
--Adult Levy Contracted Apprenticeships Totals
INSERT INTO [Report].[FundingSummary_TotalAdultLevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'Total Adult Levy Contracted Apprenticeships' as SubGroupHeader,17 as SortOrder,'LineTotalsAdultLevyContractedApprenticeships' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From [Report].[FundingSummary_AdultLevyContractedApprenticeships]) TOTAL
--Total Levy Budget
INSERT INTO [Report].[FundingSummary_TotalLevyBudget]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT 'Total Levy Contracted Apprenticeships Budget for starts on or after 1 May 2017' as SubGroupHeader,1 as SortOrder,'LineTotalsLevyBudget' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,
sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul FROM (
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1618LevyContractedApprenticeships UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_TotalAdultLevyContractedApprenticeships) as a
/********************************************************************************************************************************************************************/
--Non-Levy Contracted Apprenticeships Budget for starts on or after 1 May 2017
/********************************************************************************************************************************************************************/
--16-18 Non-Levy Contracted Apprenticeships
INSERT INTO [Report].[FundingSummary_1618NonLevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'ILR 16-18 Non-Levy Contracted Apprenticeships Programme Aim Indicative Earnings'as SubGroupHeader,1 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'ProgrammeAimOnProgPayment,ProgrammeAimBalPayment,ProgrammeAimCompletionPayment') UNION
SELECT '...of which Indicative Co-Investment Earnings'as SubGroupHeader,2 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'ProgrammeAimProgFundIndMinCoInvest') UNION
SELECT 'ILR 16-18 Non-Levy Contracted Apprenticeships Maths and English Programme Funding'as SubGroupHeader,3 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'MathEngOnProgPayment,MathEngBalPayment') UNION
SELECT 'ILR 16-18 Non-Levy Contracted Apprenticeships Framework Uplift'as SubGroupHeader,4 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LDApplic1618FrameworkUpliftBalancingPayment,LDApplic1618FrameworkUpliftCompletionPayment,LDApplic1618FrameworkUpliftOnProgPayment') UNION
SELECT 'ILR 16-18 Non-Levy Contracted Apprenticeships Disadvantage Payments'as SubGroupHeader,5 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'DisadvFirstPayment,DisadvSecondPayment') UNION
SELECT 'ILR 16-18 Non-Levy Contracted Apprenticeships Additional Payments for Providers'as SubGroupHeader,6 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LearnDelFirstProv1618Pay,LearnDelSecondProv1618Pay') UNION
SELECT 'ILR 16-18 Non-Levy Contracted Apprenticeships Additional Payments for Employers'as SubGroupHeader,7 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LearnDelFirstEmp1618Pay,LearnDelSecondEmp1618Pay') UNION
SELECT 'ILR 16-18 Non-Levy Contracted Apprenticeships Learning Support'as SubGroupHeader,8 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('16-18 Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LearnSuppFundCash')
UNION
SELECT 'EAS 16-18 Non-Levy Contracted Apprenticeships Training Audit Adjustments' as SubGroupHeader,10 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Non-Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Non-Levy Contracted Apprenticeships Training Authorised Claims' as SubGroupHeader,11 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Non-Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Non-Levy Contracted Apprenticeships Additional Payments for Providers Audit Adjustments' as SubGroupHeader,12 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Non-Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Non-Levy Contracted Apprenticeships Additional Payments for Providers Authorised Claims ' as SubGroupHeader,13 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Non-Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Non-Levy Contracted Apprenticeships Additional Payments for Providers Learner Support' as SubGroupHeader,14 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 16-18 Non-Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Non-Levy Contracted Apprenticeships Additional Payments for Employers Audit Adjustments ' as SubGroupHeader,15 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Non-Levy Apprenticeships - Employer', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Non-Levy Contracted Apprenticeships Additional Payments for Employers Authorised Claims' as SubGroupHeader,16 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Non-Levy Apprenticeships - Employer', @CollectionPeriodInt)
) AS [1618NonLevyContractedApprenticeships]
--16-18 Non-Levy Contracted Apprenticeships Totals
INSERT INTO [Report].[FundingSummary_Total1618NonLevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'Total 16-18 Non-Levy Contracted Apprenticeships' as SubGroupHeader,18 as SortOrder,'LineTotals1618NonLevyContractedApprenticeships' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From [Report].[FundingSummary_1618NonLevyContractedApprenticeships] Where SubGroupHeader NOT IN ('...of which Indicative Co-Investment Earnings') ) TOTAL
--Adult Non-Levy Contracted Apprenticeships
INSERT INTO [Report].[FundingSummary_AdultNonLevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'ILR Adult Non-Levy Contracted Apprenticeships Programme Aim Indicative Earnings'as SubGroupHeader,1 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'ProgrammeAimOnProgPayment,ProgrammeAimBalPayment,ProgrammeAimCompletionPayment') UNION
SELECT '...of which Indicative Co-Investment Earnings'as SubGroupHeader,2 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'ProgrammeAimProgFundIndMinCoInvest') UNION
SELECT 'ILR Adult Non-Levy Contracted Apprenticeships Maths and English Programme Funding'as SubGroupHeader,3 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'MathEngOnProgPayment,MathEngBalPayment') UNION
SELECT 'ILR Adult Non-Levy Contracted Apprenticeships Framework Uplift'as SubGroupHeader,4 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LDApplic1618FrameworkUpliftBalancingPayment,LDApplic1618FrameworkUpliftCompletionPayment,LDApplic1618FrameworkUpliftOnProgPayment') UNION
SELECT 'ILR Adult Non-Levy Contracted Apprenticeships Disadvantage Payments'as SubGroupHeader,5 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'DisadvFirstPayment,DisadvSecondPayment') UNION
SELECT 'ILR Adult Non-Levy Contracted Apprenticeships Additional Payments for Providers'as SubGroupHeader,6 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LearnDelFirstProv1618Pay,LearnDelSecondProv1618Pay') UNION
SELECT 'ILR Adult Non-Levy Contracted Apprenticeships Additional Payments for Employers'as SubGroupHeader,7 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LearnDelFirstEmp1618Pay,LearnDelSecondEmp1618Pay') UNION
SELECT 'ILR Adult Non-Levy Contracted Apprenticeships Learning Support'as SubGroupHeader,8 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,* FROM [dbo].[GetAECFundingForType] ('19+ Apprenticeship (From May 2017) Non-Levy Contract',@CollectionPeriodInt,'LearnSuppFundCash')
UNION
SELECT 'EAS Adult Non-Levy Contracted Apprenticeships Training Audit Adjustments' as SubGroupHeader,10 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: Adult Non-Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Non-Levy Contracted Apprenticeships Training Authorised Claims' as SubGroupHeader,11 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: Adult Non-Levy Apprenticeships - Training', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Non-Levy Contracted Apprenticeships Additional Payments for Providers Audit Adjustments' as SubGroupHeader,12 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: Adult Non-Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Non-Levy Contracted Apprenticeships Additional Payments for Providers Authorised Claims ' as SubGroupHeader,13 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: Adult Non-Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Non-Levy Contracted Apprenticeships Additional Payments for Providers Learner Support' as SubGroupHeader,14 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: Adult Non-Levy Apprenticeships - Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Non-Levy Contracted Apprenticeships Additional Payments for Employers Audit Adjustments ' as SubGroupHeader,15 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: Adult Non-Levy Apprenticeships - Employer', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Non-Levy Contracted Apprenticeships Additional Payments for Employers Authorised Claims' as SubGroupHeader,16 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: Adult Non-Levy Apprenticeships - Employer', @CollectionPeriodInt)
) AS [AdultNonLevyContractedApprenticeships]
--Adult Non-Levy Contracted Apprenticeships Totals
INSERT INTO [Report].[FundingSummary_TotalAdultNonLevyContractedApprenticeships]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT *
FROM
(SELECT 'Total Adult Non-Levy Contracted Apprenticeships' as SubGroupHeader,18 as SortOrder,'LineTotalsAdultNonLevyContractedApprenticeships' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From [Report].[FundingSummary_AdultNonLevyContractedApprenticeships] Where SubGroupHeader NOT IN ('...of which Indicative Co-Investment Earnings') ) TOTAL
--Total NonLevy Budget
INSERT INTO [Report].[FundingSummary_TotalNonLevyBudget]
(SubGroupHeader, SortOrder, DataSetName, YTDCalc, TotalCalc, AugToMar, AprToJul, FundCalcAug, FundCalcSep, FundCalcOct, FundCalcNov, FundCalcDec, FundCalcJan, FundCalcFeb, FundCalcMar, FundCalcApr, FundCalcMay, FundCalcJun, FundCalcJul)
SELECT 'Total Non-Levy Contracted Apprenticeships Budget for starts on or after 1 May 2017' as SubGroupHeader,1 as SortOrder,'LineTotalsNonLevyBudget' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,
sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul FROM (
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1618NonLevyContractedApprenticeships UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_TotalAdultNonLevyContractedApprenticeships) as a
/********************************************************************************************************************************************************************/
INSERT INTO [Report].[FundingSummary_AebOther]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR AEB - Other Learning Programme Funding' as SubGroupHeader,1 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName, * FROM dbo.GetSFAFundingForType('AEB - Other Learning', @CollectionPeriodInt) UNION
SELECT 'ILR AEB - Other Learning (EFA Model) Programme Funding' as SubGroupHeader,2 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName, * FROM dbo.GetEFAFundingForType('Adult Skills Funded EFA Model', @CollectionPeriodInt) UNION
SELECT 'ILR AEB - Other Learning (25+ High Needs Students) Programme Funding' as SubGroupHeader,3 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName, * FROM dbo.GetEFAFundingForType('25+ Students with an LDA or EHCP', @CollectionPeriodInt) UNION
SELECT 'ILR AEB - Other Learning Learning Support' as SubGroupHeader,4 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName, * FROM dbo.GetLSFFundingForType('AEB - Other Learning', @CollectionPeriodInt) UNION
SELECT 'EAS AEB - Other Learning Audit Adjustments' as SubGroupHeader,6 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: AEB-Other Learning', @CollectionPeriodInt) UNION
SELECT 'EAS AEB - Other Learning Authorised Claims' as SubGroupHeader,7 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: AEB-Other Learning', @CollectionPeriodInt) UNION
SELECT 'EAS AEB - Other Learning Excess Learning Support' as SubGroupHeader,8 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: AEB-Other Learning', @CollectionPeriodInt) ) AS a
INSERT INTO [Report].[FundingSummary_TotalAebOther]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total AEB - Other Learning' as SubGroupHeader,10 as SortOrder,'LineTotalsAebOtherLearning' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_AebOther) TOTAL
INSERT INTO [Report].[FundingSummary_24PlusAdvLoansBursary]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR Advanced Loans Bursary Funding' as SubGroupHeader,1 as SortOrder,'LineTotals24PlusAdvLoansBursary' as DataSetName, * FROM dbo.GetBursaryFundingForType('Advanced Learner Loans Bursary', @CollectionPeriodInt) UNION
SELECT 'ILR Advanced Loans Bursary Area Costs' as SubGroupHeader,2 as SortOrder,'LineTotals24PlusAdvLoansBursary' as DataSetName, * FROM dbo.GetBursaryLoansAreaUpliftForType('Advanced Learner Loans Bursary', @CollectionPeriodInt) UNION
SELECT 'EAS Advanced Loans Bursary Excess Support' as SubGroupHeader,4 as SortOrder,'LineTotals24PlusAdvLoansBursary' as DataSetName, * FROM dbo.GetEASFunding('Excess Support: Advanced Learner Loans Bursary', @CollectionPeriodInt) UNION
SELECT 'EAS Advanced Loans Bursary Area Costs Audit Adjustments' as SubGroupHeader,5 as SortOrder,'LineTotals24PlusAdvLoansBursary' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: Advanced Learner Loans Bursary', @CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_Total24PlusAdvLoansBursary]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total Advanced Loans Bursary' as SubGroupHeader,7 as SortOrder,'LineTotals24PlusAdvLoansBursary' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_24PlusAdvLoansBursary) TOTAL
INSERT INTO [Report].[FundingSummary_AdultOLASS]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR Adult OLASS Programme Funding' as SubGroupHeader,1 as SortOrder,'LineTotalsAdultOLASS' as DataSetName, * FROM dbo.GetSFAFundingForType('Adult OLASS', @CollectionPeriodInt) UNION
SELECT 'ILR Adult OLASS Learning Support' as SubGroupHeader,2 as SortOrder,'LineTotalsAdultOLASS' as DataSetName, * FROM dbo.GetLSFFundingForType('Adult OLASS', @CollectionPeriodInt) UNION
SELECT 'EAS Adult OLASS Audit Adjustments' as SubGroupHeader,4 as SortOrder,'LineTotalsAdultOLASS' as DataSetName, * FROM dbo.GetOLASSEASAuditAdjustmentsFunding(@CollectionPeriodInt)UNION
SELECT 'EAS Adult OLASS Authorised Claims' as SubGroupHeader,5 as SortOrder,'LineTotalsAdultOLASS' as DataSetName, * FROM dbo.GetOLASSEASAuthorisedClaimsFunding(@CollectionPeriodInt)UNION
SELECT 'EAS Adult OLASS Excess Learning Support' as SubGroupHeader,6 as SortOrder,'LineTotalsAdultOLASS' as DataSetName, * FROM dbo.GetOLASSEASExcessLearningSupportFunding(@CollectionPeriodInt) ) AS a
INSERT INTO [Report].[FundingSummary_TotalAdultOLASS]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total Adult OLASS' as SubGroupHeader,8 as SortOrder,'LineTotalsAdultOLASS' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From Report.FundingSummary_AdultOLASS) TOTAL
INSERT INTO [Report].[FundingSummary_1618Trailblazers]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 16-18 Trailblazer Apprenticeships Programme Funding (Core Government Contribution, Maths and English)' as SubGroupHeader,1 as SortOrder,'LineTotals1618Trailblazers' as DataSetName, * FROM dbo.GetTrailblazerOnProgFundingForType('16-18 Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 16-18 Trailblazer Apprenticeships Employer Incentive Payments (Achievement, Small Employer, 16-18)' as SubGroupHeader,2 as SortOrder,'LineTotals1618Trailblazers' as DataSetName, * FROM dbo.GetTrailblazerIncentivesFundingForType('16-18 Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 16-18 Trailblazer Apprenticeships Learning Support' as SubGroupHeader,3 as SortOrder,'LineTotals1618Trailblazers' as DataSetName, * FROM dbo.GetTrailblazerLSFFundingForType('16-18 Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Trailblazer Apprenticeships Audit Adjustments' as SubGroupHeader,5 as SortOrder,'LineTotals1618Trailblazers' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 16-18 Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Trailblazer Apprenticeships Authorised Claims' as SubGroupHeader,6 as SortOrder,'LineTotals1618Trailblazers' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 16-18 Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Trailblazer Apprenticeships Excess Learning Support' as SubGroupHeader,7 as SortOrder,'LineTotals1618Trailblazers' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 16-18 Trailblazer Apprenticeships', @CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_Total1618Trailblazers]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 16-18 Trailblazer Apprenticeships for starts before 1 May 2017' as SubGroupHeader,9 as SortOrder,'LineTotals1618Trailblazers' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From [Report].[FundingSummary_1618Trailblazers]) TOTAL
INSERT INTO [Report].[FundingSummary_1923Trailblazers]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 19-23 Trailblazer Apprenticeships Programme Funding (Core Government Contribution, Maths and English)' as SubGroupHeader,1 as SortOrder,'LineTotals1923Trailblazers' as DataSetName, * FROM dbo.GetTrailblazerOnProgFundingForType('19-23 Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 19-23 Trailblazer Apprenticeships Employer Incentive Payments (Achievement, Small Employer, 16-18)' as SubGroupHeader,2 as SortOrder,'LineTotals1923Trailblazers' as DataSetName, * FROM dbo.GetTrailblazerAdultIncentivesFundingForType('19-23 Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 19-23 Trailblazer Apprenticeships Learning Support' as SubGroupHeader,3 as SortOrder,'LineTotals1923Trailblazers' as DataSetName, * FROM dbo.GetTrailblazerLSFFundingForType('19-23 Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Trailblazer Apprenticeships Audit Adjustments' as SubGroupHeader,5 as SortOrder,'LineTotals1923Trailblazers' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 19-23 Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Trailblazer Apprenticeships Authorised Claims' as SubGroupHeader,6 as SortOrder,'LineTotals1923Trailblazers' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 19-23 Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Trailblazer Apprenticeships Excess Learning Support' as SubGroupHeader,7 as SortOrder,'LineTotals1923Trailblazers' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 19-23 Trailblazer Apprenticeships', @CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_Total1923Trailblazers]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 19-23 Trailblazer Apprenticeships' as SubGroupHeader,9 as SortOrder,'LineTotals1923Trailblazers' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From [Report].[FundingSummary_1923Trailblazers]) TOTAL
INSERT INTO [Report].[FundingSummary_24PlusTrailblazers]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'ILR 24+ Trailblazer Apprenticeships Programme Funding (Core Government Contribution, Maths and English)' as SubGroupHeader,1 as SortOrder,'LineTotals24PlusTrailblazers' as DataSetName, * FROM dbo.GetTrailblazerOnProgFundingForType('24+ Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 24+ Trailblazer Apprenticeships Employer Incentive Payments (Achievement, Small Employer, 16-18)' as SubGroupHeader,2 as SortOrder,'LineTotals24PlusTrailblazers' as DataSetName, * FROM dbo.GetTrailblazerAdultIncentivesFundingForType('24+ Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'ILR 24+ Trailblazer Apprenticeships Learning Support' as SubGroupHeader,3 as SortOrder,'LineTotals24PlusTrailblazers' as DataSetName, * FROM dbo.GetTrailblazerLSFFundingForType('24+ Trailblazer Apprenticeship', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Trailblazer Apprenticeships Audit Adjustments' as SubGroupHeader,5 as SortOrder,'LineTotals24PlusTrailblazers' as DataSetName, * FROM dbo.GetEASFunding('Audit Adjustments: 24+ Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Trailblazer Apprenticeships Authorised Claims' as SubGroupHeader,6 as SortOrder,'LineTotals24PlusTrailblazers' as DataSetName, * FROM dbo.GetEASFunding('Authorised Claims: 24+ Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Trailblazer Apprenticeships Excess Learning Support' as SubGroupHeader,7 as SortOrder,'LineTotals24PlusTrailblazers' as DataSetName, * FROM dbo.GetEASFunding('Excess Learning Support: 24+ Trailblazer Apprenticeships', @CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_Total24PlusTrailblazers]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(SELECT 'Total 24+ Trailblazer Apprenticeships' as SubGroupHeader,9 as SortOrder,'LineTotals24PlusTrailblazers' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
From [Report].[FundingSummary_24PlusTrailblazers]) TOTAL
INSERT INTO [Report].[FundingSummary_Total1618Budget]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT 'Total 16-18 Apprenticeships Budget' as SubGroupHeader,1 as SortOrder,'LineTotals1618Budget' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,
sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul FROM (
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1618 UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1618Trailblazers) as a
INSERT INTO [Report].[FundingSummary_TotalAdultAppBudget]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT 'Total Adult Apprenticeships Budget for starts before 1 May 2017' as SubGroupHeader,1 as SortOrder,'LineTotalsAdultBudget' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,
sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul FROM (
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1923 UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1923Trailblazers UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total24PlusTrailblazers UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total24Plus) as a
INSERT INTO [Report].[FundingSummary_TotalNonAppBudget]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT 'Total Non-Apprenticeships' as SubGroupHeader,1 as SortOrder,'LineTotalsNonApprenticeships' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc ,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,
sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul
FROM (
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1924Traineeships UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_TotalAebOther) as a
INSERT INTO [Report].[FundingSummary_TotalAdultBudget]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT 'Total Adult Education Budget' as SubGroupHeader,1 as SortOrder,'LineTotalsAdultSkillsBudget' as DataSetName,
SUM(YTDCalc) AS YTDCalc, SUM (TotalCalc) AS TotalCalc,sum(AugToMar) AS AugToMar,sum(AprToJul) AS AprToJul,sum(FundCalcAug) AS FundCalcAug,sum(FundCalcSep) AS FundCalcSep,sum(FundCalcOct) AS FundCalcOct,
sum(FundCalcNov) AS FundCalcNov,sum(FundCalcDec) AS FundCalcDec,
sum(FundCalcJan) AS FundCalcJan,sum(FundCalcFeb) AS FundCalcFeb,sum(FundCalcMar) AS FundCalcMar,sum(FundCalcApr) AS FundCalcApr,sum(FundCalcMay) AS FundCalcMay,sum(FundCalcJun) AS FundCalcJun,sum(FundCalcJul) AS FundCalcJul FROM (
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_Total1924Traineeships UNION
select FundCalcAug,FundCalcSep,FundCalcOct,FundCalcNov,FundCalcDec,FundCalcJan,FundCalcFeb,FundCalcMar,FundCalcApr,FundCalcMay,FundCalcJun,FundCalcJul,YTDCalc, TotalCalc,AugToMar,AprToJul from Report.FundingSummary_TotalAebOther) as a
INSERT INTO [Report].[FundingSummary_LineTotalsOLASSEASCancellationCosts]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(
SELECT 'EAS Adult OLASS Cancellation Costs' as SubGroupHeader,1 as SortOrder,'LineTotalsOLASSEASCancellationCosts' as DataSetName, * FROM dbo.GetOLASSEASCancellationCostsFunding(@CollectionPeriodInt)) AS a
INSERT INTO [Report].[FundingSummary_ExceptionalLearningSupport]
([SubGroupHeader],[SortOrder],[DataSetName],[YTDCalc],[TotalCalc],[AugToMar],[AprToJul],[FundCalcAug],[FundCalcSep],[FundCalcOct],[FundCalcNov],[FundCalcDec]
,[FundCalcJan],[FundCalcFeb] ,[FundCalcMar] ,[FundCalcApr],[FundCalcMay] ,[FundCalcJun],[FundCalcJul])
SELECT *
FROM
(
SELECT 'EAS 16-18 Apprenticeship Frameworks Exceptional Learning Support' as SubGroupHeader,1 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 16-18 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Trailblazer Apprenticeships Exceptional Learning Support' as SubGroupHeader,2 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 16-18 Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Apprenticeship Frameworks Exceptional Learning Support' as SubGroupHeader,3 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 19-23 Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 19-23 Trailblazer Apprenticeships Exceptional Learning Support' as SubGroupHeader,4 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 19-23 Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Apprenticeship Frameworks Exceptional Learning Support' as SubGroupHeader,5 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 24+ Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 24+ Trailblazer Apprenticeships Exceptional Learning Support' as SubGroupHeader,6 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 24+ Trailblazer Apprenticeships', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Levy contracted Apprenticeships Exceptional Learning Support' as SubGroupHeader,7 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 16-18 Levy Apprenticeships – Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Levy contracted Apprenticeships Exceptional Learning Support' as SubGroupHeader,8 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: Adult Levy Apprenticeships – Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 16-18 Non-levy contracted Apprenticeships Exceptional Learning Support' as SubGroupHeader,9 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 16-18 Non-Levy Apprenticeships – Provider', @CollectionPeriodInt) UNION
SELECT 'EAS Adult Non-levy contracted Apprenticeships Exceptional Learning Support' as SubGroupHeader,10 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: Adult Non-Levy Apprenticeships – Provider', @CollectionPeriodInt) UNION
SELECT 'EAS 19-24 Traineeships Exceptional Learning Support' as SubGroupHeader,11 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: 19-24 Traineeships', @CollectionPeriodInt) UNION
SELECT 'EAS AEB - Other Learning Exceptional Learning Support' as SubGroupHeader,12 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: AEB-Other Learning', @CollectionPeriodInt) UNION
SELECT 'EAS Advanced Loans Bursary Exceptional Learning Support' as SubGroupHeader,13 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetEASFunding('Exceptional Learning Support: Advanced Learner Loans Bursary', @CollectionPeriodInt) UNION
SELECT 'EAS Adult OLASS Exceptional Learning Support' as SubGroupHeader,14 as SortOrder,'LineTotalsExceptionalLearningSupport' as DataSetName, * FROM dbo.GetOLASSEASExceptionalLearningSupportFunding(@CollectionPeriodInt)) AS a
END
GO |
<reponame>08162021-dotnet-uta/P2_Group2<filename>Project2DDL.sql
--DDL for P2Group2SocialGame
--Still need to add the on delete cascades and set nulls
CREATE DATABASE P2_NotFightClub
Go
USE P2_NotFightClub
Go
CREATE TABLE UserInfo(
UserId uniqueidentifier not null default newId() primary key,
UserName nvarchar(50) not null,
PWord nvarchar(100) not null,
Email nvarchar(50),
DOB date,
Bucks int default 20 check (Bucks>=20)
)
CREATE TABLE Trait(
TraitId int not null identity(1,1) primary key,
[Description] nvarchar(300)
)
CREATE TABLE Weapon(
WeaponId int not null identity(1,1) primary key,
[Description] nvarchar(300)
)
CREATE TABLE [Character](
CharacterId int not null identity (1,1) Primary Key,
[Name] nvarchar(100) not null,
[Level] int,
Wins int,
Losses int,
Ties int,
Baseform nvarchar(100),
UserId uniqueidentifier not null FOREIGN KEY REFERENCES UserInfo(UserId),
TraitId int not null FOREIGN KEY REFERENCES Trait(TraitId) on delete no action ,
WeaponId int not null FOREIGN KEY REFERENCES Weapon(WeaponId) on delete no action
)
CREATE TABLE [Location](
LocationId int not null identity(1,1) primary key,
[Location] nvarchar(100) not null
)
CREATE TABLE Weather(
WeatherId int not null identity(1,1) primary key,
[Description] nvarchar(100) not null
)
CREATE TABLE Fight(
FightId int not null identity (1,1) primary key,
Winner int FOREIGN KEY REFERENCES [Character](CharacterId) on delete no action,
Loser int FOREIGN KEY REFERENCES [Character](CharacterId) on delete no action,
[Date] date default getdate(),
Result nvarchar(300),
[Location] int foreign key references [Location](LocationId),
Weather int foreign key references Weather(WeatherId)
)
CREATE TABLE Fighter(
FighterId int not null identity(1,1) primary key,
FightId int FOREIGN KEY REFERENCES Fight(FightId) on delete no action ,
CharacterId int FOREIGN KEY REFERENCES [Character](CharacterId) on delete no action,
Votes int
)
CREATE TABLE Comment(
CommentId int not null identity(1,1) primary key,
FightId int FOREIGN KEY REFERENCES Fight(FightId) on delete cascade,
UserId uniqueidentifier FOREIGN KEY REFERENCES UserInfo(UserId) on delete no action,
[Date] date default GetDate(),
Comment nvarchar(1000),
Parentcomment int Foreign key references Comment(CommentId)
)
CREATE TABLE Wager(
WagerId int not null identity(1,1) primary key,
UserId uniqueidentifier FOREIGN KEY REFERENCES UserInfo(UserId) on delete no action,
FightId int FOREIGN KEY REFERENCES Fight(FightId) on delete cascade,
Amount int,
FighterId int FOREIGN KEY REFERENCES Fighter(FighterId)
)
|
/*
Navicat Premium Data Transfer
Source Server : localhost_3306
Source Server Type : MySQL
Source Server Version : 100131
Source Host : localhost:3306
Source Schema : ges
Target Server Type : MySQL
Target Server Version : 100131
File Encoding : 65001
Date: 03/04/2020 21:42:00
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for m_batch
-- ----------------------------
DROP TABLE IF EXISTS `m_batch`;
CREATE TABLE `m_batch` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`REF` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`batch_code` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`batch_name` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`course_ref` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`course_code` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`course_name` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`des` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`start_date` date NULL DEFAULT NULL,
`day` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`s_time` time(0) NULL DEFAULT NULL,
`e_time` time(0) NULL DEFAULT NULL,
`amount` decimal(12, 2) NULL DEFAULT NULL,
`sys_time` timestamp(0) NULL DEFAULT NULL,
`user` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`active` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`status` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of m_batch
-- ----------------------------
INSERT INTO `m_batch` VALUES (11, 'PAY/0000005', 'ddfsdfs', NULL, '2020-04-02', '5345345.00', '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `m_batch` VALUES (12, 'BAT/0000001', 'dfdxscx', NULL, '2020-04-02', '0.00', '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `m_batch` VALUES (13, 'BAT/0000002', 'fsd', 'fsd', 'fsdf', 'sdf', 'sdfsdf', 'sd', '2020-04-22', 'sdf', '02:00:00', '23:00:00', 253654.00, NULL, '', '1', NULL);
INSERT INTO `m_batch` VALUES (14, 'BAT/0000003', 'fsd', 'fsd', 'fsdf', 'sdf', 'sdfsdf', 'sd', '0000-00-00', 'sdf', '00:00:00', '00:00:00', 253654.00, NULL, 'user', '1', NULL);
INSERT INTO `m_batch` VALUES (15, 'BAT/0000004', '', '', '', '', '', '', '0000-00-00', '', '00:00:00', '00:00:00', 0.00, NULL, '', '1', NULL);
INSERT INTO `m_batch` VALUES (16, 'BAT/0000005', '', '', '', '', '', '', '0000-00-00', '', '00:00:00', '00:00:00', 0.00, NULL, '', '1', NULL);
INSERT INTO `m_batch` VALUES (18, 'BAT/0000006', '', '', '', '', '', '', '0000-00-00', '', '00:00:00', '00:00:00', 0.00, NULL, 'user', '1', NULL);
INSERT INTO `m_batch` VALUES (19, 'BAT/0000007', '', '', '', '', '', '', '0000-00-00', '', '00:00:00', '00:00:00', 0.00, NULL, 'user', '1', NULL);
-- ----------------------------
-- Table structure for m_content
-- ----------------------------
DROP TABLE IF EXISTS `m_content`;
CREATE TABLE `m_content` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`REF` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`content_code` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`content_name` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`user` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sys_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
`active` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of m_content
-- ----------------------------
INSERT INTO `m_content` VALUES (11, 'PAY/0000005', 'fsdfs', 'dfsdf', NULL, '2020-04-02 00:41:09', NULL);
INSERT INTO `m_content` VALUES (12, 'CON/0000001', 'fdsf', 'fsd', NULL, '2020-04-02 19:09:15', NULL);
-- ----------------------------
-- Table structure for m_course
-- ----------------------------
DROP TABLE IF EXISTS `m_course`;
CREATE TABLE `m_course` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`REF` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`course_code` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`course_name` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`faculty_ref` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`faculty_name` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`batch_ref` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`batch_code` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`des` varchar(3000) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`level` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`type` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`requirement_1` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`requirement_2` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`requirement_3` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`requirement_4` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`requirement_5` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`duration` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`amount` decimal(15, 2) NULL DEFAULT NULL,
`active` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`status` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`user` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sys_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of m_course
-- ----------------------------
INSERT INTO `m_course` VALUES (1, 'COR/0000002', 'fsds', 'fsdf', 'sdf', 'sdf', 'sdf', 'sdf', 'sdfddsf', 'fsdf', 'sdf', 'fds', 'fsdf', 'sdfsd', 'fsdf', 'sdf', 'fdsf', 423423.00, '1', NULL, 'user', '2020-04-03 20:07:56');
INSERT INTO `m_course` VALUES (2, 'COR/0000003', 'fd', 'tuv', 'fvu', 'fv', 'uv', 'yuv', 'fsdfsd', 'uykvuykv', 'ku', 'yv', 'uykv', 'ukyvyukv', 'uykv', 'yuk', 'vukyv', 54768.00, '1', NULL, 'user', '2020-04-03 20:08:35');
-- ----------------------------
-- Table structure for m_faculty
-- ----------------------------
DROP TABLE IF EXISTS `m_faculty`;
CREATE TABLE `m_faculty` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`REF` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`faculty_code` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`faculty_name` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`user` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sys_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
`active` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of m_faculty
-- ----------------------------
INSERT INTO `m_faculty` VALUES (11, 'PAY/0000005', NULL, NULL, NULL, '2020-04-02 00:41:09', NULL);
INSERT INTO `m_faculty` VALUES (12, 'CON/0000001', NULL, NULL, NULL, '2020-04-02 19:09:15', NULL);
INSERT INTO `m_faculty` VALUES (13, 'CON/0000001', 'fsdf', 'sdfsd', NULL, '2020-04-03 20:59:13', '1');
INSERT INTO `m_faculty` VALUES (14, 'CON/0000002', 'fsdf', 'sdfs', NULL, '2020-04-03 20:59:37', '1');
-- ----------------------------
-- Table structure for m_lecturer
-- ----------------------------
DROP TABLE IF EXISTS `m_lecturer`;
CREATE TABLE `m_lecturer` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`REF` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`lecturer_name` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`des` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`address_1` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`address_2` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`tel_1` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`tel_2` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`email` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`active` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sys_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
`user` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of m_lecturer
-- ----------------------------
INSERT INTO `m_lecturer` VALUES (1, 'CON/0000001', 'fsdf', 'sdfsdf', 'fsdfs', 'dfsdf', 'sdfsd', 'f', 'fsdf', '1', '2020-04-03 19:52:47', NULL);
-- ----------------------------
-- Table structure for m_payment
-- ----------------------------
DROP TABLE IF EXISTS `m_payment`;
CREATE TABLE `m_payment` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`REF` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`player_ref` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`player_name` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`mdate` date NULL DEFAULT NULL,
`amount` decimal(12, 2) NULL DEFAULT NULL,
`cancel` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`user` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sys_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of m_payment
-- ----------------------------
INSERT INTO `m_payment` VALUES (11, 'PAY/0000005', 'ddfsdfs', 'fsdfsdf', '2020-04-02', 5345345.00, '0', NULL, '2020-04-02 00:41:09');
-- ----------------------------
-- Table structure for m_registration
-- ----------------------------
DROP TABLE IF EXISTS `m_registration`;
CREATE TABLE `m_registration` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`REF` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`first_name` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`last_name` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`guardian_name` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`guardian_tel` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`address_1` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`address_2` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`tel_1` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`tel_2` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sex` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`dob` date NULL DEFAULT NULL,
`email` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`remark` varchar(300) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`joineddate` date NULL DEFAULT NULL,
`active` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`black_list` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`status` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`approve` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`platform` varchar(15) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`user` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sys_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0),
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 49 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of m_registration
-- ----------------------------
INSERT INTO `m_registration` VALUES (43, 'REG/0000022', 'fsdfsd', 'fsdf', 'sdfsd', '4345345', '534gfdfg', '5435ergfdg', '543534', '5345', 'gdfg', '2020-04-14', '5435345', '5345345', '2020-04-02', '1', '0', '0', '0', NULL, NULL, '2020-04-02 00:31:55');
INSERT INTO `m_registration` VALUES (44, 'REG/0000022', '', '', '', '', '', '', '', '', '', '0000-00-00', '', '', '2020-04-02', '1', '0', '0', '0', NULL, NULL, '2020-04-02 00:33:22');
INSERT INTO `m_registration` VALUES (45, 'REG/0000022', '', '', '', '', '', '', '', '', '', '0000-00-00', '', '', '2020-04-02', '1', '0', '0', '0', NULL, NULL, '2020-04-02 00:33:49');
INSERT INTO `m_registration` VALUES (46, 'REG/0000022', '', '', '', '', '', '', '', '', '', '0000-00-00', '', '', '2020-04-02', '1', '0', '0', '0', NULL, NULL, '2020-04-02 00:34:19');
INSERT INTO `m_registration` VALUES (48, 'REG/0000022', '', '', '', '', '', '', '', '', '', '0000-00-00', '', '', '2020-04-02', '1', '0', '0', '0', NULL, NULL, '2020-04-02 00:37:18');
-- ----------------------------
-- Table structure for sys_entry
-- ----------------------------
DROP TABLE IF EXISTS `sys_entry`;
CREATE TABLE `sys_entry` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`entry` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`url` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`des` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`super` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`main` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`sub` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`class_1` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`class_2` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`color` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`block` varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of sys_entry
-- ----------------------------
INSERT INTO `sys_entry` VALUES (2, 'Registration', 'registration', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `sys_entry` VALUES (3, 'Payment', 'pay', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `sys_entry` VALUES (5, 'Batch', 'batch', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `sys_entry` VALUES (6, 'Course', 'course', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `sys_entry` VALUES (7, 'Content', 'content', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `sys_entry` VALUES (8, 'Faculty', 'faculty', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `sys_entry` VALUES (9, 'Lecturer', 'lecturer', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-- ----------------------------
-- Table structure for sys_info
-- ----------------------------
DROP TABLE IF EXISTS `sys_info`;
CREATE TABLE `sys_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`COM_NAME` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`COM_EMAIL` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`COM_ADD1` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`COM_ADD2` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`COM_TEL1` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`COM_TEL2` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`COM_FAX` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`registration_ref` int(12) NULL DEFAULT NULL,
`payment_ref` int(12) NULL DEFAULT NULL,
`batch_ref` int(12) NULL DEFAULT NULL,
`content_ref` int(12) NULL DEFAULT NULL,
`course_ref` int(12) NULL DEFAULT NULL,
`faculty_ref` int(12) NULL DEFAULT NULL,
`lecturer_ref` int(12) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of sys_info
-- ----------------------------
INSERT INTO `sys_info` VALUES (1, 'Quotro', NULL, NULL, NULL, NULL, NULL, NULL, 23, 6, 8, 2, 4, 3, 2);
-- ----------------------------
-- Table structure for user_mast
-- ----------------------------
DROP TABLE IF EXISTS `user_mast`;
CREATE TABLE `user_mast` (
`user_name` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`password` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`user_type` varchar(40) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`user_depart` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`U_email` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`R_email` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
`user_level` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0',
`dev` varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '0'
) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of user_mast
-- ----------------------------
INSERT INTO `user_mast` VALUES ('admin', '123', 'ADMIN', 'HR', NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('akila', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('akidla', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('akiddla', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('akiladsfds', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('dsfsdfsd', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('akiladsfsdfsdf', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('akilaew', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('mmmy', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('mmy', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('sanjaya', '123', NULL, NULL, NULL, NULL, '0', '0');
INSERT INTO `user_mast` VALUES ('qeew', '963', NULL, NULL, NULL, NULL, '0', '0');
SET FOREIGN_KEY_CHECKS = 1;
|
<reponame>noms-digital-studio/custody-api
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID) VALUES ( -1, TO_DATE('2018-04-23', 'YYYY-MM-DD'), 'REL', 'DD', 1);
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID) VALUES ( -2, TO_DATE('2018-04-19', 'YYYY-MM-DD'), 'REL', 'DD', 2);
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID, EVENT_STATUS) VALUES ( -4, TO_DATE('2018-04-23', 'YYYY-MM-DD'), 'REL', 'DD', 1, 'SCH');
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID) VALUES ( -7, TO_DATE('2018-01-05', 'YYYY-MM-DD'), 'REL', 'DD', 3);
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID) VALUES ( -9, TO_DATE('2018-01-13', 'YYYY-MM-DD'), 'REL', 'DD', 4);
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID) VALUES (-17, TO_DATE('2018-01-16', 'YYYY-MM-DD'), 'REL', 'DD', 5);
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID) VALUES (-24, TO_DATE('2022-02-02', 'YYYY-MM-DD'), 'REL', 'DD', 6);
INSERT INTO OFFENDER_RELEASE_DETAILS (OFFENDER_BOOK_ID, RELEASE_DATE, MOVEMENT_TYPE, MOVEMENT_REASON_CODE, EVENT_ID) VALUES (-25, TO_DATE('2023-03-03', 'YYYY-MM-DD'), 'REL', 'DD', 7);
|
ALTER TABLE `cqdata`.`stats` CHANGE COLUMN `target` `target` TEXT NULL DEFAULT NULL ;
|
SELECT count(*) FROM pTab
SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1
CREATE TABLE Ex1(c1 int, c2 int, c3 text)
SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)
CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
SELECT col FROM tbl);
CREATE TABLE ex1(** a INTEGER PRIMARY KEY,** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x)** )
SELECT a, b FROM tbl WHERE a = 1;
CREATE TABLE %Q.sqlite_sequence(name,seq)
CREATE INDEX i3 ON t1(c);
CREATE TABLE sqlite_stat1(tbl, idx, stat)
CREATE TABLE xxx.yyy (...)
CREATE TABLE IF NOT EXISTS topics (\n\ id INTEGER PRIMARY KEY,\n\ topic TEXT,\n\ structure TEXT)
SELECT * FROM t1 WHERE a;
CREATE TABLE p(pk PRIMARY KEY)
SELECT * FROM tab2;
SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)
SELECT ProcessId,CommandLine FROM Win32_Process
SELECT * FROM one;
CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c)
SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid
SELECT * FROM <table2>
SELECT * FROM t1 WHERE a=1 AND b>2;
SELECT * FROM main.' || quote(name) || ';
SELECT name FROM sqlite_master
CREATE INDEX i ON abc(a)', 'def')** -> '
SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;
SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat3
SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1
SELECT * FROM %s
SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?
CREATE INDEX i1 ON t1(a);
CREATE TABLE yyy(...)
SELECT * FROM temp.ex1;
SELECT tbl,idx,stat FROM %Q.sqlite_stat1
None
CREATE TABLE t1(c1 VARIANT)
SELECT id FROM tags)");
SELECT src,dest,srcFull,destFull,mode FROM subscriptions WHERE ((src = %Q AND EXISTS (SELECT NULL FROM live WHERE name=dest)) OR (dest = %Q AND EXISTS (SELECT NULL FROM live WHERE name=src))) UNION SELECT s1.src, s2.dest, s1.srcFull, s2.destFull, NULL FROM subscriptions s1, subscriptions s2, topics t WHERE (s1.dest = t.topic AND s2.src = t.topic AND ((s1.src = %Q AND EXISTS (SELECT NULL FROM live WHERE name=s2.dest)) OR (s2.dest = %Q AND EXISTS (SELECT NULL FROM live WHERE name=s1.src))))
SELECT 1 FROM %Q.'%q_stat' WHERE id=2
SELECT * FROM %Q.%Q
SELECT name FROM sqlite_master
SELECT * FROM <table2>;
SELECT topic FROM topics WHERE topic = %Q
SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL
SELECT size FROM %Q.'%q_docsize' WHERE docid=?
SELECT topic FROM topics WHERE topic = s.src), EXISTS(SELECT topic FROM topics WHERE topic = s.dest), s.mode FROM subscriptions s ORDER BY s.src, s.dest
SELECT * FROM %_segdir WHERE level = ? ORDER BY ...
SELECT * FROM t2, t1 WHERE t2.rowid = t1.a;
None
SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1
SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1
SELECT * FROM t1 WHERE a=0 AND b=0;
SELECT abc FROM (SELECT col AS abc FROM tbl);
CREATE TABLE \"%w\".\"%w_node\"(nodeno INTEGER PRIMARY KEY, data BLOB)
CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE)
SELECT src,dest,srcFull,destFull FROM subscriptions WHERE (src = %Q OR dest= %Q) AND EXISTS (SELECT NULL FROM live WHERE name=src) AND EXISTS (SELECT NULL FROM live WHERE name=dest) UNION SELECT s1.src, s2.dest, s1.srcFull, s2.destFull FROM subscriptions s1, subscriptions s2, topics t WHERE (s1.dest = t.topic AND s2.src = t.topic) AND (s1.src = %Q OR s2.dest = %Q) AND EXISTS (SELECT NULL FROM live WHERE name=s1.src) AND EXISTS (SELECT NULL FROM live WHERE name=s2.dest)
SELECT src,dest,srcFull,destFull,mode FROM subscriptions WHERE ((src = %Q AND (mode IS NOT NULL OR EXISTS (SELECT NULL FROM live WHERE name=dest))) OR (dest = %Q AND (mode IS NOT NULL OR EXISTS (SELECT NULL FROM live WHERE name=src)))) UNION SELECT s1.src, s2.dest, s1.srcFull, s2.destFull, NULL FROM subscriptions s1, subscriptions s2, topics t WHERE (s1.dest = t.topic AND s2.src = t.topic AND ((s1.src = %Q AND EXISTS (SELECT NULL FROM live WHERE name=s2.dest)) OR (s2.dest = %Q AND EXISTS (SELECT NULL FROM live WHERE name=s1.src))))
SELECT data FROM '%q'.'%q_node' WHERE nodeno = :1
CREATE TABLE main.ex1(a)
CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample)
SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?
CREATE TABLE IF NOT EXISTS structures (\n\ name TEXT PRIMARY KEY,\n\ yarp TEXT)
SELECT level FROM %Q.'%q_segdir' GROUP BY level HAVING count(*)>=?
CREATE TABLE IF NOT EXISTS tags (\n\ id INTEGER PRIMARY KEY,\n\ rid INTEGER,\n\ ns TEXT,\n\ name TEXT,\n\ value TEXT)
INSERT INTO table1 VALUES('It''s a happy day!')
CREATE TABLE IF NOT EXISTS live (\n\ id INTEGER PRIMARY KEY,\n\ name TEXT UNIQUE,\n\ stamp DATETIME)
CREATE TABLE t(x PRIMARY KEY, y)
SELECT topic FROM topics WHERE topic = s.src), EXISTS(SELECT topic FROM topics WHERE topic = s.dest), s.mode FROM subscriptions s WHERE s.src = %Q OR s.dest= %Q ORDER BY s.src, s.dest
CREATE TABLE t1(a,b,c,d)
CREATE TABLE t1(a TEXT PRIMARY KEY, b)
SELECT col FROM tbl;
INSERT INTO t1 VALUES(1, 2, 3.1)
SELECT a FROM ex1;
UPDATE tags SET value = %Q WHERE id = %Q
CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample)
CREATE TABLE IF NOT EXISTS subscriptions (\n\ id INTEGER PRIMARY KEY,\n\ src TEXT,\n\ dest TEXT,\n\ srcFull TEXT,\n\ destFull TEXT,\n\ mode TEXT)
CREATE TABLE t(x, y, UNIQUE(x, y))
SELECT sql FROM sqlite_master
SELECT * FROM t1 WHERE (select a from t1);
SELECT * FROM two;
CREATE TABLE IF NOT EXISTS %Q.'%q_stat'" "(id INTEGER PRIMARY KEY, value BLOB)
SELECT id FROM tags WHERE %s
SELECT * FROM main.xxx;
CREATE TABLE NamespaceTable (Id INTEGER PRIMARY KEY,Name TEXT )
CREATE TABLE \"%w\".\"%w_rowid\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB)
SELECT docid FROM ex1 WHERE b MATCH 'one two three';
CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB)
CREATE INDEX i1 ON t1(a,b,a);
CREATE TABLE %Q.%s(%s)
CREATE TABLE IndexFilterTable (FilterAttributeId INTEGER, IndexId INTEGER )
SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ...
CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)
CREATE TABLE \"%w\".\"%w_parent\"(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC
CREATE INDEX i2 ON t1(b);
SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid
SELECT %s FROM structures WHERE name = %Q
CREATE INDEX idx ON t(a,b,c);
CREATE TABLE %Q.'%q_content'(%s)
CREATE TABLE FileNameTable (FolderId INTEGER, Name TEXT, FileId INTEGER, Title TEXT )
CREATE TABLE t1(col INTEGER)
CREATE INDEX Ex2 ON Ex1(c3,c1);
SELECT name FROM sqlite_temp_master
SELECT id, ns, name, value FROM tags WHERE %s
SELECT value FROM %Q.'%q_stat' WHERE id=?
SELECT name, type, sql FROM sqlite_master
SELECT a, b, c FROM tbl WHERE a = 1;
CREATE TABLE t1(a, b)
CREATE TABLE t1(a)
SELECT topic FROM topics
CREATE INDEX statements on
SELECT col FROM tbl;
SELECT * FROM subscriptions WHERE src = %Q OR dest= %Q
SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
CREATE TABLE t1(a PRIMARY KEY)
SELECT optimize(t) FROM t LIMIT 1;
CREATE TABLE x(term, col, documents, occurrences)
SELECT * FROM t1, t2, t3 WHERE ...;
CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)
CREATE TABLE t2(c, d)
|
<reponame>ef-gy/blog
create table fsm(
state integer not null, -- current state
trans char(1), -- transition character
to_ integer, -- new state after transition
final integer not null, -- 1 = the new state is an accepting state, 0 otherwise
check(final in (0,1))
);
create table word(
pos integer not null,
item char(1) not null
);
insert into fsm
(state, trans, to_, final)
values
(1, 'a', 2, 0),
(1, 'b', 3, 0),
(2, 'a', 2, 0),
(2, 'c', 4, 1),
(3, 'b', 3, 0),
(3, 'd', 4, 1);
-- aaaac
insert into word
(pos, item)
values
(1, 'a'),
(2, 'a'),
(3, 'a'),
(4, 'a'),
(5, 'c');
with recursive check_word (curr_state, final, curr_pos) as
(
select m.state as curr_state, m.final as final, w.pos as curr_pos from FSM m, word w where m.state = 1 and w.pos = 1
union all
select m.to_ as curr_state, m.final as final, cw.curr_pos + 1 as curr_pos from check_word cw, FSM m, word w
where m.state = curr_state and w.pos = cw.curr_pos and w.item = m.trans
)
select distinct 'accept' as check from check_word cw where final = 1 and curr_pos >= all (select c.curr_pos from check_word c);
delete from word;
insert into word
(pos, item)
values
(1, 'a'),
(2, 'a'),
(3, 'b'),
(4, 'c'),
(5, 'a');
with recursive check_word (curr_state, final, curr_pos) as
(
select m.state as curr_state, m.final as final, w.pos as curr_pos from FSM m, word w where m.state = 1 and w.pos = 1
union all
select m.to_ as curr_state, m.final as final, cw.curr_pos + 1 as curr_pos from check_word cw, FSM m, word w
where m.state = curr_state and w.pos = cw.curr_pos and w.item = m.trans
)
select distinct 'accept' as check from check_word cw where final = 1 and curr_pos >= all (select c.curr_pos from check_word c); |
DROP TABLE IF EXISTS public.export_all_paris_road_name2 ;
CREATE TABLE IF NOT EXISTS public.export_all_paris_road_name2 AS
SELECT DISTINCT ON (cname) woparis AS road_name
FROM historical_geocoding.rough_localisation
, geohistorical_object.clean_text(normalised_name) AS cname
, regexp_replace( normalised_name, ', paris', '', 'i') AS woparis
WHERE normalised_name ILIKE '%PARIS'
AND numerical_origin_process NOT ILIKE 'jacoubet_paris_quartier'
AND cname NOT ILIKE '%acces %' ;
SELECT *
FROM export_all_paris_road_name2
, regexp_replace( normalised_name, ', paris', '', 'i') AS woparis
WHERE woparis ILIKE '%PARIS%'
ORDER BY normalised_name ASC
LIMIT 100;
SELECT *
FROM export_all_paris_road_name2
LIMIT 100;
COPY export_all_paris_road_name2 TO '/tmp/export_paris_road.csv' |
# 최솟값 구하기
SELECT MIN(DATETIME)
FROM ANIMAL_INS;
|
INSERT INTO comment__category_group (id, description, url, is_quiet) VALUES (701, 'Test Category', '/discussion', 0);
INSERT INTO comment__category (id, group_id, author_user_id, name, description, created_at, deleted_at, sort, is_quiet) VALUES (101, 701, 10144, 'General', 'Description', '2010-10-02 00:00:00', null, null, 0);
INSERT INTO comment__thread (id, category_id, author_user_id, title, created_at, deleted_at, is_quiet) VALUES (201, 101, 164395, 'Thread title', '2013-05-25 14:30:52', null, 0);
INSERT INTO comment__comment (id, thread_id, author_user_id, created_at, updated_at, deleted_at, content) VALUES (301, 201, 164395, '2010-08-04 16:00:00', null, null, 'Comment content');
INSERT INTO comment__comment (id, thread_id, author_user_id, created_at, updated_at, deleted_at, content) VALUES (302, 201, 12345, '2010-08-04 16:36:37', null, null, 'Comment content 2');
INSERT INTO comment__comment (id, thread_id, author_user_id, created_at, updated_at, deleted_at, content) VALUES (351, 201, 10144, '2010-09-05 16:38:45', null, '2010-09-05 16:38:45', 'Deleted comment');
|
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Oct 20, 2020 at 04:51 AM
-- Server version: 5.7.24
-- PHP Version: 7.2.19
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `db_monalisa`
--
-- --------------------------------------------------------
--
-- Table structure for table `captcha`
--
CREATE TABLE `captcha` (
`captcha_id` bigint(13) UNSIGNED NOT NULL,
`captcha_time` int(10) UNSIGNED NOT NULL,
`ip_address` varchar(45) NOT NULL,
`word` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `groups`
--
CREATE TABLE `groups` (
`id` mediumint(8) UNSIGNED NOT NULL,
`name` varchar(20) NOT NULL,
`description` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `groups`
--
INSERT INTO `groups` (`id`, `name`, `description`) VALUES
(1, 'admin', 'Administrator'),
(2, 'members', 'General User');
-- --------------------------------------------------------
--
-- Table structure for table `login_attempts`
--
CREATE TABLE `login_attempts` (
`id` int(11) UNSIGNED NOT NULL,
`ip_address` varchar(45) NOT NULL,
`login` varchar(100) NOT NULL,
`time` int(11) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `login_attempts`
--
INSERT INTO `login_attempts` (`id`, `ip_address`, `login`, `time`) VALUES
(1, '::1', 'admin', 1603163254),
(2, '::1', '<EMAIL>', 1603167295);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) UNSIGNED NOT NULL,
`ip_address` varchar(45) NOT NULL,
`username` varchar(100) DEFAULT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(254) NOT NULL,
`activation_selector` varchar(255) DEFAULT NULL,
`activation_code` varchar(255) DEFAULT NULL,
`forgotten_password_selector` varchar(255) DEFAULT NULL,
`forgotten_password_code` varchar(255) DEFAULT NULL,
`forgotten_password_time` int(11) UNSIGNED DEFAULT NULL,
`remember_selector` varchar(255) DEFAULT NULL,
`remember_code` varchar(255) DEFAULT NULL,
`created_on` int(11) UNSIGNED NOT NULL,
`last_login` int(11) UNSIGNED DEFAULT NULL,
`active` tinyint(1) UNSIGNED DEFAULT NULL,
`first_name` varchar(50) DEFAULT NULL,
`last_name` varchar(50) DEFAULT NULL,
`company` varchar(100) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `ip_address`, `username`, `password`, `email`, `activation_selector`, `activation_code`, `forgotten_password_selector`, `forgotten_password_code`, `forgotten_password_time`, `remember_selector`, `remember_code`, `created_on`, `last_login`, `active`, `first_name`, `last_name`, `company`, `phone`) VALUES
(1, '127.0.0.1', 'administrator', '$2y$12$60KRcp.03u3vf6uAoK4a0OEsYdpfTk47wpFQJ7JNi1FIlCFDOWEH.', '<EMAIL>', NULL, '', NULL, NULL, NULL, NULL, NULL, 1268889823, 1603167392, 1, 'Admin', 'istrator', 'ADMIN', '0');
-- --------------------------------------------------------
--
-- Table structure for table `users_groups`
--
CREATE TABLE `users_groups` (
`id` int(11) UNSIGNED NOT NULL,
`user_id` int(11) UNSIGNED NOT NULL,
`group_id` mediumint(8) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `users_groups`
--
INSERT INTO `users_groups` (`id`, `user_id`, `group_id`) VALUES
(1, 1, 1),
(2, 1, 2);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `captcha`
--
ALTER TABLE `captcha`
ADD PRIMARY KEY (`captcha_id`),
ADD KEY `word` (`word`);
--
-- Indexes for table `groups`
--
ALTER TABLE `groups`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `login_attempts`
--
ALTER TABLE `login_attempts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uc_email` (`email`),
ADD UNIQUE KEY `uc_activation_selector` (`activation_selector`),
ADD UNIQUE KEY `uc_forgotten_password_selector` (`forgotten_password_selector`),
ADD UNIQUE KEY `uc_remember_selector` (`remember_selector`);
--
-- Indexes for table `users_groups`
--
ALTER TABLE `users_groups`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `uc_users_groups` (`user_id`,`group_id`),
ADD KEY `fk_users_groups_users1_idx` (`user_id`),
ADD KEY `fk_users_groups_groups1_idx` (`group_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `captcha`
--
ALTER TABLE `captcha`
MODIFY `captcha_id` bigint(13) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `groups`
--
ALTER TABLE `groups`
MODIFY `id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `login_attempts`
--
ALTER TABLE `login_attempts`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `users_groups`
--
ALTER TABLE `users_groups`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `users_groups`
--
ALTER TABLE `users_groups`
ADD CONSTRAINT `fk_users_groups_groups1` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_users_groups_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<reponame>difo23/bd_sql_practico_postgres
/**
* RETO: Extraer los campos de hora de una fecha
*/
-- Extract --
SELECT EXTRACT(HOUR FROM fecha_incorporacion) AS hora_incorporacion,
EXTRACT(MINUTE FROM fecha_incorporacion) AS minuto_incorporacion,
EXTRACT(SECOND FROM fecha_incorporacion) AS segundo_incorporacion
FROM platzi.alumnos;
-- Date_Part --
SELECT DATE_PART('HOUR', fecha_incorporacion) AS hora_incorporacion,
DATE_PART('MINUTE', fecha_incorporacion) AS minuto_incorporacion,
DATE_PART('SECOND', fecha_incorporacion) AS segundo_incorporacion
FROM platzi.alumnos;
/**
* Filtrar los alumnos que se inscribieron en 2019
*/
-- Filtro EXTRACT --
SELECT *
FROM platzi.alumnos
WHERE (EXTRACT(YEAR FROM fecha_incorporacion)) = 2019;
-- Filtro DATE_PART --
SELECT *
FROM platzi.alumnos
WHERE (DATE_PART('YEAR', fecha_incorporacion)) = 2019;
-- Filtro subquery DATE_PART --
SELECT *
FROM (
SELECT *,
DATE_PART('YEAR', fecha_incorporacion) AS anio_incorporacion
FROM platzi.alumnos
) AS alumnos_con_anio_mes
WHERE anio_incorporacion = 2019;
|
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MetricValueStats](
[ServerID] [int] NOT NULL,
[MetricSetID] [int] NOT NULL,
[MetricID] [int] NOT NULL,
[GrHours] [tinyint] NOT NULL,
[GrNumber] [tinyint] NOT NULL,
[DayInWeek] [tinyint] NOT NULL,
[StartTimeID] [smallint] NOT NULL,
[EndTimeID] [smallint] NOT NULL,
[Value_Lo] [float] NOT NULL,
[Value_Hi] [float] NOT NULL,
[Value_Avg] [float] NOT NULL,
[Value_Std] [float] NOT NULL,
CONSTRAINT [PK_MetricValueStats] PRIMARY KEY CLUSTERED
(
[ServerID] ASC,
[MetricSetID] ASC,
[MetricID] ASC,
[GrHours] ASC,
[DayInWeek] ASC,
[StartTimeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [Stats]
) ON [Stats]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [FK_MetricValueStats_MetricSets] FOREIGN KEY([MetricSetID])
REFERENCES [dbo].[MetricSets] ([ID])
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [FK_MetricValueStats_MetricSets]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [FK_MetricValueStats_Metrics] FOREIGN KEY([MetricID])
REFERENCES [dbo].[Metrics] ([ID])
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [FK_MetricValueStats_Metrics]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [FK_MetricValueStats_Servers] FOREIGN KEY([ServerID])
REFERENCES [dbo].[Servers] ([ID])
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [FK_MetricValueStats_Servers]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [FK_MetricValueStats_Times] FOREIGN KEY([StartTimeID])
REFERENCES [dbo].[Times] ([ID])
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [FK_MetricValueStats_Times]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [FK_MetricValueStats_TimesEnd] FOREIGN KEY([EndTimeID])
REFERENCES [dbo].[Times] ([ID])
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [FK_MetricValueStats_TimesEnd]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [CK_MetricValueStats_DayInWeek] CHECK (([DayInWeek]>=(1) AND [DayInWeek]<=(7)))
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [CK_MetricValueStats_DayInWeek]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [CK_MetricValueStats_GrHours] CHECK (([GrHours]=(12) OR [GrHours]=(8) OR [GrHours]=(6) OR [GrHours]=(4) OR [GrHours]=(2) OR [GrHours]=(1) OR [GrHours]=(0)))
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [CK_MetricValueStats_GrHours]
GO
ALTER TABLE [dbo].[MetricValueStats] WITH CHECK ADD CONSTRAINT [CK_MetricValueStats_GrNumber] CHECK (([GrNumber]>=(0) AND [GrNumber]<=(23)))
GO
ALTER TABLE [dbo].[MetricValueStats] CHECK CONSTRAINT [CK_MetricValueStats_GrNumber]
GO
|
-- fts4aa.test
--
-- db eval {
-- DELETE FROM t1 WHERE docid!=1050026;
-- SELECT hex(size) FROM t1_docsize;
-- SELECT hex(value) FROM t1_stat;
-- }
DELETE FROM t1 WHERE docid!=1050026;
SELECT hex(size) FROM t1_docsize;
SELECT hex(value) FROM t1_stat; |
<filename>src/test/resources/sql/select/60e90d5b.sql
-- file:float8.sql ln:42 expect:true
SELECT 'nan'::float8 / 'nan'::float8
|
-- file:regex.linux.utf8.sql ln:34 expect:true
SELECT 'a⓪' ~ 'a[a-ⓩ]' AS f
|
<reponame>xlm1226/A-Definitive-Guide-to-Apache-ShardingSphere
INSERT INTO table_name (column1,...) VALUES (value1...) /*foo:bar,...*/;
|
CREATE TABLE auth_tokens
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
user BIGINT,
token TEXT,
expiration BIGINT,
created BIGINT
) |
<reponame>GrantBirki/iphonebackuptools
CREATE TABLE ZACCOUNT (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZDIDCHOOSETOMIGRATE INTEGER,
ZTYPE INTEGER,
ZDEFAULTSTORE INTEGER,
ZACCOUNTIDENTIFIER VARCHAR,
ZCONSTRAINTSPATH VARCHAR,
ZNAME VARCHAR );
CREATE TABLE ZNEXTID (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZCOUNTER INTEGER );
CREATE TABLE ZNOTE (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZCONTAINSCJK INTEGER,
ZCONTENTTYPE INTEGER,
ZDELETEDFLAG INTEGER,
ZEXTERNALFLAGS INTEGER,
ZEXTERNALSEQUENCENUMBER INTEGER,
ZEXTERNALSERVERINTID INTEGER,
ZINTEGERID INTEGER,
ZISBOOKKEEPINGENTRY INTEGER,
ZBODY INTEGER,
ZSTORE INTEGER,
ZCREATIONDATE TIMESTAMP,
ZMODIFICATIONDATE TIMESTAMP,
ZAUTHOR VARCHAR,
ZGUID VARCHAR,
ZSERVERID VARCHAR,
ZSUMMARY VARCHAR,
ZTITLE VARCHAR );
CREATE TABLE ZNOTEATTACHMENT (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZNOTE INTEGER,
ZCONTENTID VARCHAR,
ZFILENAME VARCHAR,
ZMIMETYPE VARCHAR );
CREATE TABLE ZNOTEBODY (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZOWNER INTEGER,
ZCONTENT VARCHAR,
ZEXTERNALCONTENTREF VARCHAR,
ZEXTERNALREPRESENTATION BLOB );
CREATE TABLE ZNOTECHANGE (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZCHANGETYPE INTEGER,
ZSTORE INTEGER,
ZNOTEINTEGERIDS BLOB,
ZNOTESERVERIDS BLOB,
ZNOTESERVERINTIDS BLOB );
CREATE TABLE ZPROPERTY (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZPROPERTYKEY VARCHAR,
ZPROPERTYVALUE BLOB );
CREATE TABLE ZSTORE (
Z_PK INTEGER PRIMARY KEY,
Z_ENT INTEGER,
Z_OPT INTEGER,
ZACCOUNT INTEGER,
ZEXTERNALIDENTIFIER VARCHAR,
ZNAME VARCHAR,
ZSYNCANCHOR VARCHAR );
CREATE INDEX ZACCOUNT_ZDEFAULTSTORE_INDEX ON ZACCOUNT (ZDEFAULTSTORE);
CREATE INDEX ZNOTE_ZINTEGERID_INDEX ON ZNOTE (ZINTEGERID);
CREATE INDEX ZNOTE_ZBODY_INDEX ON ZNOTE (ZBODY);
CREATE INDEX ZNOTE_ZSTORE_INDEX ON ZNOTE (ZSTORE);
CREATE INDEX ZNOTEATTACHMENT_ZNOTE_INDEX ON ZNOTEATTACHMENT (ZNOTE);
CREATE INDEX ZNOTEBODY_ZOWNER_INDEX ON ZNOTEBODY (ZOWNER);
CREATE INDEX ZNOTECHANGE_ZSTORE_INDEX ON ZNOTECHANGE (ZSTORE);
CREATE INDEX ZSTORE_ZACCOUNT_INDEX ON ZSTORE (ZACCOUNT);
CREATE TABLE Z_PRIMARYKEY (
Z_ENT INTEGER PRIMARY KEY,
Z_NAME VARCHAR,
Z_SUPER INTEGER,
Z_MAX INTEGER);
CREATE TABLE Z_METADATA (
Z_VERSION INTEGER PRIMARY KEY,
Z_UUID VARCHAR(255),
Z_PLIST BLOB);
CREATE TABLE Z_MODELCACHE (
Z_CONTENT BLOB);
|
IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL
BEGIN
CREATE TABLE [__EFMigrationsHistory] (
[MigrationId] nvarchar(150) NOT NULL,
[ProductVersion] nvarchar(32) NOT NULL,
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
);
END;
BEGIN TRANSACTION;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [AspNetRoles] (
[Id] nvarchar(450) NOT NULL,
[Name] nvarchar(256) NULL,
[NormalizedName] nvarchar(256) NULL,
[ConcurrencyStamp] nvarchar(max) NULL,
CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [AspNetUsers] (
[Id] nvarchar(450) NOT NULL,
[UserName] nvarchar(256) NULL,
[NormalizedUserName] nvarchar(256) NULL,
[Email] nvarchar(256) NULL,
[NormalizedEmail] nvarchar(256) NULL,
[EmailConfirmed] bit NOT NULL,
[PasswordHash] nvarchar(max) NULL,
[SecurityStamp] nvarchar(max) NULL,
[ConcurrencyStamp] nvarchar(max) NULL,
[PhoneNumber] nvarchar(max) NULL,
[PhoneNumberConfirmed] bit NOT NULL,
[TwoFactorEnabled] bit NOT NULL,
[LockoutEnd] datetimeoffset NULL,
[LockoutEnabled] bit NOT NULL,
[AccessFailedCount] int NOT NULL,
CONSTRAINT [PK_AspNetUsers] PRIMARY KEY ([Id])
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [OpenIddictApplications] (
[Id] uniqueidentifier NOT NULL,
[ClientId] nvarchar(100) NULL,
[ClientSecret] nvarchar(max) NULL,
[ConcurrencyToken] nvarchar(50) NULL,
[ConsentType] nvarchar(50) NULL,
[DisplayName] nvarchar(max) NULL,
[DisplayNames] nvarchar(max) NULL,
[Permissions] nvarchar(max) NULL,
[PostLogoutRedirectUris] nvarchar(max) NULL,
[Properties] nvarchar(max) NULL,
[RedirectUris] nvarchar(max) NULL,
[Requirements] nvarchar(max) NULL,
[Type] nvarchar(50) NULL,
CONSTRAINT [PK_OpenIddictApplications] PRIMARY KEY ([Id])
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [OpenIddictScopes] (
[Id] uniqueidentifier NOT NULL,
[ConcurrencyToken] nvarchar(50) NULL,
[Description] nvarchar(max) NULL,
[Descriptions] nvarchar(max) NULL,
[DisplayName] nvarchar(max) NULL,
[DisplayNames] nvarchar(max) NULL,
[Name] nvarchar(200) NULL,
[Properties] nvarchar(max) NULL,
[Resources] nvarchar(max) NULL,
CONSTRAINT [PK_OpenIddictScopes] PRIMARY KEY ([Id])
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [AspNetRoleClaims] (
[Id] int NOT NULL IDENTITY,
[RoleId] nvarchar(450) NOT NULL,
[ClaimType] nvarchar(max) NULL,
[ClaimValue] nvarchar(max) NULL,
CONSTRAINT [PK_AspNetRoleClaims] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AspNetRoleClaims_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [AspNetUserClaims] (
[Id] int NOT NULL IDENTITY,
[UserId] nvarchar(450) NOT NULL,
[ClaimType] nvarchar(max) NULL,
[ClaimValue] nvarchar(max) NULL,
CONSTRAINT [PK_AspNetUserClaims] PRIMARY KEY ([Id]),
CONSTRAINT [FK_AspNetUserClaims_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [AspNetUserLogins] (
[LoginProvider] nvarchar(450) NOT NULL,
[ProviderKey] nvarchar(450) NOT NULL,
[ProviderDisplayName] nvarchar(max) NULL,
[UserId] nvarchar(450) NOT NULL,
CONSTRAINT [PK_AspNetUserLogins] PRIMARY KEY ([LoginProvider], [ProviderKey]),
CONSTRAINT [FK_AspNetUserLogins_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [AspNetUserRoles] (
[UserId] nvarchar(450) NOT NULL,
[RoleId] nvarchar(450) NOT NULL,
CONSTRAINT [PK_AspNetUserRoles] PRIMARY KEY ([UserId], [RoleId]),
CONSTRAINT [FK_AspNetUserRoles_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE,
CONSTRAINT [FK_AspNetUserRoles_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [AspNetUserTokens] (
[UserId] nvarchar(450) NOT NULL,
[LoginProvider] nvarchar(450) NOT NULL,
[Name] nvarchar(450) NOT NULL,
[Value] nvarchar(max) NULL,
CONSTRAINT [PK_AspNetUserTokens] PRIMARY KEY ([UserId], [LoginProvider], [Name]),
CONSTRAINT [FK_AspNetUserTokens_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [OpenIddictAuthorizations] (
[Id] uniqueidentifier NOT NULL,
[ApplicationId] uniqueidentifier NULL,
[ConcurrencyToken] nvarchar(50) NULL,
[CreationDate] datetime2 NULL,
[Properties] nvarchar(max) NULL,
[Scopes] nvarchar(max) NULL,
[Status] nvarchar(50) NULL,
[Subject] nvarchar(400) NULL,
[Type] nvarchar(50) NULL,
CONSTRAINT [PK_OpenIddictAuthorizations] PRIMARY KEY ([Id]),
CONSTRAINT [FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId] FOREIGN KEY ([ApplicationId]) REFERENCES [OpenIddictApplications] ([Id]) ON DELETE NO ACTION
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE TABLE [OpenIddictTokens] (
[Id] uniqueidentifier NOT NULL,
[ApplicationId] uniqueidentifier NULL,
[AuthorizationId] uniqueidentifier NULL,
[ConcurrencyToken] nvarchar(50) NULL,
[CreationDate] datetime2 NULL,
[ExpirationDate] datetime2 NULL,
[Payload] nvarchar(max) NULL,
[Properties] nvarchar(max) NULL,
[RedemptionDate] datetime2 NULL,
[ReferenceId] nvarchar(100) NULL,
[Status] nvarchar(50) NULL,
[Subject] nvarchar(400) NULL,
[Type] nvarchar(50) NULL,
CONSTRAINT [PK_OpenIddictTokens] PRIMARY KEY ([Id]),
CONSTRAINT [FK_OpenIddictTokens_OpenIddictApplications_ApplicationId] FOREIGN KEY ([ApplicationId]) REFERENCES [OpenIddictApplications] ([Id]) ON DELETE NO ACTION,
CONSTRAINT [FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId] FOREIGN KEY ([AuthorizationId]) REFERENCES [OpenIddictAuthorizations] ([Id]) ON DELETE NO ACTION
);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [IX_AspNetRoleClaims_RoleId] ON [AspNetRoleClaims] ([RoleId]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
EXEC(N'CREATE UNIQUE INDEX [RoleNameIndex] ON [AspNetRoles] ([NormalizedName]) WHERE [NormalizedName] IS NOT NULL');
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [IX_AspNetUserClaims_UserId] ON [AspNetUserClaims] ([UserId]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [IX_AspNetUserLogins_UserId] ON [AspNetUserLogins] ([UserId]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [IX_AspNetUserRoles_RoleId] ON [AspNetUserRoles] ([RoleId]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [EmailIndex] ON [AspNetUsers] ([NormalizedEmail]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
EXEC(N'CREATE UNIQUE INDEX [UserNameIndex] ON [AspNetUsers] ([NormalizedUserName]) WHERE [NormalizedUserName] IS NOT NULL');
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
EXEC(N'CREATE UNIQUE INDEX [IX_OpenIddictApplications_ClientId] ON [OpenIddictApplications] ([ClientId]) WHERE [ClientId] IS NOT NULL');
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type] ON [OpenIddictAuthorizations] ([ApplicationId], [Status], [Subject], [Type]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
EXEC(N'CREATE UNIQUE INDEX [IX_OpenIddictScopes_Name] ON [OpenIddictScopes] ([Name]) WHERE [Name] IS NOT NULL');
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [IX_OpenIddictTokens_ApplicationId_Status_Subject_Type] ON [OpenIddictTokens] ([ApplicationId], [Status], [Subject], [Type]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
CREATE INDEX [IX_OpenIddictTokens_AuthorizationId] ON [OpenIddictTokens] ([AuthorizationId]);
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
EXEC(N'CREATE UNIQUE INDEX [IX_OpenIddictTokens_ReferenceId] ON [OpenIddictTokens] ([ReferenceId]) WHERE [ReferenceId] IS NOT NULL');
END;
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20210904153137_CreateOpenIddictModels')
BEGIN
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20210904153137_CreateOpenIddictModels', N'5.0.9');
END;
COMMIT;
|
# ************************************************************
# Sequel Pro SQL dump
# Version 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.5.52-0ubuntu0.14.04.1)
# Database: lingyun_lyadmin
# Generation Time: 2017-10-24 16:43:32 +0000
# ************************************************************
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
# Dump of table ly_admin_access
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_access`;
CREATE TABLE `ly_admin_access` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '管理员ID',
`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`group` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '管理员用户组',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='后台管理员与用户组对应关系表';
LOCK TABLES `ly_admin_access` WRITE;
/*!40000 ALTER TABLE `ly_admin_access` DISABLE KEYS */;
INSERT INTO `ly_admin_access` (`id`, `uid`, `group`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,1,1,1438651748,1438651748,0,1);
/*!40000 ALTER TABLE `ly_admin_access` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_admin_addon
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_addon`;
CREATE TABLE `ly_admin_addon` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(32) DEFAULT NULL COMMENT '插件名或标识',
`title` varchar(32) NOT NULL DEFAULT '' COMMENT '中文名',
`description` text NOT NULL COMMENT '插件描述',
`logo` varchar(63) NOT NULL DEFAULT '' COMMENT '图片图标',
`icon` varchar(31) NOT NULL DEFAULT '' COMMENT '图标',
`icon_color` varchar(7) NOT NULL DEFAULT '' COMMENT '图标颜色',
`config` text COMMENT '配置',
`author` varchar(32) NOT NULL DEFAULT '' COMMENT '作者',
`version` varchar(8) NOT NULL DEFAULT '' COMMENT '版本号',
`adminlist` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '是否有后台列表',
`type` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '插件类型',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '安装时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='插件表';
# Dump of table ly_admin_config
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_config`;
CREATE TABLE `ly_admin_config` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '配置ID',
`title` varchar(32) NOT NULL DEFAULT '' COMMENT '配置标题',
`name` varchar(32) DEFAULT NULL COMMENT '配置名称',
`value` text NOT NULL COMMENT '配置值',
`group` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '配置分组',
`type` varchar(16) NOT NULL DEFAULT '' COMMENT '配置类型',
`options` varchar(255) NOT NULL DEFAULT '' COMMENT '配置额外值',
`tip` varchar(100) NOT NULL DEFAULT '' COMMENT '配置说明',
`is_dev` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否开发模式才显示',
`is_system` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否系统配置',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`sort` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统配置表';
LOCK TABLES `ly_admin_config` WRITE;
/*!40000 ALTER TABLE `ly_admin_config` DISABLE KEYS */;
INSERT INTO `ly_admin_config` (`id`, `title`, `name`, `value`, `group`, `type`, `options`, `tip`, `is_dev`, `is_system`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,'站点开关','TOGGLE_WEB_SITE','1',1,'toggle','0:关闭\r\n1:开启','站点关闭后将不能访问',0,1,1378898976,1406992386,1,1),
(2,'网站标题','WEB_SITE_TITLE','零云lyadmin',1,'text','','网站标题前台显示标题',0,1,1378898976,1379235274,2,1),
(3,'网站口号','WEB_SITE_SLOGAN','轻量级通用后台',1,'text','','网站口号、宣传标语、一句话介绍',0,1,1434081649,1434081649,3,1),
(4,'网站LOGO','WEB_SITE_LOGO','',1,'picture','','网站LOGO',0,1,1407003397,1407004692,4,1),
(5,'网站反色LOGO','WEB_SITE_LOGO_INVERSE','',1,'picture','','匹配深色背景上的LOGO',0,1,1476700797,1476700797,5,1),
(6,'网站描述','WEB_SITE_DESCRIPTION','lyadmin是一套轻量级通用后台,追求简单、高效、卓越。可轻松实现支持多终端的WEB产品快速搭建、部署、上线。系统功能采用模块化、组件化、插件化等开放化低耦合设计,应用商城拥有丰富的功能模块、插件、主题,便于用户灵活扩展和二次开发。',1,'textarea','','网站搜索引擎描述',0,1,1378898976,1379235841,6,1),
(7,'网站关键字','WEB_SITE_KEYWORD','零云,新一代云平台,微信小程序开发,微信应用号开发,零云网络,零云科技,零云CMF,零云OA,OpenCMF,CoreThink,南京科斯克网络科技,corethink官网,corethink手册,php框架,web框架,网站开发,php教程,php开发,开源php框架,零云科技,域名注册,零云短租,零云商城,零云Docker,零云金融,零云贷,零云搜,零云视频,零云教育,零云在线,零云钱包,零云支付,零云IM,零云CMF',1,'textarea','','网站搜索引擎关键字',0,1,1378898976,1381390100,7,1),
(8,'版权信息','WEB_SITE_COPYRIGHT','Copyright © 南京科斯克网络科技有限公司 All rights reserved.',1,'text','','设置在网站底部显示的版权信息,如“版权所有 © 2014-2015 科斯克网络科技”',0,1,1406991855,1406992583,8,1),
(9,'网站备案号','WEB_SITE_ICP','苏ICP备1502009号',1,'text','','设置在网站底部显示的备案号,如“苏ICP备1502009号\"',0,1,1378900335,1415983236,9,1),
(10,'站点统计','WEB_SITE_STATISTICS','',1,'textarea','','支持百度、Google、cnzz等所有Javascript的统计代码',0,1,1378900335,1415983236,10,1),
(11,'公司名称','COMPANY_TITLE','南京科斯克网络科技有限公司',3,'text','','',0,1,1481014715,1481014715,1,1),
(12,'公司地址','COMPANY_ADDRESS','南京市鼓楼区广东路38号',3,'text','','',0,1,1481014768,1481014768,2,1),
(13,'公司邮箱','COMPANY_EMAIL','<EMAIL>',3,'text','','',0,1,1481014914,1481014914,3,1),
(14,'公司电话','COMPANY_PHONE','15005173785',3,'text','','',0,1,1481014961,1481014961,4,1),
(15,'公司QQ','COMPANY_QQ','209216005',3,'text','','',0,1,1481015016,1481015016,5,1),
(16,'公司QQ群','COMPANY_QQQUN','105108204',3,'text','','',0,1,1481015198,1481015198,6,1),
(17,'网站二维码','QR_CODE','',3,'picture','','',0,1,1481009623,1481009623,7,1),
(18,'IOS二维码','QR_IOS','',3,'picture','','',0,1,1481009623,1481009623,8,1),
(19,'安卓二维码','QR_ANDROID','',3,'picture','','',0,1,1481009921,1481009921,9,1),
(20,'微信公众号二维码','QR_WEIXIN','',3,'picture','','',0,1,1481009959,1481009959,10,1),
(21,'微信小程序二维码','QR_WEIXIN_APP','',3,'picture','','',0,1,1481009959,1481009959,11,1),
(22,'文件上传大小','UPLOAD_FILE_SIZE','2',5,'num','','文件上传大小单位:MB',0,1,1428681031,1428681031,1,1),
(23,'图片上传大小','UPLOAD_IMAGE_SIZE','0.5',5,'num','','图片上传大小单位:MB',0,1,1428681071,1428681071,2,1),
(25,'分页数量','ADMIN_PAGE_ROWS','10',5,'num','','分页时每页的记录数',1,1,1434019462,1434019481,4,1),
(26,'后台主题','ADMIN_THEME','admin',5,'select','admin:默认主题\r\naliyun:阿里云风格\r\ngreen:绿色生活\r\nweixin:微信风格\r\nred:红色风格\r\npink:粉色风格','后台界面主题',0,1,1436678171,1436690570,5,1),
(27,'导航分组','NAV_GROUP_LIST','top:顶部导航\r\nmain:主导航\r\nbottom:底部导航',5,'array','','导航分组',1,1,1458382037,1458382061,6,1),
(28,'配置分组','CONFIG_GROUP_LIST','1:基本\r\n3:扩展\r\n5:系统\r\n7:部署\r\n99:授权',5,'array','','配置分组',1,1,1379228036,1426930700,7,1),
(29,'开发模式','DEVELOP_MODE','1',7,'toggle','1:开启\r\n0:关闭','开发模式下会显示菜单管理、配置管理、数据字典等开发者工具',0,1,1432393583,1432393583,1,1),
(30,'页面Trace','APP_TRACE','0',7,'toggle','0:关闭\r\n1:开启','是否显示页面Trace信息',1,1,1387165685,1387165685,2,1),
(31,'URL模式','URL_MODEL','3',7,'select','1:PATHINFO模式\r\n2:REWRITE模式\r\n3:兼容模式','',1,1,1438423248,1438423248,3,1),
(34,'默认模块','DEFAULT_MODULE','Site',7,'select','callback:D(\'Admin/Module\')->getNameList','',1,1,1471458914,1471458914,6,1),
(41,'百度地图AK','BDMAP_AK','',7,'text','','百度地图密钥',1,1,1490673564,1490673564,13,1),
(42,'官网账号','AUTH_USERNAME','trial',99,'text','','官网登陆账号(用户名)',0,1,1438647815,1438647815,1,1),
(43,'官网密码','AUTH_PASSWORD','<PASSWORD>',99,'text','','官网密码',0,1,1438647815,1438647815,2,1),
(44,'密钥','AUTH_SN','',99,'textarea','','密钥请通过登陆官网至个人中心获取',0,1,1438647815,1438647815,3,1);
/*!40000 ALTER TABLE `ly_admin_config` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_admin_group
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_group`;
CREATE TABLE `ly_admin_group` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '部门ID',
`pid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上级部门ID',
`title` varchar(31) NOT NULL DEFAULT '' COMMENT '部门名称',
`icon` varchar(31) NOT NULL DEFAULT '' COMMENT '图标',
`menu_auth` text NOT NULL COMMENT '权限列表',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '排序(同级有效)',
`status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='部门信息表';
LOCK TABLES `ly_admin_group` WRITE;
/*!40000 ALTER TABLE `ly_admin_group` DISABLE KEYS */;
INSERT INTO `ly_admin_group` (`id`, `pid`, `title`, `icon`, `menu_auth`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,0,'超级管理员','','',1426881003,1427552428,0,1);
/*!40000 ALTER TABLE `ly_admin_group` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_admin_hook
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_hook`;
CREATE TABLE `ly_admin_hook` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '钩子ID',
`name` varchar(32) DEFAULT NULL COMMENT '钩子名称',
`description` text NOT NULL COMMENT '描述',
`addons` varchar(255) NOT NULL DEFAULT '' COMMENT '钩子挂载的插件',
`type` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '类型',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='钩子表';
LOCK TABLES `ly_admin_hook` WRITE;
/*!40000 ALTER TABLE `ly_admin_hook` DISABLE KEYS */;
INSERT INTO `ly_admin_hook` (`id`, `name`, `description`, `addons`, `type`, `create_time`, `update_time`, `status`)
VALUES
(1,'AdminIndex','后台首页小工具','后台首页小工具',1,1446522155,1446522155,1),
(2,'FormBuilderExtend','FormBuilder类型扩展Builder','',1,1447831268,1447831268,1),
(3,'UploadFile','上传文件钩子','',1,1407681961,1407681961,1),
(4,'PageHeader','页面header钩子,一般用于加载插件CSS文件和代码','',1,1407681961,1407681961,1),
(5,'PageFooter','页面footer钩子,一般用于加载插件CSS文件和代码','',1,1407681961,1407681961,1),
(6,'CommonHook','通用钩子,自定义用途,一般用来定制特殊功能','',1,1456147822,1456147822,1);
/*!40000 ALTER TABLE `ly_admin_hook` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_admin_module
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_module`;
CREATE TABLE `ly_admin_module` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(31) DEFAULT NULL COMMENT '名称',
`title` varchar(63) NOT NULL DEFAULT '' COMMENT '标题',
`logo` varchar(63) NOT NULL DEFAULT '' COMMENT '图片图标',
`icon` varchar(31) NOT NULL DEFAULT '' COMMENT '字体图标',
`icon_color` varchar(7) NOT NULL DEFAULT '' COMMENT '字体图标颜色',
`description` varchar(127) NOT NULL DEFAULT '' COMMENT '描述',
`developer` varchar(31) NOT NULL DEFAULT '' COMMENT '开发者',
`version` varchar(7) NOT NULL DEFAULT '' COMMENT '版本',
`user_nav` text NOT NULL COMMENT '个人中心导航',
`home_nav` text COMMENT '个人主页导航',
`config` text NOT NULL COMMENT '配置',
`admin_menu` text NOT NULL COMMENT '菜单节点',
`router` text COMMENT '路由规则',
`is_system` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否允许卸载',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='模块功能表';
LOCK TABLES `ly_admin_module` WRITE;
/*!40000 ALTER TABLE `ly_admin_module` DISABLE KEYS */;
INSERT INTO `ly_admin_module` (`id`, `name`, `title`, `logo`, `icon`, `icon_color`, `description`, `developer`, `version`, `user_nav`, `home_nav`, `config`, `admin_menu`, `router`, `is_system`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,'Admin','系统','','fa fa-cog','#3CA6F1','核心系统','南京科斯克网络科技有限公司','1.6.2','','','','{\"1\":{\"pid\":\"0\",\"title\":\"\\u7cfb\\u7edf\",\"icon\":\"fa fa-cog\",\"level\":\"system\",\"id\":\"1\"},\"2\":{\"pid\":\"1\",\"title\":\"\\u7cfb\\u7edf\\u529f\\u80fd\",\"icon\":\"fa fa-folder-open-o\",\"id\":\"2\"},\"3\":{\"pid\":\"2\",\"title\":\"\\u7cfb\\u7edf\\u8bbe\\u7f6e\",\"icon\":\"fa fa-wrench\",\"url\":\"Admin\\/Config\\/group\",\"id\":\"3\"},\"4\":{\"pid\":\"3\",\"title\":\"\\u4fee\\u6539\\u8bbe\\u7f6e\",\"url\":\"Admin\\/Config\\/groupSave\",\"id\":\"4\"},\"5\":{\"pid\":\"2\",\"title\":\"\\u5bfc\\u822a\\u7ba1\\u7406\",\"icon\":\"fa fa-map-signs\",\"url\":\"Admin\\/Nav\\/index\",\"id\":\"5\"},\"6\":{\"pid\":\"5\",\"title\":\"\\u65b0\\u589e\",\"url\":\"Admin\\/Nav\\/add\",\"id\":\"6\"},\"7\":{\"pid\":\"5\",\"title\":\"\\u7f16\\u8f91\",\"url\":\"Admin\\/Nav\\/edit\",\"id\":\"7\"},\"8\":{\"pid\":\"5\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Nav\\/setStatus\",\"id\":\"8\"},\"9\":{\"pid\":\"2\",\"title\":\"\\u5e7b\\u706f\\u7ba1\\u7406\",\"icon\":\"fa fa-image\",\"url\":\"Admin\\/Slider\\/index\",\"id\":\"9\"},\"10\":{\"pid\":\"9\",\"title\":\"\\u65b0\\u589e\",\"url\":\"Admin\\/Slider\\/add\",\"id\":\"10\"},\"11\":{\"pid\":\"9\",\"title\":\"\\u7f16\\u8f91\",\"url\":\"Admin\\/Slider\\/edit\",\"id\":\"11\"},\"12\":{\"pid\":\"9\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Slider\\/setStatus\",\"id\":\"12\"},\"17\":{\"pid\":\"2\",\"title\":\"\\u914d\\u7f6e\\u7ba1\\u7406\",\"icon\":\"fa fa-cogs\",\"url\":\"Admin\\/Config\\/index\",\"is_dev\":1,\"id\":\"17\"},\"18\":{\"pid\":\"17\",\"title\":\"\\u65b0\\u589e\",\"url\":\"Admin\\/Config\\/add\",\"id\":\"18\"},\"19\":{\"pid\":\"17\",\"title\":\"\\u7f16\\u8f91\",\"url\":\"Admin\\/Config\\/edit\",\"id\":\"19\"},\"20\":{\"pid\":\"17\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Config\\/setStatus\",\"id\":\"20\"},\"21\":{\"pid\":\"2\",\"title\":\"\\u4e0a\\u4f20\\u7ba1\\u7406\",\"icon\":\"fa fa-upload\",\"url\":\"Admin\\/Upload\\/index\",\"id\":\"21\"},\"22\":{\"pid\":\"21\",\"title\":\"\\u4e0a\\u4f20\\u6587\\u4ef6\",\"url\":\"Admin\\/Upload\\/upload\",\"id\":\"22\"},\"23\":{\"pid\":\"21\",\"title\":\"\\u5220\\u9664\\u6587\\u4ef6\",\"url\":\"Admin\\/Upload\\/delete\",\"id\":\"23\"},\"24\":{\"pid\":\"21\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Upload\\/setStatus\",\"id\":\"24\"},\"25\":{\"pid\":\"21\",\"title\":\"\\u4e0b\\u8f7d\\u8fdc\\u7a0b\\u56fe\\u7247\",\"url\":\"Admin\\/Upload\\/downremoteimg\",\"id\":\"25\"},\"26\":{\"pid\":\"21\",\"title\":\"\\u6587\\u4ef6\\u6d4f\\u89c8\",\"url\":\"Admin\\/Upload\\/fileManager\",\"id\":\"26\"},\"27\":{\"pid\":\"1\",\"title\":\"\\u7cfb\\u7edf\\u6743\\u9650\",\"icon\":\"fa fa-folder-open-o\",\"id\":\"27\"},\"28\":{\"pid\":\"27\",\"title\":\"\\u7528\\u6237\\u7ba1\\u7406\",\"icon\":\"fa fa-user\",\"url\":\"Admin\\/User\\/index\",\"id\":\"28\"},\"29\":{\"pid\":\"28\",\"title\":\"\\u65b0\\u589e\",\"url\":\"Admin\\/User\\/add\",\"id\":\"29\"},\"30\":{\"pid\":\"28\",\"title\":\"\\u7f16\\u8f91\",\"url\":\"Admin\\/User\\/edit\",\"id\":\"30\"},\"31\":{\"pid\":\"28\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/User\\/setStatus\",\"id\":\"31\"},\"32\":{\"pid\":\"27\",\"title\":\"\\u7ba1\\u7406\\u5458\\u7ba1\\u7406\",\"icon\":\"fa fa-lock\",\"url\":\"Admin\\/Access\\/index\",\"id\":\"32\"},\"33\":{\"pid\":\"32\",\"title\":\"\\u65b0\\u589e\",\"url\":\"Admin\\/Access\\/add\",\"id\":\"33\"},\"34\":{\"pid\":\"32\",\"title\":\"\\u7f16\\u8f91\",\"url\":\"Admin\\/Access\\/edit\",\"id\":\"34\"},\"35\":{\"pid\":\"32\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Access\\/setStatus\",\"id\":\"35\"},\"36\":{\"pid\":\"27\",\"title\":\"\\u7528\\u6237\\u7ec4\\u7ba1\\u7406\",\"icon\":\"fa fa-sitemap\",\"url\":\"Admin\\/Group\\/index\",\"id\":\"36\"},\"37\":{\"pid\":\"36\",\"title\":\"\\u65b0\\u589e\",\"url\":\"Admin\\/Group\\/add\",\"id\":\"37\"},\"38\":{\"pid\":\"36\",\"title\":\"\\u7f16\\u8f91\",\"url\":\"Admin\\/Group\\/edit\",\"id\":\"38\"},\"39\":{\"pid\":\"36\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Group\\/setStatus\",\"id\":\"39\"},\"40\":{\"pid\":\"1\",\"title\":\"\\u6269\\u5c55\\u4e2d\\u5fc3\",\"icon\":\"fa fa-folder-open-o\",\"id\":\"40\"},\"48\":{\"pid\":\"40\",\"title\":\"\\u529f\\u80fd\\u6a21\\u5757\",\"icon\":\"fa fa-th-large\",\"url\":\"Admin\\/Module\\/index\",\"id\":\"48\"},\"49\":{\"pid\":\"48\",\"title\":\"\\u5b89\\u88c5\\u68c0\\u67e5\",\"url\":\"Admin\\/Module\\/install_before\",\"id\":\"49\"},\"50\":{\"pid\":\"48\",\"title\":\"\\u5b89\\u88c5\",\"url\":\"Admin\\/Module\\/install\",\"id\":\"50\"},\"51\":{\"pid\":\"48\",\"title\":\"\\u5378\\u8f7d\\u68c0\\u67e5\",\"url\":\"Admin\\/Module\\/uninstall_before\",\"id\":\"51\"},\"52\":{\"pid\":\"48\",\"title\":\"\\u5378\\u8f7d\",\"url\":\"Admin\\/Module\\/uninstall\",\"id\":\"52\"},\"53\":{\"pid\":\"48\",\"title\":\"\\u66f4\\u65b0\\u4fe1\\u606f\",\"url\":\"Admin\\/Module\\/updateInfo\",\"id\":\"53\"},\"54\":{\"pid\":\"48\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Module\\/setStatus\",\"id\":\"54\"},\"55\":{\"pid\":\"40\",\"title\":\"\\u63d2\\u4ef6\\u7ba1\\u7406\",\"icon\":\"fa fa-th\",\"url\":\"Admin\\/Addon\\/index\",\"id\":\"55\"},\"56\":{\"pid\":\"55\",\"title\":\"\\u5b89\\u88c5\",\"url\":\"Admin\\/Addon\\/install\",\"id\":\"56\"},\"57\":{\"pid\":\"55\",\"title\":\"\\u5378\\u8f7d\",\"url\":\"Admin\\/Addon\\/uninstall\",\"id\":\"57\"},\"58\":{\"pid\":\"55\",\"title\":\"\\u8fd0\\u884c\",\"url\":\"Admin\\/Addon\\/execute\",\"id\":\"58\"},\"59\":{\"pid\":\"55\",\"title\":\"\\u8bbe\\u7f6e\",\"url\":\"Admin\\/Addon\\/config\",\"id\":\"59\"},\"60\":{\"pid\":\"55\",\"title\":\"\\u540e\\u53f0\\u7ba1\\u7406\",\"url\":\"Admin\\/Addon\\/adminList\",\"id\":\"60\"},\"61\":{\"pid\":\"60\",\"title\":\"\\u65b0\\u589e\\u6570\\u636e\",\"url\":\"Admin\\/Addon\\/adminAdd\",\"id\":\"61\"},\"62\":{\"pid\":\"60\",\"title\":\"\\u7f16\\u8f91\\u6570\\u636e\",\"url\":\"Admin\\/Addon\\/adminEdit\",\"id\":\"62\"},\"63\":{\"pid\":\"60\",\"title\":\"\\u8bbe\\u7f6e\\u72b6\\u6001\",\"url\":\"Admin\\/Addon\\/setStatus\",\"id\":\"63\"}}','',1,1438651748,1508861463,0,1),
(2,'Site','站点','','fa fa-at','#8EF79D','独立站群模块','南京科斯克网络科技有限公司','1.0.0','','','{\"title\":\"\\u96f6\\u4e91\\u5efa\\u7ad9\",\"logo\":\"__APP_DIR__Home\\/View\\/Public\\/img\\/default\\/logo_title.png\",\"theme\":\"1\",\"company\":\"\\u5357\\u4eac\\u79d1\\u65af\\u514b\\u7f51\\u7edc\\u79d1\\u6280\\u6709\\u9650\\u516c\\u53f8\",\"email\":\"<EMAIL>\",\"phone\":\"18185882821\",\"address\":\"\\u5357\\u4eac\\u5e02\\u9f13\\u697c\\u533a\\u5e7f\\u4e1c\\u8def38\\u53f7\",\"qq\":\"209216005\",\"qq_qun\":\"\",\"qr_code\":\"\",\"qr_weixin\":\"\",\"qr_ios\":\"\",\"qr_android\":\"\",\"description\":\"\",\"keywords\":\"\",\"icp\":\"\\u82cfICP\\u590715020094\\u53f7\",\"upload_driver\":\"Local\"}','{\"1\":{\"pid\":\"0\",\"title\":\"\\u7ad9\\u70b9\",\"icon\":\"fa fa-at\",\"id\":\"1\"},\"2\":{\"pid\":\"1\",\"title\":\"\\u7f51\\u7ad9\\u7ba1\\u7406\",\"icon\":\"fa fa-folder-open-o\",\"id\":\"2\"},\"3\":{\"pid\":\"2\",\"title\":\"\\u7f51\\u7ad9\\u8bbe\\u7f6e\",\"icon\":\"fa fa-wrench\",\"url\":\"Site\\/Index\\/module_config\",\"id\":\"3\"},\"4\":{\"pid\":\"2\",\"title\":\"\\u6982\\u51b5\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Index\\/index\",\"id\":\"4\"},\"5\":{\"pid\":\"4\",\"title\":\"\\u81ea\\u5b9a\\u4e49\\u6a21\\u677f\\u914d\\u7f6e\",\"url\":\"Site\\/Index\\/theme_config\",\"id\":\"5\"},\"10\":{\"pid\":\"2\",\"title\":\"\\u9996\\u9875\\u5e7b\\u706f\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Slider\\/slider\",\"id\":\"10\"},\"11\":{\"pid\":\"10\",\"title\":\"\\u65b0\\u589e\\u5e7b\\u706f\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Slider\\/slider_add\",\"id\":\"11\"},\"12\":{\"pid\":\"10\",\"title\":\"\\u7f16\\u8f91\\u5e7b\\u706f\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Slider\\/slider_edit\",\"id\":\"12\"},\"15\":{\"pid\":\"2\",\"title\":\"\\u5206\\u7c7b\\u7ba1\\u7406\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Category\\/category\",\"id\":\"15\"},\"16\":{\"pid\":\"15\",\"title\":\"\\u65b0\\u589e\\u5206\\u7c7b\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Category\\/category_add\",\"id\":\"16\"},\"17\":{\"pid\":\"15\",\"title\":\"\\u7f16\\u8f91\\u5206\\u7c7b\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Category\\/category_edit\",\"id\":\"17\"},\"20\":{\"pid\":\"2\",\"title\":\"\\u6587\\u7ae0\\u7ba1\\u7406\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Article\\/article\",\"id\":\"20\"},\"21\":{\"pid\":\"20\",\"title\":\"\\u65b0\\u589e\\u6587\\u7ae0\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Article\\/article_add\",\"id\":\"21\"},\"22\":{\"pid\":\"20\",\"title\":\"\\u7f16\\u8f91\\u6587\\u7ae0\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Article\\/article_edit\",\"id\":\"22\"},\"25\":{\"pid\":\"2\",\"title\":\"\\u53cb\\u60c5\\u94fe\\u63a5\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Flink\\/flink\",\"id\":\"25\"},\"26\":{\"pid\":\"25\",\"title\":\"\\u65b0\\u589e\\u94fe\\u63a5\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Flink\\/flink_add\",\"id\":\"26\"},\"27\":{\"pid\":\"25\",\"title\":\"\\u7f16\\u8f91\\u94fe\\u63a5\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Flink\\/flink_edit\",\"id\":\"27\"},\"30\":{\"pid\":\"2\",\"title\":\"\\u7559\\u8a00\\u7ba1\\u7406\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Liuyan\\/liuyan\",\"id\":\"30\"},\"35\":{\"pid\":\"2\",\"title\":\"\\u81ea\\u5b9a\\u4e49\\u8868\\u5355\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Form\\/Form\",\"id\":\"35\"},\"36\":{\"pid\":\"25\",\"title\":\"\\u65b0\\u589e\\u8868\\u5355\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Form\\/flink_add\",\"id\":\"36\"},\"37\":{\"pid\":\"25\",\"title\":\"\\u7f16\\u8f91\\u8868\\u5355\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Form\\/flink_edit\",\"id\":\"37\"},\"38\":{\"pid\":\"25\",\"title\":\"\\u7f16\\u8f91\\u5b57\\u6bb5\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Field\\/field\",\"id\":\"38\"},\"39\":{\"pid\":\"25\",\"title\":\"\\u65b0\\u589e\\u5b57\\u6bb5\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Field\\/field_add\",\"id\":\"39\"},\"40\":{\"pid\":\"25\",\"title\":\"\\u7f16\\u8f91\\u5b57\\u6bb5\",\"icon\":\"fa fa-list\",\"url\":\"Site\\/Field\\/field_edit\",\"id\":\"40\"}}','',0,1508861392,1508861443,0,1);
/*!40000 ALTER TABLE `ly_admin_module` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_admin_nav
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_nav`;
CREATE TABLE `ly_admin_nav` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`group` varchar(11) NOT NULL DEFAULT '' COMMENT '分组',
`pid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父ID',
`title` varchar(31) NOT NULL DEFAULT '' COMMENT '导航标题',
`type` varchar(15) NOT NULL DEFAULT '' COMMENT '导航类型',
`value` text COMMENT '导航值',
`api_route` varchar(255) NOT NULL DEFAULT '' COMMENT 'API路由',
`target` varchar(11) NOT NULL DEFAULT '' COMMENT '打开方式',
`icon` varchar(32) NOT NULL DEFAULT '' COMMENT '图标',
`cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图标',
`list_template` varchar(63) NOT NULL DEFAULT '' COMMENT '列表页模板',
`detail_template` varchar(63) NOT NULL DEFAULT '' COMMENT '详情页模板',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='前台导航表';
LOCK TABLES `ly_admin_nav` WRITE;
/*!40000 ALTER TABLE `ly_admin_nav` DISABLE KEYS */;
INSERT INTO `ly_admin_nav` (`id`, `group`, `pid`, `title`, `type`, `value`, `api_route`, `target`, `icon`, `cover`, `list_template`, `detail_template`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,'bottom',0,'关于','page','','','','','','','',1449742225,1449742255,0,1),
(2,'bottom',1,'关于我们','page','','','','','','','',1449742312,1449742312,0,1),
(3,'bottom',1,'服务产品','page','','','','','','','',1449742597,1449742651,0,1),
(4,'bottom',1,'商务合作','page','','','','','','','',1449742664,1449742664,0,1),
(5,'bottom',1,'加入我们','page','','','','','','','',1449742678,1449742697,0,1),
(6,'bottom',0,'帮助','page','','','','','','','',1449742688,1449742688,0,1),
(7,'bottom',6,'用户协议','page','','','','','','','',1449742706,1449742706,0,1),
(8,'bottom',6,'意见反馈','page','','','','','','','',1449742716,1449742716,0,1),
(9,'bottom',6,'常见问题','page','','','','','','','',1449742728,1449742728,0,1),
(10,'bottom',0,'联系方式','page','','','','','','','',1449742742,1449742742,0,1),
(11,'bottom',10,'联系我们','page','','','','','','','',1449742752,1449742752,0,1),
(12,'bottom',10,'新浪微博','page','','','','','','','',1449742802,1449742802,0,1),
(13,'main',0,'首页','link','','','','','','','',1457084559,1472993801,0,1),
(14,'main',0,'客户服务','page','','','','','','','',1457084572,1457084572,0,1),
(15,'main',0,'产品展示','page','<p>查看前台演示,请点击右上角“网站导航”查看具体内容。</p><p>查看后台演示,请点击顶部<a target=\"_blank\" href=\"http://demo.lingyun.net/admin2.php?s=/admin/login/login.html&account=admin&password=admin\" style=\"color: rgb(0, 115, 229); text-decoration: underline; outline: 0px; text-align: center;\">点击这里体验强大的零云后台管理</a>。</p> ','','','fa-search','','lists','detail',1486516611,1488506030,0,1),
(16,'main',0,'新闻动态','page','<p>查看前台演示,请点击右上角“网站导航”查看具体内容。</p><p>查看后台演示,请点击顶部<a target=\"_blank\" href=\"http://demo.lingyun.net/admin2.php?s=/admin/login/login.html&account=admin&password=admin\" style=\"color: rgb(0, 115, 229); text-decoration: underline; outline: 0px; text-align: center;\">点击这里体验强大的零云后台管理</a>。</p> ','','','','','','',1457084714,1488505991,0,1),
(17,'main',0,'联系我们','page','<p>查看前台演示,请点击右上角“网站导航”查看具体内容。</p><p>查看后台演示,请点击顶部<a target=\"_blank\" href=\"http://demo.lingyun.net/admin2.php?s=/admin/login/login.html&account=admin&password=<PASSWORD>\" style=\"color: rgb(0, 115, 229); text-decoration: underline; outline: 0px; text-align: center;\">点击这里体验强大的零云后台管理</a>。</p> ','','','','','','',1457084725,1488506009,0,1),
(18,'main',0,'案例展示','page','<p>查看前台演示,请点击右上角“网站导航”查看具体内容。</p><p>查看后台演示,请点击顶部<a target=\"_blank\" href=\"http://demo.lingyun.net/admin2.php?s=/admin/login/login.html&account=admin&password=<PASSWORD>\" style=\"color: rgb(0, 115, 229); text-decoration: underline; outline: 0px; text-align: center;\">点击这里体验强大的零云后台管理</a>。</p><p> </p>','','','','','','',1457084583,1488505982,0,1);
/*!40000 ALTER TABLE `ly_admin_nav` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_admin_post
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_post`;
CREATE TABLE `ly_admin_post` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`cid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '分类ID',
`title` varchar(127) NOT NULL DEFAULT '' COMMENT '标题',
`cover` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '封面',
`abstract` varchar(255) DEFAULT '' COMMENT '摘要',
`content` text COMMENT '内容',
`view_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '阅读',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章列表';
# Dump of table ly_admin_session
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_session`;
CREATE TABLE `ly_admin_session` (
`session_id` varchar(255) NOT NULL,
`session_expire` int(11) NOT NULL,
`session_data` blob,
`uid` int(11) unsigned NOT NULL COMMENT '用户ID',
`update_time` int(11) unsigned NOT NULL COMMENT '更新时间',
UNIQUE KEY `session_id` (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='session存储表';
LOCK TABLES `ly_admin_session` WRITE;
/*!40000 ALTER TABLE `ly_admin_session` DISABLE KEYS */;
INSERT INTO `ly_admin_session` (`session_id`, `session_expire`, `session_data`, `uid`, `update_time`)
VALUES
('6ljeqq8jqn8f72b46345sgvte7',1509727195,X'6C795F61646D696E5F7C613A333A7B733A373A22666F7277617264223B733A33343A22687474703A2F2F6C6F63616C686F73742F6C7961646D696E2F61646D696E2E706870223B733A393A22757365725F61757468223B613A343A7B733A333A22756964223B733A313A2231223B733A383A22757365726E616D65223B733A353A2261646D696E223B733A383A226E69636B6E616D65223B733A31353A22E8B685E7BAA7E7AEA1E79086E59198223B733A363A22617661746172223B733A313A2230223B7D733A31343A22757365725F617574685F7369676E223B733A34303A2239653265336438623339663531356366333935373235356235613439326139663633383862666339223B7D6C795F686F6D655F7C613A313A7B733A373A22666F7277617264223B733A35333A22687474703A2F2F6C6F63616C686F73742F6C7961646D696E2F696E6465782E7068703F733D2F736974652F696E6465782E68746D6C223B7D',0,1508863195);
/*!40000 ALTER TABLE `ly_admin_session` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_admin_slider
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_slider`;
CREATE TABLE `ly_admin_slider` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '幻灯ID',
`title` char(80) NOT NULL DEFAULT '' COMMENT '标题',
`cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '点击链接',
`target` varchar(11) NOT NULL DEFAULT '' COMMENT '新窗口打开',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='幻灯切换表';
# Dump of table ly_admin_upload
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_upload`;
CREATE TABLE `ly_admin_upload` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'UID',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名',
`path` varchar(255) NOT NULL DEFAULT '' COMMENT '文件路径',
`url` varchar(255) DEFAULT '' COMMENT '文件链接',
`ext` char(4) NOT NULL DEFAULT '' COMMENT '文件类型',
`size` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '文件大小',
`md5` char(32) DEFAULT '' COMMENT '文件md5',
`sha1` char(40) DEFAULT '' COMMENT '文件sha1编码',
`location` varchar(15) NOT NULL DEFAULT '' COMMENT '文件存储位置',
`download` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '下载次数',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上传时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文件上传表';
# Dump of table ly_admin_user
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_admin_user`;
CREATE TABLE `ly_admin_user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'UID',
`pid` int(11) unsigned NOT NULL COMMENT '上级',
`user_type` int(11) NOT NULL DEFAULT '1' COMMENT '用户类型',
`nickname` varchar(63) DEFAULT NULL COMMENT '昵称',
`username` varchar(31) NOT NULL DEFAULT '' COMMENT '用户名',
`password` varchar(63) NOT NULL DEFAULT '' COMMENT '密码',
`email` varchar(63) NOT NULL DEFAULT '' COMMENT '邮箱',
`email_bind` tinyint(1) NOT NULL DEFAULT '0' COMMENT '邮箱验证',
`mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号',
`mobile_bind` tinyint(1) NOT NULL DEFAULT '0' COMMENT '手机验证',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像',
`score` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '积分',
`money` decimal(11,2) NOT NULL DEFAULT '0.00' COMMENT '余额',
`reg_ip` bigint(20) NOT NULL DEFAULT '0' COMMENT '注册IP',
`reg_type` varchar(15) NOT NULL DEFAULT '' COMMENT '注册方式',
`invite_code` varchar(32) NOT NULL DEFAULT '' COMMENT '邀请码',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户账号表';
LOCK TABLES `ly_admin_user` WRITE;
/*!40000 ALTER TABLE `ly_admin_user` DISABLE KEYS */;
INSERT INTO `ly_admin_user` (`id`, `pid`, `user_type`, `nickname`, `username`, `password`, `email`, `email_bind`, `mobile`, `mobile_bind`, `avatar`, `score`, `money`, `reg_ip`, `reg_type`, `invite_code`, `create_time`, `update_time`, `status`)
VALUES
(1,0,1,'超级管理员','admin','<PASSWORD>','',0,'',0,'0',0,0.00,0,'','',1438651748,1438651748,1);
/*!40000 ALTER TABLE `ly_admin_user` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_site_article
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_article`;
CREATE TABLE `ly_site_article` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '文章ID',
`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'UID',
`cid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '分类ID',
`title` varchar(32) NOT NULL DEFAULT '' COMMENT '文章标题',
`cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图',
`cover_slider` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图???',
`banner` varchar(255) NOT NULL DEFAULT '' COMMENT '幻灯切换专用图',
`abstract` varchar(255) NOT NULL DEFAULT '' COMMENT '简介',
`content` text COMMENT '文章内容',
`view_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '阅读次数',
`detail_template` varchar(255) NOT NULL DEFAULT '' COMMENT '详情页模版',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章表';
LOCK TABLES `ly_site_article` WRITE;
/*!40000 ALTER TABLE `ly_site_article` DISABLE KEYS */;
INSERT INTO `ly_site_article` (`id`, `uid`, `cid`, `title`, `cover`, `cover_slider`, `banner`, `abstract`, `content`, `view_count`, `detail_template`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,1,2,'测试文章1','__APP_DIR__Site/View/Public/img/product1.png','__APP_DIR__Site/View/Public/img/slider.png','','','测试文章123',0,'',1500028451,0,0,1),
(2,1,2,'测试文章2','__APP_DIR__Site/View/Public/img/product1.png','','','','测试文章123',0,'',1500028451,0,0,1),
(3,1,2,'测试文章3','__APP_DIR__Site/View/Public/img/product2.png','','','','测试文章123',0,'',1500028451,0,0,1),
(4,1,2,'测试文章4','__APP_DIR__Site/View/Public/img/product3.png','','','','测试文章123',0,'',1500028451,0,0,1),
(5,1,2,'测试文章5','__APP_DIR__Site/View/Public/img/product4.png','','','','测试文章123',1,'',1500028451,0,0,1),
(6,1,2,'测试文章6','__APP_DIR__Site/View/Public/img/product5.png','','','','测试文章123',0,'',1500028451,0,0,1),
(7,1,3,'测试文章7','__APP_DIR__Site/View/Public/img/product6.png','','','','测试文章123',1,'',1500028451,0,0,1),
(8,1,3,'测试文章8','__APP_DIR__Site/View/Public/img/product6.png','','','','测试文章123',0,'',1500028451,0,0,1),
(9,1,3,'测试文章9','__APP_DIR__Site/View/Public/img/product6.png','','','','测试文章123',0,'',1500028451,0,0,1),
(10,1,3,'测试文章10','__APP_DIR__Site/View/Public/img/product6.png','','','','测试文章123',0,'',1500028451,0,0,1),
(11,1,3,'测试文章11','__APP_DIR__Site/View/Public/img/product6.png','','','','测试文章123',0,'',1500028451,0,0,1),
(12,1,3,'测试文章11','__APP_DIR__Site/View/Public/img/product6.png','','','','测试文章123',0,'',1500028451,0,0,1);
/*!40000 ALTER TABLE `ly_site_article` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_site_category
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_category`;
CREATE TABLE `ly_site_category` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '分类ID',
`cate_type` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '分类类型',
`pid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父分类ID',
`title` varchar(32) NOT NULL DEFAULT '' COMMENT '分类标题',
`content` text COMMENT '分类单页内容',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '外链',
`cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图',
`banner` varchar(255) NOT NULL DEFAULT '' COMMENT 'Banner图',
`is_show` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否显示',
`list_template` varchar(255) NOT NULL DEFAULT '' COMMENT '列表模版',
`detail_template` varchar(255) NOT NULL DEFAULT '' COMMENT '详情模版',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章分类表';
LOCK TABLES `ly_site_category` WRITE;
/*!40000 ALTER TABLE `ly_site_category` DISABLE KEYS */;
INSERT INTO `ly_site_category` (`id`, `cate_type`, `pid`, `title`, `content`, `url`, `cover`, `banner`, `is_show`, `list_template`, `detail_template`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,0,0,'公司简介','','','','',1,'','',0,0,0,1),
(2,0,0,'新闻中心','','','','',1,'','',0,0,0,1),
(3,0,0,'产品中心','','','','',1,'','',0,0,0,1),
(4,0,0,'合作案例','','','','',1,'','',0,0,0,1),
(5,0,0,'联系我们','','','','',1,'','',0,0,0,1);
/*!40000 ALTER TABLE `ly_site_category` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_site_data
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_data`;
CREATE TABLE `ly_site_data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fid` int(11) NOT NULL COMMENT '来自表单的标题',
`data` varchar(255) NOT NULL COMMENT 'json格式的数据',
`create_time` int(11) NOT NULL,
`update_time` int(11) NOT NULL,
`status` tinyint(4) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='数据列表';
LOCK TABLES `ly_site_data` WRITE;
/*!40000 ALTER TABLE `ly_site_data` DISABLE KEYS */;
INSERT INTO `ly_site_data` (`id`, `fid`, `data`, `create_time`, `update_time`, `status`)
VALUES
(1,1,'{\"\\u540d\\u5b57\":\"\\u8001\\u738b\",\"\\u5e74\\u9f84\":\"23\",\"\\u4f4f\\u5740\":\"\\u5357\\u4eac\",\"\\u6027\\u522b\":\"\\u7537\",\"\\u7231\\u597d\":\"\\u8dd1\\u6b65\",\"\\u804c\\u4e1a\":\"\\u516c\\u52a1\\u5458\"}',1504608576,1504608576,1);
/*!40000 ALTER TABLE `ly_site_data` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_site_field
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_field`;
CREATE TABLE `ly_site_field` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '字段主键',
`fid` int(11) NOT NULL COMMENT '表单外键',
`name` varchar(255) NOT NULL COMMENT '字段name',
`type` varchar(255) NOT NULL COMMENT '字段类型 text之类的',
`title` varchar(255) NOT NULL COMMENT '字段标题',
`hint` varchar(255) NOT NULL COMMENT '字段提示',
`create_time` int(11) NOT NULL,
`update_time` int(11) NOT NULL,
`status` tinyint(4) NOT NULL,
`choose` varchar(255) NOT NULL COMMENT '当选择多选单选时用来选择的值',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='字段列表';
LOCK TABLES `ly_site_field` WRITE;
/*!40000 ALTER TABLE `ly_site_field` DISABLE KEYS */;
INSERT INTO `ly_site_field` (`id`, `fid`, `name`, `type`, `title`, `hint`, `create_time`, `update_time`, `status`, `choose`)
VALUES
(1,1,'名字','text','姓名','你的姓名',1504601168,1504601168,1,''),
(2,1,'年龄','text','年龄','你的实际年龄',1504601177,1504601177,1,''),
(3,1,'住址','text','户籍','输入户籍',1504601188,1504601188,1,''),
(4,1,'性别','radio','请选择性别','请选择性别',1504596019,1504596019,1,'男/女/保密'),
(5,1,'爱好','checkbox','爱好','爱好',1504599321,1504599321,1,'游泳/跑步/篮球/足球'),
(6,1,'职业','select','职业','职业',1504604858,1504604858,1,'学生/蓝领/白领/公务员');
/*!40000 ALTER TABLE `ly_site_field` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_site_flink
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_flink`;
CREATE TABLE `ly_site_flink` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`pid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上级ID',
`title` varchar(32) NOT NULL DEFAULT '' COMMENT '友链名称',
`logo` varchar(255) NOT NULL DEFAULT '' COMMENT '友链logo',
`url` text COMMENT '友链链接',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='友情链接表';
# Dump of table ly_site_form
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_form`;
CREATE TABLE `ly_site_form` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '表单id',
`create_time` int(11) NOT NULL,
`update_time` int(11) NOT NULL,
`status` tinyint(4) NOT NULL DEFAULT '1',
`title` varchar(255) NOT NULL COMMENT '表单标题',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='表单列表';
LOCK TABLES `ly_site_form` WRITE;
/*!40000 ALTER TABLE `ly_site_form` DISABLE KEYS */;
INSERT INTO `ly_site_form` (`id`, `create_time`, `update_time`, `status`, `title`)
VALUES
(1,1504520124,1504520124,1,'示例表单');
/*!40000 ALTER TABLE `ly_site_form` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_site_liuyan
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_liuyan`;
CREATE TABLE `ly_site_liuyan` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '幻灯ID',
`pid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上级ID',
`name` char(80) NOT NULL DEFAULT '' COMMENT '姓名',
`email` varchar(255) NOT NULL DEFAULT '' COMMENT '邮箱',
`phone` varchar(255) NOT NULL DEFAULT '' COMMENT '电话',
`content` text COMMENT '内容',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='留言表';
# Dump of table ly_site_slider
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_slider`;
CREATE TABLE `ly_site_slider` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '幻灯ID',
`title` char(80) NOT NULL DEFAULT '' COMMENT '标题',
`cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '点击链接',
`target` varchar(11) NOT NULL DEFAULT '' COMMENT '新窗口打开',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='幻灯切换表';
LOCK TABLES `ly_site_slider` WRITE;
/*!40000 ALTER TABLE `ly_site_slider` DISABLE KEYS */;
INSERT INTO `ly_site_slider` (`id`, `title`, `cover`, `url`, `target`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,'默认Banner','__APP_DIR__Site/View/Public/img/slider1.jpg','','_blank',0,1501061741,0,1),
(2,'默认Banner','__APP_DIR__Site/View/Public/img/slider2.jpg','','_blank',0,1501061741,0,1),
(3,'默认Banner','__APP_DIR__Site/View/Public/img/slider3.jpg','','_blank',0,1501061741,0,1);
/*!40000 ALTER TABLE `ly_site_slider` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table ly_site_theme
# ------------------------------------------------------------
DROP TABLE IF EXISTS `ly_site_theme`;
CREATE TABLE `ly_site_theme` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主题ID',
`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'UID',
`cid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '分类ID',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '主题名称',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '主题标题',
`cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图',
`images` text COMMENT '图片预览',
`config` longtext COMMENT '模板配置',
`view_count` int(11) NOT NULL DEFAULT '0' COMMENT '访问次数',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='主题模板';
LOCK TABLES `ly_site_theme` WRITE;
/*!40000 ALTER TABLE `ly_site_theme` DISABLE KEYS */;
INSERT INTO `ly_site_theme` (`id`, `uid`, `cid`, `name`, `title`, `cover`, `images`, `config`, `view_count`, `create_time`, `update_time`, `sort`, `status`)
VALUES
(1,1,1,'default','默认主题','__APP_DIR__Site/View/Public/img/theme_default.png','','{\"index_news_cid\":\"2\",\"index_product_cid\":\"3\"}',95,0,0,0,1);
/*!40000 ALTER TABLE `ly_site_theme` ENABLE KEYS */;
UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<reponame>attilakreiner/cassandra-homework<filename>01-create-script.sql
-- Fix the following Cassandra DDL, so that all queries from the files below can be executed without changes
-- 02-upsert-readonly.sql and
-- 03-query-readonly.sql
-- Create keyspace (press TAB for autocomplete in cqlsh)
CREATE KEYSPACE homework WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 } AND durable_writes = true;
-- Use keyspace
USE homework;
-- Fix the following table creation script so that the subsequent queries work as expected
-- The table contains both the invoice header and the invoice detail fields
CREATE table invoice
(
-- header fields
invoice_id text,
invoice_date date static,
invoice_address text static,
-- detail fields
line_id int,
article_name text,
article_price decimal,
PRIMARY KEY (invoice_id, article_name, line_id)
);
CREATE INDEX ON invoice (invoice_date);
|
<reponame>Gemplify/App
-- phpMyAdmin SQL Dump
-- version 4.7.7
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1:8889
-- Tiempo de generación: 24-05-2021 a las 15:39:59
-- Versión del servidor: 5.6.38
-- Versión de PHP: 7.2.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: `gempliCardsEC219`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `block`
--
CREATE TABLE `block` (
`id` int(11) NOT NULL,
`text` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` int(11) NOT NULL DEFAULT '1',
`status` int(11) NOT NULL DEFAULT '1',
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `block_rel_deck`
--
CREATE TABLE `block_rel_deck` (
`id` int(11) NOT NULL,
`block_id` int(11) NOT NULL,
`version_id` int(11) NOT NULL,
`deck_id` int(11) NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `card`
--
CREATE TABLE `card` (
`id` int(11) NOT NULL,
`blockreldeck_id` int(11) NOT NULL,
`text` text COLLATE utf8mb4_unicode_ci NOT NULL,
`options` text COLLATE utf8mb4_unicode_ci NOT NULL,
`zIndex` int(3) NOT NULL DEFAULT '1',
`type` int(2) NOT NULL,
`status` int(1) NOT NULL,
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `deck`
--
CREATE TABLE `deck` (
`id` int(11) NOT NULL,
`text` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `relation`
--
CREATE TABLE `relation` (
`id` int(11) NOT NULL,
`version_id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`type` int(2) NOT NULL,
`status` int(2) NOT NULL,
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `relation_card`
--
CREATE TABLE `relation_card` (
`id` int(11) NOT NULL,
`card_id` int(11) NOT NULL,
`relation_id` int(11) NOT NULL,
`type` int(2) NOT NULL,
`status` int(2) NOT NULL,
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `session`
--
CREATE TABLE `session` (
`id` int(11) NOT NULL,
`version_id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`share` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`expiration` datetime DEFAULT NULL,
`type` int(2) NOT NULL,
`status` int(2) NOT NULL,
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `session_rel`
--
CREATE TABLE `session_rel` (
`id` int(11) NOT NULL,
`session_id` int(11) NOT NULL,
`card_id` int(11) DEFAULT NULL,
`answer` text COLLATE utf8mb4_unicode_ci,
`config_card` text COLLATE utf8mb4_unicode_ci,
`type` int(2) NOT NULL,
`status` int(2) NOT NULL,
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `user`
--
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`surname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`last_login` datetime NOT NULL,
`status` tinyint(1) NOT NULL,
`type` int(2) NOT NULL COMMENT '0-admin, 1-user',
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `version`
--
CREATE TABLE `version` (
`id` int(11) NOT NULL,
`block_id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`type` int(11) NOT NULL DEFAULT '1',
`status` int(11) NOT NULL DEFAULT '1',
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `block`
--
ALTER TABLE `block`
ADD PRIMARY KEY (`id`);
ALTER TABLE `block` ADD FULLTEXT KEY `text` (`text`);
--
-- Indices de la tabla `block_rel_deck`
--
ALTER TABLE `block_rel_deck`
ADD PRIMARY KEY (`id`),
ADD KEY `block_id` (`block_id`),
ADD KEY `reld_id` (`deck_id`),
ADD KEY `version_id` (`version_id`);
--
-- Indices de la tabla `card`
--
ALTER TABLE `card`
ADD PRIMARY KEY (`id`),
ADD KEY `blockreldeck_id` (`blockreldeck_id`);
--
-- Indices de la tabla `deck`
--
ALTER TABLE `deck`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `relation`
--
ALTER TABLE `relation`
ADD PRIMARY KEY (`id`),
ADD KEY `version_id` (`version_id`);
--
-- Indices de la tabla `relation_card`
--
ALTER TABLE `relation_card`
ADD PRIMARY KEY (`id`),
ADD KEY `card_id` (`card_id`),
ADD KEY `relation_id` (`relation_id`);
--
-- Indices de la tabla `session`
--
ALTER TABLE `session`
ADD PRIMARY KEY (`id`),
ADD KEY `version_id` (`version_id`);
ALTER TABLE `session` ADD FULLTEXT KEY `name` (`name`);
--
-- Indices de la tabla `session_rel`
--
ALTER TABLE `session_rel`
ADD PRIMARY KEY (`id`),
ADD KEY `session_id` (`session_id`),
ADD KEY `card_id` (`card_id`);
--
-- Indices de la tabla `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `version`
--
ALTER TABLE `version`
ADD PRIMARY KEY (`id`),
ADD KEY `block_id` (`block_id`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `block`
--
ALTER TABLE `block`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29;
--
-- AUTO_INCREMENT de la tabla `block_rel_deck`
--
ALTER TABLE `block_rel_deck`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=122;
--
-- AUTO_INCREMENT de la tabla `card`
--
ALTER TABLE `card`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=129;
--
-- AUTO_INCREMENT de la tabla `deck`
--
ALTER TABLE `deck`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;
--
-- AUTO_INCREMENT de la tabla `relation`
--
ALTER TABLE `relation`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT de la tabla `relation_card`
--
ALTER TABLE `relation_card`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35;
--
-- AUTO_INCREMENT de la tabla `session`
--
ALTER TABLE `session`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT de la tabla `session_rel`
--
ALTER TABLE `session_rel`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=110;
--
-- AUTO_INCREMENT de la tabla `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT de la tabla `version`
--
ALTER TABLE `version`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `block_rel_deck`
--
ALTER TABLE `block_rel_deck`
ADD CONSTRAINT `block_rel_deck_ibfk_1` FOREIGN KEY (`block_id`) REFERENCES `block` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `block_rel_deck_ibfk_2` FOREIGN KEY (`deck_id`) REFERENCES `deck` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `block_rel_deck_ibfk_3` FOREIGN KEY (`version_id`) REFERENCES `version` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `card`
--
ALTER TABLE `card`
ADD CONSTRAINT `card_ibfk_1` FOREIGN KEY (`blockreldeck_id`) REFERENCES `block_rel_deck` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `relation`
--
ALTER TABLE `relation`
ADD CONSTRAINT `relation_ibfk_1` FOREIGN KEY (`version_id`) REFERENCES `version` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `relation_card`
--
ALTER TABLE `relation_card`
ADD CONSTRAINT `relation_card_ibfk_1` FOREIGN KEY (`card_id`) REFERENCES `card` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `relation_card_ibfk_2` FOREIGN KEY (`relation_id`) REFERENCES `relation` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `session`
--
ALTER TABLE `session`
ADD CONSTRAINT `session_ibfk_1` FOREIGN KEY (`version_id`) REFERENCES `version` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `session_rel`
--
ALTER TABLE `session_rel`
ADD CONSTRAINT `session_rel_ibfk_1` FOREIGN KEY (`card_id`) REFERENCES `card` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `session_rel_ibfk_2` FOREIGN KEY (`session_id`) REFERENCES `session` (`id`) ON DELETE CASCADE;
--
-- Filtros para la tabla `version`
--
ALTER TABLE `version`
ADD CONSTRAINT `version_ibfk_1` FOREIGN KEY (`block_id`) REFERENCES `block` (`id`) ON DELETE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE TABLE tb_estado (
codigo BIGINT(20) PRIMARY KEY,
id_estado_ibge BIGINT(20) NOT NULL,
nome VARCHAR(50) NOT NULL,
sigla VARCHAR(2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE tb_cidade (
codigo BIGINT(20) PRIMARY KEY AUTO_INCREMENT,
nome VARCHAR(50) NOT NULL,
codigo_estado BIGINT(20) NOT NULL,
FOREIGN KEY (codigo_estado) REFERENCES tb_estado(codigo)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (1,11,'Rondônia','RO');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (2,12,'Acre','AC');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (3,13,'Amazonas','AM');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (4,14,'Roraima','RR');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (5,15,'Pará','PA');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (6,16,'Amapá','AP');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (7,17,'Tocantins','TO');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (8,21,'Maranhão','MA');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (9,22,'Piauí','PI');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (10,23,'Ceará','CE');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (11,24,'Rio Grande do Norte','RN');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (12,25,'Paraíba','PB');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (13,26,'Pernambuco','PE');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (14,27,'Alagoas','AL');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (15,28,'Sergipe','SE');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (16,29,'Bahia','BA');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (17,31,'Minas Gerais','MG');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (18,32,'Espírito Santo','ES');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (19,33,'Rio de Janeiro','RJ');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (20,35,'São Paulo','SP');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (21,41,'Paraná','PR');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (22,42,'Santa Catarina','SC');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (23,43,'Rio Grande do Sul','RS');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (24,50,'Mato Grosso do Sul','MS');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (25,51,'Mato Grosso','MT');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (26,52,'Goiás','GO');
INSERT INTO tb_estado (codigo, id_estado_ibge, nome, sigla) VALUES (27,53,'Distrito Federal','DF');
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Rio Branco', 2);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Cruzeiro do Sul', 2);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Salvador', 16);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Porto Seguro', 16);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Santana', 16);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Belo Horizonte', 17);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Uberlândia', 17);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Montes Claros', 17);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('São Paulo', 20);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Ribeirão Preto', 20);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Campinas', 20);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Santos', 20);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Florianópolis', 22);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Criciúma', 22);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Camboriú', 22);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Lages', 22);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Goiânia', 26);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Itumbiara', 26);
INSERT INTO tb_cidade (nome, codigo_estado) VALUES ('Novo Brasil', 26); |
CREATE TABLE `botkit_user` (
`id` char(9) NOT NULL,
`access_token` varchar(51) NOT NULL,
`scopes` varchar(500) NOT NULL,
`team_id` char(9) NOT NULL,
`user` varchar(36) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `botkit_team` (
`id` char(9) NOT NULL,
`createdBy` char(9) NOT NULL,
`url` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`token` varchar(51) NOT NULL,
`bot` varchar(500) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `botkit_channel` (
`id` char(9) NOT NULL,
`json` MEDIUMTEXT NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
\ir include/insert_two_partitions.sql
SELECT * FROM hypertable_detailed_size('"public"."two_Partitions"');
SELECT * FROM hypertable_index_size('"public"."two_Partitions_device_id_timeCustom_idx"');
SELECT * FROM hypertable_index_size('"public"."two_Partitions_timeCustom_device_id_idx"');
SELECT * FROM hypertable_index_size('"public"."two_Partitions_timeCustom_idx"');
SELECT * FROM hypertable_index_size('"public"."two_Partitions_timeCustom_series_0_idx"');
SELECT * FROM hypertable_index_size('"public"."two_Partitions_timeCustom_series_1_idx"');
SELECT * FROM hypertable_index_size('"public"."two_Partitions_timeCustom_series_2_idx"');
SELECT * FROM hypertable_index_size('"public"."two_Partitions_timeCustom_series_bool_idx"');
SELECT * FROM chunks_detailed_size('"public"."two_Partitions"') order by chunk_name;
CREATE TABLE timestamp_partitioned(time TIMESTAMP, value TEXT);
SELECT * FROM create_hypertable('timestamp_partitioned', 'time', 'value', 2);
INSERT INTO timestamp_partitioned VALUES('2004-10-19 10:23:54', '10');
INSERT INTO timestamp_partitioned VALUES('2004-12-19 10:23:54', '30');
SELECT * FROM chunks_detailed_size('timestamp_partitioned') order by chunk_name;
CREATE TABLE timestamp_partitioned_2(time TIMESTAMP, value CHAR(9));
SELECT * FROM create_hypertable('timestamp_partitioned_2', 'time', 'value', 2);
INSERT INTO timestamp_partitioned_2 VALUES('2004-10-19 10:23:54', '10');
INSERT INTO timestamp_partitioned_2 VALUES('2004-12-19 10:23:54', '30');
SELECT * FROM chunks_detailed_size('timestamp_partitioned_2') order by chunk_name;
CREATE TABLE toast_test(time TIMESTAMP, value TEXT);
-- Set storage type to EXTERNAL to prevent PostgreSQL from compressing my
-- easily compressable string and instead store it with TOAST
ALTER TABLE toast_test ALTER COLUMN value SET STORAGE EXTERNAL;
SELECT * FROM create_hypertable('toast_test', 'time');
INSERT INTO toast_test VALUES('2004-10-19 10:23:54', $$
this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k. this must be over 2k.
$$);
SELECT * FROM chunks_detailed_size('toast_test');
--
-- Tests for approximate_row_count()
--
-- Regular table
--
CREATE TABLE approx_count(time TIMESTAMP, value int);
INSERT INTO approx_count VALUES('2004-01-01 10:00:01', 1);
INSERT INTO approx_count VALUES('2004-01-01 10:00:02', 2);
INSERT INTO approx_count VALUES('2004-01-01 10:00:03', 3);
INSERT INTO approx_count VALUES('2004-01-01 10:00:04', 4);
INSERT INTO approx_count VALUES('2004-01-01 10:00:05', 5);
INSERT INTO approx_count VALUES('2004-01-01 10:00:06', 6);
INSERT INTO approx_count VALUES('2004-01-01 10:00:07', 7);
SELECT * FROM approximate_row_count('approx_count');
ANALYZE approx_count;
SELECT count(*) FROM approx_count;
SELECT * FROM approximate_row_count('approx_count');
DROP TABLE approx_count;
-- Regular table with basic inheritance
--
CREATE TABLE approx_count(id int);
CREATE TABLE approx_count_child(id2 int) INHERITS (approx_count);
INSERT INTO approx_count_child VALUES(0);
INSERT INTO approx_count VALUES(1);
SELECT count(*) FROM approx_count;
SELECT * FROM approximate_row_count('approx_count');
ANALYZE approx_count;
SELECT * FROM approximate_row_count('approx_count');
ANALYZE approx_count_child;
SELECT * FROM approximate_row_count('approx_count');
DROP TABLE approx_count CASCADE;
-- Regular table with nested inheritance
--
CREATE TABLE approx_count(id int);
CREATE TABLE approx_count_a(id2 int) INHERITS (approx_count);
CREATE TABLE approx_count_b(id3 int) INHERITS (approx_count_a);
CREATE TABLE approx_count_c(id4 int) INHERITS (approx_count_b);
INSERT INTO approx_count_a VALUES(0);
INSERT INTO approx_count_b VALUES(1);
INSERT INTO approx_count_c VALUES(2);
INSERT INTO approx_count VALUES(3);
SELECT * FROM approximate_row_count('approx_count');
ANALYZE approx_count_a;
ANALYZE approx_count_b;
ANALYZE approx_count_c;
ANALYZE approx_count;
SELECT count(*) FROM approx_count;
SELECT * FROM approximate_row_count('approx_count');
SELECT count(*) FROM approx_count_a;
SELECT * FROM approximate_row_count('approx_count_a');
SELECT count(*) FROM approx_count_b;
SELECT * FROM approximate_row_count('approx_count_b');
SELECT count(*) FROM approx_count_c;
SELECT * FROM approximate_row_count('approx_count_c');
DROP TABLE approx_count CASCADE;
-- table with declarative partitioning
--
CREATE TABLE approx_count_dp(time TIMESTAMP, value int) PARTITION BY RANGE(time);
CREATE TABLE approx_count_dp0 PARTITION OF approx_count_dp
FOR VALUES FROM ('2004-01-01 00:00:00') TO ('2005-01-01 00:00:00');
CREATE TABLE approx_count_dp1 PARTITION OF approx_count_dp
FOR VALUES FROM ('2005-01-01 00:00:00') TO ('2006-01-01 00:00:00');
CREATE TABLE approx_count_dp2 PARTITION OF approx_count_dp
FOR VALUES FROM ('2006-01-01 00:00:00') TO ('2007-01-01 00:00:00');
INSERT INTO approx_count_dp VALUES('2004-01-01 10:00:00', 1);
INSERT INTO approx_count_dp VALUES('2004-01-01 11:00:00', 1);
INSERT INTO approx_count_dp VALUES('2004-01-01 12:00:01', 1);
INSERT INTO approx_count_dp VALUES('2005-01-01 10:00:00', 1);
INSERT INTO approx_count_dp VALUES('2005-01-01 11:00:00', 1);
INSERT INTO approx_count_dp VALUES('2005-01-01 12:00:01', 1);
INSERT INTO approx_count_dp VALUES('2006-01-01 10:00:00', 1);
INSERT INTO approx_count_dp VALUES('2006-01-01 11:00:00', 1);
INSERT INTO approx_count_dp VALUES('2006-01-01 12:00:01', 1);
SELECT count(*) FROM approx_count_dp;
SELECT count(*) FROM approx_count_dp0;
SELECT count(*) FROM approx_count_dp1;
SELECT count(*) FROM approx_count_dp2;
SELECT * FROM approximate_row_count('approx_count_dp');
ANALYZE approx_count_dp;
SELECT * FROM approximate_row_count('approx_count_dp');
SELECT * FROM approximate_row_count('approx_count_dp0');
SELECT * FROM approximate_row_count('approx_count_dp1');
SELECT * FROM approximate_row_count('approx_count_dp2');
CREATE TABLE approx_count_dp_nested(time TIMESTAMP, device_id int, value int) PARTITION BY RANGE(time);
CREATE TABLE approx_count_dp_nested_0 PARTITION OF approx_count_dp_nested FOR VALUES FROM ('2004-01-01 00:00:00') TO ('2005-01-01 00:00:00') PARTITION BY RANGE (device_id);
CREATE TABLE approx_count_dp_nested_0_0 PARTITION OF approx_count_dp_nested_0 FOR VALUES FROM (0) TO (10);
CREATE TABLE approx_count_dp_nested_0_1 PARTITION OF approx_count_dp_nested_0 FOR VALUES FROM (10) TO (20);
CREATE TABLE approx_count_dp_nested_1 PARTITION OF approx_count_dp_nested FOR VALUES FROM ('2005-01-01 00:00:00') TO ('2006-01-01 00:00:00') PARTITION BY RANGE (device_id);
CREATE TABLE approx_count_dp_nested_1_0 PARTITION OF approx_count_dp_nested_1 FOR VALUES FROM (0) TO (10);
CREATE TABLE approx_count_dp_nested_1_1 PARTITION OF approx_count_dp_nested_1 FOR VALUES FROM (10) TO (20);
INSERT INTO approx_count_dp_nested VALUES('2004-01-01 10:00:00', 1, 1);
INSERT INTO approx_count_dp_nested VALUES('2004-01-01 10:00:00', 2, 1);
INSERT INTO approx_count_dp_nested VALUES('2004-01-01 10:00:00', 3, 1);
INSERT INTO approx_count_dp_nested VALUES('2004-01-01 10:00:00', 11, 1);
INSERT INTO approx_count_dp_nested VALUES('2004-01-01 10:00:00', 12, 1);
INSERT INTO approx_count_dp_nested VALUES('2004-01-01 10:00:00', 13, 1);
INSERT INTO approx_count_dp_nested VALUES('2005-01-01 10:00:00', 1, 1);
INSERT INTO approx_count_dp_nested VALUES('2005-01-01 10:00:00', 2, 1);
INSERT INTO approx_count_dp_nested VALUES('2005-01-01 10:00:00', 3, 1);
INSERT INTO approx_count_dp_nested VALUES('2005-01-01 10:00:00', 11, 1);
INSERT INTO approx_count_dp_nested VALUES('2005-01-01 10:00:00', 12, 1);
INSERT INTO approx_count_dp_nested VALUES('2005-01-01 10:00:00', 13, 1);
SELECT * FROM approximate_row_count('approx_count_dp_nested');
ANALYZE approx_count_dp_nested;
SELECT
(SELECT count(*) FROM approx_count_dp_nested) AS dp_nested,
(SELECT count(*) FROM approx_count_dp_nested_0) AS dp_nested_0,
(SELECT count(*) FROM approx_count_dp_nested_0_0) AS dp_nested_0_0,
(SELECT count(*) FROM approx_count_dp_nested_0_1) AS dp_nested_0_1,
(SELECT count(*) FROM approx_count_dp_nested_1) AS dp_nested_1,
(SELECT count(*) FROM approx_count_dp_nested_1_0) AS dp_nested_1_0,
(SELECT count(*) FROM approx_count_dp_nested_1_1) AS dp_nested_1_1
UNION ALL
SELECT
approximate_row_count('approx_count_dp_nested'),
approximate_row_count('approx_count_dp_nested_0'),
approximate_row_count('approx_count_dp_nested_0_0'),
approximate_row_count('approx_count_dp_nested_0_1'),
approximate_row_count('approx_count_dp_nested_1'),
approximate_row_count('approx_count_dp_nested_1_0'),
approximate_row_count('approx_count_dp_nested_1_1');
-- Hypertable
--
CREATE TABLE approx_count(time TIMESTAMP, value int);
SELECT * FROM create_hypertable('approx_count', 'time');
INSERT INTO approx_count VALUES('2004-01-01 10:00:01', 1);
INSERT INTO approx_count VALUES('2004-01-01 10:00:02', 2);
INSERT INTO approx_count VALUES('2004-01-01 10:00:03', 3);
INSERT INTO approx_count VALUES('2004-01-01 10:00:04', 4);
INSERT INTO approx_count VALUES('2004-01-01 10:00:05', 5);
INSERT INTO approx_count VALUES('2004-01-01 10:00:06', 6);
INSERT INTO approx_count VALUES('2004-01-01 10:00:07', 7);
INSERT INTO approx_count VALUES('2004-01-01 10:00:08', 8);
INSERT INTO approx_count VALUES('2004-01-01 10:00:09', 9);
INSERT INTO approx_count VALUES('2004-01-01 10:00:10', 10);
SELECT count(*) FROM approx_count;
SELECT * FROM approximate_row_count('approx_count');
ANALYZE approx_count;
SELECT * FROM approximate_row_count('approx_count');
\set ON_ERROR_STOP 0
SELECT * FROM approximate_row_count('unexisting');
SELECT * FROM approximate_row_count();
SELECT * FROM approximate_row_count(NULL);
\set ON_ERROR_STOP 1
-- Test size functions with invalid or non-existing OID
SELECT * FROM hypertable_size(0);
SELECT * FROM hypertable_detailed_size(0) ORDER BY node_name;
SELECT * FROM chunks_detailed_size(0) ORDER BY node_name;
SELECT * FROM hypertable_compression_stats(0) ORDER BY node_name;
SELECT * FROM chunk_compression_stats(0) ORDER BY node_name;
SELECT * FROM hypertable_index_size(0);
SELECT * FROM _timescaledb_internal.relation_size(0);
SELECT * FROM hypertable_size(1);
SELECT * FROM hypertable_detailed_size(1) ORDER BY node_name;
SELECT * FROM chunks_detailed_size(1) ORDER BY node_name;
SELECT * FROM hypertable_compression_stats(1) ORDER BY node_name;
SELECT * FROM chunk_compression_stats(1) ORDER BY node_name;
SELECT * FROM hypertable_index_size(1);
SELECT * FROM _timescaledb_internal.relation_size(1);
-- Test size functions with NULL input
SELECT * FROM hypertable_size(NULL);
SELECT * FROM hypertable_detailed_size(NULL) ORDER BY node_name;
SELECT * FROM chunks_detailed_size(NULL) ORDER BY node_name;
SELECT * FROM hypertable_compression_stats(NULL) ORDER BY node_name;
SELECT * FROM chunk_compression_stats(NULL) ORDER BY node_name;
SELECT * FROM hypertable_index_size(NULL);
SELECT * FROM _timescaledb_internal.relation_size(NULL);
-- Test size functions on regular table
CREATE TABLE hypersize(time timestamptz, device int);
CREATE INDEX hypersize_time_idx ON hypersize (time);
\set ON_ERROR_STOP 0
\set VERBOSITY default
\set SHOW_CONTEXT never
SELECT pg_relation_size('hypersize'), pg_table_size('hypersize'), pg_indexes_size('hypersize'), pg_total_relation_size('hypersize'), pg_relation_size('hypersize_time_idx');
SELECT * FROM _timescaledb_internal.relation_size('hypersize');
SELECT * FROM hypertable_size('hypersize');
SELECT * FROM hypertable_detailed_size('hypersize') ORDER BY node_name;
SELECT * FROM chunks_detailed_size('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM chunk_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_index_size('hypersize_time_idx');
\set VERBOSITY terse
\set ON_ERROR_STOP 1
-- Test size functions on empty hypertable
SELECT * FROM create_hypertable('hypersize', 'time');
SELECT pg_relation_size('hypersize'), pg_table_size('hypersize'), pg_indexes_size('hypersize'), pg_total_relation_size('hypersize'), pg_relation_size('hypersize_time_idx');
SELECT * FROM _timescaledb_internal.relation_size('hypersize');
SELECT * FROM hypertable_size('hypersize');
SELECT * FROM hypertable_detailed_size('hypersize') ORDER BY node_name;
SELECT * FROM chunks_detailed_size('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM chunk_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_index_size('hypersize_time_idx');
-- Test size functions on non-empty hypertable
INSERT INTO hypersize VALUES('2021-02-25', 1);
SELECT pg_relation_size('hypersize'), pg_table_size('hypersize'), pg_indexes_size('hypersize'), pg_total_relation_size('hypersize'), pg_relation_size('hypersize_time_idx');
SELECT pg_relation_size(ch), pg_table_size(ch), pg_indexes_size(ch), pg_total_relation_size(ch)
FROM show_chunks('hypersize') ch
ORDER BY ch;
SELECT * FROM show_chunks('hypersize') ch JOIN LATERAL _timescaledb_internal.relation_size(ch) ON true;
SELECT * FROM hypertable_size('hypersize');
SELECT * FROM hypertable_detailed_size('hypersize') ORDER BY node_name;
SELECT * FROM chunks_detailed_size('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM chunk_compression_stats('hypersize') ORDER BY node_name;
SELECT * FROM hypertable_index_size('hypersize_time_idx');
|
# Todos schema
# --- !Ups
CREATE TABLE Todo (
id SERIAL,
title text NOT NULL,
completed boolean NOT NULL,
"order" int);
# --- !Downs
DROP TABLE Todo;
|
select
nation,
o_year,
sum(amount) as sum_profit
from
(
select
n_name as nation,
extract(year from o_orderdate) as o_year,
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
from
part,
supplier,
lineitem,
partsupp,
orders,
nation
where
s_suppkey = l_suppkey
and ps_suppkey = l_suppkey
and ps_partkey = l_partkey
and p_partkey = l_partkey
and o_orderkey = l_orderkey
and s_nationkey = n_nationkey
and p_name like '%green%'
) as profit
group by
nation,
o_year
order by
nation,
o_year desc
|
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/01.types-domains-tables-and-constraints/tables-and-constraints.sql --<--<--
EXECUTE dbo.drop_schema 'account';
GO
CREATE SCHEMA account;
GO
CREATE TABLE account.roles
(
role_id integer PRIMARY KEY,
role_name national character varying(100) NOT NULL UNIQUE,
is_administrator bit NOT NULL DEFAULT(0),
audit_user_id integer,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE TABLE account.installed_domains
(
domain_id integer IDENTITY NOT NULL PRIMARY KEY,
domain_name national character varying(500),
admin_email national character varying(500),
audit_user_id integer,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE UNIQUE INDEX installed_domains_domain_name_uix
ON account.installed_domains(domain_name)
WHERE deleted = 0;
CREATE TABLE account.configuration_profiles
(
configuration_profile_id integer IDENTITY PRIMARY KEY,
profile_name national character varying(100) NOT NULL UNIQUE,
is_active bit NOT NULL DEFAULT(1),
allow_registration bit NOT NULL DEFAULT(1),
registration_office_id integer NOT NULL REFERENCES core.offices,
registration_role_id integer NOT NULL REFERENCES account.roles,
allow_facebook_registration bit NOT NULL DEFAULT(1),
allow_google_registration bit NOT NULL DEFAULT(1),
google_signin_client_id national character varying(500),
google_signin_scope national character varying(500),
facebook_app_id national character varying(500),
facebook_scope national character varying(500),
audit_user_id integer,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE UNIQUE INDEX configuration_profile_uix
ON account.configuration_profiles(is_active)
WHERE is_active = 1
AND deleted = 0;
CREATE TABLE account.registrations
(
registration_id uniqueidentifier PRIMARY KEY DEFAULT(NEWID()),
name national character varying(100),
email national character varying(100) NOT NULL,
phone national character varying(100),
password national character varying(500),
browser national character varying(500),
ip_address national character varying(50),
registered_on datetimeoffset NOT NULL DEFAULT(getutcdate()),
confirmed bit DEFAULT(0),
confirmed_on datetimeoffset,
audit_user_id integer,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE UNIQUE INDEX registrations_email_uix
ON account.registrations(email)
WHERE deleted = 0;
CREATE TABLE account.users
(
user_id integer IDENTITY PRIMARY KEY,
email national character varying(100) NOT NULL,
password national character varying(500),
office_id integer NOT NULL REFERENCES core.offices,
role_id integer NOT NULL REFERENCES account.roles,
name national character varying(100),
phone national character varying(100),
status bit DEFAULT(1),
created_on datetimeoffset NOT NULL DEFAULT(getutcdate()),
last_seen_on datetimeoffset,
last_ip national character varying(500),
last_browser national character varying(500),
audit_user_id integer REFERENCES account.users,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE UNIQUE INDEX users_email_uix
ON account.users(email)
WHERE deleted = 0;
ALTER TABLE account.configuration_profiles
ADD FOREIGN KEY(audit_user_id) REFERENCES account.users;
ALTER TABLE account.roles
ADD FOREIGN KEY(audit_user_id) REFERENCES account.users;
CREATE TABLE account.reset_requests
(
request_id uniqueidentifier PRIMARY KEY DEFAULT(NEWID()),
user_id integer NOT NULL REFERENCES account.users,
email national character varying(500),
name national character varying(500),
requested_on datetimeoffset NOT NULL DEFAULT(getutcdate()),
expires_on datetimeoffset NOT NULL DEFAULT(dateadd(d, 1, getutcdate())),
browser national character varying(500),
ip_address national character varying(50),
confirmed bit DEFAULT(0),
confirmed_on datetimeoffset,
audit_user_id integer REFERENCES account.users,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE TABLE account.fb_access_tokens
(
user_id integer PRIMARY KEY REFERENCES account.users,
fb_user_id national character varying(500),
token national character varying(MAX),
audit_user_id integer REFERENCES account.users,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE TABLE account.google_access_tokens
(
user_id integer PRIMARY KEY REFERENCES account.users,
token national character varying(MAX),
audit_user_id integer REFERENCES account.users,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE TABLE account.logins
(
login_id bigint IDENTITY PRIMARY KEY,
user_id integer REFERENCES account.users,
office_id integer REFERENCES core.offices,
browser national character varying(500),
ip_address national character varying(50),
is_active bit NOT NULL DEFAULT(1),
login_timestamp datetimeoffset NOT NULL DEFAULT(getutcdate()),
culture national character varying(12) NOT NULL,
audit_user_id integer REFERENCES account.users,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE TABLE account.applications
(
application_id uniqueidentifier DEFAULT(NEWID()) PRIMARY KEY,
application_name national character varying(100) NOT NULL,
display_name national character varying(100),
version_number national character varying(100),
publisher national character varying(100) NOT NULL,
published_on date,
application_url national character varying(500),
description national character varying(500),
browser_based_app bit NOT NULL,
privacy_policy_url national character varying(500),
terms_of_service_url national character varying(500),
support_email national character varying(100),
culture national character varying(12),
redirect_url national character varying(500),
app_secret national character varying(500) UNIQUE,
audit_user_id integer REFERENCES account.users,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
CREATE UNIQUE INDEX applications_app_name_uix
ON account.applications(application_name)
WHERE deleted = 0;
CREATE TABLE account.access_tokens
(
access_token_id uniqueidentifier DEFAULT(NEWID()) PRIMARY KEY,
issued_by national character varying(500) NOT NULL,
audience national character varying(500) NOT NULL,
ip_address national character varying(100),
user_agent national character varying(500),
header national character varying(500),
subject national character varying(500),
token_id national character varying(500),
application_id uniqueidentifier NULL REFERENCES account.applications,
login_id bigint NOT NULL REFERENCES account.logins,
client_token national character varying(MAX),
claims national character varying(MAX),
created_on datetimeoffset NOT NULL,
expires_on datetimeoffset NOT NULL,
revoked bit NOT NULL DEFAULT(0),
revoked_by integer REFERENCES account.users,
revoked_on datetimeoffset,
audit_user_id integer REFERENCES account.users,
audit_ts DATETIMEOFFSET NULL DEFAULT(GETUTCDATE()),
deleted bit DEFAULT(0)
);
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.add_installed_domain.sql --<--<--
IF OBJECT_ID('account.add_installed_domain') IS NOT NULL
DROP PROCEDURE account.add_installed_domain;
GO
CREATE PROCEDURE account.add_installed_domain
(
@domain_name national character varying(500),
@admin_email national character varying(500)
)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
IF EXISTS
(
SELECT * FROM account.installed_domains
WHERE domain_name = @domain_name
AND account.installed_domains.deleted = 0
)
BEGIN
UPDATE account.installed_domains
SET admin_email = @admin_email
WHERE domain_name = @domain_name;
RETURN;
END;
INSERT INTO account.installed_domains(domain_name, admin_email)
SELECT @domain_name, @admin_email;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.can_confirm_registration.sql --<--<--
IF OBJECT_ID('account.can_confirm_registration') IS NOT NULL
DROP FUNCTION account.can_confirm_registration;
GO
CREATE FUNCTION account.can_confirm_registration(@token uniqueidentifier)
RETURNS bit
AS
BEGIN
IF EXISTS
(
SELECT *
FROM account.registrations
WHERE registration_id = @token
AND confirmed = 0
AND account.registrations.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.can_register_with_facebook.sql --<--<--
IF OBJECT_ID('account.can_register_with_facebook') IS NOT NULL
DROP FUNCTION account.can_register_with_facebook;
GO
CREATE FUNCTION account.can_register_with_facebook()
RETURNS bit
AS
BEGIN
IF EXISTS
(
SELECT 1 FROM account.configuration_profiles
WHERE is_active = 1
AND allow_registration = 1
AND allow_facebook_registration = 1
AND account.configuration_profiles.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.can_register_with_google.sql --<--<--
IF OBJECT_ID('account.can_register_with_google') IS NOT NULL
DROP FUNCTION account.can_register_with_google;
GO
CREATE FUNCTION account.can_register_with_google()
RETURNS bit
AS
BEGIN
IF EXISTS
(
SELECT 1 FROM account.configuration_profiles
WHERE is_active = 1
AND allow_registration = 1
AND allow_google_registration = 1
AND account.configuration_profiles.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.complete_reset.sql --<--<--
IF OBJECT_ID('account.complete_reset') IS NOT NULL
DROP PROCEDURE account.complete_reset;
GO
CREATE PROCEDURE account.complete_reset
(
@request_id uniqueidentifier,
@password national character varying(500)
)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @user_id integer;
DECLARE @email national character varying(500);
BEGIN TRY
DECLARE @tran_count int = @@TRANCOUNT;
IF(@tran_count= 0)
BEGIN
BEGIN TRANSACTION
END;
SELECT
@user_id = account.users.user_id,
@email = account.users.email
FROM account.reset_requests
INNER JOIN account.users
ON account.users.user_id = account.reset_requests.user_id
WHERE account.reset_requests.request_id = @request_id
AND expires_on >= getutcdate()
AND account.reset_requests.deleted = 0;
UPDATE account.users
SET
password = <PASSWORD>
WHERE user_id = @user_id;
UPDATE account.reset_requests
SET confirmed = 1, confirmed_on = getutcdate()
WHERE user_id = @user_id;
IF(@tran_count = 0)
BEGIN
COMMIT TRANSACTION;
END;
END TRY
BEGIN CATCH
IF(XACT_STATE() <> 0 AND @tran_count = 0)
BEGIN
ROLLBACK TRANSACTION;
END;
DECLARE @ErrorMessage national character varying(4000) = ERROR_MESSAGE();
DECLARE @ErrorSeverity int = ERROR_SEVERITY();
DECLARE @ErrorState int = ERROR_STATE();
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.confirm_registration.sql --<--<--
IF OBJECT_ID('account.confirm_registration') IS NOT NULL
DROP PROCEDURE account.confirm_registration;
GO
CREATE PROCEDURE account.confirm_registration(@token uniqueidentifier)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @can_confirm bit;
DECLARE @office_id integer;
DECLARE @role_id integer;
BEGIN TRY
DECLARE @tran_count int = @@TRANCOUNT;
IF(@tran_count= 0)
BEGIN
BEGIN TRANSACTION
END;
SET @can_confirm = account.can_confirm_registration(@token);
IF(@can_confirm = 0)
BEGIN
SELECT 0;
RETURN;
END;
SELECT
TOP 1
@office_id = registration_office_id
FROM account.configuration_profiles
WHERE is_active = 1;
INSERT INTO account.users(email, password, office_id, role_id, name, phone)
SELECT email, password, @office_id, account.get_registration_role_id(email), name, phone
FROM account.registrations
WHERE registration_id = @token
AND confirmed = 0;
UPDATE account.registrations
SET
confirmed = 1,
confirmed_on = getutcdate()
WHERE registration_id = @token;
IF(@tran_count = 0)
BEGIN
COMMIT TRANSACTION;
END;
SELECT 1;
END TRY
BEGIN CATCH
IF(XACT_STATE() <> 0 AND @tran_count = 0)
BEGIN
ROLLBACK TRANSACTION;
END;
DECLARE @ErrorMessage national character varying(4000) = ERROR_MESSAGE();
DECLARE @ErrorSeverity int = ERROR_SEVERITY();
DECLARE @ErrorState int = ERROR_STATE();
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.email_exists.sql --<--<--
IF OBJECT_ID('account.email_exists') IS NOT NULL
DROP FUNCTION account.email_exists;
GO
CREATE FUNCTION account.email_exists(@email national character varying(100))
RETURNS bit
AS
BEGIN
DECLARE @count integer;
SELECT @count = count(*)
FROM account.users
WHERE email = @email
AND account.users.deleted = 0;
IF(COALESCE(@count, 0) = 0)
BEGIN
SELECT @count = count(*)
FROM account.registrations
WHERE email = @email
AND account.registrations.deleted = 0;
END;
IF COALESCE(@count, 0) > 0
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.fb_sign_in.sql --<--<--
IF OBJECT_ID('account.fb_sign_in') IS NOT NULL
DROP PROCEDURE account.fb_sign_in;
GO
CREATE PROCEDURE account.fb_sign_in
(
@fb_user_id national character varying(500),
@email national character varying(500),
@office_id integer,
@name national character varying(500),
@token national character varying(500),
@browser national character varying(500),
@ip_address national character varying(500),
@culture national character varying(500)
)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @user_id integer;
DECLARE @login_id bigint;
DECLARE @auto_register bit = 0;
DECLARE @result TABLE
(
login_id bigint,
status bit,
message national character varying(500)
);
BEGIN TRY
DECLARE @tran_count int = @@TRANCOUNT;
IF(@tran_count= 0)
BEGIN
BEGIN TRANSACTION
END;
IF(COALESCE(@office_id, 0) = 0)
BEGIN
IF(SELECT COUNT(*) FROM core.offices) = 1
BEGIN
SELECT @office_id = office_id
FROM core.offices;
END;
END;
IF account.is_restricted_user(@email) = 1
BEGIN
--LOGIN IS RESTRICTED TO THIS USER
INSERT INTO @result
SELECT CAST(NULL AS bigint), 0, 'Access is denied';
SELECT * FROM @result;
RETURN;
END;
SELECT @user_id = user_id
FROM account.users
WHERE account.users.email = @email;
IF account.user_exists(@email) = 0 AND account.can_register_with_facebook() = 1
BEGIN
INSERT INTO account.users(role_id, office_id, email, name)
SELECT account.get_registration_role_id(@email), account.get_registration_office_id(), @email, @name;
SET @user_id = SCOPE_IDENTITY();
END;
IF account.fb_user_exists(@user_id) = 0
BEGIN
INSERT INTO account.fb_access_tokens(user_id, fb_user_id, token)
SELECT COALESCE(@user_id, account.get_user_id_by_email(@email)), @fb_user_id, @token;
END
ELSE
BEGIN
UPDATE account.fb_access_tokens
SET token = @token
WHERE user_id = @user_id;
END;
IF(@user_id IS NULL)
BEGIN
SELECT @user_id = user_id
FROM account.users
WHERE account.users.email = @email;
END;
UPDATE account.logins
SET is_active = 0
WHERE user_id=@user_id
AND office_id = @office_id
AND browser = @browser
AND ip_address = @ip_address;
INSERT INTO account.logins(user_id, office_id, browser, ip_address, login_timestamp, culture)
SELECT @user_id, @office_id, @browser, @ip_address, getutcdate(), COALESCE(@culture, '');
SET @login_id = SCOPE_IDENTITY();
INSERT INTO @result
SELECT @login_id, 1, 'Welcome';
SELECT * FROM @result;
IF(@tran_count = 0)
BEGIN
COMMIT TRANSACTION;
END;
END TRY
BEGIN CATCH
IF(XACT_STATE() <> 0 AND @tran_count = 0)
BEGIN
ROLLBACK TRANSACTION;
END;
DECLARE @ErrorMessage national character varying(4000) = ERROR_MESSAGE();
DECLARE @ErrorSeverity int = ERROR_SEVERITY();
DECLARE @ErrorState int = ERROR_STATE();
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.fb_user_exists.sql --<--<--
IF OBJECT_ID('account.fb_user_exists') IS NOT NULL
DROP FUNCTION account.fb_user_exists;
GO
CREATE FUNCTION account.fb_user_exists(@user_id integer)
RETURNS bit
AS
BEGIN
IF EXISTS
(
SELECT *
FROM account.fb_access_tokens
WHERE account.fb_access_tokens.user_id = @user_id
AND account.fb_access_tokens.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_email_by_user_id.sql --<--<--
IF OBJECT_ID('account.get_email_by_user_id') IS NOT NULL
DROP FUNCTION account.get_email_by_user_id;
GO
CREATE FUNCTION account.get_email_by_user_id(@user_id integer)
RETURNS national character varying(500)
AS
BEGIN
RETURN
(
SELECT
account.users.email
FROM account.users
WHERE account.users.user_id = @user_id
AND account.users.deleted = 0
);
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_name_by_user_id.sql --<--<--
IF OBJECT_ID('account.get_name_by_user_id') IS NOT NULL
DROP FUNCTION account.get_name_by_user_id;
GO
CREATE FUNCTION account.get_name_by_user_id(@user_id integer)
RETURNS national character varying(500)
AS
BEGIN
RETURN
(
SELECT
account.users.name
FROM account.users
WHERE account.users.user_id = @user_id
AND account.users.deleted = 0
);
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_office_id_by_login_id.sql --<--<--
IF OBJECT_ID('account.get_office_id_by_login_id') IS NOT NULL
DROP FUNCTION account.get_office_id_by_login_id;
GO
CREATE FUNCTION account.get_office_id_by_login_id(@login_id bigint)
RETURNS integer
AS
BEGIN
RETURN
(
SELECT account.logins.office_id
FROM account.logins
WHERE account.logins.login_id = @login_id
);
END;
GO
--SELECT account.get_office_id_by_login_id(1);
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_registration_office_id.sql --<--<--
IF OBJECT_ID('account.get_registration_office_id') IS NOT NULL
DROP FUNCTION account.get_registration_office_id;
GO
CREATE FUNCTION account.get_registration_office_id()
RETURNS integer
AS
BEGIN
RETURN
(
SELECT
registration_office_id
FROM account.configuration_profiles
WHERE is_active = 1
AND account.configuration_profiles.deleted = 0
);
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_registration_role_id.sql --<--<--
IF OBJECT_ID('account.get_registration_role_id') IS NOT NULL
DROP FUNCTION account.get_registration_role_id;
GO
CREATE FUNCTION account.get_registration_role_id(@email national character varying(500))
RETURNS integer
AS
BEGIN
DECLARE @is_admin bit = 0;
DECLARE @role_id integer;
IF EXISTS
(
SELECT * FROM account.installed_domains
WHERE admin_email = @email
AND account.installed_domains.deleted = 0
)
BEGIN
SET @is_admin = 1;
END;
IF(@is_admin = 1)
BEGIN
SELECT
TOP 1
@role_id = role_id
FROM account.roles
WHERE is_administrator = 1
AND account.roles.deleted = 0;
END
ELSE
BEGIN
SELECT
@role_id = registration_role_id
FROM account.configuration_profiles
WHERE is_active = 1
AND account.configuration_profiles.deleted = 0;
END;
RETURN @role_id;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_role_name_by_role_id.sql --<--<--
IF OBJECT_ID('account.get_role_name_by_role_id') IS NOT NULL
DROP FUNCTION account.get_role_name_by_role_id;
GO
CREATE FUNCTION account.get_role_name_by_role_id(@role_id integer)
RETURNS national character varying(100)
AS
BEGIN
RETURN
(
SELECT account.roles.role_name
FROM account.roles
WHERE account.roles.role_id = @role_id
);
END
GO
--SELECT account.get_role_name_by_role_id(9999);
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_user_id_by_email.sql --<--<--
IF OBJECT_ID('account.get_user_id_by_email') IS NOT NULL
DROP FUNCTION account.get_user_id_by_email;
GO
CREATE FUNCTION account.get_user_id_by_email(@email national character varying(100))
RETURNS integer
AS
BEGIN
RETURN
(
SELECT
user_id
FROM account.users
WHERE account.users.email = @email
AND account.users.deleted = 0
);
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.get_user_id_by_login_id.sql --<--<--
IF OBJECT_ID('account.get_user_id_by_login_id') IS NOT NULL
DROP FUNCTION account.get_user_id_by_login_id;
GO
CREATE FUNCTION account.get_user_id_by_login_id(@login_id bigint)
RETURNS integer
AS
BEGIN
RETURN
(
SELECT
user_id
FROM account.logins
WHERE account.logins.login_id = @login_id
AND account.logins.deleted = 0
);
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.google_sign_in.sql --<--<--
IF OBJECT_ID('account.google_sign_in') IS NOT NULL
DROP PROCEDURE account.google_sign_in;
GO
CREATE PROCEDURE account.google_sign_in
(
@email national character varying(500),
@office_id integer,
@name national character varying(500),
@token national character varying(500),
@browser national character varying(500),
@ip_address national character varying(500),
@culture national character varying(500)
)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @user_id integer;
DECLARE @login_id bigint;
DECLARE @result TABLE
(
login_id bigint,
status bit,
message text
);
BEGIN TRY
DECLARE @tran_count int = @@TRANCOUNT;
IF(@tran_count= 0)
BEGIN
BEGIN TRANSACTION
END;
IF(COALESCE(@office_id, 0) = 0)
BEGIN
IF(SELECT COUNT(*) FROM core.offices) = 1
BEGIN
SELECT @office_id = office_id
FROM core.offices;
END;
END;
IF account.is_restricted_user(@email) = 1
BEGIN
--LOGIN IS RESTRICTED TO THIS USER
INSERT INTO @result
SELECT CAST(NULL AS bigint), 0, 'Access is denied';
SELECT * FROM @result;
RETURN;
END;
IF account.user_exists(@email) = 0 AND account.can_register_with_google() = 1
BEGIN
INSERT INTO account.users(role_id, office_id, email, name)
SELECT account.get_registration_role_id(@email), account.get_registration_office_id(), @email, @name;
SET @user_id = SCOPE_IDENTITY();
END;
SELECT @user_id = user_id
FROM account.users
WHERE account.users.email = @email;
IF account.google_user_exists(@user_id) = 0
BEGIN
INSERT INTO account.google_access_tokens(user_id, token)
SELECT COALESCE(@user_id, account.get_user_id_by_email(@email)), @token;
END
ELSE
BEGIN
UPDATE account.google_access_tokens
SET token = @token
WHERE user_id = @user_id;
END;
UPDATE account.logins
SET is_active = 0
WHERE user_id=@user_id
AND office_id = @office_id
AND browser = @browser
AND ip_address = @ip_address;
INSERT INTO account.logins(user_id, office_id, browser, ip_address, login_timestamp, culture)
SELECT @user_id, @office_id, @browser, @ip_address, getutcdate(), COALESCE(@culture, '');
SET @login_id = SCOPE_IDENTITY();
INSERT INTO @result
SELECT @login_id, 1, 'Welcome';
SELECT * FROM @result;
IF(@tran_count = 0)
BEGIN
COMMIT TRANSACTION;
END;
END TRY
BEGIN CATCH
IF(XACT_STATE() <> 0 AND @tran_count = 0)
BEGIN
ROLLBACK TRANSACTION;
END;
DECLARE @ErrorMessage national character varying(4000) = ERROR_MESSAGE();
DECLARE @ErrorSeverity int = ERROR_SEVERITY();
DECLARE @ErrorState int = ERROR_STATE();
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.google_user_exists.sql --<--<--
IF OBJECT_ID('account.google_user_exists') IS NOT NULL
DROP FUNCTION account.google_user_exists;
GO
CREATE FUNCTION account.google_user_exists(@user_id integer)
RETURNS bit
AS
BEGIN
IF EXISTS
(
SELECT *
FROM account.google_access_tokens
WHERE account.google_access_tokens.user_id = @user_id
AND account.google_access_tokens.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.has_account.sql --<--<--
IF OBJECT_ID('account.has_account') IS NOT NULL
DROP FUNCTION account.has_account;
GO
CREATE FUNCTION account.has_account(@email national character varying(100))
RETURNS bit
AS
BEGIN
DECLARE @count integer;
SELECT @count = count(*)
FROM account.users
WHERE email = @email
AND account.users.deleted = 0;
IF COALESCE(@count, 0) = 1
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.has_active_reset_request.sql --<--<--
IF OBJECT_ID('account.has_active_reset_request') IS NOT NULL
DROP FUNCTION account.has_active_reset_request;
GO
CREATE FUNCTION account.has_active_reset_request(@email national character varying(500))
RETURNS bit
AS
BEGIN
DECLARE @expires_on datetimeoffset = dateadd(d, 1, getutcdate());
IF EXISTS
(
SELECT * FROM account.reset_requests
WHERE email = @email
AND expires_on <= @expires_on
AND account.reset_requests.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.is_admin.sql --<--<--
IF OBJECT_ID('account.is_admin') IS NOT NULL
DROP FUNCTION account.is_admin;
GO
CREATE FUNCTION account.is_admin(@user_id integer)
RETURNS bit
AS
BEGIN
RETURN
(
SELECT account.roles.is_administrator FROM account.users
INNER JOIN account.roles
ON account.users.role_id = account.roles.role_id
WHERE account.users.user_id=@user_id
);
END;
GO
--SELECT account.is_admin(1);
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.is_restricted_user.sql --<--<--
IF OBJECT_ID('account.is_restricted_user') IS NOT NULL
DROP FUNCTION account.is_restricted_user;
GO
CREATE FUNCTION account.is_restricted_user(@email national character varying(100))
RETURNS bit
AS
BEGIN
IF EXISTS
(
SELECT *
FROM account.users
WHERE account.users.email = @email
AND account.users.status = 0
AND account.users.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.is_valid_client_token.sql --<--<--
IF OBJECT_ID('account.is_valid_client_token') IS NOT NULL
DROP FUNCTION account.is_valid_client_token;
GO
CREATE FUNCTION account.is_valid_client_token(@client_token national character varying(MAX), @ip_address national character varying(500), @user_agent national character varying(500))
RETURNS bit
AS
BEGIN
DECLARE @created_on datetimeoffset;
DECLARE @expires_on datetimeoffset;
DECLARE @revoked bit;
IF(COALESCE(@client_token, '') = '')
BEGIN
RETURN 0;
END;
SELECT
@created_on = created_on,
@expires_on = expires_on,
@revoked = revoked
FROM account.access_tokens
WHERE client_token = @client_token
AND ip_address = @ip_address
AND user_agent = @user_agent
AND account.access_tokens.deleted = 0;
IF(COALESCE(@revoked, 1)) = 1
BEGIN
RETURN 0;
END;
IF(@created_on > getutcdate())
BEGIN
RETURN 0;
END;
IF(COALESCE(@expires_on, getutcdate()) <= getutcdate())
BEGIN
RETURN 0;
END;
RETURN 1;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.is_valid_login_id.sql --<--<--
IF OBJECT_ID('account.is_valid_login_id') IS NOT NULL
DROP FUNCTION account.is_valid_login_id;
GO
CREATE FUNCTION account.is_valid_login_id(@login_id bigint)
RETURNS bit
BEGIN
IF EXISTS(SELECT 1 FROM account.logins WHERE login_id=@login_id)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
--SELECT account.is_valid_login_id(1);
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.reset_account.sql --<--<--
IF OBJECT_ID('account.reset_account') IS NOT NULL
DROP PROCEDURE account.reset_account;
GO
CREATE PROCEDURE account.reset_account
(
@email national character varying(500),
@browser national character varying(500),
@ip_address national character varying(500)
)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @request_table_variable TABLE(request_id uniqueidentifier);
DECLARE @user_id integer;
DECLARE @name national character varying(500);
DECLARE @expires_on datetimeoffset = dateadd(d, 1, getutcdate());
BEGIN TRY
DECLARE @tran_count int = @@TRANCOUNT;
IF(@tran_count= 0)
BEGIN
BEGIN TRANSACTION
END;
IF(account.user_exists(@email) = 0 OR account.is_restricted_user(@email) = 1)
BEGIN
RETURN;
END;
SELECT
@user_id = user_id,
@name = name
FROM account.users
WHERE email = @email
AND account.users.deleted = 0;
IF account.has_active_reset_request(@email) = 1
BEGIN
SELECT
TOP 1
* FROM account.reset_requests
WHERE email = @email
AND expires_on <= @expires_on
AND account.reset_requests.deleted = 0;
RETURN;
END;
INSERT INTO account.reset_requests(user_id, email, name, browser, ip_address, expires_on)
OUTPUT INSERTED.request_id INTO @request_table_variable
SELECT @user_id, @email, @name, @browser, @ip_address, @expires_on
SELECT *
FROM account.reset_requests
WHERE request_id =
(
SELECT request_id
FROM @request_table_variable
);
IF(@tran_count = 0)
BEGIN
COMMIT TRANSACTION;
END;
END TRY
BEGIN CATCH
IF(XACT_STATE() <> 0 AND @tran_count = 0)
BEGIN
ROLLBACK TRANSACTION;
END;
DECLARE @ErrorMessage national character varying(4000) = ERROR_MESSAGE();
DECLARE @ErrorSeverity int = ERROR_SEVERITY();
DECLARE @ErrorState int = ERROR_STATE();
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.sign_in.sql --<--<--
IF OBJECT_ID('account.sign_in') IS NOT NULL
DROP PROCEDURE account.sign_in;
GO
CREATE PROCEDURE account.sign_in
(
@email national character varying(500),
@office_id integer,
@browser national character varying(500),
@ip_address national character varying(500),
@culture national character varying(500)
)
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @login_id bigint;
DECLARE @user_id integer;
DECLARE @result TABLE
(
login_id bigint,
status bit,
message national character varying(100)
);
BEGIN TRY
DECLARE @tran_count int = @@TRANCOUNT;
IF(@tran_count= 0)
BEGIN
BEGIN TRANSACTION
END;
IF(COALESCE(@office_id, 0) = 0)
BEGIN
IF(SELECT COUNT(*) FROM core.offices) = 1
BEGIN
SELECT @office_id = office_id
FROM core.offices;
END;
END;
IF account.is_restricted_user(@email) = 1
BEGIN
INSERT INTO @result
SELECT CAST(NULL AS bigint), 0, 'Access is denied';
SELECT * FROM @result;
RETURN;
END;
SELECT @user_id = user_id
FROM account.users
WHERE email = @email;
UPDATE account.logins
SET is_active = 0
WHERE user_id=@user_id
AND office_id = @office_id
AND browser = @browser
AND ip_address = @ip_address;
INSERT INTO account.logins(user_id, office_id, browser, ip_address, login_timestamp, culture)
SELECT @user_id, @office_id, @browser, @ip_address, getutcdate(), COALESCE(@culture, '');
SET @login_id = SCOPE_IDENTITY();
INSERT INTO @result
SELECT @login_id, 1, 'Welcome';
SELECT * FROM @result;
IF(@tran_count = 0)
BEGIN
COMMIT TRANSACTION;
END;
END TRY
BEGIN CATCH
IF(XACT_STATE() <> 0 AND @tran_count = 0)
BEGIN
ROLLBACK TRANSACTION;
END;
DECLARE @ErrorMessage national character varying(4000) = ERROR_MESSAGE();
DECLARE @ErrorSeverity int = ERROR_SEVERITY();
DECLARE @ErrorState int = ERROR_STATE();
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.functions-and-logic/account.user_exists.sql --<--<--
IF OBJECT_ID('account.user_exists') IS NOT NULL
DROP FUNCTION account.user_exists;
GO
CREATE FUNCTION account.user_exists(@email national character varying(100))
RETURNS bit
AS
BEGIN
IF EXISTS
(
SELECT *
FROM account.users
WHERE account.users.email = @email
AND account.users.deleted = 0
)
BEGIN
RETURN 1;
END;
RETURN 0;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.relationships/auth.sql --<--<--
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.relationships/core.sql --<--<--
ALTER TABLE core.offices
ADD FOREIGN KEY(audit_user_id) REFERENCES account.users;
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/02.triggers/account.token_auto_expiry_trigger.sql --<--<--
IF OBJECT_ID('account.token_auto_expiry_trigger') IS NOT NULL
DROP TRIGGER account.token_auto_expiry_trigger;
GO
CREATE TRIGGER account.token_auto_expiry_trigger
ON account.access_tokens
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
DECLARE @ip_address national character varying(100);
DECLARE @user_agent national character varying(500);
SELECT
@ip_address = ip_address,
@user_agent = user_agent
FROM inserted;
UPDATE account.access_tokens
SET
revoked = 1,
revoked_on = getutcdate()
WHERE ip_address = @ip_address
AND user_agent = @user_agent;
INSERT INTO account.access_tokens(access_token_id, issued_by, audience, ip_address, user_agent, header, subject, token_id, application_id, login_id, client_token, claims, created_on, expires_on, revoked, revoked_by, revoked_on)
SELECT access_token_id, issued_by, audience, ip_address, user_agent, header, subject, token_id, application_id, login_id, client_token, claims, created_on, expires_on, revoked, revoked_by, revoked_on
FROM inserted;
END;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/03.menus/menus.sql --<--<--
EXECUTE core.create_app 'Frapid.Account', 'Account', 'Account', '1.0', 'MixERP Inc.', 'December 1, 2015', 'grey lock', '/dashboard/account/user/list', NULL;
EXECUTE core.create_menu 'Frapid.Account', 'Roles', 'Roles', '/dashboard/account/roles', 'users', '';
EXECUTE core.create_menu 'Frapid.Account', 'Users', 'Users', '', 'user', '';
EXECUTE core.create_menu 'Frapid.Account', 'AddNewUser', 'Add a New User', '/dashboard/account/user/add', 'user', 'Users';
EXECUTE core.create_menu 'Frapid.Account', 'ChangePassword', 'Change Password', '/dashboard/account/user/change-password', 'user', 'Users';
EXECUTE core.create_menu 'Frapid.Account', 'ListUsers', 'List Users', '/dashboard/account/user/list', 'user', 'Users';
EXECUTE core.create_menu 'Frapid.Account', 'ConfigurationProfile', 'Configuration Profile', '/dashboard/account/configuration-profile', 'configure', '';
EXECUTE core.create_menu 'Frapid.Account', 'EmailTemplates', 'Email Templates', '', 'mail', '';
EXECUTE core.create_menu 'Frapid.Account', 'AccountVerification', 'Account Verification', '/dashboard/account/email-templates/account-verification', 'checkmark box', 'Email Templates';
EXECUTE core.create_menu 'Frapid.Account', 'PasswordReset', 'Password Reset', '/dashboard/account/email-templates/password-reset', 'key', 'Email Templates';
EXECUTE core.create_menu 'Frapid.Account', 'WelcomeEmail', 'Welcome Email', '/dashboard/account/email-templates/welcome-email', 'star', 'Email Templates';
EXECUTE core.create_menu 'Frapid.Account', 'WelcomeEmail3rdParty)', 'Welcome Email (3rd Party)', '/dashboard/account/email-templates/welcome-email-other', 'star outline', 'Email Templates';
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/04.default-values/01.default-values.sql --<--<--
INSERT INTO account.roles(role_id, role_name, is_administrator)
SELECT 1000, 'Guest', 0 UNION ALL
SELECT 2000, 'Website User', 0 UNION ALL
SELECT 3000, 'Partner', 0 UNION ALL
SELECT 4000, 'Content Editor', 0 UNION ALL
SELECT 5000, 'Backoffice User', 0 UNION ALL
SELECT 9999, 'Admin', 1;
INSERT INTO account.configuration_profiles(profile_name, is_active, allow_registration, registration_role_id, registration_office_id)
SELECT 'Default', 1, 1, 2000, 1;
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/05.scrud-views/account.configuration_profile_scrud_view.sql --<--<--
IF OBJECT_ID('account.configuration_profile_scrud_view') IS NOT NULL
DROP VIEW account.configuration_profile_scrud_view;
GO
CREATE VIEW account.configuration_profile_scrud_view
AS
SELECT
account.configuration_profiles.configuration_profile_id,
account.configuration_profiles.profile_name,
account.configuration_profiles.is_active,
account.configuration_profiles.allow_registration,
account.roles.role_name AS defult_role,
core.offices.office_code + ' (' + core.offices.office_name + ')' AS default_office
FROM account.configuration_profiles
LEFT JOIN account.roles
ON account.roles.role_id = account.configuration_profiles.registration_role_id
LEFT JOIN core.offices
ON core.offices.office_id = account.configuration_profiles.registration_office_id
WHERE account.configuration_profiles.deleted = 0;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/05.scrud-views/account.user_scrud_view.sql --<--<--
IF OBJECT_ID('account.user_scrud_view') IS NOT NULL
DROP VIEW account.user_scrud_view;
GO
CREATE VIEW account.user_scrud_view
AS
SELECT
account.users.user_id,
account.users.email,
account.users.name,
account.users.phone,
core.offices.office_code + ' (' + core.offices.office_name + ')' AS office,
account.roles.role_name
FROM account.users
INNER JOIN account.roles
ON account.roles.role_id = account.users.role_id
INNER JOIN core.offices
ON core.offices.office_id = account.users.office_id
WHERE account.users.deleted = 0;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/05.scrud-views/account.user_selector_view.sql --<--<--
IF OBJECT_ID('account.user_selector_view') IS NOT NULL
DROP VIEW account.user_selector_view;
GO
CREATE VIEW account.user_selector_view
AS
SELECT
account.users.user_id,
account.users.name AS user_name
FROM account.users
WHERE account.users.deleted = 0;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/05.views/account.sign_in_view.sql --<--<--
IF OBJECT_ID('account.sign_in_view') IS NOT NULL
DROP VIEW account.sign_in_view;
GO
CREATE VIEW account.sign_in_view
AS
SELECT
account.logins.login_id,
account.users.name,
account.users.email,
account.logins.user_id,
account.roles.role_id,
account.roles.role_name,
account.roles.is_administrator,
account.logins.browser,
account.logins.ip_address,
account.logins.login_timestamp,
account.logins.culture,
account.logins.is_active,
account.logins.office_id,
core.offices.office_code,
core.offices.office_name,
core.offices.office_code + ' (' + core.offices.office_name + ')' AS office,
core.offices.logo,
core.offices.registration_date,
core.offices.po_box,
core.offices.address_line_1,
core.offices.address_line_2,
core.offices.street,
core.offices.city,
core.offices.state,
core.offices.zip_code,
core.offices.country,
core.offices.email AS office_email,
core.offices.phone,
core.offices.fax,
core.offices.url,
core.offices.currency_code,
core.currencies.currency_name,
core.currencies.currency_symbol,
core.currencies.hundredth_name,
core.offices.pan_number,
account.users.last_seen_on
FROM account.logins
INNER JOIN account.users
ON account.users.user_id = account.logins.user_id
INNER JOIN account.roles
ON account.roles.role_id = account.users.role_id
INNER JOIN core.offices
ON core.offices.office_id = account.logins.office_id
LEFT JOIN core.currencies
ON core.currencies.currency_code = core.offices.currency_code
WHERE account.logins.deleted = 0;
GO
-->-->-- src/Frapid.Web/Areas/Frapid.Account/db/SQL Server/1.x/1.0/src/99.ownership.sql --<--<--
IF(IS_ROLEMEMBER ('db_owner') = 1)
BEGIN
EXEC sp_addrolemember @rolename = 'db_owner', @membername = 'frapid_db_user';
END
GO
IF(IS_ROLEMEMBER ('db_owner') = 1)
BEGIN
EXEC sp_addrolemember @rolename = 'db_datareader', @membername = 'report_user'
END
GO
DECLARE @proc sysname
DECLARE @cmd varchar(8000)
DECLARE cur CURSOR FOR
SELECT '[' + schema_name(schema_id) + '].[' + name + ']' FROM sys.objects
WHERE type IN('FN')
AND is_ms_shipped = 0
ORDER BY 1
OPEN cur
FETCH next from cur into @proc
WHILE @@FETCH_STATUS = 0
BEGIN
SET @cmd = 'GRANT EXEC ON ' + @proc + ' TO report_user';
EXEC (@cmd)
FETCH next from cur into @proc
END
CLOSE cur
DEALLOCATE cur
GO
|
--
-- Copyright (C) 2016 Red Hat, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
CREATE DATABASE customer OPTIONS (ANNOTATION 'Customer VDB');
USE DATABASE customer;
CREATE FOREIGN DATA WRAPPER fake2 TYPE fake;
CREATE FOREIGN DATA WRAPPER fake3 TYPE fake;
CREATE SERVER fakeSource FOREIGN DATA WRAPPER fake;
CREATE SERVER fakeSource2 FOREIGN DATA WRAPPER fake2;
CREATE SERVER fakeSource3 FOREIGN DATA WRAPPER fake3 OPTIONS ("myProperty" 'foo');
CREATE SERVER amazonAthena FOREIGN DATA WRAPPER "amazon-athena";
CREATE SCHEMA accounts SERVER fakeSource;
CREATE SCHEMA accounts2 SERVER fakeSource2;
CREATE SCHEMA accounts3 SERVER fakeSource3;
CREATE SCHEMA accounts4 SERVER amazonAthena;
CREATE VIRTUAL SCHEMA viewaccount;
SET SCHEMA accounts;
IMPORT FOREIGN SCHEMA public FROM SERVER fakeSource INTO accounts OPTIONS("importer.useFullSchemaName" 'false');
SET SCHEMA accounts2;
IMPORT FOREIGN SCHEMA public FROM SERVER fakeSource2 INTO accounts2 OPTIONS("importer.useFullSchemaName" 'false');
SET SCHEMA accounts3;
IMPORT FOREIGN SCHEMA public FROM SERVER fakeSource3 INTO accounts3 OPTIONS("importer.useFullSchemaName" 'false');
SET SCHEMA accounts4;
IMPORT FOREIGN SCHEMA public FROM SERVER amazonAthena INTO accounts4 OPTIONS("importer.useFullSchemaName" 'false');
SET SCHEMA viewaccount;
CREATE VIEW a2 as select mycolumn from "accounts.mytable";
|
CREATE STREAM {APP_PREFIX}_SESSION_DATA (
"session_id" INT,
"era" INT,
"block_end" BIGINT,
"validators" ARRAY < VARCHAR >,
"nominators" ARRAY < VARCHAR >,
"eras" VARCHAR,
"block_time" BIGINT
) WITH (
kafka_topic = '{APP_PREFIX}_SESSION_DATA',
value_format = 'JSON'
);
CREATE STREAM {APP_PREFIX}_SESSION_END (
"id" INT,
"era" INT,
"block_end" BIGINT,
"block_time" BIGINT
) WITH (
KAFKA_TOPIC='{APP_PREFIX}_SESSION_END',
PARTITIONS=1,
REPLICAS=1,
VALUE_FORMAT='AVRO'
);
INSERT INTO {APP_PREFIX}_SESSION_END SELECT
S."session_id" "id",
S."era" "era",
S."block_end" "block_end",
(S."block_time" / 1000) "block_time"
FROM {APP_PREFIX}_SESSION_DATA S
EMIT CHANGES; |
--1. easiest , behaviour = 3, histology is not null, vocabulary = icd10cm -> to concatenate
--Note, when Histology is empty the behaviour is described in ICD9/10CM code
create table oemr_map_v0 as
select i.concept_name as icd_name,h.concept_name as histology_name, a.*, b.concept_id as source_concept_id, b.concept_code as source_value,
c.*
from (
select
case
when length (icd_code) = 3 then histology_code || '/' || behavior ||'-' || substring (icd_code, 1, 5) ||'.9'
when icd_code in ('C64.2', 'C64.1') then histology_code || '/' || behavior ||'-' || 'C64.9'
when icd_code in ('C43.5') then histology_code || '/' || behavior ||'-' || 'C44.5'
else histology_code || '/' || behavior ||'-' || substring (icd_code, 1, 5) end
as source_concept_code, *
from oncemr_combo where behavior = 3 and histology_code is not null and diag_vers_typ_id = 2
) a
join concept i on i.concept_code = icd_code and i.vocabulary_id = 'ICD10CM'
join concept h on h.concept_code = histology_code || '/' || behavior and h.vocabulary_id ='ICDO3'
join concept b on a.source_concept_code = b.concept_code and b.vocabulary_id = 'ICDO3'
join concept_relationship r on r.concept_id_1 = b.concept_id and relationship_id ='Maps to'
join concept c on c.concept_id = r.concept_id_2
;
--2. Attribute based approach, which covers any behaviour / ICDversion / histology if such present in our vocabulary
create table onc_emr_mapped as
select
a.*, t.*
from oncemr_combo a
join concept i on i.concept_code = icd_code and ( diag_vers_typ_id = 1 and i.vocabulary_id = 'ICD9CM' or diag_vers_typ_id = 2 and i.vocabulary_id = 'ICD10CM') -- get ICD9/10 concept_id
join concept_relationship rm on i.concept_id = rm.concept_id_1 and rm.relationship_id ='Maps to' and rm.invalid_reason is null-- get the SNOMED mapping
join concept_relationship st on rm.concept_id_2= st.concept_id_1 and st.relationship_id ='Has finding site' -- get the SNOMED mapping (st.concept_id_2 = SNOMED topography')
join concept h on h.concept_code = histology_code || '/' || behavior and h.vocabulary_id ='ICDO3' -- get the histology concept (h.concept_id)
join concept_relationship hm on h.concept_id = hm.concept_id_1 and hm.relationship_id = 'ICDO - SNOMED' -- get the histology mapping (hm.concept_id_2)
join concept_relationship ts on st.concept_id_2 = ts.concept_id_1 and ts.relationship_id ='Finding site of' -- get the target concept by topography (ts.concept_id_2)
join concept_relationship hs on hm.concept_id_2= hs.concept_id_1 and hs.relationship_id ='Asso morph of'
join concept t on hs.concept_id_2 = t.concept_id
where hs.concept_id_2 = ts.concept_id_2
;
--1st approach is more straightforward and less ambigous
--keep its results as primary
--3. deduping attribute based approach mappings
--take the shortest term as a best one
select distinct icd_code, histology_code, behavior, cnt,
first_value (concept_id) over (partition by icd_code, histology_code, behavior order by length (concept_name)) as concept_id,
first_value (concept_name) over (partition by icd_code, histology_code, behavior order by length (concept_name)) as concept_name,
first_value (concept_code) over (partition by icd_code, histology_code, behavior order by length (concept_name)) as concept_code
from onc_emr_mapped
where (icd_code, histology_code, behavior) not in (select icd_code, histology_code, behavior from oemr_map_v0)
;
--4. resulting union
create table oemr_map as
select icd_code,histology_code,behavior,cnt, concept_id,concept_name,concept_code, histology_code || '/' || behavior|| '-' || icd_code as condition_source_value,null as condition_source_concept_id from onc_emr_mapped_dedup
union all
select icd_code,histology_code,behavior,cnt, concept_id,concept_name,concept_code , source_value as condition_source_value , source_concept_id as condition_source_concept_id from oemr_map_v0
;
--5. look up with all the descriptions needed
select b.concept_name as icd_name , h.concept_name as hist_name,
case when behavior = 3 then 'MALIGNANT PRIMARY'
when behavior = 6 then 'SEcondary'
when behavior = 2 then 'IN SITU'
when behavior = 0 then 'Benign'
when behavior = 1 then 'Unspec'
else null end as behaviour_descr,
a.* from oemr_map a join concept B on icd_code = b.concept_code and b.vocabulary_id in ('ICD10CM', 'ICD9CM')
join concept h on h.concept_code = histology_code || '/' || behavior and h.vocabulary_id ='ICDO3'
|
<filename>src/test/modules/test_shm_mq/test_shm_mq--1.0.sql
/* src/test/modules/test_shm_mq/test_shm_mq--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_shm_mq" to load this file. \quit
CREATE FUNCTION test_shm_mq(queue_size pg_catalog.int8,
message pg_catalog.text,
repeat_count pg_catalog.int4 default 1,
num_workers pg_catalog.int4 default 1)
RETURNS pg_catalog.void STRICT
AS 'MODULE_PATHNAME' LANGUAGE C;
CREATE FUNCTION test_shm_mq_pipelined(queue_size pg_catalog.int8,
message pg_catalog.text,
repeat_count pg_catalog.int4 default 1,
num_workers pg_catalog.int4 default 1,
verify pg_catalog.bool default true)
RETURNS pg_catalog.void STRICT
AS 'MODULE_PATHNAME' LANGUAGE C;
|
<filename>src/test/tinc/tincrepo/mpp/gpdb/tests/storage/aoco_compression/other_tests/ao_co_alter_table_42.sql
-- @product_version gpdb: [-4.2]
-- start_ignore
DROP TABLE IF EXISTS like1;
DROP TABLE IF EXISTS like2;
DROP TABLE IF EXISTS child2;
DROP TABLE IF EXISTS carpe_diem;
DROP TABLE IF EXISTS cot_table11;
-- end_ignore
CREATE TABLE cot_table11 (
id BIGINT,
wealth MONEY CONSTRAINT wealth_not_null_constraint NOT NULL,
crazy_like_a_box BOX,
pointless POINT,
outer_circle CIRCLE,
uncharacteristic CHAR(1000) DEFAULT 'Twas brillig and the slithy toves...',
thymestamp TIMESTAMP
)
WITH (
APPENDONLY='True',
ORIENTATION='Column'
)
DISTRIBUTED BY (wealth);
INSERT INTO cot_table11 (
id,
wealth,
crazy_like_a_box,
pointless,
outer_circle,
uncharacteristic,
thymestamp
)
VALUES (
2147483648,
'6.75',
'( (0, 0), (2, 2) )',
'(-1, -1)',
'( (0, -1), 3)',
'I live in the mid-S.F. Bay ' ||
'now a suburb of northern L.A. ' ||
'which extends from the south Baja coast ' ||
'to the point of the snows northern-most.' ||
'Did you know that the high point in New York ' ||
'is not a building or high-flying storks ' ||
'but instead is the city landfill' ||
'which makes Everest seem a molehill?' ||
'And all the land we can see' ||
'is piled high with quite-toxic debris.',
'2008-09-28 12:00:00'
);
ALTER TABLE cot_table11 RENAME COLUMN thymestamp TO timeless;
-- This should fail because a column has been renamed but this uses the
-- old name.
INSERT INTO cot_table11 (
id,
wealth,
crazy_like_a_box,
pointless,
outer_circle,
uncharacteristic,
thymestamp
)
VALUES (
0,
0,
'( ( 19, 20), (20, 19) )',
'(0,0)',
'( (0,0) , 0)',
'Present tense' ||
'the future is even more tense' ||
'and I am long past tense',
'2009-07-31 12:59:59'
);
-- Rename the table twice.
ALTER TABLE cot_table11 RENAME TO high_seize;
ALTER TABLE high_seize RENAME TO carp_die;
ALTER TABLE carp_die RENAME uncharacteristic TO out_of_character;
ALTER TABLE carp_die SET DISTRIBUTED BY (timeless);
ALTER TABLE carp_die SET DISTRIBUTED randomly;
-- Make sure that we can still insert into the table after we have
-- renamed the table and at least one of its columns and made other
-- alterations.
INSERT INTO carp_die (
id,
wealth,
crazy_like_a_box,
pointless,
outer_circle,
out_of_character,
timeless
)
VALUES (
-1,
'7.25'::money,
'((16, 16), (17, 17))',
'(-2147483648, -2147483648)',
'((19, 21.5), 1)',
'When you can walk on plastic ' ||
'from Santa Catalina to Laguna ' ||
'will you think it is fantastic' ||
'that there is more mercury than fish inside your Tuna?',
'2020-02-29 23:59:59.999999'
);
ALTER TABLE carp_die ALTER out_of_character SET DEFAULT
'Little tis the luck I have had, and oh tis comfort small ' ||
'to think that many another lad has had no luck at all.' ||
' -- e.e. cummings';
-- Insert a record and make sure that the default value for the
-- out_of_character column was inserted.
INSERT INTO carp_die (id, wealth, timeless) VALUES (121, '121', '2010-03-02 15:45:00.00');
SELECT out_of_character FROM carp_die WHERE id = 121;
ALTER TABLE carp_die ALTER out_of_character DROP DEFAULT;
-- This time the out_of_character column for the new row should be empty
-- because we dropped the DEFAULT value for the column.
INSERT INTO carp_die (id, wealth, timeless) VALUES (122, '122', '2010-03-02 15:46:00');
SELECT out_of_character FROM carp_die WHERE id = 122;
-- The table cannot have already been clustered, since we do not allow indexes
-- on AO/COT tables, but let's just see what happens when we run this command.
ALTER TABLE carp_die SET WITHOUT CLUSTER;
DROP FUNCTION IF EXISTS money_to_text(MONEY) CASCADE;
CREATE FUNCTION money_to_text(MONEY) RETURNS TEXT AS
$$
SELECT textin(cash_out($1))
$$ LANGUAGE SQL;
CREATE CAST (MONEY AS TEXT)
WITH FUNCTION money_to_text(money)
AS IMPLICIT
;
ALTER TABLE carp_die ALTER COLUMN wealth TYPE TEXT;
-- Try to violate the NOT NULL constraint on the wealth column.
INSERT INTO carp_die (id, wealth) VALUES (102, NULL); -- explicit NULL
INSERT INTO carp_die (id) VALUES (102); -- implicit NULL
-- This command should affect performance, not correctness of output, and
-- this test doesn't measure performance, so all we are really testing with
-- the following statement is that we don't do something horribly bad.
ALTER TABLE carp_die ALTER COLUMN out_of_character SET STATISTICS 20;
-- Normally, this isn't the way you would add a NOT NULL constraint, but I
-- believe that this is a reasonable thing to do, so let's try it.
ALTER TABLE carp_die ADD CONSTRAINT momomo CHECK (timeless IS NOT NULL);
-- These 2 inserts should fail since they violate the "momomo" constraint created above.
INSERT INTO carp_die (id, wealth, timeless) VALUES (1000001, 1000001, NULL);
INSERT INTO carp_die (id, wealth) VALUES (1000001, 1000001);
-- Drop the constraint.
ALTER TABLE carp_die DROP CONSTRAINT momomo;
ALTER TABLE carp_die ADD COLUMN temporary1 VARCHAR DEFAULT '<NAME>'
CONSTRAINT cococo CHECK(temporary1 > 'A');
-- This should work.
INSERT INTO carp_die (id, wealth, temporary1) values (5, 10, 'Christine');
-- This should fail because '801Live' violates the constraint "temporary1 > 'A'".
INSERT INTO carp_die (id, wealth, temporary1) values (801, 11, '801Live');
-- There shouldn't be any rows that have num_wealth IS NULL.
SELECT COUNT(*) AS num_wealth_null
FROM carp_die
WHERE wealth IS NULL;
SELECT id, wealth, timeless, pointless, outer_circle, crazy_like_a_box
FROM carp_die
ORDER BY id
;
SELECT id, out_of_character
FROM carp_die
ORDER BY id
;
-- Create a child table of carp_die, using the INHERITS clause, without
-- specifying whether the table should be column-oriented.
-- Should it inherit the column-orientedness of the parent?
CREATE TABLE carpe_diem () INHERITS (carp_die);
-- Normally, you wouldn't copy records from a parent table to a child table,
-- but I think I'll try it.
INSERT INTO carpe_diem SELECT * FROM carp_die;
SELECT id, wealth
FROM carpe_diem
ORDER BY id;
-- If the new (child) table is column-oriented, then it should follow the
-- same restrictions as a column-oriented table. Since deletes on
-- column-oriented tables are illegal, this should be illegal, too.
-- However, this isn't failing, which implies that the child table was not
-- created as a column-oriented table. Is that a bug, or is the user
-- required to specify that a child table be column-oriented???!!!
DELETE FROM carpe_diem WHERE wealth = '$122.00';
SELECT id, wealth
FROM carpe_diem
ORDER BY id;
-- Create a table with the same structure as carp_die, using the LIKE clause,
-- without specifying whether the table should be column-oriented.
-- Should it automatically acquire the column-orientedness of the parent?
CREATE TABLE like1 (LIKE carp_die);
INSERT INTO like1 SELECT * FROM carp_die;
SELECT id, wealth
FROM like1
ORDER BY id;
-- If the new table is column-oriented, then it should follow the
-- same restrictions as a column-oriented table. Since deletes on
-- column-oriented tables are illegal, this should be illegal, too.
-- However, this isn't failing, which implies that the new table was not
-- created as a column-oriented table. Is that a bug, or is the user
-- required to specify that the new table be column-oriented???!!!
DELETE FROM like1 WHERE wealth = '$121.00';
SELECT id, wealth
FROM like1
ORDER BY id;
-- Create a table with the same structure as carp_die, using the LIKE clause,
-- but this time specify that the table should be column-oriented.
CREATE TABLE like2 (LIKE carp_die) WITH (appendonly=True, orientation='column');
INSERT INTO like2 SELECT * FROM carp_die;
-- If the new table is column-oriented, then it should follow the
-- same restrictions as a column-oriented table. Since deletes on
-- column-oriented tables are illegal, this should be illegal, too.
DELETE FROM like2 WHERE wealth = '$7.25';
ALTER TABLE carp_die DROP COLUMN temporary1;
SELECT temporary1 FROM carp_die; -- Should fail, of course.
-- Should the column be dropped from the child table? I think it should be,
-- and this seems to show that indeed it is.
SELECT temporary1 from carpe_diem;
-- The column should NOT be dropped from the tables created via LIKE, because
-- those tables "are completely decoupled after creation is complete",
-- according to the GP Admin Guide. Therefore, the following should succeed:
SELECT temporary1 from like1 ORDER BY temporary1;
SELECT temporary1 from like2 ORDER BY temporary1;
-- These should fail because the table no longer has this name.
DROP TABLE cot_table11;
DROP TABLE high_seize;
-- These should succeed.
DROP TABLE carp_die CASCADE;
DROP TABLE like1;
DROP TABLE like2;
DROP FUNCTION IF EXISTS money_to_text(MONEY) CASCADE;
|
--
-- Additional tests for combocids, for sharing the the array between QE
-- processes, and for growing the array.
--
-- These tests are mostly copied from the upstream 'combocid' test, but
-- the SELECT queries are replaced with a more complicated query that runs
-- on two slices.
--
CREATE TEMP TABLE combocidtest (foobar int, distkey int) distributed by (distkey);
BEGIN;
-- a few dummy ops to push up the CommandId counter
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest SELECT 1 LIMIT 0;
INSERT INTO combocidtest VALUES (1);
INSERT INTO combocidtest VALUES (2);
SELECT ctid,cmin,* FROM combocidtest;
SAVEPOINT s1;
UPDATE combocidtest SET foobar = foobar + 10;
-- here we should see only updated tuples
SELECT * FROM combocidtest a, combocidtest b WHERE a.foobar < b.foobar;
ROLLBACK TO s1;
-- now we should see old tuples, but with combo CIDs starting at 0
SELECT * FROM combocidtest a, combocidtest b WHERE a.foobar < b.foobar;
COMMIT;
-- combo data is not there anymore, but should still see tuples
SELECT * FROM combocidtest a, combocidtest b WHERE a.foobar < b.foobar;
-- Test combo cids with portals
BEGIN;
INSERT INTO combocidtest VALUES (333);
DECLARE c CURSOR FOR SELECT * FROM combocidtest a, combocidtest b WHERE a.foobar < b.foobar;
DELETE FROM combocidtest;
FETCH ALL FROM c;
ROLLBACK;
SELECT * FROM combocidtest a, combocidtest b WHERE a.foobar < b.foobar;
--
-- Test growing the combocids array, including the shared combocids array.
--
CREATE TEMP TABLE manycombocids (i int, t text, distkey int) distributed by (distkey);
CREATE INDEX ON manycombocids (i);
BEGIN;
INSERT INTO manycombocids SELECT g, 'initially inserted',1 from generate_series(1, 10000) g;
-- update some of the rows. The combocids generated by this are included in
-- the initial snapshot that the first FETCH acquires.
DO $$
declare
j int;
begin
set enable_seqscan=off;
for j in 1..10 loop
UPDATE manycombocids set t = 'updated1' where i = j;
end loop;
end;
$$;
-- Launch a query that will scan the table, using a cursor.
--
-- Requirements for this test query:
--
-- - it should run on at least two slices, so that the combocids array is
-- shared between the QE processes
--
-- - it should return the rows in a deterministic order, because we use MOVE to
-- skip rows. This is just to keep the expected output reasonably short.
--
-- - it mustn't materialize the whole result on the first FETCH. Otherwise, the
-- reader processes won't see the combocids that are created only after the
-- first FETCH.
--
set enable_indexonlyscan=off;
set enable_indexscan=off;
set enable_bitmapscan=on;
explain (costs off) SELECT a.i, b.i, a.t FROM manycombocids a, manycombocids b WHERE a.i = b.i AND a.distkey=1;
DECLARE c CURSOR FOR SELECT a.i, b.i, a.t FROM manycombocids a, manycombocids b WHERE a.i = b.i AND a.distkey=1;
-- Start the cursor.
FETCH 1 FROM c;
-- Perform more updates.
DO $$
declare
j int;
begin
set enable_seqscan=off;
for j in 1..1000 loop
UPDATE manycombocids set t = 'updated2' where i = j * 10;
end loop;
end;
$$;
-- Run the cursor to completion. This will encounter the combocids generated by the
-- previous updates, and should correctly see that the updates are not visible to
-- the cursor. (MOVE to keep the expected output at a reasonable size.)
MOVE 9900 FROM c;
FETCH ALL FROM c;
rollback;
|
--Inheritance
DROP TABLE IF EXISTS a_t, b_t, c_t, a_b_c;
CREATE class a_t(a int PRIMARY KEY, b int);
CREATE class b_t(a int PRIMARY KEY, b int, c int);
CREATE class c_t(b int PRIMARY KEY, d int);
CREATE class a_b_c under a_t, b_t, c_t inherit a OF b_t, b OF b_t;
INSERT INTO a_b_c
VALUES (1,1,1,1);
INSERT INTO a_t
VALUES (2,2);
INSERT INTO b_t
VALUES (3,3,3);
INSERT INTO c_t
VALUES (4,4);
--only
SELECT /*+ recompile */ count(*)
FROM all a_t a
LEFT OUTER JOIN a_t b
ON a.a = b.a;
SELECT /*+ recompile */ count(*)
FROM all a_t a
LEFT OUTER JOIN only a_t b
ON a.a = b.a;
--all
SELECT /*+ recompile */ count(*)
FROM all a_t a
LEFT OUTER JOIN ALL a_t b
ON a.a = b.a;
DROP TABLE a_t, b_t, c_t, a_b_c;
|
<filename>hasura/migrations/1612905279045_alter_table_public_AttendeeGoogleAccount_add_column_youtubeData/up.sql<gh_stars>10-100
ALTER TABLE "public"."AttendeeGoogleAccount" ADD COLUMN "youtubeData" jsonb NULL;
|
-- Add new field to tblhostingaddons for subscriptionid
set @query = if ((select count(*) from information_schema.columns where table_schema=database() and table_name='tblhostingaddons' and column_name='subscriptionid') = 0, 'alter table `tblhostingaddons` add `subscriptionid` VARCHAR(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT \'\' AFTER `notes`', 'DO 0');
prepare statement from @query;
execute statement;
deallocate prepare statement;
|
<gh_stars>0
ALTER TABLE git
ADD token VARCHAR(200) NOT NULL; |
<reponame>christophanneser/Bao-for-Presto
SELECT COUNT(*)
FROM
tag as t,
site as s,
question as q,
tag_question as tq
WHERE
t.site_id = s.site_id
AND q.site_id = s.site_id
AND tq.site_id = s.site_id
AND tq.question_id = q.id
AND tq.tag_id = t.id
AND (s.site_name in ('stackoverflow'))
AND (t.name in ('android-canvas','arguments','const','custom-controls','directx','jenkins-plugins','jpeg','obfuscation','pass-by-reference','retrofit2','syntax-error','token'))
AND (q.favorite_count >= 0)
AND (q.favorite_count <= 10000)
|
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 12 Des 2018 pada 17.08
-- Versi server: 10.1.34-MariaDB
-- Versi PHP: 5.6.37
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `assignment1`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `custorder`
--
CREATE TABLE `custorder` (
`id` int(10) NOT NULL,
`username` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`phone` text NOT NULL,
`subjek` varchar(50) NOT NULL,
`barber` varchar(50) NOT NULL,
`datebooking` date NOT NULL,
`timebooking` varchar(50) NOT NULL,
`message` varchar(255) NOT NULL,
`status` varchar(10) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `custorder`
--
INSERT INTO `custorder` (`id`, `username`, `email`, `phone`, `subjek`, `barber`, `datebooking`, `timebooking`, `message`, `status`, `timestamp`) VALUES
(1, 'AAAAA', '<EMAIL>', '1111111111', 'HAIRCUT', 'AAA Barber', '2018-12-12', '10.00', 'aaaaaaaaa', 'COMPLETED', '2018-12-12 07:33:47'),
(2, 'BBBBB', '<EMAIL>', '111111111', 'HAIR COLOR', 'BBB Barber', '2018-12-12', '11.00', 'AAAAAAAAa', 'WAITING', '2018-12-12 07:47:52'),
(3, 'BBBBB', '<EMAIL>', '122222222222', 'SHAVE', 'CCC Barber', '2018-12-12', '12.00', '', 'CANCEL', '2018-12-12 07:47:40');
-- --------------------------------------------------------
--
-- Struktur dari tabel `laybarber`
--
CREATE TABLE `laybarber` (
`id` int(10) NOT NULL,
`barber` varchar(50) NOT NULL,
`description` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `laybarber`
--
INSERT INTO `laybarber` (`id`, `barber`, `description`) VALUES
(1, 'AAA Barber', 'AAA Description'),
(2, 'BBB Barber', 'BBB Description'),
(3, 'CCC Barber', 'CCC Description');
-- --------------------------------------------------------
--
-- Struktur dari tabel `laycover`
--
CREATE TABLE `laycover` (
`id` int(10) NOT NULL,
`subjek1` varchar(50) NOT NULL,
`subjek2` varchar(50) NOT NULL,
`description` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `laycover`
--
INSERT INTO `laycover` (`id`, `subjek1`, `subjek2`, `description`) VALUES
(1, 'Subjek1', 'Subjek2 AAA', 'Description AAA');
-- --------------------------------------------------------
--
-- Struktur dari tabel `layfaq`
--
CREATE TABLE `layfaq` (
`id` int(10) NOT NULL,
`question` varchar(50) NOT NULL,
`answer` varchar(255) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `layfaq`
--
INSERT INTO `layfaq` (`id`, `question`, `answer`, `timestamp`) VALUES
(1, 'AAA Question', 'AAA Answer', '2018-12-10 15:49:14'),
(2, 'BBB Question', 'BBB Answer', '2018-12-10 15:49:06');
-- --------------------------------------------------------
--
-- Struktur dari tabel `layprice`
--
CREATE TABLE `layprice` (
`id` int(10) NOT NULL,
`subjek` varchar(10) NOT NULL,
`pricing` varchar(10) NOT NULL,
`description1` varchar(50) NOT NULL,
`description2` varchar(50) NOT NULL,
`description3` varchar(50) NOT NULL,
`description4` varchar(50) NOT NULL,
`description5` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `layprice`
--
INSERT INTO `layprice` (`id`, `subjek`, `pricing`, `description1`, `description2`, `description3`, `description4`, `description5`) VALUES
(1, 'HAIRCUT', '1', '1aaa', '1bbb', '1ccc', '1ddd', '1eee'),
(2, 'HAIR COLOR', '2', '2aaa', '2bbb', '2ccc', '2ddd', '2eee'),
(3, 'SHAVE', '3', '3aaa', '3bbb', '3ccc', '3ddd', '3eee');
-- --------------------------------------------------------
--
-- Struktur dari tabel `layservice`
--
CREATE TABLE `layservice` (
`id` int(10) NOT NULL,
`subjek` varchar(50) NOT NULL,
`description` varchar(255) NOT NULL,
`picture` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `layservice`
--
INSERT INTO `layservice` (`id`, `subjek`, `description`, `picture`) VALUES
(1, 'CUT', 'AAA', 'service-icon-1.png'),
(2, 'SHAVE', 'BBB', 'service-icon-2.png'),
(3, 'CARE', 'CCC', 'service-icon-3.png');
-- --------------------------------------------------------
--
-- Struktur dari tabel `laytitle`
--
CREATE TABLE `laytitle` (
`id` int(10) NOT NULL,
`specialfeature` varchar(50) NOT NULL,
`price` varchar(50) NOT NULL,
`specialteam` varchar(50) NOT NULL,
`testimonial` varchar(50) NOT NULL,
`faq` varchar(50) NOT NULL,
`appointment` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `laytitle`
--
INSERT INTO `laytitle` (`id`, `specialfeature`, `price`, `specialteam`, `testimonial`, `faq`, `appointment`) VALUES
(1, 'AAA AAA', 'BBB AAA', 'CCC AAA', 'DDD AAA', 'EEE AAA', 'FFF AAA');
-- --------------------------------------------------------
--
-- Struktur dari tabel `reglogin`
--
CREATE TABLE `reglogin` (
`id` int(10) NOT NULL,
`firstName` varchar(50) NOT NULL,
`lastName` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `reglogin`
--
INSERT INTO `reglogin` (`id`, `firstName`, `lastName`, `email`, `password`, `timestamp`) VALUES
(1, 'Admin', 'Admin1', '<EMAIL>', 'admin', '2018-12-10 03:55:00'),
(2, 'User', 'User1', '<EMAIL>', 'user', '2018-12-11 11:20:13');
-- --------------------------------------------------------
--
-- Struktur dari tabel `testing`
--
CREATE TABLE `testing` (
`id` int(10) NOT NULL,
`kd_mk` varchar(6) NOT NULL,
`nm_mk` varchar(50) NOT NULL,
`sks_mk` smallint(6) NOT NULL,
`sms_mk` char(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data untuk tabel `testing`
--
INSERT INTO `testing` (`id`, `kd_mk`, `nm_mk`, `sks_mk`, `sms_mk`) VALUES
(1, 'MKB001', 'Bahasa Pemograman I', 3, '1'),
(2, 'MKB002', 'Praktik Bahasa Pemograman I', 2, '1'),
(3, 'MKK001', 'Fisika', 3, '1'),
(4, 'MKB004', 'Kalkulus Dasar', 3, '1');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `custorder`
--
ALTER TABLE `custorder`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `laybarber`
--
ALTER TABLE `laybarber`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `laycover`
--
ALTER TABLE `laycover`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `layfaq`
--
ALTER TABLE `layfaq`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `layprice`
--
ALTER TABLE `layprice`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `layservice`
--
ALTER TABLE `layservice`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `laytitle`
--
ALTER TABLE `laytitle`
ADD PRIMARY KEY (`id`);
--
-- Indeks untuk tabel `reglogin`
--
ALTER TABLE `reglogin`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`);
--
-- Indeks untuk tabel `testing`
--
ALTER TABLE `testing`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `custorder`
--
ALTER TABLE `custorder`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `laybarber`
--
ALTER TABLE `laybarber`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `laycover`
--
ALTER TABLE `laycover`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT untuk tabel `layfaq`
--
ALTER TABLE `layfaq`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT untuk tabel `layprice`
--
ALTER TABLE `layprice`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `layservice`
--
ALTER TABLE `layservice`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT untuk tabel `laytitle`
--
ALTER TABLE `laytitle`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT untuk tabel `reglogin`
--
ALTER TABLE `reglogin`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT untuk tabel `testing`
--
ALTER TABLE `testing`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*
Warnings:
- You are about to drop the column `scheduleDate` on the `Post` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Post" DROP COLUMN "scheduleDate";
-- CreateTable
CREATE TABLE "Schedule" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"schedule" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Schedule_pkey" PRIMARY KEY ("id")
);
|
ALTER TABLE [dbo].[UnitAssociations]
ADD CONSTRAINT [FK_UnitAssociations_Unit] FOREIGN KEY ([UnitID]) REFERENCES [dbo].[Unit] ([UnitID]) ON DELETE NO ACTION ON UPDATE NO ACTION;
|
CREATE VIEW [dbo].[vw_sqlwatch_report_fact_xes_wait_events] with schemabinding
as
select e.[event_time]
,ws.[wait_type]
,ws.wait_category
,e.[duration]
,e.[signal_duration]
,e.[session_id]
,e.[username]
,e.[client_hostname]
,e.[client_app_name]
,e.[sql_instance]
,e.[snapshot_time]
,e.[snapshot_type_id]
,sq.sql_statement_sample
,e.query_plan_hash
,e.query_hash
,db.database_name
,e.sqlwatch_procedure_id
from [dbo].[sqlwatch_logger_xes_wait_event] e
inner join dbo.vw_sqlwatch_meta_wait_stats_category ws
on e.[wait_type_id] = ws.[wait_type_id]
and e.sql_instance = ws.sql_instance
inner join dbo.[sqlwatch_meta_database] db
on db.sqlwatch_database_id = e.sqlwatch_database_id
and db.sql_instance = e.sql_instance
and db.database_create_date = e.database_create_date
left join [dbo].[sqlwatch_meta_sql_query] sq
on sq.sql_instance = e.sql_instance
and sq.query_hash = e.query_hash
and sq.sqlwatch_database_id = e.sqlwatch_database_id
and sq.sqlwatch_procedure_id = e.sqlwatch_procedure_id; |
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema health_center
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema health_center
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `health_center` DEFAULT CHARACTER SET utf8 COLLATE utf8_polish_ci ;
USE `health_center` ;
-- -----------------------------------------------------
-- Table `health_center`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`user` (
`ID` INT NOT NULL AUTO_INCREMENT,
`pesel` INT(11) NOT NULL,
`gender` VARCHAR(45) NOT NULL,
`name` VARCHAR(45) NOT NULL,
`surname` VARCHAR(45) NOT NULL,
`birthDate` DATE NOT NULL,
`password` VARCHAR(80) NOT NULL,
`streetAddress` VARCHAR(45) NOT NULL,
`city` VARCHAR(45) NOT NULL,
`postalCode` VARCHAR(45) NOT NULL,
`phone` VARCHAR(45) NOT NULL,
`email` VARCHAR(254) NOT NULL,
`role` VARCHAR(45) NOT NULL DEFAULT 'ROLE_USER',
`enabled` INT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`doctor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`doctor` (
`ID` INT NOT NULL,
`specialization_1` VARCHAR(45) NULL,
`specialization_2` VARCHAR(45) NULL,
`specialization_3` VARCHAR(45) NULL,
`medical_title` VARCHAR(45) NULL,
`information` VARCHAR(45) NULL,
PRIMARY KEY (`ID`),
CONSTRAINT `fk_doctor_user1`
FOREIGN KEY (`ID`)
REFERENCES `health_center`.`user` (`ID`)
ON DELETE CASCADE
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`duty`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`duty` (
`ID` INT NOT NULL AUTO_INCREMENT,
`doctor_ID` INT NOT NULL,
`date` TIMESTAMP NOT NULL,
`room` VARCHAR(45) NOT NULL,
`free_slots` INT(2) NOT NULL,
`start_date` TIMESTAMP NULL,
`end_date` TIMESTAMP NULL,
PRIMARY KEY (`ID`),
INDEX `fk_duty_doctor1_idx` (`doctor_ID` ASC),
CONSTRAINT `fk_duty_doctor1`
FOREIGN KEY (`doctor_ID`)
REFERENCES `health_center`.`doctor` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`work_schedule`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`work_schedule` (
`ID` INT NOT NULL AUTO_INCREMENT,
`doctor_ID` INT NOT NULL,
`day` VARCHAR(45) NOT NULL,
`room` VARCHAR(45) NOT NULL,
`start` INT(2) NOT NULL,
`end` INT(2) NOT NULL,
PRIMARY KEY (`ID`),
INDEX `fk_work_schedule_doctor1_idx` (`doctor_ID` ASC),
CONSTRAINT `fk_work_schedule_doctor1`
FOREIGN KEY (`doctor_ID`)
REFERENCES `health_center`.`doctor` (`ID`)
ON DELETE CASCADE
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`patient`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`patient` (
`ID` INT NOT NULL,
`sensitizations` VARCHAR(400) NULL,
`chronic_diseases` VARCHAR(300) NULL,
`solid_drugs` VARCHAR(500) NULL,
PRIMARY KEY (`ID`),
CONSTRAINT `fk_patient_user1`
FOREIGN KEY (`ID`)
REFERENCES `health_center`.`user` (`ID`)
ON DELETE CASCADE
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`visit`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`visit` (
`ID` INT NOT NULL AUTO_INCREMENT,
`patient_ID` INT NOT NULL,
`duty_ID` INT NOT NULL,
`presence` INT(1) NOT NULL DEFAULT 3,
`position_in_queue` INT(3) NOT NULL,
PRIMARY KEY (`ID`),
INDEX `fk_visits_duty1_idx` (`duty_ID` ASC),
INDEX `fk_visit_patient1_idx` (`patient_ID` ASC),
CONSTRAINT `fk_visits_duty1`
FOREIGN KEY (`duty_ID`)
REFERENCES `health_center`.`duty` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_visit_patient1`
FOREIGN KEY (`patient_ID`)
REFERENCES `health_center`.`patient` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`patient_card`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`patient_card` (
`ID` INT NOT NULL AUTO_INCREMENT,
`patient_ID` INT NOT NULL,
`visit_ID` INT NOT NULL,
`comments` VARCHAR(1000) NULL,
`diagnosis` VARCHAR(200) NULL,
`prescribed_medicines` VARCHAR(400) NULL,
`recommendations` VARCHAR(400) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_patient_card_visit1_idx` (`visit_ID` ASC),
INDEX `fk_patient_card_patient1_idx` (`patient_ID` ASC),
CONSTRAINT `fk_patient_card_visit1`
FOREIGN KEY (`visit_ID`)
REFERENCES `health_center`.`visit` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_patient_card_patient1`
FOREIGN KEY (`patient_ID`)
REFERENCES `health_center`.`patient` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`Uploads`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`Uploads` (
`file_name` VARCHAR(100) NOT NULL,
`file` LONGBLOB NOT NULL,
PRIMARY KEY (`file_name`),
UNIQUE INDEX `file_name_UNIQUE` (`file_name` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`doctor_rating`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`doctor_rating` (
`ID` INT NOT NULL AUTO_INCREMENT,
`doctor_ID` INT NOT NULL,
`user_ID` INT NOT NULL,
`comment` VARCHAR(1000) NOT NULL,
`rating` VARCHAR(45) NOT NULL,
`comment_date` DATETIME NOT NULL,
PRIMARY KEY (`ID`),
INDEX `fk_doctor_rating_doctor1_idx` (`doctor_ID` ASC),
INDEX `fk_doctor_rating_user1_idx` (`user_ID` ASC),
CONSTRAINT `fk_doctor_rating_doctor1`
FOREIGN KEY (`doctor_ID`)
REFERENCES `health_center`.`doctor` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_doctor_rating_user1`
FOREIGN KEY (`user_ID`)
REFERENCES `health_center`.`user` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `health_center`.`News`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `health_center`.`News` (
`ID` INT NOT NULL AUTO_INCREMENT,
`Uploads_file_name` VARCHAR(100) NOT NULL,
`title` VARCHAR(100) NOT NULL,
`date` DATETIME NOT NULL,
`information` VARCHAR(5000) NOT NULL,
`for_roles` VARCHAR(100) NOT NULL,
`author` VARCHAR(45) NOT NULL,
`update_author` VARCHAR(45) NULL,
`update_date` VARCHAR(45) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_News_Uploads1_idx` (`Uploads_file_name` ASC),
CONSTRAINT `fk_News_Uploads1`
FOREIGN KEY (`Uploads_file_name`)
REFERENCES `health_center`.`Uploads` (`file_name`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
# Problem Description at -> https://leetcode.com/problems/second-highest-salary/
-- First solution
SELECT MAX(Salary) AS SecondHighestSalary
FROM ((SELECT Salary FROM Employee
WHERE Salary <> (SELECT MAX(Salary) FROM Employee)) AS NX);
-- Second solution
SELECT (SELECT DISTINCT Salary
FROM Employee
ORDER BY Salary DESC
LIMIT 1 OFFSET 1) AS SecondHighestSalary;
-- Third solution
SELECT MAX(Salary) AS SecondHighestSalary FROM Employee WHERE Salary <> (SELECT MAX(Salary) FROM Employee);
# OR
# SELECT MAX(Salary) AS SecondHighestSalary FROM Employee WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee);
|
<gh_stars>0
DROP TABLE IF EXISTS `t_task`;
CREATE TABLE `t_task` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(100) DEFAULT NULL,
`schedule_date` date DEFAULT NULL,
`status` bit(1) NOT NULL,
`description` text DEFAULT NULL,
`user_id` varchar(10) DEFAULT NULL,
PRIMARY KEY(
`id`
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
-- Up
CREATE TABLE `playing` (
`playingID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `playingString` varchar(64) NOT NULL
);
INSERT INTO playing VALUES(1,'with your emotions');
INSERT INTO playing VALUES(2,'with fire');
INSERT INTO playing VALUES(3,'with myself');
INSERT INTO playing VALUES(4,'God');
INSERT INTO playing VALUES(5,'with your mind');
INSERT INTO playing VALUES(6,'with code');
INSERT INTO playing VALUES(7,'cards');
INSERT INTO playing VALUES(8,'for keeps');
INSERT INTO playing VALUES(9,'Gangnam Style');
INSERT INTO playing VALUES(10,'Knifey-Spoony');
INSERT INTO playing VALUES(11,'Half-Life 3');
INSERT INTO playing VALUES(12,'with magnets');
CREATE TABLE `soundboard` (
`soundID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `alias` varchar(16) NOT NULL
, `description` varchar(64) NOT NULL
, `path` varchar(64) NOT NULL
);
INSERT INTO soundboard VALUES(1,'bennyhill','Hilarity Ensues','bennyHill.mp3');
INSERT INTO soundboard VALUES(2,'skype','You have a call waiting','skype.mp3');
INSERT INTO soundboard VALUES(3,'techdiff','We are currently experiencing some technical difficulties','techdiff.mp3');
INSERT INTO soundboard VALUES(4,'gamenight','What is it?','gamenight.mp3');
INSERT INTO soundboard VALUES(5,'fffkk','For arguments','fightfightfight.mp3');
INSERT INTO soundboard VALUES(7,'ateamplan','I love it when a plan comes together','plancomestogether.mp3');
INSERT INTO soundboard VALUES(11,'birdnoise','How does Gavin even make this sound?','birdnoise.mp3');
INSERT INTO soundboard VALUES(13,'freeserver','They are giving them away!','freeserver.mp3');
INSERT INTO soundboard VALUES(14,'freeserverfull','Epsilon Not Included :(','freeserverfull.mp3');
INSERT INTO soundboard VALUES(15,'freshprince','Now, this is a story all about how...','freshprince.mp3');
CREATE TABLE IF NOT EXISTS "pickgame" (
'gameId' integer NOT NULL PRIMARY KEY AUTOINCREMENT
, 'gameName' varchar(64) NOT NULL
);
CREATE TABLE IF NOT EXISTS "reminders" (
'reminderId' integer NOT NULL PRIMARY KEY AUTOINCREMENT
, 'channelId' varchar(64) NOT NULL
, 'remindee' varchar(64) NOT NULL
, 'message' varchar(64) NOT NULL
, 'timestamp' varchar(64) NOT NULL
);
-- Down
DROP TABLE playing;
DROP TABLE soundboard;
DROP TABLE pickgame;
DROP TABLE reminders
|
-- ******************************************************** --
-- Batch mode on rowstore
-- See https://aka.ms/IQP for more background
-- Demo scripts: https://aka.ms/IQPDemos
-- This demo is on SQL Server 2019 Public Preview and coming soon to Azure SQL DB
-- Email <EMAIL> for questions\feedback
-- ******************************************************** --
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
GO
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
GO
-- Row mode due to hint
SELECT [Tax Rate],
[Lineage Key],
SUM([Quantity]) AS SUM_QTY,
SUM([Unit Price]) AS SUM_BASE_PRICE,
COUNT(*) AS COUNT_ORDER
FROM [Fact].[OrderHistoryExtended]
WHERE [Order Date Key] <= dateadd(dd, -73, '2015-11-13')
GROUP BY [Tax Rate],
[Lineage Key]
ORDER BY [Tax Rate],
[Lineage Key]
OPTION (RECOMPILE, USE HINT('DISALLOW_BATCH_MODE'));
-- Batch mode on rowstore eligible
SELECT [Tax Rate],
[Lineage Key],
[Salesperson Key],
SUM([Quantity]) AS SUM_QTY,
SUM([Unit Price]) AS SUM_BASE_PRICE,
COUNT(*) AS COUNT_ORDER
FROM [Fact].[OrderHistoryExtended]
WHERE [Order Date Key] <= dateadd(dd, -73, '2015-11-13')
GROUP BY [Tax Rate],
[Lineage Key],
[Salesperson Key]
ORDER BY [Tax Rate],
[Lineage Key],
[Salesperson Key]
OPTION (RECOMPILE); |
<reponame>aliostad/deep-learning-lang-detection
-- -----------------------------------------------------
-- HOW TO USE THIS FILE:
-- Replace all instances of #_ with your prefix
-- In PHPMYADMIN or the equiv, run the entire SQL
-- -----------------------------------------------------
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
drop table if exists `#__testimonials_config`;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; |
ALTER TABLE asset
ADD COLUMN asset_author_user_id INT NULL AFTER asset_author;
UPDATE asset
SET asset_author_user_id = (SELECT u.user_id FROM user u WHERE u.user_username = asset_author);
ALTER TABLE asset
DROP COLUMN asset_author; |
CREATE TABLE BRUKERTILTAK_V2
(
AKTIVITETID VARCHAR(25) NOT NULL,
AKTOERID VARCHAR(20),
PERSONID VARCHAR(20),
TILTAKSKODE VARCHAR(10),
TILDATO TIMESTAMP,
PRIMARY KEY (AKTIVITETID)
);
CREATE TABLE TILTAKKODEVERKET_V2
(
KODE VARCHAR(10),
VERDI VARCHAR(80),
PRIMARY KEY (KODE)
);
CREATE INDEX PERSONID_BRUKERTILTAK_V2_IDX ON BRUKERTILTAK_V2 (PERSONID); |
<reponame>dram/metasfresh
CREATE OR REPLACE FUNCTION GenerateHUAttributesKey(huId numeric)
RETURNS text
LANGUAGE 'sql'
COST 100
STABLE
AS $BODY$
-- IMPORTANT: keep in sync with other Generate*AttributesKey functions (e.g. GenerateASIStorageAttributesKey)
SELECT COALESCE(string_agg(sub.keyPart, '&'), '-1002'/*NONE*/)
FROM (
SELECT
(case
when a.AttributeValueType = 'S' and coalesce(hua.Value, '') != '' then a.M_Attribute_ID || '=' || coalesce(hua.Value, '')::varchar
when a.AttributeValueType = 'N' and coalesce(hua.valuenumber,0) != 0 then a.M_Attribute_ID || '=' || coalesce(trim(hua.ValueNumber::varchar, '0'), '')
when a.AttributeValueType = 'D' and hua.valuedate is not null then a.M_Attribute_ID || '=' || coalesce(to_char(hua.ValueDate, 'YYYY-MM-DD'), '')::varchar
when a.AttributeValueType = 'L' and av.m_attributevalue_id is not null then av.M_AttributeValue_ID::varchar
else null
end) as keyPart
FROM M_HU hu
INNER JOIN M_HU_Attribute hua ON hua.M_HU_ID=hu.M_HU_ID
INNER JOIN M_Attribute a ON a.M_Attribute_ID=hua.M_Attribute_ID
LEFT OUTER JOIN M_AttributeValue av ON av.Value=hua.Value AND av.M_Attribute_ID=a.M_Attribute_ID
WHERE hu.M_HU_ID = huId
AND hua.IsActive='Y'
-- AND av.IsActive='Y'
AND a.IsActive='Y'
AND a.IsStorageRelevant='Y'
ORDER BY
av.M_AttributeValue_ID NULLS LAST,
a.M_Attribute_ID
) sub
WHERE sub.keyPart is not null
;
$BODY$;
COMMENT ON FUNCTION GenerateHUAttributesKey(numeric) IS
'This function is used to generate values for the MD_Stock.AttributesKey column when initializing or resetting the MD_Stock table.
Please make sure it is in sync with the java implemention in AttributesKeys.createAttributesKeyFromASIStorageAttributes().
Note that we sort by M_AttributeValue_ID and M_Attribute_ID because that is what AttributesKey.ofAttributeValueIds() does.
Belongs to issue "Show onhand quantity in new WebUI MRP Product Info Window" https://github.com/metasfresh/metasfresh-webui-api/issues/762';
|
-- 2021-02-09T07:47:13.716Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Menu_Trl WHERE AD_Menu_ID=540234
;
-- 2021-02-09T07:47:13.724Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Menu WHERE AD_Menu_ID=540234
;
-- 2021-02-09T07:47:13.732Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_TreeNodeMM n WHERE Node_ID=540234 AND EXISTS (SELECT * FROM AD_Tree t WHERE t.AD_Tree_ID=n.AD_Tree_ID AND t.AD_Table_ID=116)
;
-- 2021-02-09T07:47:20.719Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Process_Trl WHERE AD_Process_ID=540163
;
-- 2021-02-09T07:47:20.720Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
DELETE FROM AD_Process WHERE AD_Process_ID=540163
;
|
<filename>packages-old/acs-kernel/sql/postgresql/acs-drop.sql
--
-- packages/acs-kernel/sql/acs-drop.sql
--
-- @author <EMAIL>
-- @creation-date 2000-08-22
-- @cvs-id $Id: acs-drop.sql,v 1.4 2015/12/04 13:49:25 cvs Exp $
--
drop view cc_users;
drop view registered_users;
\t
select drop_package('acs');
\t
drop table acs_magic_objects;
|
/* このファイルに記述されているSQLは起動時に実行されます */
CREATE TABLE IF NOT EXISTS TODO_APP (
TODO_ID int PRIMARY KEY,
TITLE varchar(30) NOT NULL,
DETAIL varchar(100) NOT NULL,
/* カテゴリを追加 */
CATEGORY varchar(50) NOT NULL
); |
create database if not exists keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
IDENTIFIED BY 'KEYSTONE_NBI';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
IDENTIFIED BY 'KEYSTONE_NBI';
|
CREATE TABLE [dbo].[EmployeeDetails] (
[EmpId] [int] IDENTITY(1,1) NOT NULL,
[EmpName] [nvarchar](50) NOT NULL,
[EmpCity] [nvarchar](50) NOT NULL,
[EmpSalary] [int] NOT NULL,
CONSTRAINT [PK_EmployeeDetails] PRIMARY KEY CLUSTERED ([EmpId] ASC),
CONSTRAINT [FK_EmployeeContact_EmployeeDetails] FOREIGN KEY ([EmpId]) REFERENCES [dbo].[EmployeeContact] ([Id])
)
|
<gh_stars>1-10
-- SPDX-License-Identifier: Apache-2.0
-- Licensed to the Ed-Fi Alliance under one or more agreements.
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
-- See the LICENSE and NOTICES files in the project root for more information.
CREATE UNIQUE INDEX IF NOT EXISTS UX_b2452d_Id ON tpdm.Candidate(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_fc61b2_Id ON tpdm.CandidateEducatorPreparationProgramAssociation(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_195935_Id ON tpdm.EducatorPreparationProgram(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_163e44_Id ON tpdm.Evaluation(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_e53186_Id ON tpdm.EvaluationElement(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_4479ea_Id ON tpdm.EvaluationElementRating(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_d4565d_Id ON tpdm.EvaluationObjective(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_7ae19d_Id ON tpdm.EvaluationObjectiveRating(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_bfaa20_Id ON tpdm.EvaluationRating(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_a465f2_Id ON tpdm.FinancialAid(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_15d685_Id ON tpdm.PerformanceEvaluation(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_759abe_Id ON tpdm.PerformanceEvaluationRating(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_643c81_Id ON tpdm.RubricDimension(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_520027_Id ON tpdm.SurveyResponsePersonTargetAssociation(Id);
CREATE UNIQUE INDEX IF NOT EXISTS UX_e21e4b_Id ON tpdm.SurveySectionResponsePersonTargetAssociation(Id);
|
<gh_stars>1000+
--
-- Test assorted system views
--
-- This test is mainly meant to provide some code coverage for the
-- set-returning functions that underlie certain system views.
-- The output of most of these functions is very environment-dependent,
-- so our ability to test with fixed expected output is pretty limited;
-- but even a trivial check of count(*) will exercise the normal code path
-- through the SRF.
select count(*) >= 0 as ok from pg_available_extension_versions;
select count(*) >= 0 as ok from pg_available_extensions;
-- At introduction, pg_config had 23 entries; it may grow
select count(*) > 20 as ok from pg_config;
-- We expect no cursors in this test; see also portals.sql
select count(*) = 0 as ok from pg_cursors;
select count(*) >= 0 as ok from pg_file_settings;
-- There will surely be at least one rule
select count(*) > 0 as ok from pg_hba_file_rules;
-- There will surely be at least one active lock
select count(*) > 0 as ok from pg_locks;
-- We expect no prepared statements in this test; see also prepare.sql
select count(*) = 0 as ok from pg_prepared_statements;
-- See also prepared_xacts.sql
select count(*) >= 0 as ok from pg_prepared_xacts;
-- This is to record the prevailing planner enable_foo settings during
-- a regression test run.
select name, setting from pg_settings where name like 'enable%';
-- Test that the pg_timezone_names and pg_timezone_abbrevs views are
-- more-or-less working. We can't test their contents in any great detail
-- without the outputs changing anytime IANA updates the underlying data,
-- but it seems reasonable to expect at least one entry per major meridian.
-- (At the time of writing, the actual counts are around 38 because of
-- zones using fractional GMT offsets, so this is a pretty loose test.)
select count(distinct utc_offset) >= 24 as ok from pg_timezone_names;
select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;
-- Let's check the non-default timezone abbreviation sets, too
set timezone_abbreviations = 'Australia';
select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;
set timezone_abbreviations = 'India';
select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;
|
-- MODULE XTS741
-- SQL Test Suite, V6.0, Interactive SQL, xts741.sql
-- 59-byte ID
-- TEd Version #
-- AUTHORIZATION CTS1
SELECT USER FROM HU.ECCO;
-- RERUN if USER value does not match preceding AUTHORIZATION comment
ROLLBACK WORK;
-- date_time print
-- TEST:7041 COUNT(ALL NULLIF...) with generated Nulls!
DELETE FROM EMPTY740;
-- PASS:7041 If delete completed successfully?
INSERT INTO EMPTY740
VALUES('NICKOS','NICK',NULL,116,TIME'18:00:00');
-- PASS:7041 If 1 row inserted successfully?
INSERT INTO EMPTY740
VALUES('MARIA',NULL,NULL,NULL,TIME'12:00:00');
-- PASS:7041 If 1 row inserted successfully?
INSERT INTO EMPTY740
VALUES('KILLER','BUCK',NULL,127,TIME'09:30:30');
-- PASS:7041 If 1 row inserted successfully?
INSERT INTO EMPTY740
VALUES('JOYCE',NULL,NULL,17,TIME'15:43:52');
-- PASS:7041 If 1 row inserted successfully?
INSERT INTO EMPTY740
VALUES('ANGIE','TREE',NULL,7,TIME'12:53:13');
-- PASS:7041 If 1 row inserted successfully?
INSERT INTO EMPTY740
VALUES('BUCK','BUCK',NULL,12,TIME'16:29:22');
-- PASS:7041 If 1 row inserted successfully?
COMMIT WORK;
SELECT COUNT(ALL NULLIF ('Nickos','Nickos '))
FROM EMPTY740;
-- PASS:7041 If COUNT = 0 and ?
-- PASS:7041 WARNING - null value eliminated in set function ?
SELECT COUNT(ALL NULLIF (COL_1,'JANET'))
FROM EMPTY740;
-- PASS:7041 If COUNT = 6?
SELECT COUNT(ALL NULLIF ('NICKOS',COL_1))
FROM EMPTY740;
-- PASS:7041 If COUNT = 5 and ?
-- PASS:7041 WARNING - null value eliminated in set function ?
SELECT COUNT(ALL NULLIF (COL_2,COL_1))
FROM EMPTY740;
-- PASS:7041 If COUNT = 3 and ?
-- PASS:7041 WARNING - null value eliminated in set function ?
SELECT COUNT(ALL NULLIF (COL_4,COL_3))
FROM EMPTY740;
-- PASS:7041 If COUNT = 5 and ?
-- PASS:7041 WARNING - null value eliminated in set function ?
SELECT COUNT(ALL NULLIF (COL_5,TIME'12:00:00'))
FROM EMPTY740;
-- PASS:7041 If COUNT = 5 and ?
-- PASS:7041 WARNING - null value eliminated in set function ?
ROLLBACK WORK;
DELETE FROM EMPTY740;
-- PASS:7041 If delete completed successfully?
COMMIT WORK;
-- END TEST >>> 7041 <<< END TEST
-- *********************************************
-- *************************************************////END-OF-MODULE
|
<filename>modules/recurringinvoices/install/tablefindoptions.sql
INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('tbld:3434bf2d-1337-5cab-0a7a-25e04f1c6d8f', 'All Records', 'recurringinvoices.id!=-1', '0', ''); |
<reponame>Zhaojia2019/cubrid-testcases
autocommit off;
update shipment_c set product.descr = 'junk';
rollback;
|
-- @testpoint:opengauss关键字binary_integer(非保留),作为函数名
--关键字不带引号-合理报错
drop function if exists binary_integer;
create function binary_integer(i integer)
returns integer
as $$
begin
return i+1;
end;
$$ language plpgsql;
/
--清理环境
drop function binary_integer;
--关键字带双引号-成功
drop function if exists "binary_integer";
create function "binary_integer"(i integer)
returns integer
as $$
begin
return i+1;
end;
$$ language plpgsql;
/
--清理环境
drop function "binary_integer";
--关键字带单引号-合理报错
drop function if exists 'binary_integer';
create function 'binary_integer'(i integer)
returns integer
as $$
begin
return i+1;
end;
$$ language plpgsql;
/
--关键字带反引号-合理报错
drop function if exists `binary_integer`;
create function `binary_integer`(i integer)
returns integer
as $$
begin
return i+1;
end;
$$ language plpgsql;
/ |
<filename>openGaussBase/testcase/KEYWORDS/timezone_hour/Opengauss_Function_Keyword_Timezone_hour_Case0031.sql
-- @testpoint:opengauss关键字timezone_hour(非保留),作为字段数据类型(合理报错)
--前置条件
drop table if exists explain_test cascade;
--关键字不带引号-合理报错
create table explain_test(id int,name timezone_hour);
--关键字带双引号-合理报错
create table explain_test(id int,name "timezone_hour");
--关键字带单引号-合理报错
create table explain_test(id int,name 'timezone_hour');
--关键字带反引号-合理报错
create table explain_test(id int,name `timezone_hour`);
|
<filename>db/seeds.sql
INSERT INTO department(department_name)
VALUES
("Sales"),
("HR"),
("Customer Service"),
("Engineering"),
("Legal");
INSERT INTO role(title, salary, department_id)
VALUES
("Lawyer",150000.00,5),
("Human Resource Manager",65000.00,2),
("Customer Care Agent",45000.00,3),
("Sales Representative",60000.00,1),
("Sales Team Lead",85000.00,1),
("Junior Engineer",65000.00,4),
("Senior Engineer",80000.00,4);
INSERT INTO employee(first_name, last_name, role_id, manager_id)
VALUES
("Michael", "Scott", 5, 1),
("Jim", "Halpert", 4, 1),
("Pam", "Beesly", 3,2),
("Andy","Bernard",5,4),
("Phyllis", "Vance",2,3),
("Dwight", "Shrute",7,1),
("Angela", "Martin",6,6);
("Stanley", "Hudson",2,3 );
|
<gh_stars>0
CREATE TABLE "public"."project_languages" ("id" serial NOT NULL, "uuid" uuid NOT NULL, "project_id" integer NOT NULL, "language_id" integer NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE cascade ON DELETE cascade, FOREIGN KEY ("language_id") REFERENCES "public"."languages"("id") ON UPDATE cascade ON DELETE cascade, UNIQUE ("id"), UNIQUE ("uuid"));
|
CREATE TABLE categories (
id SERIAL PRIMARY KEY,
name VARCHAR (20) UNIQUE NOT NULL
);
CREATE TABLE movies (
id SERIAL PRIMARY KEY,
title VARCHAR (50) NOT NULL,
trailer_url VARCHAR(200) NOT NULL,
original_source_url VARCHAR(200) NOT NULL,
cover_url VARCHAR(200) NOT NULL,
imdb_id VARCHAR(20) NOT NULL,
imdb_score REAL,
description TEXT,
release_date TIMESTAMP
);
INSERT INTO categories (name) VALUES ('Action'), ('Adventure'), ('Animation'), ('Biography'), ('Comedy'), ('Crime'), ('Documentary'),
('Drama'), ('Family'), ('Fantasy'), ('Film Noir'), ('History'), ('Horror'), ('Music'), ('Musical'),
('Mystery'), ('Romance'), ('Sci-Fi'), ('Short Film'), ('Sport'), ('Superhero'), ('Thriller'),
('War'), ('Western');
INSERT INTO movies (title, trailer_url, original_source_url, cover_url, imdb_id, imdb_score, description, release_date)
VALUES ('Big Little Lies', 'https://www.imdb.com/title/tt3920596/videoplayer/vi4110728217', 'https://www.imdb.com/title/tt3920596/',
'https://m.media-amazon.com/images/M/MV5BZmNjYzdjN2ItOTBlNy00Mjc0LWE4YmMtYTQ4ZjQzNTMyNDc4XkEyXkFqcGdeQXVyMTkxNjUyNQ@@._V1_.jpg',
'tt3920596', 8.6, 'The apparently perfect lives of upper-class mothers, at a prestigious elementary school, unravel to the point of ||
murder when a single-mother moves to their quaint Californian beach town.', '2019-06-17'),
('The Angry Birds Movie 2', 'https://www.imdb.com/title/tt6095472/videoplayer/vi2958933017', 'https://www.imdb.com/title/tt6095472/',
'https://m.media-amazon.com/images/M/MV5BYzdkNGJhNzQtMjY1OC00MDI3LTk0ZDUtNzU0MGZiY2YwZGUxXkEyXkFqcGdeQXVyNzMxNjQxMTk@._V1_.jpg',
'tt6095472', 6.4, 'The flightless birds and scheming green pigs take their feud to the next level.', '2019-08-14'); |
<filename>SQL/running_total.sql
/* This code is part of my tutorial on running total (cumulative sum, running sum) in SQL
Blog post: habr.com/ru/post/474458/ (in Russian)
*/
--- Division 0: Create testing data ---
-- simpliest case: plain data, no groups
create table test_simple (dt date null,
val int null
);
-- insert some data // warning: dates in ANSI format
-- use appropriate date format in your DMBS (or change settings, e.g. using NLS_DATE_FORMAT in Oracle)
insert into test_simple (dt, val) values ('2019-11-01', 6);
insert into test_simple (dt, val) values ('2019-11-02', 3);
insert into test_simple (dt, val) values ('2019-11-03', 3);
insert into test_simple (dt, val) values ('2019-11-04', 4);
insert into test_simple (dt, val) values ('2019-11-05', 2);
insert into test_simple (dt, val) values ('2019-11-06', 4);
insert into test_simple (dt, val) values ('2019-11-07', 8);
insert into test_simple (dt, val) values ('2019-11-08', 0);
insert into test_simple (dt, val) values ('2019-11-09', 6);
insert into test_simple (dt, val) values ('2019-11-10', 0);
insert into test_simple (dt, val) values ('2019-11-11', 8);
insert into test_simple (dt, val) values ('2019-11-12', 8);
insert into test_simple (dt, val) values ('2019-11-13', 0);
insert into test_simple (dt, val) values ('2019-11-14', 2);
insert into test_simple (dt, val) values ('2019-11-15', 8);
insert into test_simple (dt, val) values ('2019-11-16', 7);
-- check data
select * from test_simple order by dt;
--sophisticated case: grouped data
create table test_groups (grp varchar null, -- varchar2(1) in Oracle, etc
dt date null,
val int null
);
-- insert some data // warning: dates in ANSI format
-- use appropriate date format in your DMBS (or change settings, e.g. using NLS_DATE_FORMAT in Oracle)
insert into test_groups (grp, dt, val) values ('a', '2019-11-06', 1);
insert into test_groups (grp, dt, val) values ('a', '2019-11-07', 3);
insert into test_groups (grp, dt, val) values ('a', '2019-11-08', 4);
insert into test_groups (grp, dt, val) values ('a', '2019-11-09', 1);
insert into test_groups (grp, dt, val) values ('a', '2019-11-10', 7);
insert into test_groups (grp, dt, val) values ('b', '2019-11-06', 9);
insert into test_groups (grp, dt, val) values ('b', '2019-11-07', 10);
insert into test_groups (grp, dt, val) values ('b', '2019-11-08', 9);
insert into test_groups (grp, dt, val) values ('b', '2019-11-09', 1);
insert into test_groups (grp, dt, val) values ('b', '2019-11-10', 10);
insert into test_groups (grp, dt, val) values ('c', '2019-11-06', 4);
insert into test_groups (grp, dt, val) values ('c', '2019-11-07', 10);
insert into test_groups (grp, dt, val) values ('c', '2019-11-08', 9);
insert into test_groups (grp, dt, val) values ('c', '2019-11-09', 4);
insert into test_groups (grp, dt, val) values ('c', '2019-11-10', 4);
-- check data
select * from test_groups order by grp, dt;
--- Division 1: Solutions for simple case (no groups) ---
-- Window functions
select s.*,
coalesce(sum(s.val) over (order by s.dt
rows between unbounded preceding and current row),
0) as total
from test_simple s
order by s.dt;
-- Subquary
select s.*,
(select coalesce(sum(t2.val), 0)
from test_simple t2
where t2.dt <= s.dt) as total
from test_simple s
order by s.dt;
-- Inner join
select s.*,
coalesce(sum(t2.val), 0) as total
from test_simple s
inner join test_simple t2
on t2.dt <= s.dt
group by s.dt,
s.val
order by s.dt;
-- Cartesian join
select s.*,
coalesce(sum(t2.val), 0) as total
from test_simple s,
test_simple t2
where t2.dt <= s.dt
group by s.dt,
s.val
order by s.dt;
-- Recursive query
-- required condition: no gaps in dt field
with cte (dt, val, total)
as
(select dt, val, val as total
from test_simple
where dt = (select min(dt) from test_simple)
union all
select r.dt,
r.val,
cte.total + r.val
from cte
inner join test_simple r
-- r.dt = dateadd(day, 1, cte.dt) in SQL Server, r.dt = cte.dt + 1 in Oracle, etc
on r.dt = dateadd(day, 1, cte.dt)
)
select dt,
val,
total
from cte
order by dt;
-- Recursive query & window function row_number
-- here gaps in dt field became acceptable
with cte1 (dt, val, rn)
as (select dt, val,
row_number() over (order by dt) as rn
from test_simple),
cte2 (dt, val, rn, total)
as
(select dt, val, rn, val as total
from cte1
where rn = 1
union all
select cte1.dt,
cte1.val,
cte1.rn,
cte2.total + cte1.val
from cte2
inner join cte1
on cte1.rn = cte2.rn + 1
)
select dt,
val,
total
from cte2
order by dt;
-- cross apply (SQL Server, SQL Server) or lateral (MySQL, PostgreSQL)
select s.*,
t2.total
from test_simple s
cross apply (select coalesce(sum(t2.val), 0) as total
from test_simple t2
where t2.dt <= s.dt
) t2
order by s.dt;
--- Division 2: Solutions for grouped data ---
-- Window functions
select g.*,
coalesce(sum(g.val) over (partition by g.grp order by g.dt
rows between unbounded preceding and current row),
0) as total
from test_groups g
order by g.grp, g.dt;
-- Correlated subquery
select g.*,
(select coalesce(sum(t2.val), 0) as total
from test_groups t2
where g.grp = t2.grp
and t2.dt <= g.dt) as total
from test_groups g
order by g.grp, g.dt;
-- Inner join
select g.*,
coalesce(sum(t2.val), 0) as total
from test_groups g
inner join test_groups t2
on g.grp = t2.grp
and t2.dt <= g.dt
group by g.grp,
g.dt,
g.val
order by g.grp,
g.dt;
-- Cartesian join
select g.*,
coalesce(sum(t2.val), 0) as total
from test_groups g,
test_groups t2
where g.grp = t2.grp
and t2.dt <= g.dt
group by g.grp,
g.dt,
g.val
order by g.grp,
g.dt;
-- Recursive query
-- required condition: no gaps in dt field
with cte (dt, grp, val, total)
as
(select g.dt, g.grp, g.val, g.val as total
from test_groups g
where g.dt = (select min(dt) from test_groups where grp = g.grp)
union all
select r.dt, r.grp, r.val, cte.total + r.val
from cte
inner join test_groups r
-- r.dt = dateadd(day, 1, cte.dt) in SQL Server, r.dt = cte.dt + 1 in Oracle, etc
on r.dt = dateadd(day, 1, cte.dt)
and cte.grp = r.grp
)
select dt,
grp,
val,
total
from cte
order by grp,
dt;
-- Recursive query & window function row_number
-- here gaps in dt field became acceptable
with cte1 (dt, grp, val, rn)
as (select dt, grp, val,
row_number() over (partition by grp order by dt) as rn
from test_groups),
cte2 (dt, grp, val, rn, total)
as
(select dt, grp, val, rn, val as total
from cte1
where rn = 1
union all
select cte1.dt,
cte1.grp,
cte1.val,
cte1.rn,
cte2.total + cte1.val
from cte2
inner join cte1
on cte1.grp = cte2.grp
and cte1.rn = cte2.rn + 1
)
select dt, grp, val, total
from cte2
order by grp, dt;
-- CROSS APPLY (SQL Server, SQL Server) / LATERAL JOIN (MySQL, PostgreSQL)
select g.*,
t2.total
from test_groups g
cross apply (select coalesce(sum(t2.val), 0) as total
from test_groups t2
where g.grp = t2.grp
and t2.dt <= g.dt
) t2
order by g.grp,
g.dt;
--- Division 3: Vendor-specific solutions (simple case only) ---
-- Use of MODEL clause (Oracle)
select dt, val, total
from
(select dt,
val,
val as total
from test_simple) t
model
dimension by (row_number() over (order by dt) as rn)
measures (dt, val, total)
rules (total[rn >= 2] = total[cv() - 1] + val[cv()])
order by dt;
-- Update to local variable (SQL Server)
declare @VarTotal int = 0;
declare @tv table
(dt date null,
val int null,
total int null
);
insert @tv (dt, val, total)
select dt,
val,
0 as total
from test_simple
order by dt;
update @tv
set @VarTotal = total = @VarTotal + val
from @tv;
select * from @tv order by dt;
-- Cursor (SQL Server)
create table #temp
(dt date primary key,
val int null,
total int null
);
insert #temp (dt, val)
select dt, val
from test_simple
order by dt;
declare @VarTotal int,
@VarDT date,
@VarVal int;
set @VarTotal = 0;
declare cur cursor local static read_only forward_only
for select dt, val from #temp order by dt;
open cur;
fetch cur into @VarDT, @VarVal;
while @@fetch_status = 0
begin
set @VarTotal = @VarTotal + @VarVal;
update #temp
set total = @VarTotal
where dt = @VarDT;
fetch cur into @VarDT, @VarVal;
end;
close cur;
deallocate cur;
select dt, val, total
from #temp
order by dt;
drop table #temp;
|
-- phpMyAdmin SQL Dump
-- version 4.6.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 11, 2016 at 12:44 PM
-- Server version: 10.0.23-MariaDB
-- PHP Version: 5.6.22
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `tc`
--
-- --------------------------------------------------------
--
-- Table structure for table `x_users_tests_attempts`
--
DROP TABLE IF EXISTS `x_users_tests_attempts`;
CREATE TABLE `x_users_tests_attempts` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`test_id` int(11) NOT NULL,
`score_pct` int(11) NOT NULL,
`pass` tinyint(1) NOT NULL DEFAULT '0',
`stime` timestamp NULL DEFAULT NULL,
`duration` int(11) NOT NULL,
`cdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`mdate` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`muser_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `x_users_tests_attempts`
--
ALTER TABLE `x_users_tests_attempts`
ADD PRIMARY KEY (`id`),
ADD KEY `user_id` (`user_id`),
ADD KEY `test_id` (`test_id`),
ADD KEY `muser_id` (`muser_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `x_users_tests_attempts`
--
ALTER TABLE `x_users_tests_attempts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `x_users_tests_attempts`
--
ALTER TABLE `x_users_tests_attempts`
ADD CONSTRAINT `fk_xuta_t_id` FOREIGN KEY (`test_id`) REFERENCES `tests` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_xuta_u_id_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_xuta_u_id_2` FOREIGN KEY (`muser_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
INSERT INTO user (
username,
password
) VALUES (
:username,
:password
); |
-- phpMyAdmin SQL Dump
-- version 4.5.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 30, 2019 at 10:42 နံနက်
-- Server version: 10.1.19-MariaDB
-- PHP Version: 7.0.9
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `eapi`
--
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `migrations`
--
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_10_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_resets_table', 1),
(3, '2019_01_30_084744_create_products_table', 1),
(4, '2019_01_30_084844_create_reviews_table', 1);
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`detail` text COLLATE utf8mb4_unicode_ci NOT NULL,
`price` int(11) NOT NULL,
`stock` int(11) NOT NULL,
`discount` int(11) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `name`, `detail`, `price`, `stock`, `discount`, `created_at`, `updated_at`) VALUES
(1, 'consequuntur', 'Soluta corporis numquam et soluta. Quasi earum autem harum est quae impedit. Eaque id incidunt est itaque placeat consequatur. Blanditiis quisquam qui deserunt earum voluptatum.', 908, 4, 11, '2019-01-30 03:08:51', '2019-01-30 03:08:51'),
(2, 'voluptatem', 'Sunt perferendis tenetur aut quis iure ut eos sed. Assumenda vitae modi dolorem officiis. In et temporibus quo soluta non soluta corporis. Voluptatum voluptas fuga ab maiores consequatur dolorum. Magni quia amet dolores inventore enim.', 494, 2, 3, '2019-01-30 03:08:51', '2019-01-30 03:08:51'),
(3, 'id', 'Eum aperiam illo itaque similique vel ut ea blanditiis. Sed deleniti dignissimos et numquam. Ut culpa deserunt iure quia voluptatem est impedit omnis.', 848, 1, 5, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(4, 'fuga', 'Minima excepturi fugit quasi velit quia rerum. Dolore saepe facere accusantium inventore architecto ex ipsa. Beatae labore consequatur laudantium ab iusto itaque. Aut aspernatur occaecati ipsum aut reiciendis aspernatur.', 918, 2, 23, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(5, 'consequuntur', 'Est illum nihil et et. Alias ut expedita et cum nihil commodi. Fugit ipsa amet quibusdam ipsum. Sunt architecto officiis inventore.', 432, 2, 18, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(6, 'doloremque', 'Et et nobis consectetur voluptas praesentium maiores. Iusto necessitatibus nihil velit quis illum et nam. Non amet tempora nihil nulla maiores consectetur. Aut tenetur nemo consequatur voluptas quis.', 356, 0, 25, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(7, 'adipisci', 'Doloremque eaque a esse cum. Saepe provident est itaque sint fuga. At earum consequatur eum odio.', 522, 6, 8, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(8, 'maxime', 'Est consequatur quis est aut. Autem sapiente sunt et aliquid.', 109, 2, 22, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(9, 'in', 'Quam provident est tempore deserunt magni. Beatae iste perspiciatis dolores quia provident sit eum. Vel id eum qui aut qui et. Aut placeat aliquam vel dolores nostrum.', 986, 3, 21, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(10, 'natus', 'Quia architecto assumenda praesentium et modi. Quia ullam molestiae soluta voluptas enim provident atque. Consectetur aut quia consequatur rerum et maxime. Odit consequatur et ab corrupti veniam autem.', 388, 1, 10, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(11, 'a', 'Placeat ad adipisci magnam perspiciatis cum impedit eum. Non ratione omnis in doloremque non. Consequatur et omnis debitis quaerat unde inventore eum laborum. Fugit quia provident ullam dolor.', 991, 9, 15, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(12, 'maiores', 'Molestiae accusantium quos et inventore consequatur adipisci qui saepe. Aliquid vel non deleniti quia sapiente. Laboriosam quo et voluptas ducimus ad sed repellendus. Veritatis sed est neque nihil.', 684, 5, 8, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(13, 'sed', 'Fugit ut vero ullam dolor officiis suscipit tempora. Hic quidem laboriosam in iure eos. Et neque molestiae et assumenda exercitationem quo distinctio. Consequatur in sunt deleniti unde maxime distinctio.', 848, 0, 14, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(14, 'sit', 'Necessitatibus consequatur doloremque et voluptas quidem. Vel dignissimos hic nemo dolorum.', 321, 8, 28, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(15, 'nulla', 'Blanditiis ea id sapiente at molestiae nemo beatae quis. Quidem nesciunt sed ullam eum debitis laboriosam. Modi sint beatae consequatur est. Hic necessitatibus et et tempore beatae soluta reprehenderit.', 938, 0, 10, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(16, 'tempore', 'Dolorem quo unde quia atque maiores aut quibusdam. Eveniet adipisci soluta neque.', 685, 4, 12, '2019-01-30 03:08:52', '2019-01-30 03:08:52'),
(17, 'voluptatem', 'Voluptatum aliquam dolorum soluta nostrum amet. Nesciunt est quo consequuntur maiores.', 682, 2, 5, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(18, 'atque', 'Corporis qui quia omnis enim modi. Dolor animi sit aliquam dolorum reprehenderit. Consequuntur voluptates veniam aut et non non. Illo accusantium ipsum reprehenderit officiis dolor numquam delectus illo.', 794, 4, 9, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(19, 'fugiat', 'Nisi quaerat nulla unde et. Ut consequatur eius nesciunt. Sed possimus ea ea totam dolores dolorum.', 684, 9, 14, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(20, 'distinctio', 'Omnis sint rerum ut fugiat porro accusamus dolorem. Delectus sint animi culpa itaque dicta. Distinctio iste impedit iste at qui. Placeat eaque in impedit ut quaerat dolor.', 385, 8, 13, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(21, 'at', 'Et sit consequatur provident. Et quia recusandae omnis dolor occaecati. Sit voluptas doloribus asperiores quos autem.', 156, 7, 27, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(22, 'fugiat', 'Numquam ut natus sint hic nesciunt. Neque laborum quam quod est. Rerum debitis quia eveniet explicabo enim.', 482, 6, 20, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(23, 'quibusdam', 'Sed dicta quasi non minima quidem. Beatae dolores occaecati nam aspernatur recusandae. Assumenda modi rerum consequatur sed maiores voluptatum. Velit voluptatum et voluptatem error recusandae.', 401, 0, 13, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(24, 'velit', 'Atque officia voluptas ducimus doloribus ex ut doloribus voluptate. Quas fuga aspernatur non et vel officiis. Amet assumenda repudiandae aut sunt ipsam voluptatum voluptas ut. Eos ut officia nam sint delectus velit.', 994, 9, 28, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(25, 'in', 'Deserunt perspiciatis sed vel est asperiores quasi. Id ullam laudantium repellendus dolorem cupiditate et consequatur. Sit qui suscipit a ullam omnis et. Deserunt sit neque commodi iste sit pariatur temporibus.', 267, 3, 18, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(26, 'dolor', 'Deserunt nostrum voluptatem esse ducimus delectus nulla quasi et. Nostrum omnis est nostrum iste. Id sit dicta consectetur enim. Fugiat quia perferendis tempora et.', 504, 2, 14, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(27, 'et', 'Commodi et expedita quas minus sint. Consequatur maxime temporibus eligendi ipsam voluptatem vitae.', 611, 7, 4, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(28, 'neque', 'Sit asperiores quam deleniti nam ipsum dicta quia. Ipsum ut delectus sequi a aut. Libero et sit itaque quis explicabo culpa ut.', 772, 3, 10, '2019-01-30 03:08:53', '2019-01-30 03:08:53'),
(29, 'quo', 'Quisquam reiciendis alias enim velit est ut dolorem. Eveniet provident quia eum omnis sit non voluptas sit. Perferendis dolore aliquid consequatur voluptate consequatur rerum aliquam. Fugit perspiciatis quis veritatis debitis aut dolorum. Sit velit quis laborum omnis quo laboriosam.', 869, 5, 4, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(30, 'aut', 'Animi quia ab eaque dolorum neque. Perspiciatis sint architecto repellat. Illum aut earum pariatur illum voluptas omnis.', 855, 8, 2, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(31, 'fugiat', 'At sequi ut aut ea fugiat odio. Quia aut quo rerum et. Vel cupiditate fugiat adipisci qui quis.', 425, 9, 29, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(32, 'earum', 'Unde corporis est sed exercitationem. Quis et velit eius modi praesentium quis facilis. Officia provident impedit ex. Est natus ea qui explicabo magnam et impedit.', 892, 2, 29, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(33, 'quia', 'Dolorem voluptatum et expedita. Dolor ipsam voluptas non rem consectetur dolores. Iusto dolor eaque voluptatem.', 722, 6, 18, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(34, 'odit', 'Dolores rerum aliquid fugit repellat. Ab ab culpa praesentium pariatur quas tempore. Occaecati dolores saepe quae ex aut quibusdam. Quis placeat alias sint autem.', 682, 9, 29, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(35, 'et', 'Doloribus qui qui soluta ad quibusdam sint. Alias atque voluptate modi excepturi eius atque officia. Minus voluptatem cupiditate explicabo assumenda eos. Ut iure fuga quia nobis.', 252, 5, 20, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(36, 'qui', 'Minus illum aperiam laboriosam ut ut qui quia. Quas illo quos aut nam harum velit rerum placeat. Fugiat aspernatur esse aliquam laborum quia illo illo. Laborum aut ullam id ratione voluptas consectetur beatae.', 264, 2, 26, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(37, 'nostrum', 'In unde debitis tenetur debitis odit laudantium aut. Eligendi accusantium ab ut pariatur et sapiente rem. Qui voluptas aliquid non consequatur iste eligendi eligendi.', 666, 9, 20, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(38, 'pariatur', 'Vero minima est eaque perferendis iste natus. Quos ea atque ipsam quam quia error recusandae. Dolorem deserunt a aut nemo rerum exercitationem aliquid.', 390, 1, 2, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(39, 'consequatur', 'Consequatur saepe velit voluptas cumque amet. Sequi inventore asperiores cum voluptatum est. Omnis assumenda voluptatibus est enim corporis dolores. Qui doloribus nam ut voluptates similique.', 595, 0, 27, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(40, 'vel', 'Quos voluptatum illum commodi adipisci mollitia. Animi ut voluptates et aut vel quas quisquam. Ut excepturi aliquid dignissimos.', 133, 4, 13, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(41, 'ut', 'Quam dolorum voluptatibus perferendis qui autem culpa soluta rerum. Provident et est est et sed deleniti quae temporibus. Soluta maxime eveniet rerum itaque dolore.', 923, 0, 13, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(42, 'quisquam', 'Consequuntur vel qui suscipit non itaque. Dolor commodi cupiditate dicta praesentium veritatis dicta. Voluptatem aut quia doloremque repudiandae repellat aliquam sit deleniti.', 633, 2, 17, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(43, 'voluptatum', 'Et sunt voluptas autem quis placeat. Praesentium esse voluptas quia exercitationem tempore quae harum. Odio maxime et consequatur doloremque ab possimus. Fugiat voluptatem dolores rem voluptate rerum.', 547, 6, 21, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(44, 'aut', 'Reiciendis illum quaerat porro iure sint quam. Sequi porro velit et placeat delectus ut. Officia aut id cupiditate non ea numquam. Autem nobis beatae tempore vel laboriosam sunt.', 380, 8, 30, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(45, 'rerum', 'Eaque et sit ea esse ex sint. Quae ratione est adipisci iste perspiciatis. Nobis numquam enim dolor ducimus. Voluptatibus et cupiditate et iure ipsa alias totam.', 297, 5, 6, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(46, 'sed', 'Ex quae sint nihil. Explicabo quod explicabo quod sint. Occaecati sed provident voluptatum deserunt voluptatibus nisi. Laboriosam excepturi repellat quas sed.', 974, 7, 13, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(47, 'et', 'Ratione omnis doloribus sit dolores perferendis similique. Porro cum hic occaecati quam. Non occaecati ut nihil voluptatem eos nulla est.', 539, 0, 2, '2019-01-30 03:08:54', '2019-01-30 03:08:54'),
(48, 'maiores', 'Nulla iusto non aut corrupti cum dolore. Alias blanditiis culpa totam reprehenderit debitis ad ex. Dolores odit sed quod qui fugiat reiciendis. Consequatur laudantium et omnis nam. In rerum reprehenderit assumenda maiores voluptate suscipit voluptas.', 933, 5, 7, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(49, 'iste', 'Dignissimos nemo accusantium ab minima non inventore. Alias quia consequuntur consectetur doloribus inventore sit debitis. Dolor ut qui reprehenderit eligendi unde nulla. Id odit blanditiis nihil.', 221, 3, 20, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(50, 'nesciunt', 'Quo quam laborum eius ea. Id est earum voluptas nobis minus officia. Illum modi doloremque quia ea. Vitae molestiae numquam fugiat deserunt. Modi repudiandae eos quidem fuga corporis.', 342, 5, 24, '2019-01-30 03:08:55', '2019-01-30 03:08:55');
-- --------------------------------------------------------
--
-- Table structure for table `reviews`
--
CREATE TABLE `reviews` (
`id` int(10) UNSIGNED NOT NULL,
`product_id` int(10) UNSIGNED NOT NULL,
`customer` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`review` text COLLATE utf8mb4_unicode_ci NOT NULL,
`star` int(11) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `reviews`
--
INSERT INTO `reviews` (`id`, `product_id`, `customer`, `review`, `star`, `created_at`, `updated_at`) VALUES
(1, 10, '<NAME>', 'Praesentium distinctio delectus non ut. Blanditiis asperiores qui totam quo magni ab. Itaque iure et repellat dolores rem corrupti nulla corrupti.', 5, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(2, 21, '<NAME> I', 'Et voluptas eos consequatur dolor esse. Veniam sint pariatur dignissimos et qui et. Repudiandae atque nam illum maxime incidunt qui.', 0, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(3, 27, '<NAME>', 'Dignissimos ut enim fuga nobis accusamus dolor voluptatem. Accusamus ratione incidunt ab recusandae placeat soluta ipsum dolor. Nobis sit ipsa facere sit incidunt. Molestias aut et et.', 5, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(4, 50, '<NAME> Sr.', 'Recusandae eum velit libero consequuntur odio et. Sed quas fuga sit accusamus. Nemo animi est est et explicabo in. Dolorem molestias incidunt non officiis delectus.', 4, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(5, 42, '<NAME>', 'Laudantium corrupti velit iure non quas. Sunt odit voluptatem impedit voluptatem officia omnis omnis ipsam. Placeat minus nihil officiis saepe debitis.', 0, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(6, 15, '<NAME> DDS', 'Id quo sit quis qui veniam. Consequuntur quod nostrum aperiam quasi exercitationem ad aliquid. Repudiandae dicta quisquam ut ipsa iste. Velit possimus vitae vero.', 1, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(7, 16, '<NAME> PhD', 'Provident quo necessitatibus labore eos eum numquam. Odio et ut similique expedita consequuntur voluptas. Sed quaerat sunt est sed cum. Distinctio possimus et rerum qui.', 2, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(8, 26, '<NAME>', 'Ipsum sint rerum blanditiis dolor qui molestiae neque. Porro qui fugit voluptatibus illum minima quo. Magnam aut dolorem omnis nulla iste. Blanditiis eveniet nihil aut corporis earum earum provident.', 0, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(9, 13, '<NAME>', 'Quos et rerum vel dolores. Soluta aliquid in ducimus ut et veniam. Consequatur autem quos quis iusto.', 4, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(10, 17, 'Prof. <NAME> III', 'Rerum atque qui culpa nihil. Ut accusamus quos quia eligendi delectus quia omnis. Rerum quos quis consequatur qui quia vero. Officia in placeat ea corporis voluptas omnis cupiditate nobis.', 2, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(11, 5, 'Ms. <NAME>', 'Non et cupiditate reiciendis deserunt iste. Autem ut dignissimos et. Hic voluptate placeat id nesciunt molestias.', 5, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(12, 4, '<NAME> II', 'Quia non minus recusandae harum. Iusto dolore id quo. Occaecati ipsam velit dolores et.', 3, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(13, 24, '<NAME>', 'Dolores culpa in eos voluptatem sequi nihil pariatur qui. Perferendis et dignissimos tenetur laboriosam quo. Incidunt omnis odio vitae earum omnis aliquid.', 5, '2019-01-30 03:08:55', '2019-01-30 03:08:55'),
(14, 4, 'Dr. <NAME> DVM', 'Necessitatibus officiis minus occaecati rerum. Soluta voluptas voluptas totam architecto consequatur cupiditate provident. Non ea temporibus omnis magni sit. Adipisci inventore unde ut quia. Provident repellendus nisi nobis atque.', 2, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(15, 3, 'Dr. <NAME>', 'Aperiam assumenda doloribus nihil architecto. Enim maiores blanditiis nemo quia eligendi assumenda. Non consequatur tempora asperiores quia repellendus. Tenetur ut repellat fugit eum earum assumenda.', 5, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(16, 44, '<NAME> Sr.', 'Sequi commodi corrupti excepturi quos error sunt. Veniam adipisci nostrum et repudiandae qui praesentium. Non voluptatem commodi saepe voluptas corporis sit unde.', 1, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(17, 2, '<NAME>', 'Consequatur repellat quae qui fugit praesentium in. In dolorum facilis eos quia perspiciatis sit omnis. Sequi enim quidem fuga magni earum. Maxime quo id distinctio aut.', 5, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(18, 42, '<NAME>', 'Quas quidem rerum qui nisi officia quis quas. Consequatur ipsum similique alias quas. Numquam omnis accusamus laborum consectetur. Et ut rem temporibus debitis eveniet sit laboriosam.', 3, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(19, 11, '<NAME>', 'Dolorum sunt repellendus sint modi ut nihil ut ullam. Accusamus dolorum qui dicta dolore consequatur esse. Ut ut eaque error suscipit voluptatibus magni aspernatur. Impedit aliquid unde eos non distinctio maiores ipsam.', 5, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(20, 23, '<NAME>', 'Quia maxime est quis praesentium. Natus eum iste magni est dolores. Omnis repellat nobis expedita voluptates.', 4, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(21, 30, 'Mr. <NAME>', 'Molestiae voluptatibus esse porro id voluptatem alias sequi. Nobis libero tempora hic consequuntur quisquam. Occaecati sit non voluptates sed consequatur.', 5, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(22, 39, '<NAME>', 'Laboriosam distinctio maiores sit ex. Placeat rem qui non tempore commodi fugit. Consequuntur quisquam odio enim. Repellendus aut sint earum commodi saepe recusandae reiciendis.', 5, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(23, 22, 'Prof. <NAME>', 'Rerum aliquam labore voluptate debitis. Doloremque est voluptas numquam optio natus perferendis dolore fugiat. Eligendi iste totam provident minima itaque. Animi eos optio sit blanditiis sapiente facere quasi.', 0, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(24, 38, '<NAME>', 'Neque quo mollitia aut eos consequatur sequi. Ut dolorem dolorem veritatis quas saepe facilis dolorum. Fugit inventore non quas sint.', 3, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(25, 19, 'Dr. <NAME> DVM', 'Aut quae libero qui sit ut. Nemo omnis corporis sit dolorem atque fugit. Enim atque dolorem nobis aut.', 5, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(26, 47, 'Dr. <NAME> III', 'Doloribus quae sunt doloribus aut aut rerum. Est praesentium voluptatem omnis unde explicabo ut animi. Sunt distinctio excepturi voluptatem nesciunt. Blanditiis tenetur ipsum enim enim quo. Nemo delectus labore occaecati aut mollitia.', 4, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(27, 5, '<NAME>', 'Sed aut in expedita reprehenderit. Ab eum aut sit consequatur. Rerum reiciendis qui quo veniam quod. Ut nulla voluptatibus dolorum.', 1, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(28, 20, 'Ms. <NAME> II', 'Eos qui saepe consequatur vitae. Similique tempore nihil laudantium expedita quo temporibus asperiores. Recusandae libero eos sint dolorem aspernatur dolorem similique qui. Error a non aliquid nemo eveniet quas.', 2, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(29, 10, '<NAME>', 'Aut eveniet vitae sed quos occaecati veniam reprehenderit aperiam. Et qui quaerat et. Inventore nihil quo sit laborum doloribus quibusdam.', 3, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(30, 45, 'Mrs. <NAME> DVM', 'Qui corporis nesciunt quam perferendis vel autem maxime. Reprehenderit quasi id omnis perferendis.', 0, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(31, 5, 'Prof. <NAME> Sr.', 'Enim minima quidem aliquam rerum vitae debitis ut. Dicta sint qui animi sed. Aperiam illum perspiciatis nihil. In exercitationem quia a sunt cupiditate.', 5, '2019-01-30 03:08:56', '2019-01-30 03:08:56'),
(32, 25, '<NAME> I', 'Voluptatem est architecto eius ut. Qui in dolores ea quam voluptatum praesentium adipisci aut. Dicta corrupti delectus dicta velit qui ut in.', 3, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(33, 1, '<NAME>', 'Sunt ea minima laudantium molestiae ut necessitatibus inventore. Dolorem aut voluptas sapiente sint possimus quia. Sed nostrum sit ut dolore eum aut voluptas. Inventore ea est officia suscipit cupiditate.', 0, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(34, 12, '<NAME>', 'Eum maiores enim ducimus aliquam ratione. Est et rerum qui iste ea. Officia ab facere itaque ut. Expedita nemo asperiores minus sequi deleniti quibusdam adipisci sit.', 0, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(35, 48, 'Dr. <NAME> III', 'Libero eos consequatur tempora libero. Qui error labore quo aut ut. Vero sed asperiores qui quas harum corporis. Quia eos sed ex nihil accusamus optio.', 0, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(36, 36, '<NAME>', 'Velit provident vel eveniet ut voluptates ad. Enim et aut velit et blanditiis minus sequi. Nesciunt eum molestiae nesciunt in enim. Assumenda voluptatem vel cupiditate aut.', 5, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(37, 50, 'Prof. <NAME>', 'Ab aut sapiente voluptatem distinctio. Repellendus accusantium rerum eos maxime. Assumenda numquam et fugit ea explicabo voluptatem. Numquam non quia repudiandae eius illo.', 0, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(38, 48, 'Delphine Considine', 'Ab nulla perferendis et nulla nisi enim sint. Ipsam ut consectetur quisquam reprehenderit recusandae itaque officia. Reiciendis vel ullam dolorum omnis impedit fuga vel.', 3, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(39, 16, '<NAME>', 'Unde similique voluptatem officia provident est provident eaque. Minus ullam incidunt quia molestiae laudantium. At eaque autem nemo nam qui voluptas aut.', 4, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(40, 23, 'Miss <NAME> Jr.', 'Error omnis magnam ducimus numquam eveniet. Porro voluptate dolorem ut labore illo magnam dolore. Neque quis est delectus suscipit dolorum. Temporibus reprehenderit perferendis minus magni.', 0, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(41, 39, '<NAME> DDS', 'Numquam excepturi qui quos repudiandae. Quia ut aut modi numquam dolor et. Sed eligendi et distinctio odio nostrum saepe. Ad dolores ullam et aut aut ea.', 5, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(42, 50, '<NAME>', 'Deleniti fugiat quibusdam totam atque non. Porro est odio id non sint voluptate eius enim. Tempore saepe voluptas debitis est architecto sed. A et officiis omnis sed aut. Cupiditate ut minima nam placeat explicabo ut aspernatur earum.', 4, '2019-01-30 03:08:57', '2019-01-30 03:08:57'),
(43, 49, '<NAME>', 'Porro velit expedita sit itaque distinctio ut voluptatem dolor. Iure consequuntur inventore ut. Architecto et esse consequatur dolor exercitationem quia modi. Esse rerum perferendis rerum dolores non velit magni.', 0, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(44, 39, '<NAME>', 'Ut architecto sit beatae quasi voluptas reiciendis. Labore occaecati ducimus neque vel. Dolorum laborum et rem nam rerum voluptas. Aut consequatur voluptas nesciunt eaque qui et et enim. Veritatis eos modi est qui omnis enim.', 5, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(45, 24, '<NAME>', 'Architecto possimus enim deleniti aperiam sed delectus veritatis. Et hic molestias qui nostrum laborum quidem est. Dolores molestias beatae fugiat rerum. Quia iure natus aut sed tempore molestiae.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(46, 5, '<NAME> DDS', 'Qui similique nobis in magnam. Omnis adipisci enim minima.', 2, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(47, 6, '<NAME> III', 'Quas veniam sunt sit quos. Quibusdam aut atque corrupti quo fugit. Quia vel ut ullam aut at.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(48, 44, '<NAME>', 'Ea autem voluptatum nihil quo voluptatum et. Voluptas delectus tempora neque hic et distinctio facere. Reiciendis quo quaerat recusandae ipsam quia. Praesentium ut qui sunt qui qui odio asperiores repellat.', 1, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(49, 2, 'Miss <NAME>', 'Dolor et dolores exercitationem voluptates autem veniam quibusdam. Officiis consectetur velit voluptas placeat. Molestiae et sunt qui reprehenderit. Aspernatur in est eum omnis vel.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(50, 43, '<NAME>', 'Nobis et in suscipit repellendus ipsam. Nulla dicta voluptatem molestias quos. Nisi exercitationem temporibus tempore dolore placeat maxime.', 4, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(51, 28, '<NAME>', 'Quo dolore placeat officiis quis assumenda. A et voluptas nam sapiente eaque ratione laboriosam. Ad delectus nihil mollitia ducimus aperiam.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(52, 36, '<NAME> DVM', 'Assumenda repudiandae est saepe tempore rerum et exercitationem eius. Nihil et delectus ea dignissimos deserunt. Dolorem inventore dolorem architecto fugit at.', 4, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(53, 48, 'Prof. <NAME>', 'Veritatis aut porro recusandae rerum totam. Accusamus ipsa quia deleniti aliquid consequatur quae eos. Voluptatibus nulla quaerat consequatur qui veniam blanditiis et autem.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(54, 49, '<NAME>', 'Porro commodi aut eveniet cupiditate. Sunt incidunt eum ut. Quos voluptatem laboriosam dignissimos omnis sit repellendus.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(55, 49, '<NAME>', 'Distinctio quo sed aliquid saepe accusamus id rerum perspiciatis. Ea ut doloribus eius temporibus quos qui et. Exercitationem voluptatum voluptatem voluptas beatae et consequatur.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(56, 10, '<NAME>', 'Non fugiat natus quam corporis assumenda voluptatum. Excepturi ea natus at minus voluptatum beatae. Ut omnis eos rem.', 1, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(57, 47, '<NAME>', 'Earum ratione optio facere quia suscipit reiciendis quo. Qui totam occaecati veniam. Modi qui tempora quis earum non ut molestiae eligendi. Magni occaecati iusto est eos rerum quidem consectetur. Labore asperiores facere ipsum dolor ullam dolores nostrum sed.', 3, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(58, 43, 'Miss <NAME> V', 'Dolores quis asperiores est illo et. Fugit illum occaecati voluptas perferendis expedita cupiditate. Suscipit dicta quae sed qui cumque et.', 5, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(59, 38, '<NAME> DDS', 'Autem ut maxime ducimus qui dolores. Perspiciatis sed itaque alias dolor placeat tempore ipsum. Ut similique facilis enim earum expedita sunt non commodi. Placeat incidunt voluptas culpa voluptas.', 0, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(60, 35, '<NAME> I', 'Sint ab expedita ut rerum commodi commodi ea ut. Maiores praesentium et veniam ea nulla fugit. Et deleniti ut qui.', 0, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(61, 34, '<NAME> Sr.', 'Distinctio a aperiam sequi nulla unde et assumenda eum. Nihil animi aut nemo eum sit animi et. Cumque labore explicabo fugiat pariatur. Minus odit molestiae voluptatem.', 2, '2019-01-30 03:08:58', '2019-01-30 03:08:58'),
(62, 42, '<NAME>', 'Repellat dolorem perspiciatis provident culpa dolor dolorum dolor. Fugiat omnis aperiam non consequatur et sit aliquid. Molestiae distinctio et aut atque.', 1, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(63, 44, 'Miss <NAME>', 'Hic voluptate nesciunt a ipsa voluptas voluptatum unde rerum. Autem odio earum et. Rerum eligendi consequatur unde sit mollitia quasi ut itaque.', 4, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(64, 43, '<NAME> PhD', 'Libero voluptatum quis consequatur pariatur. Cupiditate ducimus sed dolor molestias. Quia id quibusdam non.', 0, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(65, 50, '<NAME>', 'Mollitia libero maxime ipsum quam. Et magni laborum eum ipsum adipisci quo et. Non libero est qui commodi aut.', 2, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(66, 9, 'Mr. <NAME> Jr.', 'Eligendi architecto ducimus illo illo est. Expedita ea vel voluptatem ut aut atque enim. Molestias quod eligendi saepe numquam id eligendi. Non recusandae et beatae quam et et.', 3, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(67, 10, '<NAME> III', 'Necessitatibus omnis quaerat qui architecto vel non. Natus velit sunt sunt molestiae. Accusamus voluptatem et repudiandae reprehenderit.', 3, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(68, 32, '<NAME>', 'Maiores perspiciatis vitae quia rerum voluptas alias unde. Ducimus et adipisci in recusandae dignissimos dolorum architecto. Placeat ducimus omnis non enim.', 3, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(69, 19, '<NAME>', 'Cupiditate ut neque est tenetur facere velit. Excepturi voluptatem voluptatibus voluptates. Doloribus quia nihil non assumenda tempore aut.', 5, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(70, 4, '<NAME>', 'Vel exercitationem ut qui illo. Earum exercitationem beatae aut.', 3, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(71, 26, '<NAME>', 'Rerum aut sequi vel ut. Minima id enim soluta reiciendis totam praesentium. Provident voluptate sed non quod dolore quo occaecati.', 1, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(72, 47, '<NAME>', 'Totam qui eaque saepe officiis dolore vero. Possimus quia eos porro. Voluptatem quidem et ex ullam illum quos sit. Dignissimos magnam ut nulla delectus odio praesentium dolor. Autem earum non impedit accusantium rem soluta rem.', 0, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(73, 20, '<NAME>', 'Ut recusandae ut consequatur odit quia porro at. Est laborum quia commodi dolorem aut impedit. Dolor iste repudiandae vero rerum vero quibusdam impedit eum. Id repellat repellat vel fugiat dolores. Aut adipisci architecto voluptatem consectetur voluptatem eum.', 4, '2019-01-30 03:08:59', '2019-01-30 03:08:59'),
(74, 4, '<NAME>', 'Autem nostrum quisquam voluptates possimus recusandae rerum cumque. Cum odit fugit blanditiis non autem enim officiis. Quibusdam quia asperiores quibusdam explicabo est. Distinctio nobis quo quaerat repellat voluptas.', 3, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(75, 49, '<NAME>', 'Qui sint sint quaerat quos. Consectetur temporibus eum quo odit odit. Enim ex quae suscipit in.', 5, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(76, 17, 'Mr. <NAME>', 'Reiciendis ut unde dicta et cum expedita molestias. Mollitia sunt nobis animi dolorem qui quibusdam neque. Ea sed id cumque et.', 1, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(77, 27, '<NAME>', 'Repellat minus quod quos qui officiis. Beatae repellendus beatae unde sunt facere dolores. Sed rem dicta perferendis aut ipsa.', 3, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(78, 19, '<NAME>', 'Sint dolores doloremque sint. Libero eius dolores hic alias ut. Id ullam perspiciatis quibusdam. Et officiis molestiae facere repellendus nobis.', 3, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(79, 18, '<NAME>', 'Corrupti iure minima reprehenderit harum magnam atque. Quo animi quod sit. Ad hic non et. Ut dolore delectus praesentium ut in esse perferendis.', 1, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(80, 47, '<NAME>', 'Ab consequatur nobis possimus et. Sint quia quisquam doloribus veniam. Rem nesciunt neque mollitia.', 1, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(81, 7, '<NAME>', 'Rerum alias consequatur nesciunt perspiciatis. Itaque alias expedita et est quibusdam voluptas. Molestiae quae deserunt nesciunt ut nulla quis.', 5, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(82, 1, '<NAME>', 'Inventore eos impedit dolor animi fuga. Porro labore odio facere fuga qui non. Inventore vero vel explicabo ut et non. Nisi voluptatibus voluptatem similique sapiente et placeat rerum.', 1, '2019-01-30 03:09:00', '2019-01-30 03:09:00'),
(83, 9, '<NAME>', 'Alias quia repudiandae ea quaerat eos a ipsum. Et accusantium laborum ut fugit et dolores quas. Et fugiat provident aut rerum qui omnis. Itaque sunt optio sequi harum dolores atque sed ea.', 1, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(84, 3, '<NAME>', 'Maiores unde accusantium debitis aperiam rerum. Tempora quasi totam dolor officia iste iste velit qui. Quia adipisci eaque hic inventore aut. Voluptatem dolores possimus totam quasi.', 2, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(85, 16, 'Mrs. <NAME>', 'Consequuntur corporis aliquid id repudiandae quo ratione tempora. Vel qui dolorum sed. Error rerum doloremque porro est.', 3, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(86, 3, '<NAME>', 'Animi fuga non in officiis odio. Quia et voluptate est earum ut. Sunt voluptatem ut soluta.', 5, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(87, 40, '<NAME>', 'Omnis eos dicta amet voluptate ut enim. Est quo odit qui sint et. Sit maiores necessitatibus harum in dolores iste rerum. Quo quisquam voluptates autem minus ea. Laboriosam sapiente velit unde eaque dolorem.', 5, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(88, 44, 'Dr. <NAME>', 'Ut reiciendis molestiae ut. Asperiores architecto aut autem accusantium neque omnis ut.', 3, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(89, 32, '<NAME> MD', 'Temporibus blanditiis voluptatem illo vel exercitationem nesciunt nihil. Unde facere cupiditate a. Ab laboriosam nam eum et magni beatae eius.', 4, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(90, 19, 'Mrs. <NAME> PhD', 'Ad laboriosam perferendis consequatur explicabo rerum sit labore tempore. Dolorum ad temporibus qui cupiditate velit tempora modi nemo. Consequatur necessitatibus voluptates nemo praesentium eos. Explicabo voluptas quibusdam harum beatae dolorem dolore a. Praesentium asperiores quae dolor alias.', 2, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(91, 28, '<NAME>', 'Culpa vel placeat ea. Voluptatem voluptates facilis voluptatem rerum deleniti aut. Qui qui error velit voluptatem sed explicabo ab.', 4, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(92, 49, '<NAME> DDS', 'Tenetur eveniet quam pariatur deleniti. Et expedita placeat sint quo. Nisi temporibus id voluptas harum molestias exercitationem suscipit. Itaque et dolorum et aut optio omnis suscipit fuga.', 0, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(93, 21, 'Prof. <NAME> DDS', 'Atque maxime dolores aliquid placeat. Dolor sit quasi blanditiis rerum reiciendis. Qui non culpa excepturi est consequuntur corporis.', 4, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(94, 19, '<NAME>', 'Vitae doloremque voluptatum praesentium ducimus eligendi. Eum doloribus autem aut consectetur qui et repellat. Ad voluptatem doloremque vitae. Sunt necessitatibus maiores quaerat aut natus est nesciunt.', 2, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(95, 26, '<NAME>', 'Voluptas nam esse nam voluptates sit tempore in quia. Error aliquam odit rerum qui nobis assumenda. Perferendis harum maiores dolor maxime fugit ad labore sit.', 4, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(96, 35, '<NAME> DDS', 'Et ut necessitatibus praesentium aut sunt. Nihil sint aliquam ex sed. Ut impedit sunt dolorum iure excepturi.', 0, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(97, 32, 'Mr. <NAME>', 'Consequatur dolores repudiandae ut omnis dolorum ex. Voluptas unde eius deserunt enim. Error ut excepturi nihil vel. Quasi et et aliquid voluptatem vitae ullam deleniti unde. Quia enim sit voluptas ut similique nesciunt.', 5, '2019-01-30 03:09:01', '2019-01-30 03:09:01'),
(98, 11, '<NAME>', 'Illo illo voluptate ut ipsam ea. Esse dolorem voluptas quas ullam dolorem autem cum. Reprehenderit consequuntur autem deleniti sunt perferendis. Sit quae dolores temporibus aut asperiores neque aut.', 2, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(99, 30, '<NAME> V', 'Sit architecto corporis molestiae nobis quo earum. Aperiam ratione et a et autem odit quia delectus. Ea et maxime corporis aut provident.', 2, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(100, 34, '<NAME> I', 'Adipisci hic autem minus fuga veniam. Quasi quidem et perspiciatis expedita aperiam accusantium autem. Ullam qui omnis amet incidunt qui odio. Quos voluptas sint sit ut quibusdam molestias.', 5, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(101, 19, '<NAME>', 'Unde facilis reprehenderit inventore deleniti at. Quasi amet sit ipsa maxime reprehenderit. Officia in dolor sunt nihil et officiis. Necessitatibus nam et accusamus hic harum consequuntur dolorum.', 1, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(102, 45, '<NAME>', 'Non est placeat est et quia. Quisquam ea nostrum rerum fugiat. In quia debitis voluptas error enim cum ea.', 4, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(103, 33, '<NAME>', 'Magni nostrum ea necessitatibus omnis sed. Assumenda fugiat corrupti fugiat ducimus similique mollitia sed. Suscipit quia occaecati quia.', 4, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(104, 41, 'Dr. <NAME> IV', 'Autem reprehenderit aspernatur alias. Tempora deleniti doloremque provident. Blanditiis aliquid deleniti nisi quas nostrum.', 2, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(105, 24, '<NAME>', 'Repellendus et culpa veniam vero. Sunt atque consequatur ut sint. Commodi at voluptatem fugiat est. Aut exercitationem officiis et.', 1, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(106, 13, 'Dr. <NAME> III', 'Eius nam dicta voluptatem impedit. Corrupti quibusdam voluptatum asperiores.', 0, '2019-01-30 03:09:02', '2019-01-30 03:09:02'),
(107, 6, '<NAME>', 'Sint et iste soluta nostrum vitae et. Omnis cumque tenetur est sed eos. Ut ut id placeat qui. Labore neque commodi voluptatem recusandae unde nemo eum.', 5, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(108, 38, '<NAME>', 'Omnis voluptas impedit voluptas facilis sint. Quia cumque voluptates ipsa. Beatae voluptate omnis ea et laudantium alias. At assumenda ipsum atque quam odit.', 1, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(109, 47, '<NAME> III', 'Iusto consequatur enim ipsam magnam aut. Molestias sequi autem aliquam aut libero amet voluptatibus. Eaque maxime assumenda ut veniam et eveniet.', 0, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(110, 44, '<NAME>', 'Non commodi quia autem dolorem dolor id consectetur. Id blanditiis rem qui dolorem quo laboriosam. Omnis omnis quis quia quo quia eaque quia possimus. Perspiciatis eos aliquid voluptatibus quod ad suscipit maxime dolorem.', 1, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(111, 31, 'Prof. <NAME> Sr.', 'Placeat blanditiis ratione quia. Voluptates reprehenderit qui porro alias optio exercitationem. Non est eum rerum.', 5, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(112, 34, '<NAME>', 'Corporis quia similique non aut. Dicta est eum pariatur omnis dolores dolor similique. Maxime rerum ut rem quidem quia impedit nobis quasi. Cum repudiandae dignissimos sunt eum atque.', 4, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(113, 28, 'Prof. <NAME>', 'Facere optio debitis qui omnis omnis dolorem velit quas. Cupiditate sed autem sit aut. Nulla ad labore dolorem eligendi. Maiores cum harum aut amet deleniti. Et quaerat ea consequuntur sed.', 2, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(114, 40, 'Mrs. <NAME> Jr.', 'Ipsa qui natus quia. Earum expedita aut maxime officia deserunt ipsa occaecati sit. Officiis illo et id necessitatibus quae sint unde architecto. Quibusdam quia dolor perferendis eius. Ea quo et incidunt rerum quo dignissimos doloremque ullam.', 5, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(115, 2, '<NAME>', 'Repellat deleniti et perspiciatis et eveniet autem aspernatur. Alias ut at porro. Nostrum incidunt cumque ducimus qui.', 5, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(116, 20, '<NAME>', 'Ad aut similique voluptatem qui omnis et. Cupiditate ratione est rerum id. Ut esse eos est.', 5, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(117, 5, '<NAME>', 'Qui nemo optio modi eveniet ut minus. Non est dolor laboriosam totam ea. Sit facere optio quo illo. Nihil sit hic enim sed doloribus deleniti.', 4, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(118, 15, '<NAME>', 'Delectus architecto labore unde magnam. Quis aperiam cumque at asperiores. Labore repudiandae suscipit dolorum quasi illo provident non. Maxime animi a dolor est assumenda.', 1, '2019-01-30 03:09:03', '2019-01-30 03:09:03'),
(119, 5, 'Prof. <NAME> V', 'Aliquid autem optio minus ea. Odit reiciendis aut cumque beatae ea quod. Enim distinctio laborum modi voluptatem voluptatem magni esse. Ipsam et ipsum consequuntur est recusandae.', 4, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(120, 35, '<NAME>', 'Ut beatae vel cupiditate. Nemo aliquid distinctio consequatur ratione. Quos similique enim quas temporibus iusto et voluptatem.', 5, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(121, 48, 'Prof. <NAME> DDS', 'Qui autem consequatur culpa odio. Doloremque vitae qui quam ut culpa autem. Nisi porro magnam quas reprehenderit incidunt doloribus repellendus dignissimos. Perspiciatis consequuntur modi quis velit sint eveniet.', 5, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(122, 5, '<NAME>', 'Sunt laborum in iusto. Sint sint minus laborum omnis voluptatem. Expedita ipsam rerum saepe.', 0, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(123, 44, '<NAME>', 'Dolores deleniti harum a velit ducimus facilis voluptatem. Ut enim blanditiis nulla nihil quia accusamus quidem. Voluptatem tempore officiis et quas ad deserunt consectetur.', 5, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(124, 45, '<NAME> III', 'Facere autem quisquam rerum. Sit praesentium et et quis. Ut facere porro aut. Architecto facere aut magnam totam error.', 4, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(125, 6, 'Miss <NAME>', 'Natus repellendus occaecati deleniti nihil eaque. Fugit quis maiores eveniet sed. Iste dolores eius pariatur autem vitae vitae rerum iure. Et at quisquam eum est.', 5, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(126, 42, '<NAME>', 'Assumenda repellendus dolorum dolore ex. Qui facere et maiores animi harum nihil. Doloribus tempore voluptas vitae saepe quis. Quibusdam error eius iste repellendus deleniti.', 3, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(127, 24, 'Prof. <NAME>', 'Ut ratione id beatae qui neque laborum suscipit. Blanditiis quisquam exercitationem voluptatum exercitationem. Ullam nihil reprehenderit eos occaecati amet in consequatur. Modi quo sunt velit architecto id.', 0, '2019-01-30 03:09:04', '2019-01-30 03:09:04'),
(128, 10, '<NAME>', 'Eum autem omnis a cupiditate sint consectetur. Unde et dolores aperiam est nostrum cumque. Minus aut illo eligendi autem ex numquam. Eos dolorum quo et recusandae nesciunt. Nam dicta omnis distinctio.', 5, '2019-01-30 03:09:05', '2019-01-30 03:09:05'),
(129, 49, '<NAME> I', 'Molestias explicabo exercitationem voluptas dolores nisi. Officiis qui nostrum ab corporis ex ab. Consequatur sunt adipisci et qui similique eum quo. Tenetur enim quis nemo id.', 3, '2019-01-30 03:09:05', '2019-01-30 03:09:05'),
(130, 22, '<NAME>', 'Et et magnam in nam sed. Iusto ullam non quia impedit cupiditate. Fugiat eaque voluptatibus rerum velit beatae rem. Minima minima et consequatur omnis.', 5, '2019-01-30 03:09:05', '2019-01-30 03:09:05'),
(131, 34, 'Dr. <NAME>', 'Debitis modi veritatis quia a neque consequuntur eius. Voluptas rem reprehenderit architecto. Sed quia impedit adipisci. Voluptatem adipisci blanditiis quibusdam beatae quia provident. Non ad cupiditate et ex aperiam est fuga.', 1, '2019-01-30 03:09:05', '2019-01-30 03:09:05'),
(132, 27, '<NAME>', 'Natus sed in quod voluptas. Laboriosam ipsum quo officia et assumenda quo. Saepe consectetur corporis architecto eos facere et commodi. Quod quaerat dolorem animi alias facilis suscipit similique. Quia maxime minima qui quidem esse.', 5, '2019-01-30 03:09:05', '2019-01-30 03:09:05'),
(133, 19, '<NAME>', 'Voluptate suscipit iste eum magnam. Soluta est optio vero. Distinctio et voluptas minima enim vero saepe.', 5, '2019-01-30 03:09:05', '2019-01-30 03:09:05'),
(134, 38, '<NAME>', 'Ea sint vel quaerat perspiciatis quo officia accusantium cum. Impedit voluptas mollitia ut.', 5, '2019-01-30 03:09:05', '2019-01-30 03:09:05'),
(135, 6, 'Dr. <NAME>', 'Est culpa eligendi voluptas dolorem ea vel. Nostrum omnis harum fugiat nihil. Consequatur et deserunt quia et ea mollitia temporibus. Aut quia dolores quis nihil nesciunt quidem.', 1, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(136, 15, 'Dr. <NAME> DDS', 'Est tempora cupiditate commodi ut et. Autem autem ab voluptas molestiae alias aliquid. Quod dolor autem in porro non sed quis. Modi fuga consequatur quis atque nemo cupiditate qui.', 3, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(137, 20, 'Prof. <NAME> III', 'Facilis nulla animi blanditiis aut minima in nulla. Optio pariatur quos quia consequatur illo rem. Vel a maiores blanditiis aut.', 3, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(138, 10, '<NAME>', 'Est ut omnis asperiores quia. Recusandae officia eligendi explicabo. Non voluptas eum earum eum quis.', 5, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(139, 26, '<NAME>', 'Laudantium suscipit dolorum saepe sunt harum aspernatur molestiae. Tempore ut voluptates voluptas sed quia aspernatur. Ut voluptas ducimus odio doloremque impedit omnis.', 4, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(140, 3, '<NAME>', 'Perspiciatis dolorum quasi ducimus et maiores consequatur ipsa. Quia omnis quasi ea ad et suscipit. Distinctio aut temporibus nihil.', 1, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(141, 45, 'Prof. <NAME>', 'Dignissimos in provident et. Iste impedit repellat aliquid. Error nam numquam sed autem. Nihil corrupti sit hic sunt.', 5, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(142, 11, '<NAME> MD', 'Cumque officia ut consequatur. Sit qui molestias accusamus inventore. Suscipit omnis ut minima inventore mollitia quo. Labore eveniet amet possimus laboriosam est saepe libero.', 1, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(143, 19, '<NAME>', 'Nam ipsa nam nisi mollitia nobis. Dolorem voluptatem placeat culpa quo iusto praesentium. Eos quisquam cupiditate aut repudiandae ut repellendus.', 1, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(144, 4, 'Liza West', 'Accusantium recusandae ut id excepturi blanditiis voluptatem. Esse nam qui est quam. Laudantium ex accusantium assumenda voluptatem voluptas voluptas mollitia.', 3, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(145, 44, 'Prof. <NAME> MD', 'Voluptas ut deserunt sit nesciunt. Quia voluptatem rem saepe laborum natus ullam.', 4, '2019-01-30 03:09:06', '2019-01-30 03:09:06'),
(146, 36, 'Prof. <NAME> III', 'Ipsa quibusdam dolorem illum vel. Ratione sapiente harum non quae dolore possimus. Quos repellat ad accusantium quam.', 1, '2019-01-30 03:09:07', '2019-01-30 03:09:07'),
(147, 2, '<NAME>', 'Enim delectus beatae libero quia reiciendis. Ut ipsa sit vero natus. Iusto quia adipisci dolorum illo distinctio in dolorem. Saepe sapiente et libero impedit illum.', 2, '2019-01-30 03:09:07', '2019-01-30 03:09:07'),
(148, 42, 'Dr. <NAME>', 'Quisquam cumque excepturi quis enim beatae nostrum. Aut provident rerum omnis consequatur quo. Omnis ex excepturi et.', 1, '2019-01-30 03:09:07', '2019-01-30 03:09:07'),
(149, 24, 'Mr. <NAME>', 'In dicta veritatis dolorum provident officiis corporis. Recusandae voluptates deserunt ipsum modi neque tenetur voluptatem. Neque perferendis voluptas et sunt explicabo. Aut voluptas et aut.', 1, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(150, 37, 'Mr. <NAME> II', 'Repudiandae esse est pariatur illo. Sit unde provident animi harum. Possimus minus sequi iure et dolore aspernatur dolor dolor.', 5, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(151, 10, '<NAME>', 'Porro quia aut sunt voluptas. Nihil quas dicta reiciendis rerum dolor nihil non. Sunt doloribus recusandae qui ad qui quo rerum.', 1, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(152, 35, '<NAME>', 'Ipsa labore ipsam odio non. Dolor molestiae ipsam quos expedita autem impedit.', 0, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(153, 17, '<NAME>', 'Et ea magni qui culpa at cum nobis consequatur. Quo odit debitis velit et occaecati error cumque. Et praesentium eaque molestiae voluptate et suscipit. Aut omnis quae soluta iste.', 0, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(154, 2, 'Prof. <NAME>', 'Et debitis repudiandae ullam veniam aut. Facere occaecati magnam est. Velit architecto nemo maxime. Sunt quis voluptate qui.', 3, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(155, 33, '<NAME>', 'Alias ipsum eum accusantium nam aut. Neque dolor voluptatem delectus omnis cum odit qui. Id eveniet corrupti magnam aut quasi pariatur. Perspiciatis facere laborum laborum sint libero.', 1, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(156, 30, 'Precious Cremin', 'Cumque expedita incidunt nulla reprehenderit et sit earum. Velit ratione voluptatem dolorem id. Sequi minima veritatis consequuntur. Fugit repellat laborum cum qui.', 3, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(157, 33, 'Ms. <NAME>', 'Cupiditate est aut voluptatem qui. Reiciendis nemo qui quos sit et. Explicabo et rerum neque molestiae. Amet assumenda sed fugit dolorum commodi.', 3, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(158, 4, 'Mrs. <NAME> IV', 'Aut expedita et et quam a debitis expedita. Quae veritatis blanditiis aut consequatur in consequatur sed. Et voluptas aliquid aut. Et corrupti aut sed aut eveniet blanditiis.', 0, '2019-01-30 03:09:08', '2019-01-30 03:09:08'),
(159, 25, '<NAME>', 'Autem blanditiis praesentium nemo illum dolorum ex aut. Placeat in quo aperiam expedita dolor iusto voluptas perferendis. Odit officia et molestias et in.', 5, '2019-01-30 03:09:09', '2019-01-30 03:09:09'),
(160, 41, '<NAME>', 'Consequatur rerum itaque animi dolores. Quo error mollitia nam non deserunt corrupti tempore accusamus. Numquam et in sed mollitia quae officiis vel aut. Amet voluptatum dolores ut nihil veritatis.', 3, '2019-01-30 03:09:09', '2019-01-30 03:09:09'),
(161, 36, '<NAME>', 'Minima atque commodi itaque consequatur et perspiciatis. Dolor possimus ut sequi aperiam voluptatem quod. Sit aut modi culpa aspernatur totam facere.', 2, '2019-01-30 03:09:09', '2019-01-30 03:09:09'),
(162, 27, '<NAME>', 'Dolorem harum et ut quod sit et. Molestiae totam cupiditate qui tempora voluptatibus est illo. Velit sit accusamus non voluptatem sapiente rerum optio. Labore odio vel voluptatibus dolor dolorum in.', 1, '2019-01-30 03:09:09', '2019-01-30 03:09:09'),
(163, 35, '<NAME>', 'Quia minus sunt qui esse. Quae possimus est sint exercitationem voluptatum tenetur. Veniam aperiam sit excepturi libero rem.', 5, '2019-01-30 03:09:09', '2019-01-30 03:09:09'),
(164, 22, '<NAME>', 'Unde dolorum consequatur ipsum nihil illo rerum. Dolor soluta illum sapiente sunt dolorem quis. Qui maiores tempore eius quidem laborum.', 1, '2019-01-30 03:09:09', '2019-01-30 03:09:09'),
(165, 45, 'Prof. <NAME>', 'Modi saepe repellat molestiae quidem qui enim. Qui vel eveniet non earum dolore. Aut quia sed magni dolore aspernatur. A eaque sint porro quos officiis illum.', 2, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(166, 14, '<NAME>', 'Inventore quidem est placeat distinctio sint corporis. Earum molestiae quia voluptatum quo. Optio molestiae dicta voluptas quasi amet porro.', 2, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(167, 30, '<NAME> DDS', 'Excepturi sint numquam ex nemo aut praesentium consequatur. Quia libero atque voluptas ipsa. Omnis ipsum aut aspernatur.', 3, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(168, 39, '<NAME>', 'Ducimus nisi est maxime et suscipit et voluptas. Aut eum enim ipsum ipsum iusto dicta in.', 2, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(169, 2, '<NAME>', 'Ea explicabo et soluta odit architecto nam laborum laboriosam. Minus fugit omnis est omnis perferendis. Non error atque cumque doloribus.', 2, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(170, 26, '<NAME>', 'Quae voluptatem consequatur ex occaecati ut harum consequuntur. Molestias ex itaque pariatur laboriosam ad doloribus excepturi. Beatae omnis et est distinctio fugiat libero. Sit dolor ut sunt sunt.', 2, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(171, 3, '<NAME>', 'Dolor perspiciatis deserunt sed est et aut. Esse voluptatum voluptas atque quis. Est hic odit et et quo voluptas. Officia maiores aperiam atque fugiat.', 3, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(172, 17, '<NAME>', 'Dignissimos ipsa aut nostrum. Quod rerum atque facere vitae minus. Quam minima quia aspernatur illum vitae aliquam officia.', 4, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(173, 34, '<NAME>', 'Eaque velit incidunt dolorum beatae necessitatibus adipisci facere illo. Numquam dolor aut in dolores. Aut corporis quia neque ullam.', 0, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(174, 18, 'Dr. <NAME> III', 'Est quibusdam autem officia harum. Laboriosam ut laborum quia nihil deserunt. Et voluptas sequi perferendis voluptatum a ut labore.', 2, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(175, 9, '<NAME>', 'Accusamus distinctio eaque aut at. Facere neque in nisi alias non voluptatem repellat. Sit quo enim sint excepturi reprehenderit quo possimus atque.', 0, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(176, 40, '<NAME>', 'Sunt porro cumque et non quia voluptatum quisquam ex. Occaecati incidunt officiis dolorem ut reprehenderit eligendi. Quia voluptatem quam quisquam sed.', 4, '2019-01-30 03:09:10', '2019-01-30 03:09:10'),
(177, 22, '<NAME>', 'Magni nemo qui laudantium aliquid praesentium minima. Sed vero quod dicta architecto quia. Nulla beatae facere perspiciatis ut.', 2, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(178, 25, '<NAME>', 'Aliquid fuga incidunt sed omnis quasi aliquam quia. Perferendis aut aut ratione non magnam. Saepe omnis nisi vero qui voluptatem.', 3, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(179, 10, '<NAME>', 'Libero voluptatem repellat dignissimos et dolor aliquid esse. Beatae officiis recusandae non magnam atque qui eius.', 2, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(180, 33, '<NAME>', 'Sapiente eaque temporibus suscipit culpa. Maiores voluptatem animi nemo nesciunt. Sed excepturi cum aut dolores ut ipsam.', 3, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(181, 32, 'Dr. <NAME> I', 'Nihil consequatur eligendi voluptates est voluptatum est rerum perferendis. Illum incidunt ipsam animi aut voluptatibus.', 2, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(182, 42, '<NAME> I', 'Nostrum ipsam autem repudiandae quisquam blanditiis porro. Facere totam omnis mollitia maiores voluptas. Tempora enim et hic ipsum.', 0, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(183, 17, '<NAME> II', 'Error impedit placeat id velit autem et. Quia omnis dignissimos aperiam aut exercitationem quisquam veniam. Rem deserunt molestiae velit ullam est et placeat provident. Rerum autem odio sapiente vel.', 4, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(184, 46, '<NAME> II', 'Incidunt quisquam ex aliquid. Quae ab nesciunt distinctio nemo quia aliquam. Dolor dolorem unde ea ducimus ullam dignissimos. Quis porro molestiae maxime perferendis accusantium.', 3, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(185, 40, 'Miss <NAME> II', 'Expedita perspiciatis molestias quo at debitis commodi excepturi. Recusandae nostrum velit et quidem rerum voluptas. Cum atque sed voluptatum sit eveniet consequatur. Nihil quia non fugit eligendi aut ut.', 1, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(186, 43, '<NAME>', 'Nemo autem et laboriosam quasi odio quidem. Nam sit voluptatibus eum consequatur facilis. Ut sit nihil et eos. Ipsa dignissimos assumenda praesentium voluptatum eos id sint omnis.', 5, '2019-01-30 03:09:11', '2019-01-30 03:09:11'),
(187, 10, '<NAME>', 'Facilis nemo itaque doloribus incidunt. Sequi magnam facere est dolorum pariatur provident. Harum voluptate doloribus dolores consequuntur illo consectetur distinctio. Doloribus quod ducimus dolorem. Nesciunt recusandae pariatur dignissimos vero vel in.', 5, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(188, 21, '<NAME>', 'Aliquam sequi aliquid nam labore architecto saepe a. Ut qui similique facere magni vel consectetur. Enim sed blanditiis nulla aut aut. Corrupti neque veniam enim saepe.', 1, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(189, 22, 'Ms. <NAME> III', 'Dolores rerum voluptatem rerum ipsum et magni a. Quidem eveniet cumque similique est deleniti mollitia harum pariatur. Quos sit voluptatibus rem dignissimos.', 1, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(190, 6, '<NAME>', 'Qui sed officiis eius eos. Sit fugit est repellendus amet. Alias laudantium repellat voluptatem nesciunt. Voluptates sunt voluptatibus est ut voluptates.', 4, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(191, 22, 'Mrs. <NAME>', 'Enim id adipisci voluptatem consequuntur vel. Et ut consectetur voluptate doloremque architecto ea facere minus. Ad optio et repellendus autem. Quod libero eius qui possimus temporibus corporis.', 4, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(192, 32, 'Miss <NAME>', 'Sit labore nulla quia temporibus eveniet sunt. Minus sapiente autem incidunt dicta expedita accusamus ut. Quo et officia repellat alias quis.', 2, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(193, 45, '<NAME>', 'Aperiam cupiditate optio distinctio esse adipisci pariatur molestias. Aut odit quo voluptatem natus assumenda autem. Est tempora officiis tempore deleniti tempore.', 4, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(194, 24, '<NAME>', 'Quos ullam expedita debitis voluptatem. Velit non perspiciatis ratione est. Nisi ipsum quia magnam quia illum.', 1, '2019-01-30 03:09:12', '2019-01-30 03:09:12'),
(195, 3, '<NAME>', 'Voluptas sed culpa ut eligendi quisquam sit. Dicta dolor ipsa totam pariatur magni dicta. Id nesciunt et quas eius alias. In sint sint molestiae ut dolor.', 2, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(196, 29, '<NAME> Sr.', 'Quia magni qui vel. Cupiditate qui non dolorem consequuntur molestiae. Occaecati quaerat quae quia aut repudiandae sunt. Et sint dolore modi.', 1, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(197, 43, '<NAME>', 'Perferendis id perspiciatis dolores ea qui eius possimus ut. Qui dolorem voluptatibus quaerat quam molestias sed consequatur. Ea distinctio odio maiores ut autem.', 3, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(198, 13, '<NAME>', 'Totam praesentium voluptatem in voluptates aut aliquid ut. Ipsum sint aperiam est doloribus sed aut voluptates. Accusamus eaque iusto inventore aut vitae molestiae sit.', 5, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(199, 48, '<NAME>', 'Natus maiores magni quod unde facere temporibus. Ipsam ut voluptas eos nihil. Consequatur quia consequatur voluptas ut amet sunt corporis. Cum qui molestiae quas perspiciatis voluptas laudantium non.', 3, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(200, 10, '<NAME>', 'Voluptas quae accusamus sed aliquid. Dolore qui nobis sequi doloremque ducimus. Sunt cumque pariatur excepturi hic.', 1, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(201, 21, '<NAME> V', 'Quas aperiam ducimus dolor sunt. Explicabo veniam accusamus et voluptatem deleniti quaerat aut. Quo aliquid optio unde consequatur. Amet et omnis corrupti ratione. Harum aut reprehenderit voluptatum soluta id eius.', 0, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(202, 11, '<NAME>', 'Deserunt eos et explicabo. Voluptatum quos fugit et repudiandae non facilis harum. Ut qui assumenda sint pariatur.', 5, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(203, 33, '<NAME>', 'Maiores qui voluptas et. Consequatur aliquam minima velit quibusdam commodi et nemo. Quaerat fugiat et unde vel et qui enim pariatur. Iure doloremque est quia perferendis. Aut dolor eius pariatur aut.', 5, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(204, 5, 'Mr. <NAME> Jr.', 'Vel eum ex veritatis incidunt est non. Tempora ducimus reprehenderit ipsa sint. Quis facilis autem odio voluptate ut. Id omnis nemo non.', 3, '2019-01-30 03:09:13', '2019-01-30 03:09:13'),
(205, 44, '<NAME>', 'Voluptates praesentium rem eum natus. Et et est sit veritatis vel. Id voluptatem voluptate beatae officia.', 4, '2019-01-30 03:09:14', '2019-01-30 03:09:14'),
(206, 29, '<NAME> DVM', 'Omnis consequatur ea facere amet. Asperiores facere aspernatur quisquam ut. Saepe qui voluptatem vel amet cupiditate ut et.', 0, '2019-01-30 03:09:14', '2019-01-30 03:09:14'),
(207, 43, '<NAME>', 'Nam est iste odio sit atque exercitationem beatae. Rerum expedita ut quo et quaerat nisi. Dolor ipsam officiis consequatur aperiam quod aperiam excepturi.', 2, '2019-01-30 03:09:14', '2019-01-30 03:09:14'),
(208, 8, '<NAME> DVM', 'Aut est voluptatum laboriosam. Qui inventore alias et. Fugiat doloremque nemo eius iure reprehenderit.', 0, '2019-01-30 03:09:14', '2019-01-30 03:09:14'),
(209, 20, '<NAME> PhD', 'Qui quia ut molestias quia numquam. Doloribus amet et fugit ab praesentium molestiae et. Ut possimus officiis aperiam perspiciatis sit. Id sit non aut voluptate error omnis.', 4, '2019-01-30 03:09:14', '2019-01-30 03:09:14'),
(210, 1, '<NAME>', 'Autem repudiandae pariatur quia sed nulla numquam illum libero. Vel vitae unde qui hic. Autem quisquam ea deserunt in. Enim aut ut deleniti eius aut quaerat.', 2, '2019-01-30 03:09:14', '2019-01-30 03:09:14'),
(211, 11, '<NAME>', 'A pariatur est laborum est. Delectus delectus nobis enim aspernatur dolorem. Quia cumque et est sit.', 2, '2019-01-30 03:09:15', '2019-01-30 03:09:15');
INSERT INTO `reviews` (`id`, `product_id`, `customer`, `review`, `star`, `created_at`, `updated_at`) VALUES
(212, 10, '<NAME> V', 'Qui recusandae ad dolore sed. Iusto necessitatibus laudantium rem eligendi tempore. Eligendi omnis velit dolorem accusantium dicta.', 0, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(213, 1, '<NAME>', 'Officia quo sit reiciendis corporis. Dolores vitae explicabo ad molestiae modi ipsam. Reprehenderit et ut libero iusto voluptatem exercitationem commodi. Nesciunt ut doloribus quia eos esse ut consequatur corporis.', 0, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(214, 4, '<NAME>', 'Omnis possimus pariatur beatae dolor voluptates quaerat. Alias quae voluptas dolor voluptas optio eos recusandae.', 2, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(215, 42, 'Kellen Altenwerth IV', 'Architecto aut repellendus nisi non. Excepturi hic quis est consectetur dolorum nobis. Accusantium adipisci magnam quia recusandae debitis molestiae.', 3, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(216, 24, 'Mr. <NAME> I', 'Consequatur perferendis et veritatis consequuntur odit. Ea iste sit recusandae quasi. Libero vitae quaerat voluptatem deserunt.', 0, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(217, 38, '<NAME>', 'Quas est quidem voluptatum natus quaerat. Voluptatem ea laborum doloribus non sed. Est enim omnis eligendi officiis cum sint. Adipisci et sint quia labore.', 5, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(218, 16, 'Prof. <NAME>', 'Cupiditate nostrum rem est. Ut facilis eligendi perferendis debitis dignissimos nisi. Quia sequi quia qui est est. Libero quia necessitatibus voluptas nobis laboriosam voluptas aut.', 3, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(219, 8, '<NAME> V', 'Dolor et consequatur maxime nisi eum assumenda sapiente. Aut modi quibusdam rem enim laudantium quas. Doloremque qui mollitia vitae libero impedit. Sed repellendus voluptatem ut et. Omnis blanditiis corporis nihil temporibus blanditiis laudantium nulla.', 0, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(220, 49, '<NAME>', 'Sed sunt nam vel cumque quas. Reprehenderit consectetur at laborum modi.', 5, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(221, 17, '<NAME>', 'Rem voluptatem quibusdam et est quo voluptatem sed. Veniam ut molestias minus quis quia. Dolorem rem eum non a dolorum laudantium nam. Repellendus quasi accusantium voluptatem reiciendis non.', 2, '2019-01-30 03:09:15', '2019-01-30 03:09:15'),
(222, 1, '<NAME>', 'Sed nihil et rerum debitis quo. Quia iste rerum est fugiat nam. Enim saepe quod dolores molestias dolor maxime nihil. Non mollitia velit quis nemo.', 5, '2019-01-30 03:09:16', '2019-01-30 03:09:16'),
(223, 44, '<NAME>', 'Quia sit earum quidem et qui nihil. Ea sunt minima voluptatem consequatur deleniti veritatis. Qui dignissimos commodi nihil aliquid et est necessitatibus.', 2, '2019-01-30 03:09:16', '2019-01-30 03:09:16'),
(224, 27, '<NAME>', 'Voluptas tempora molestiae cupiditate eum. Modi aut odit commodi. Aut vitae libero quia et officiis accusamus ut.', 4, '2019-01-30 03:09:16', '2019-01-30 03:09:16'),
(225, 36, 'Dr. <NAME>', 'Deleniti voluptas quas fugiat et inventore sapiente. Praesentium quia voluptates molestias et optio consequatur ad.', 5, '2019-01-30 03:09:16', '2019-01-30 03:09:16'),
(226, 24, '<NAME>', 'Fugiat laboriosam id quis tempora porro neque. Aut voluptatibus est eos non id quis voluptate. Animi qui rerum rerum quia voluptates ut nemo eos. Voluptatem tempora non dignissimos animi rerum.', 1, '2019-01-30 03:09:16', '2019-01-30 03:09:16'),
(227, 22, '<NAME>', 'Provident sed dolore maxime dolor eligendi ut voluptas. Doloremque est quibusdam dolor exercitationem voluptatem. Ipsa alias id fugiat dolorem hic sapiente.', 5, '2019-01-30 03:09:16', '2019-01-30 03:09:16'),
(228, 33, '<NAME>', 'Harum eligendi molestiae maxime est et. Non deleniti laborum occaecati minus tempora delectus. Velit molestias facilis ipsum ullam vero. Laboriosam eos earum nesciunt sunt.', 0, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(229, 35, 'Miss Elena O''Reilly Jr.', 'Sit aut voluptatem quia magnam voluptatibus quibusdam sequi nulla. Qui dolorem enim excepturi. Quis quo eum autem qui.', 4, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(230, 48, 'Prof. <NAME> DVM', 'Sed ipsa dolorem laudantium mollitia. Sunt nostrum sint quas sed quasi qui labore. Consequatur eos ut aut mollitia.', 5, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(231, 49, '<NAME>', 'Et vel repellat et provident. Repudiandae aut ipsum unde aut et. Sed provident eaque assumenda. Pariatur quia error ut mollitia.', 5, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(232, 49, '<NAME> III', 'Aut voluptatum nisi temporibus sed error est. Ratione quia a dolorem rerum saepe sapiente magni. Esse animi est optio iusto cupiditate.', 3, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(233, 21, '<NAME>', 'Quisquam sit in reprehenderit consectetur quo quia. Et eius quidem reiciendis. Explicabo tempora voluptate odio omnis. Autem in fugit optio iste voluptatem.', 1, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(234, 34, '<NAME> PhD', 'Omnis quis officiis occaecati et. Et repudiandae illum quis cum. Officiis tempore amet libero nostrum cum. Vel sunt labore rem itaque.', 2, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(235, 3, '<NAME>', 'Repellendus dolorum qui quibusdam quidem. Nihil debitis vitae dolores. Eveniet pariatur sunt quidem sit.', 5, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(236, 13, '<NAME> V', 'Odio sed pariatur sunt omnis dolorum quia. Error aspernatur reiciendis assumenda aut. Enim voluptatibus a officiis. Ex quibusdam est quae architecto velit.', 0, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(237, 24, '<NAME>', 'Ducimus minus eveniet enim omnis sed in est. Aut cupiditate iusto consequatur adipisci fugit suscipit dolorem. Ad nisi quo voluptatum. Neque delectus enim quidem quis pariatur.', 1, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(238, 15, 'Dr. <NAME> DVM', 'Consectetur beatae occaecati illo qui quis non. Consectetur perferendis blanditiis sint temporibus atque occaecati magni. Voluptatem sit vel tenetur. Iusto ducimus temporibus laborum rerum.', 5, '2019-01-30 03:09:17', '2019-01-30 03:09:17'),
(239, 23, '<NAME>', 'Ab quia ipsum soluta numquam consequuntur eligendi ut eum. Sit omnis voluptas ipsam iste. Consequuntur est maxime molestiae velit accusantium repudiandae sunt. Sed et et occaecati modi officia nihil magni.', 0, '2019-01-30 03:09:18', '2019-01-30 03:09:18'),
(240, 7, '<NAME>', 'A pariatur distinctio blanditiis sed. Possimus rerum harum tempora et enim reiciendis accusantium perspiciatis. Saepe nemo corrupti odit expedita dolor.', 5, '2019-01-30 03:09:18', '2019-01-30 03:09:18'),
(241, 20, '<NAME>', 'Voluptas voluptatum aut ipsum quia molestiae quas. Ipsum voluptates ut soluta cum consectetur error recusandae. Eligendi aut dolor animi voluptatibus. Nisi maxime officiis voluptatum non qui molestiae.', 5, '2019-01-30 03:09:18', '2019-01-30 03:09:18'),
(242, 26, '<NAME>', 'Inventore optio dolor ipsa corporis aut et adipisci. Excepturi enim neque error. Asperiores iste quibusdam ipsum soluta repellendus ex dignissimos. In maxime nulla sed rerum.', 5, '2019-01-30 03:09:18', '2019-01-30 03:09:18'),
(243, 42, '<NAME> Jr.', 'Exercitationem animi suscipit voluptatum quis dolores. Et facere est dolorum. Et possimus et quidem eveniet officiis sunt ullam autem. Eligendi mollitia quidem laudantium voluptatem consequuntur et.', 0, '2019-01-30 03:09:18', '2019-01-30 03:09:18'),
(244, 15, '<NAME>', 'Fuga magnam est est aperiam et necessitatibus. Sed et sit modi eos. Soluta odit fuga in est.', 1, '2019-01-30 03:09:19', '2019-01-30 03:09:19'),
(245, 24, '<NAME>', 'Animi dolorem dolorem et ab quis similique libero. Aut quia aut ut suscipit sint. Temporibus vitae quas rem rerum numquam consectetur sunt.', 4, '2019-01-30 03:09:20', '2019-01-30 03:09:20'),
(246, 10, '<NAME>', 'A nemo qui at corrupti repudiandae perferendis vero. Voluptatem odio officia at reiciendis ea quis dolor.', 2, '2019-01-30 03:09:21', '2019-01-30 03:09:21'),
(247, 27, '<NAME> DDS', 'Fuga at laudantium et sit in. Aut consequuntur et iusto deserunt quia accusantium. Officiis quos voluptatem doloribus assumenda facilis. In quia qui maiores.', 3, '2019-01-30 03:09:21', '2019-01-30 03:09:21'),
(248, 17, '<NAME> IV', 'Optio ipsa hic et eveniet. Officia id repellendus vero corporis.', 2, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(249, 43, '<NAME>', 'Temporibus earum nihil in id. Ipsam perspiciatis voluptatum quod et architecto. Fuga ea dolorem minima nesciunt magnam.', 4, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(250, 18, '<NAME>', 'Et architecto eligendi sit enim fuga id. Non incidunt error quibusdam atque necessitatibus enim. Ea ab explicabo omnis quia occaecati eius dolores. Aut consequuntur autem qui iusto at et. Quas non magnam sunt omnis quasi.', 0, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(251, 8, 'Mr. <NAME> IV', 'Voluptatum veniam molestias unde ut. Excepturi ducimus qui dolor repellat. Nostrum et provident animi corrupti quos. Sit et adipisci aliquam possimus qui est omnis blanditiis.', 3, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(252, 28, '<NAME>', 'Minima repudiandae officia eaque et exercitationem. Omnis laboriosam quidem unde aliquid.', 0, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(253, 3, '<NAME>', 'Nulla odit magnam ex non dolorum. Nisi maiores ullam voluptate. In et voluptas dolore unde omnis officia voluptatem.', 2, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(254, 9, '<NAME>', 'Laborum nihil voluptates accusantium corporis laudantium. Autem ut harum facere odio. Ut assumenda vero nihil veritatis deserunt eveniet beatae. Aliquam rem quaerat aut aut vel voluptas eos est.', 0, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(255, 13, '<NAME>', 'Cum adipisci sint earum sunt voluptatum impedit consequatur. Fugiat occaecati deserunt optio. Aut hic earum ea natus. Voluptatem sint veniam sunt molestiae iusto velit qui. Explicabo nobis error hic occaecati qui temporibus.', 2, '2019-01-30 03:09:22', '2019-01-30 03:09:22'),
(256, 4, '<NAME>', 'Neque molestiae quod error. Odit est unde et qui sequi omnis. Asperiores nesciunt natus omnis hic. Repellendus et unde qui quis. Ut voluptate enim velit magnam est.', 0, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(257, 18, '<NAME> Jr.', 'Unde excepturi nihil nisi. Amet corrupti illo doloremque ea. Enim debitis ducimus molestiae tempore. Commodi praesentium ea iusto aut debitis.', 1, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(258, 2, '<NAME>', 'Adipisci omnis delectus ipsa quia vitae aperiam et. Est rerum debitis voluptate ipsam quae consequuntur. Voluptates expedita et aut enim.', 3, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(259, 30, 'Prof. <NAME> Sr.', 'Error doloribus id quia culpa quaerat. Voluptas harum libero autem est eos id dignissimos. Beatae deserunt praesentium animi ut reiciendis quasi.', 5, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(260, 44, '<NAME>', 'Quibusdam atque minima vel accusamus quis. Asperiores quos consequuntur et a modi laborum voluptatem. Molestias beatae provident sapiente consequatur consectetur maiores in.', 3, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(261, 16, 'Brayan Prosacco DDS', 'Architecto aut et nobis impedit quo ipsa consequuntur. Consequatur impedit expedita vero non quos et consequatur. Voluptas et odit qui odit ut suscipit.', 3, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(262, 20, '<NAME>', 'Earum exercitationem voluptatem voluptas eos magni reprehenderit. Tenetur inventore omnis quia temporibus voluptatem. Corrupti omnis odio consequatur dolore ullam ullam aut.', 4, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(263, 18, '<NAME>', 'Dolor quidem vitae consequuntur fugit. Esse voluptatem dolore cumque explicabo quod voluptates. Ut doloremque dolorum quia ipsa praesentium quibusdam enim. Blanditiis et dicta porro quis eos dicta dolore.', 5, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(264, 10, '<NAME> I', 'Expedita laboriosam nihil provident voluptates adipisci quia accusantium. Aut nulla odit placeat nesciunt. Consequatur nihil soluta et ipsa qui quidem. Mollitia optio doloremque omnis voluptate corrupti. Ad non minus illo dolor qui nihil.', 3, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(265, 38, '<NAME>', 'At enim velit laborum. Sequi dolores velit quas cumque. Placeat ut eos consequatur aut nihil magnam. Laboriosam perspiciatis pariatur dignissimos excepturi autem.', 5, '2019-01-30 03:09:23', '2019-01-30 03:09:23'),
(266, 5, '<NAME>', 'Quis nemo consectetur quam alias. Illum consectetur in in aut.', 4, '2019-01-30 03:09:24', '2019-01-30 03:09:24'),
(267, 42, 'Ms. <NAME>', 'Quos et sapiente libero ut quia incidunt. Ut veniam magnam vel nihil cumque. Ea reiciendis eos asperiores nam molestiae. Quis quam dolorem vitae qui architecto et.', 5, '2019-01-30 03:09:24', '2019-01-30 03:09:24'),
(268, 1, 'Miss <NAME>', 'Sunt praesentium quia fugiat libero qui laborum quod deserunt. Quas voluptates sed enim adipisci. Ullam voluptas unde eos aut reprehenderit.', 1, '2019-01-30 03:09:24', '2019-01-30 03:09:24'),
(269, 14, '<NAME>', 'Ea accusantium facilis voluptatem explicabo. Autem fugit qui veritatis sed est quidem. Esse beatae exercitationem sint commodi maxime et. Nihil voluptatum assumenda aut doloribus accusamus aspernatur omnis.', 4, '2019-01-30 03:09:24', '2019-01-30 03:09:24'),
(270, 49, '<NAME>', 'Neque harum ut voluptas ut distinctio fugit quo. Qui quas sunt maxime aut repellendus occaecati qui. Ea laboriosam doloribus unde deleniti labore praesentium.', 2, '2019-01-30 03:09:24', '2019-01-30 03:09:24'),
(271, 28, '<NAME>', 'Commodi doloremque expedita tempore sit sint suscipit. Dicta voluptas ratione dolor et omnis. Ut nisi consequatur animi aperiam fuga eos magni. Nostrum tempore veniam aliquam voluptatem.', 2, '2019-01-30 03:09:24', '2019-01-30 03:09:24'),
(272, 28, '<NAME>', 'Voluptas non molestiae et laudantium atque alias. Sunt vitae rem qui voluptas suscipit et. Asperiores exercitationem fugiat suscipit praesentium id ea cumque. Ea accusamus eveniet explicabo odio.', 3, '2019-01-30 03:09:25', '2019-01-30 03:09:25'),
(273, 26, 'Prof. <NAME> I', 'Voluptatem aut at iure sequi rem. Et sint quidem similique qui enim autem earum aperiam. Ad recusandae vel mollitia magni vitae tempora. Et nobis adipisci delectus fugiat voluptate sint id eligendi.', 4, '2019-01-30 03:09:25', '2019-01-30 03:09:25'),
(274, 32, 'Ms. <NAME> Jr.', 'Reprehenderit vel iste molestiae sint. Alias molestias nulla aut distinctio iusto. In et ut adipisci fugit ut. Excepturi cupiditate dolores quia ea dignissimos maxime non et.', 2, '2019-01-30 03:09:25', '2019-01-30 03:09:25'),
(275, 39, '<NAME>', 'Minima iure illum neque voluptatem omnis molestias. Esse rem consequatur officia sint sequi temporibus repudiandae. Accusamus quo totam quia atque. Quibusdam possimus sed soluta mollitia eveniet.', 3, '2019-01-30 03:09:25', '2019-01-30 03:09:25'),
(276, 17, 'Dr. <NAME>', 'Pariatur hic nihil quisquam. Explicabo et est rerum delectus iste vel enim. Voluptatum sunt quaerat molestias reprehenderit voluptates nisi. Nihil amet totam quasi culpa dicta quia.', 2, '2019-01-30 03:09:25', '2019-01-30 03:09:25'),
(277, 38, '<NAME>', 'Sed voluptatem tenetur quos nesciunt velit. Consequatur quaerat adipisci quas eius temporibus.', 1, '2019-01-30 03:09:25', '2019-01-30 03:09:25'),
(278, 30, '<NAME>', 'Cumque maxime quis accusantium veniam voluptates. Soluta distinctio qui assumenda expedita. Id qui rem cumque in.', 3, '2019-01-30 03:09:26', '2019-01-30 03:09:26'),
(279, 43, 'Prof. <NAME>', 'Blanditiis blanditiis laudantium natus qui. Dolorum magni minus culpa non repellendus a eaque. Aut aut ratione qui dolore temporibus sed.', 0, '2019-01-30 03:09:26', '2019-01-30 03:09:26'),
(280, 42, '<NAME>', 'Assumenda hic rerum veniam pariatur. Distinctio sint earum quia non debitis ullam optio dicta. Laudantium unde iusto expedita aut consequatur et. Ducimus nemo at et et eum vel maxime.', 5, '2019-01-30 03:09:26', '2019-01-30 03:09:26'),
(281, 6, 'Prof. <NAME>', 'Nisi perferendis optio illum impedit quis harum est laborum. Consequuntur officia vel aliquid dolore. Voluptatem quia occaecati nihil. Laborum distinctio commodi nemo laboriosam autem.', 4, '2019-01-30 03:09:26', '2019-01-30 03:09:26'),
(282, 13, 'Ms. <NAME>', 'Et odio et amet voluptate molestias vero sit pariatur. Expedita soluta nam repellendus libero veniam.', 5, '2019-01-30 03:09:26', '2019-01-30 03:09:26'),
(283, 1, '<NAME>', 'Expedita dolorem asperiores non mollitia. Quia eveniet nisi inventore nisi. Saepe qui recusandae aut alias accusamus aut.', 2, '2019-01-30 03:09:26', '2019-01-30 03:09:26'),
(284, 40, 'Prof. <NAME>', 'Dolores iste saepe et dolor vero modi reprehenderit numquam. Perspiciatis dicta qui architecto maxime similique autem dolor eligendi. Non sunt et et architecto.', 2, '2019-01-30 03:09:26', '2019-01-30 03:09:26'),
(285, 24, 'Evangeline Upton II', 'Debitis accusantium harum dicta odit. Quia nihil aliquam laboriosam laudantium eum tempora. Est at et voluptas neque sint et. Eum cum et praesentium nostrum eius.', 2, '2019-01-30 03:09:27', '2019-01-30 03:09:27'),
(286, 30, 'Prof. <NAME>', 'Accusamus dolores et odio id ab. Ratione non ad dolorem pariatur et. Dolore voluptas earum possimus sed deserunt deleniti quibusdam. Provident veritatis qui voluptatem qui esse.', 1, '2019-01-30 03:09:27', '2019-01-30 03:09:27'),
(287, 21, '<NAME>', 'Et alias qui quia placeat reprehenderit possimus quis. Distinctio quisquam iure et. Non sit atque est dolor quasi. Ipsum expedita aut modi.', 3, '2019-01-30 03:09:27', '2019-01-30 03:09:27'),
(288, 37, 'Mrs. <NAME> III', 'Exercitationem placeat quas animi voluptatem aliquam deserunt. Sit occaecati esse atque doloremque ut neque cumque sed. Qui est repudiandae cumque exercitationem. Inventore qui quis ratione ipsa sint ullam omnis.', 1, '2019-01-30 03:09:27', '2019-01-30 03:09:27'),
(289, 32, '<NAME>', 'Praesentium maiores facilis ex ducimus et vero. Illo voluptate nemo sit quo explicabo. Animi numquam quod aut excepturi ducimus.', 1, '2019-01-30 03:09:27', '2019-01-30 03:09:27'),
(290, 3, '<NAME>', 'Earum libero aut at et suscipit repudiandae aliquid voluptatibus. Quia minima possimus animi excepturi voluptas ut.', 2, '2019-01-30 03:09:27', '2019-01-30 03:09:27'),
(291, 28, '<NAME>', 'Harum quo aut dolores ut consectetur. Cum sunt rerum repellat ut similique nam sed voluptatem. Quasi et et magni qui. Animi unde vel expedita deserunt.', 0, '2019-01-30 03:09:27', '2019-01-30 03:09:27'),
(292, 23, '<NAME>', 'Inventore doloribus sunt culpa. Praesentium voluptatem earum iure ea voluptas inventore itaque. Ullam aut sed perspiciatis voluptatem.', 4, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(293, 50, '<NAME>', 'Omnis ipsa nesciunt fugiat porro vel qui natus. Nihil nam aut inventore perspiciatis laudantium ut. Rem eligendi eum voluptatem nisi rerum.', 5, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(294, 26, '<NAME>', 'Quidem corporis non voluptas rerum molestiae. Modi qui repellendus iusto. Ab iure est quod quos a aut officia expedita.', 4, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(295, 13, '<NAME>', 'Corrupti deserunt quae qui repudiandae qui. Ea aut minima atque enim. Ipsum minus sint nihil ipsa distinctio aliquam. Atque et dolorem quia. Provident est modi perspiciatis nobis.', 2, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(296, 47, '<NAME>', 'Quae et accusamus incidunt omnis laborum accusamus nihil. Placeat rerum voluptatem in sapiente sed. Culpa a quo aut. Vel odio quasi reprehenderit fuga excepturi vitae.', 0, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(297, 50, 'Dr. <NAME> V', 'Ipsam veniam est inventore autem beatae. Enim dolorem corporis at. Nihil natus ex magnam quia similique ut. Dolor nulla sit soluta et quia qui. Et reprehenderit doloremque necessitatibus corporis exercitationem.', 3, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(298, 7, 'Dr. <NAME> I', 'Vitae consequatur aut doloremque voluptas quam nam corporis. Eveniet nesciunt rerum sapiente quibusdam atque. Enim sit sunt eos quo doloremque et excepturi. Ut et possimus consequatur repudiandae quia sequi. Atque fuga at odio eligendi maxime consequatur.', 3, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(299, 37, '<NAME>', 'Facilis omnis enim omnis qui. Rerum unde illum qui.', 3, '2019-01-30 03:09:28', '2019-01-30 03:09:28'),
(300, 27, '<NAME>', 'Quod non vel veritatis voluptate. Aut qui perferendis voluptas. Repellat explicabo praesentium et molestias incidunt quidem voluptatem. Veniam repellat quia rem.', 1, '2019-01-30 03:09:28', '2019-01-30 03:09:28');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(10) UNSIGNED NOT NULL,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `reviews`
--
ALTER TABLE `reviews`
ADD PRIMARY KEY (`id`),
ADD KEY `reviews_product_id_index` (`product_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51;
--
-- AUTO_INCREMENT for table `reviews`
--
ALTER TABLE `reviews`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=301;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `reviews`
--
ALTER TABLE `reviews`
ADD CONSTRAINT `reviews_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
<filename>code/wrangling/decisions_partial_churn_filter.sql<gh_stars>1-10
SELECT
CASE
WHEN decision='restored' THEN 'churn'
WHEN next_decision = 'restored' THEN 'churn'
ELSE 'use'
END AS churn_flag
, *
FROM (
SELECT
decisions_old.decision AS decision_copy
,LEAD(decisions_old.decision) OVER (PARTITION BY contract_number ORDER BY snapshot_id) AS next_decision
, count(decision) OVER (PARTITION BY contract_number ORDER BY snapshot_id ROWS UNBOUNDED PRECEDING) AS num_previous_snapshots
, *
FROM decisions_old
) AS decisions_portion
WHERE contract_number IN (
--Random list of contracts
SELECT contract_number
FROM (
SELECT contract_number, MIN(tracs_overall_expiration_date) AS earliest_expiration
FROM contracts
GROUP BY contract_number
LIMIT 2000
) AS random_unsorted
ORDER BY earliest_expiration
)
ORDER BY contract_number, snapshot_id
|
CREATE TABLE [dbo].[LinkUsersAlerts] (
[ID] BIGINT IDENTITY (1, 1) NOT NULL,
[UserID] NVARCHAR (128) NOT NULL,
[AlertID] BIGINT NOT NULL,
CONSTRAINT [PK_LinkUsersAlerts] PRIMARY KEY CLUSTERED ([ID] ASC),
FOREIGN KEY ([UserID]) REFERENCES [dbo].[AspNetUsers] ([Id]),
FOREIGN KEY ([UserID]) REFERENCES [dbo].[AspNetUsers] ([Id]),
CONSTRAINT [FK__LinkUsers__Alert__7EC1CEDB] FOREIGN KEY ([AlertID]) REFERENCES [dbo].[Alerts] ([ID])
);
|
-- P39D. FAMILY TYPE BY PRESENCE AND AGE OF RELATED CHILDREN (ASIAN ALONE HOUSEHOLDER)
-- designed to work with the IRE Census bulk data exports
-- see http://census.ire.org/data/bulkdata.html
CREATE TABLE ire_p39d (
geoid VARCHAR(11) NOT NULL,
sumlev VARCHAR(3) NOT NULL,
state VARCHAR(2) NOT NULL,
county VARCHAR(3),
cbsa VARCHAR(5),
csa VARCHAR(3),
necta VARCHAR(5),
cnecta VARCHAR(3),
name VARCHAR(90) NOT NULL,
pop100 INTEGER NOT NULL,
hu100 INTEGER NOT NULL,
pop100_2000 INTEGER,
hu100_2000 INTEGER,
p039d001 INTEGER,
p039d001_2000 INTEGER,
p039d002 INTEGER,
p039d002_2000 INTEGER,
p039d003 INTEGER,
p039d003_2000 INTEGER,
p039d004 INTEGER,
p039d004_2000 INTEGER,
p039d005 INTEGER,
p039d005_2000 INTEGER,
p039d006 INTEGER,
p039d006_2000 INTEGER,
p039d007 INTEGER,
p039d007_2000 INTEGER,
p039d008 INTEGER,
p039d008_2000 INTEGER,
p039d009 INTEGER,
p039d009_2000 INTEGER,
p039d010 INTEGER,
p039d010_2000 INTEGER,
p039d011 INTEGER,
p039d011_2000 INTEGER,
p039d012 INTEGER,
p039d012_2000 INTEGER,
p039d013 INTEGER,
p039d013_2000 INTEGER,
p039d014 INTEGER,
p039d014_2000 INTEGER,
p039d015 INTEGER,
p039d015_2000 INTEGER,
p039d016 INTEGER,
p039d016_2000 INTEGER,
p039d017 INTEGER,
p039d017_2000 INTEGER,
p039d018 INTEGER,
p039d018_2000 INTEGER,
p039d019 INTEGER,
p039d019_2000 INTEGER,
p039d020 INTEGER,
p039d020_2000 INTEGER,
PRIMARY KEY (geoid)
);
|
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL auto_increment,
`email` varchar(255) default NULL,
`username` varchar(255) default NULL,
`password` varchar(255) default NULL,
`name` varchar(100) default NULL,
`gender` char(1) default NULL,
`updated_at` datetime NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `user` (`id`, `email`, `username`, `password`, `name`, `gender`, `updated_at`, `created_at`) VALUES
(1, '<EMAIL>', '<PASSWORD>', NULL, 'Matt', 'm', '2011-08-16 23:41:55', '2011-08-14 10:09:57'),
(2, '<EMAIL>', 'james', NULL, 'James', 'm', '2011-08-14 10:10:24', '2011-08-14 10:10:28'),
(3, '<EMAIL>', 'adam', NULL, 'Adam', 'm', '2011-08-14 10:11:47', '2011-08-14 10:11:51'); |
--
-- Copyright 2005-2011 The Kuali Foundation
--
-- Licensed under the Educational Community License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.opensource.org/licenses/ecl2.php
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',0,'docHandler is now mandatory...','Workflow Maintenance Document',2010,'EDENSERVICE-DOCS',0,'1','Workflow Maintenance Document','none','2',6,'B169E3D4890B4A9293E46CE58385B522');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${workflow.url}/DocumentType.do?methodToCall=docHandler','Workflow Maintenance Document Type Document',2011,'EDENSERVICE-DOCS.DocumentType',0,'1','Workflow Maintenance Document Type Document',2682,'edu.iu.uis.eden.doctype.DocumentTypePostProcessor','2',2,'B169E3D4890B4A9293E46CE58385B523');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${workflow.url}/Rule.do?methodToCall=docHandler','Rule Maintenance Document Type Document',2012,'EDENSERVICE-DOCS.RuleDocument',0,'1','Rule Maintenance Document Type Document',2682,'org.kuali.rice.kew.rule.RulePostProcessor','2',2,'B169E3D4890B4A9293E46CE58385B524');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${workflow.url}/Workgroup.do?methodToCall=docHandler','Document to generate a new workgroup',2013,'EDENSERVICE-DOCS.WKGRPREQ',0,'1','Add/modify EDEN workgroup',2682,'org.kuali.rice.kew.workgroup.WorkgroupPostProcessor','1',2,'B169E3D4890B4A9293E46CE58385B525');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${workflow.url}/RemoveReplace.do?methodToCall=docHandler','A document to remove or replace users within rules and workgroups.',2014,'EDENSERVICE-DOCS.RemoveReplaceUser',0,'1','Remove/Replace User',2682,'org.kuali.rice.kew.removereplace.RemoveReplacePostProcessor','1',2,'B169E3D4890B4A9293E46CE58385B526');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Principal',2015,'KIMPrincipalMaintenanceDocument',0,'1','KIM Principal Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B527');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Group',2016,'KIMGroupMaintenanceDocument',0,'1','KIM Group Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B52');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Principal',2017,'KIMRoleMaintenanceDocument',0,'1','KIM Role Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B529');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Attribute Type',2018,'KIMAttributeTypeMaintenanceDocument',0,'1','KIM Attribute Type Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B52A');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Namespace',2019,'KIMNamespaceMaintenanceDocument',0,'1','KIM Namespace Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B52B');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a EntityType',2020,'KIMEntityTypeMaintenanceDocument',0,'1','KIM EntityType Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B52C');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Entity',2021,'KIMEntityMaintenanceDocument',0,'1','KIM Entity Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B52D');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Group Type',2022,'KIMGroupTypeMaintenanceDocument',0,'1','KIM Group Type Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B52E');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${ken.url}/DetailView.form','This is the re-usable notification document type that will be used for delivering all notifications with KEW.',2023,'KualiNotification',0,'2000','Notification','org.kuali.rice.ken.postprocessor.kew.NotificationPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B52F');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${ken.url}/AdministerNotificationRequest.form','Create a New Notification Request',2024,'SendNotificationRequest',0,'1','Send Notification Request','org.kuali.rice.ken.postprocessor.kew.NotificationSenderFormPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B530');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Organization',2025,'KualiOrganizationMaintenanceDocument',0,'1','Kuali Organization Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B531');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Organization Category',2026,'KualiOrganizationCategoryMaintenanceDocument',0,'1','Kuali Organization Category Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B532');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create or Update a Organization Context',2027,'KualiOrganizationContextMaintenanceDocument',0,'1','Kuali Organization Context Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','1',1,'B169E3D4890B4A9293E46CE58385B533');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',0,'${application.url}/travelDocument2.do?methodToCall=docHandler','Create a New Travel Request',2028,'TravelRequest',0,'1','Travel Request','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',2,'B169E3D4890B4A9293E46CE58385B534');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create a New Travel Account Maintenance Document',2029,'TravelAccountMaintenanceDocument',0,'1','Travel Account Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B535');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create a New Travel Fiscal Officer',2030,'FiscalOfficerMaintenanceDocument',0,'1','Travel Fiscal Officer','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B536');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create/edit parameter namespaces',2031,'ParameterNamespaceMaintenanceDocument',0,'1','Parameter Namespace Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B537');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create/edit a parameter type',2032,'ParameterTypeMaintenanceDocument',0,'1','Parameter Type Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B538');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create/edit a parameter detail type',2033,'ParameterDetailTypeMaintenanceDocument',0,'1','Parameter Detail Type Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B539');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create/edit a parameter',2034,'ParameterMaintenanceDocument',0,'1','Parameter Maintenance Document','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B53A');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${kr.url}/maintenance.do?methodToCall=docHandler','Create a Rice User',2035,'RiceUserMaintenanceDocument',0,'1','Create a Rice User','org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B53B');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'NONE',0,'${workflow.url}/EDocLite','eDoc.Example1 Parent Doctype',2204,'eDoc.Example1.ParentDoctype',0,'2200','eDoc.Example1 Parent Document','org.kuali.rice.kew.edl.EDocLitePostProcessor','2',3,'B169E3D4890B4A9293E46CE58385B53C');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'NONE',0,'${workflow.url}/EDocLite','eDoc.Example1 Request DocumentType',2205,'eDoc.Example1Doctype',0,'2200','eDoc.Example1 Request DocumentType',2206,'org.kuali.rice.kew.edl.EDocLitePostProcessor','2',3,'B169E3D4890B4A9293E46CE58385B53D');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'NONE',0,'${workflow.url}/EDocLite','eDoc.Example1 Parent Doctype',2206,'eDoc.Example1.ParentDoctype',1,'2200','eDoc.Example1 Parent Document','org.kuali.rice.kew.edl.EDocLitePostProcessor',2204,'2',3,'B169E3D4890B4A9293E46CE58385B53E');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'NONE',0,'${workflow.url}/EDocLite','eDoc.Example1 Request DocumentType',2215,'eDoc.Example1Doctype',1,'2200','eDoc.Example1 Request DocumentType',2217,'org.kuali.rice.kew.edl.EDocLitePostProcessor',2205,'2',4,'B169E3D4890B4A9293E46CE58385B53F');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'NONE',0,'${workflow.url}/EDocLite','eDoc.Example1 Parent Doctype',2216,'eDoc.Example1.ParentDoctype',2,'2200','eDoc.Example1 Parent Document','org.kuali.rice.kew.edl.EDocLitePostProcessor',2206,'2',2,'B169E3D4890B4A9293E46CE58385B540');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'NONE',1,'${workflow.url}/EDocLite','eDoc.Example1 Parent Doctype',2217,'eDoc.Example1.ParentDoctype',3,'2200','eDoc.Example1 Parent Document','org.kuali.rice.kew.edl.EDocLitePostProcessor',2216,'2',3,'B169E3D4890B4A9293E46CE58385B541');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',0,'none','SampleThinClientDocument',2280,'SampleThinClientDocument',0,'1','SampleThinClientDocument','org.kuali.rice.kew.postprocessor.DefaultPostProcessor','2',2,'B169E3D4890B4A9293E46CE58385B542');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'none','SampleThinClientDocument',2282,'SampleThinClientDocument',1,'1','SampleThinClientDocument','org.kuali.rice.kew.postprocessor.DefaultPostProcessor',2280,'2',1,'B169E3D4890B4A9293E46CE58385B543');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,APPL_ID,VER_NBR,OBJ_ID)
VALUES (1,'NONE',0,'${workflow.url}/EDocLite','eDoc.Example1 Request DocumentType',2320,'eDoc.Example1Doctype',2,'2200','eDoc.Example1 Request DocumentType',2217,'org.kuali.rice.kew.edl.EDocLitePostProcessor',2215,'2','FooBar',2,'B169E3D4890B4A9293E46CE58385B544');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,NOTIFY_ADDR,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'http://localhost:8080/tvl-dev/WorkflowTripDochandler.do','Travel Trip Reimbursement Document',2360,'TravelTripReimbursement',0,'1','Travel Trip Reimbursement','<EMAIL>','edu.iu.uis.tvl.workflow.routing.TravelPostProcessor','2',1,'B169E3D4890B4A9293E46CE58385B545');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_PLCY,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,APPL_ID,VER_NBR,OBJ_ID)
VALUES (1,'NONE',1,'${workflow.url}/EDocLite','eDoc.Example1 Request DocumentType',2440,'eDoc.Example1Doctype',3,'2200','eDoc.Example1 Request DocumentType',2217,'org.kuali.rice.kew.edl.EDocLitePostProcessor',2320,'2','FooBar',1,'B169E3D4890B4A9293E46CE58385B546');
--Following 2 insert statements are redundant and cause problems due to these document types already being ingested in DefaultTestData.xml
--INSERT INTO KREW_DOC_TYP_T (ACTV_IND,CUR_IND,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,LBL,POST_PRCSR,RTE_VER_NBR,VER_NBR,OBJ_ID)
-- VALUES (1,1,'KualiDocument',2680,'KualiDocument',0,'KualiDocument','none','2',2,'B169E3D4890B4A9293E46CE58385B547');
--INSERT INTO KREW_DOC_TYP_T (ACTV_IND,CUR_IND,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,LBL,PARNT_ID,RTE_VER_NBR,VER_NBR,OBJ_ID)
-- VALUES (1,1,'Parent Document Type for all Rice Documents',2681,'RiceDocument',0,'Rice Document',2680,'2',3,'B169E3D4890B4A9293E46CE58385B548');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'docHandler is now mandatory...','Workflow Maintenance Document',2682,'EDENSERVICE-DOCS',1,'1','Workflow Maintenance Document',2681,'none',2010,'2',1,'B169E3D4890B4A9293E46CE58385B549');
INSERT INTO KREW_DOC_TYP_T (ACTV_IND,BLNKT_APPR_GRP_ID,CUR_IND,DOC_HDLR_URL,DOC_TYP_DESC,DOC_TYP_ID,DOC_TYP_NM,DOC_TYP_VER_NBR,GRP_ID,LBL,PARNT_ID,POST_PRCSR,PREV_DOC_TYP_VER_NBR,RTE_VER_NBR,VER_NBR,OBJ_ID)
VALUES (1,'1',1,'${application.url}/travelDocument2.do?methodToCall=docHandler','Create a New Travel Request',2683,'TravelRequest',1,'1','Travel Request',2681,'org.kuali.rice.krad.workflow.postprocessor.KualiPostProcessor',2028,'2',1,'B169E3D4890B4A9293E46CE58385B54A');
|
<reponame>joojano/flyway-jpa<gh_stars>0
INSERT INTO tbUser(username, password) VALUES ('hanote', '<PASSWORD>');
INSERT INTO tbUser(username, password) VALUES ('luan', '<PASSWORD>');
INSERT INTO tbUser(username, password) VALUES ('cris', '<PASSWORD>'); |
-- DROP SCHEMA posfechados;
CREATE SCHEMA IF NOT EXISTS posfechados AUTHORIZATION lxzehfswwiupap;
-- posfechados.bank definition
-- Drop table
-- DROP TABLE posfechados.bank;
CREATE TABLE posfechados.bank (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
"name" varchar(255) NULL,
CONSTRAINT bank_name_uk UNIQUE (name),
CONSTRAINT bank_pkey PRIMARY KEY (id)
);
-- posfechados.client definition
-- Drop table
-- DROP TABLE posfechados.client;
CREATE TABLE posfechados.client (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
ci varchar(255) NULL,
"name" varchar(255) NULL,
ruc varchar(255) NULL,
CONSTRAINT ci_uk UNIQUE (ci),
CONSTRAINT client_pkey PRIMARY KEY (id)
);
-- posfechados.company definition
-- Drop table
-- DROP TABLE posfechados.company;
CREATE TABLE posfechados.company (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
"name" varchar(255) NULL,
CONSTRAINT company_name_uk UNIQUE (name),
CONSTRAINT company_pkey PRIMARY KEY (id)
);
-- posfechados.credit definition
-- Drop table
-- DROP TABLE posfechados.credit;
CREATE TABLE posfechados.credit (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
code varchar(255) NULL,
description varchar(255) NULL,
CONSTRAINT credit_code_uk UNIQUE (code),
CONSTRAINT credit_pkey PRIMARY KEY (id)
);
-- posfechados.currency definition
-- Drop table
-- DROP TABLE posfechados.currency;
CREATE TABLE posfechados.currency (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
code varchar(255) NULL,
description varchar(255) NULL,
CONSTRAINT currency_code_uk UNIQUE (code),
CONSTRAINT currency_pkey PRIMARY KEY (id)
);
-- posfechados.fiscal_year definition
-- Drop table
-- DROP TABLE posfechados.fiscal_year;
CREATE TABLE posfechados.fiscal_year (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
yearfiscal int4 NOT NULL,
CONSTRAINT fiscal_year_pkey PRIMARY KEY (id),
CONSTRAINT year_uk UNIQUE (yearfiscal)
);
-- posfechados.postdated_check definition
-- Drop table
-- DROP TABLE posfechados.postdated_check;
CREATE TABLE posfechados.postdated_check (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
account int8 NULL,
amount float8 NOT NULL,
checknumber varchar(255) NULL,
dateexpiration timestamp NULL,
datepayment timestamp NULL,
daterecovery timestamp NULL,
bank_id int8 NOT NULL,
client_id int8 NOT NULL,
company_id int8 NOT NULL,
credit_id int8 NOT NULL,
currency_id int8 NOT NULL,
fiscalyear_id int8 NOT NULL,
CONSTRAINT postdated_check_pkey PRIMARY KEY (id),
CONSTRAINT postdated_uk UNIQUE (bank_id, client_id, company_id, credit_id, currency_id, fiscalyear_id, account, checknumber)
);
-- posfechados.postdated_check foreign keys
ALTER TABLE posfechados.postdated_check ADD CONSTRAINT posdated_bank_fk FOREIGN KEY (bank_id) REFERENCES posfechados.bank(id);
ALTER TABLE posfechados.postdated_check ADD CONSTRAINT posdated_client_fk FOREIGN KEY (client_id) REFERENCES posfechados.client(id);
ALTER TABLE posfechados.postdated_check ADD CONSTRAINT posdated_company_fk FOREIGN KEY (company_id) REFERENCES posfechados.company(id);
ALTER TABLE posfechados.postdated_check ADD CONSTRAINT posdated_credit_fk FOREIGN KEY (credit_id) REFERENCES posfechados.credit(id);
ALTER TABLE posfechados.postdated_check ADD CONSTRAINT posdated_currency_fk FOREIGN KEY (currency_id) REFERENCES posfechados.currency(id);
ALTER TABLE posfechados.postdated_check ADD CONSTRAINT posdated_fiscalyear_fk FOREIGN KEY (fiscalyear_id) REFERENCES posfechados.fiscal_year(id);
-- posfechados.error_excel definition
-- Drop table
-- DROP TABLE posfechados.error_excel;
CREATE TABLE posfechados.error_excel (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
creation_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
creation_user int8 NOT NULL DEFAULT 0,
status bool NOT NULL DEFAULT true,
update_date timestamp NULL,
update_user int8 NULL,
account int8 NULL,
amount float8 NOT NULL,
checknumber varchar(255) NULL,
dateexpiration timestamp NULL,
datepayment timestamp NULL,
daterecovery timestamp NULL,
information varchar(2000) NULL,
bank_id int8 NULL,
client_id int8 NULL,
company_id int8 NULL,
credit_id int8 NULL,
currency_id int8 NULL,
fiscalyear_id int8 NULL,
CONSTRAINT error_excel_pkey PRIMARY KEY (id),
CONSTRAINT log_error_excel_uk UNIQUE (bank_id, client_id, company_id, credit_id, currency_id, fiscalyear_id, account, checknumber)
);
-- posfechados.error_excel foreign keys
ALTER TABLE posfechados.error_excel ADD CONSTRAINT log_bank_fk FOREIGN KEY (bank_id) REFERENCES posfechados.bank(id);
ALTER TABLE posfechados.error_excel ADD CONSTRAINT log_client_fk FOREIGN KEY (client_id) REFERENCES posfechados.client(id);
ALTER TABLE posfechados.error_excel ADD CONSTRAINT log_company_fk FOREIGN KEY (company_id) REFERENCES posfechados.company(id);
ALTER TABLE posfechados.error_excel ADD CONSTRAINT log_credit_fk FOREIGN KEY (credit_id) REFERENCES posfechados.credit(id);
ALTER TABLE posfechados.error_excel ADD CONSTRAINT log_currency_fk FOREIGN KEY (currency_id) REFERENCES posfechados.currency(id);
ALTER TABLE posfechados.error_excel ADD CONSTRAINT log_fiscalyear_fk FOREIGN KEY (fiscalyear_id) REFERENCES posfechados.fiscal_year(id);
|
----------------------------------------
-- INPUTS
-- location: neighborhood
-- vars:
-- :sigctl_search_dist=25 Search distance for traffic signals at adjacent intersection
----------------------------------------
UPDATE neighborhood_ways_intersections SET island = FALSE;
UPDATE neighborhood_ways_intersections
SET island = TRUE
WHERE legs > 2
AND EXISTS (
SELECT 1
FROM neighborhood_osm_full_point osm
WHERE osm.highway = 'crossing'
AND osm.crossing = 'island'
AND ST_DWithin(neighborhood_ways_intersections.geom, osm.way, :sigctl_search_dist)
);
|
<reponame>dr-pain/omniscidb
DROP TABLE ##TAB##
|
-- Copyright 2018 <NAME>. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
column lt_type heading "TYPE" format a4
column lt_name heading "LOCK NAME" format a32
column lt_id1_tag heading "ID1 MEANING" format a25 word_wrap
column lt_id2_tag heading "ID2 MEANING" format a25 word_wrap
column lt_us_user heading "USR" format a3
column lt_description heading "DESCRIPTION" format a60 word_wrap
prompt Show lock type info from V$LOCK_TYPE for lock &1
select
lt.type lt_type,
lt.name lt_name,
lt.id1_tag lt_id1_tag,
lt.id2_tag lt_id2_tag,
lt.is_user lt_is_user,
lt.description lt_description
from
v$lock_type lt
where
upper(type) like upper('&1')
/
|
<filename>kunlun-pg-regress/sql/lock.sql<gh_stars>10-100
--
-- Test the LOCK statement
--
-- Setup
CREATE SCHEMA lock_schema1;
SET search_path = lock_schema1;
CREATE TABLE lock_tbl1 (a BIGINT);
CREATE TABLE lock_tbl1a (a BIGINT);
CREATE VIEW lock_view1 AS SELECT * FROM lock_tbl1;
CREATE VIEW lock_view2(a,b) AS SELECT * FROM lock_tbl1, lock_tbl1a;
CREATE VIEW lock_view3 AS SELECT * from lock_view2;
CREATE VIEW lock_view4 AS SELECT (select a from lock_tbl1a limit 1) from lock_tbl1;
CREATE VIEW lock_view5 AS SELECT * from lock_tbl1 where a in (select * from lock_tbl1a);
CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub;
CREATE ROLE regress_rol_lock1;
ALTER ROLE regress_rol_lock1 SET search_path = lock_schema1;
GRANT USAGE ON SCHEMA lock_schema1 TO regress_rol_lock1;
-- Try all valid lock options; also try omitting the optional TABLE keyword.
BEGIN TRANSACTION;
LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE;
LOCK lock_tbl1 IN ROW SHARE MODE;
LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN SHARE MODE;
LOCK lock_tbl1 IN SHARE ROW EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE;
LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE;
ROLLBACK;
-- Try using NOWAIT along with valid options.
BEGIN TRANSACTION;
LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN ROW SHARE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN SHARE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN SHARE ROW EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE NOWAIT;
LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE NOWAIT;
ROLLBACK;
-- Verify that we can lock views.
BEGIN TRANSACTION;
LOCK TABLE lock_view1 IN EXCLUSIVE MODE;
-- lock_view1 and lock_tbl1 are locked.
select relname from pg_locks l, pg_class c
where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
order by relname;
ROLLBACK;
BEGIN TRANSACTION;
LOCK TABLE lock_view2 IN EXCLUSIVE MODE;
-- lock_view1, lock_tbl1, and lock_tbl1a are locked.
select relname from pg_locks l, pg_class c
where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
order by relname;
ROLLBACK;
BEGIN TRANSACTION;
LOCK TABLE lock_view3 IN EXCLUSIVE MODE;
-- lock_view3, lock_view2, lock_tbl1, and lock_tbl1a are locked recursively.
select relname from pg_locks l, pg_class c
where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
order by relname;
ROLLBACK;
BEGIN TRANSACTION;
LOCK TABLE lock_view4 IN EXCLUSIVE MODE;
-- lock_view4, lock_tbl1, and lock_tbl1a are locked.
select relname from pg_locks l, pg_class c
where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
order by relname;
ROLLBACK;
BEGIN TRANSACTION;
LOCK TABLE lock_view5 IN EXCLUSIVE MODE;
-- lock_view5, lock_tbl1, and lock_tbl1a are locked.
select relname from pg_locks l, pg_class c
where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
order by relname;
ROLLBACK;
BEGIN TRANSACTION;
LOCK TABLE lock_view6 IN EXCLUSIVE MODE;
-- lock_view6 an lock_tbl1 are locked.
select relname from pg_locks l, pg_class c
where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
order by relname;
ROLLBACK;
-- detecting infinite recursions in view definitions
--CREATE OR REPLACE VIEW lock_view2 AS SELECT * from lock_view3;
--BEGIN TRANSACTION;
--LOCK TABLE lock_view2 IN EXCLUSIVE MODE;
--ROLLBACK;
--CREATE VIEW lock_view7 AS SELECT * from lock_view2;
--BEGIN TRANSACTION;
--LOCK TABLE lock_view7 IN EXCLUSIVE MODE;
--ROLLBACK;
-- Verify that we can lock a table with inheritance children.
CREATE TABLE lock_tbl2 (b BIGINT) INHERITS (lock_tbl1);
CREATE TABLE lock_tbl3 () INHERITS (lock_tbl2);
BEGIN TRANSACTION;
LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE;
ROLLBACK;
-- Verify that we can't lock a child table just because we have permission
-- on the parent, but that we can lock the parent only.
GRANT UPDATE ON TABLE lock_tbl1 TO regress_rol_lock1;
SET ROLE regress_rol_lock1;
BEGIN;
LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE;
ROLLBACK;
BEGIN;
LOCK TABLE ONLY lock_tbl1;
ROLLBACK;
RESET ROLE;
--
-- Clean up
--
DROP VIEW lock_view7;
DROP VIEW lock_view6;
DROP VIEW lock_view5;
DROP VIEW lock_view4;
DROP VIEW lock_view3 CASCADE;
DROP VIEW lock_view1;
DROP TABLE lock_tbl3;
DROP TABLE lock_tbl2;
DROP TABLE lock_tbl1 cascade;
DROP TABLE lock_tbl1a cascade;
DROP SCHEMA lock_schema1 CASCADE;
DROP ROLE regress_rol_lock1;
-- atomic ops tests
RESET search_path;
SELECT test_atomic_ops();
|
<filename>tools/Openchain.SqlServer.Schema/Types/IdTable.sql
CREATE TYPE [Openchain].[IdTable] AS TABLE
(
[Id] VARBINARY(512) NOT NULL PRIMARY KEY
)
GO
|
<reponame>granadomoreno/oracle-db-examples
-----------------------------------------------------------------------
-- Oracle Machine Learning for SQL (OML4SQL) 21c
--
-- Clustering - O-Cluster Algorithm - dmocdemo.sql
--
-- Copyright (c) 2021 Oracle Corporation and/or its affilitiates.
--
-- The Universal Permissive License (UPL), Version 1.0
--
-- https://oss.oracle.com/licenses/upl/
-----------------------------------------------------------------------
SET serveroutput ON
SET trimspool ON
SET pages 10000
SET linesize 120
SET echo ON
-----------------------------------------------------------------------
-- SAMPLE PROBLEM
-----------------------------------------------------------------------
-- Segment the demographic data into 10 clusters and study the individual
-- clusters. Rank the clusters on probability.
-----------------------------------------------------------------------
-- SET UP AND ANALYZE THE DATA
-----------------------------------------------------------------------
-- The data for this sample is composed from base tables in SH Schema
-- (See Sample Schema Documentation) and presented through these views:
-- mining_data_build_parallel_v (build data)
-- mining_data_test_v (test data)
-- mining_data_apply_v (apply data)
-- (See dmsh.sql for view definitions).
--
-----------
-- ANALYSIS
-----------
-- For clustering using OC, perform the following on mining data.
--
-- 1. Use Data Auto Preparation
-- O-Cluster uses a special binning procedure that automatically
-- determines the number of bins based on data statistics.
--
-----------------------------------------------------------------------
-- BUILD THE MODEL
-----------------------------------------------------------------------
-- Cleanup old model with the same name for repeat runs
BEGIN DBMS_DATA_MINING.DROP_MODEL('OC_SH_Clus_sample');
EXCEPTION WHEN OTHERS THEN NULL; END;
/
-------------------
-- SPECIFY SETTINGS
--
-- Cleanup old settings table for repeat runs
--
BEGIN EXECUTE IMMEDIATE 'DROP TABLE oc_sh_sample_settings';
EXCEPTION WHEN OTHERS THEN NULL; END;
/
-- K-Means is the default clustering algorithm. Override the
-- default to set the algorithm to O-Cluster using a settings table.
--
-- CREATE AND POPULATE A SETTINGS TABLE
--
set echo off
CREATE TABLE oc_sh_sample_settings (
setting_name VARCHAR2(30),
setting_value VARCHAR2(4000));
set echo on
BEGIN
INSERT INTO oc_sh_sample_settings VALUES
(dbms_data_mining.algo_name, dbms_data_mining.algo_ocluster);
INSERT INTO oc_sh_sample_settings VALUES
(dbms_data_mining.clus_num_clusters, 10);
INSERT INTO oc_sh_sample_settings VALUES
(dbms_data_mining.prep_auto, dbms_data_mining.prep_auto_on);
-- Other possible settings are:
-- (dbms_data_mining.oclt_sensitivity, 0.5);
END;
/
---------------------
-- CREATE A NEW MODEL
--
-- Build a new OC model
-- TO_CHAR function is used to transform columns to
-- categorical attributes since numeric datatypes
-- are treated as numeric attributes.
DECLARE
xformlist dbms_data_mining_transform.TRANSFORM_LIST;
BEGIN
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'AFFINITY_CARD', null, 'TO_CHAR(AFFINITY_CARD)', null);
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'BOOKKEEPING_APPLICATION', null, 'TO_CHAR(BOOKKEEPING_APPLICATION)', null);
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'BULK_PACK_DISKETTES', null, 'TO_CHAR(BULK_PACK_DISKETTES)', null);
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'FLAT_PANEL_MONITOR', null, 'TO_CHAR(FLAT_PANEL_MONITOR)', null);
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'HOME_THEATER_PACKAGE', null, 'TO_CHAR(HOME_THEATER_PACKAGE)', null);
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'OS_DOC_SET_KANJI', null, 'TO_CHAR(OS_DOC_SET_KANJI)', null);
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'PRINTER_SUPPLIES', null, 'TO_CHAR(PRINTER_SUPPLIES)', null);
dbms_data_mining_transform.SET_TRANSFORM(
xformlist, 'Y_BOX_GAMES', null, 'TO_CHAR(Y_BOX_GAMES)', null);
DBMS_DATA_MINING.CREATE_MODEL(
model_name => 'OC_SH_Clus_sample',
mining_function => dbms_data_mining.clustering,
data_table_name => 'mining_data_build_parallel_v',
case_id_column_name => 'cust_id',
settings_table_name => 'oc_sh_sample_settings',
xform_list => xformlist);
END;
/
-------------------------
-- DISPLAY MODEL SETTINGS
--
column setting_name format a30
column setting_value format a30
SELECT setting_name, setting_value
FROM user_mining_model_settings
WHERE model_name = 'OC_SH_CLUS_SAMPLE'
ORDER BY setting_name;
--------------------------
-- DISPLAY MODEL SIGNATURE
--
column attribute_name format a40
column attribute_type format a20
SELECT attribute_name, attribute_type
FROM user_mining_model_attributes
WHERE model_name = 'OC_SH_CLUS_SAMPLE'
ORDER BY attribute_name;
-------------------------
-- DISPLAY MODEL METADATA
--
column mining_function format a20
column algorithm format a20
SELECT mining_function, algorithm
FROM user_mining_models
WHERE model_name = 'OC_SH_CLUS_SAMPLE';
------------------------
-- DISPLAY MODEL DETAILS
--
-- Get a list of model views
col view_name format a30
col view_type format a50
SELECT view_name, view_type FROM user_mining_model_views
WHERE model_name='OC_SH_CLUS_SAMPLE'
ORDER BY view_name;
-- Binning information
column attribute_name format a20
column attribute_value format a20
column lower format 99999.999
column upper format 99999.999
select attribute_name, bin_id, lower_bin_boundary lower,
upper_bin_boundary upper, attribute_value
from DM$VBOC_SH_CLUS_sample WHERE attribute_name IN ('AGE', 'CUST_GENDER');
-- Cluster details are best seen in pieces - based on the kind of
-- associations and groupings that are needed to be observed.
--
-- CLUSTERS
-- For each cluster_id, provides the number of records in the cluster,
-- the parent cluster id, and the level in the hierarchy.
-- NOTE: Unlike K-means, O-Cluster does not return a value for the
-- dispersion associated with a cluster.
--
column pname format a20
SELECT cluster_id clu_id, record_count rec_cnt, parent, tree_level
FROM DM$VDOC_SH_CLUS_SAMPLE
ORDER BY cluster_id;
-- TAXONOMY
--
SELECT cluster_id, left_child_id, right_child_id
FROM DM$VDOC_SH_CLUS_SAMPLE
ORDER BY cluster_id;
-- SPLIT PREDICATES
-- For each cluster, the split predicate indicates the attribute
-- and the condition used to assign records to the cluster's children
-- during model build. It provides an important piece of information
-- on how the population within a cluster can be divided up into
-- two smaller clusters.
--
column attribute_name format a20
column attribute_subname format a20
column operator format a2
column val format a20
SELECT cluster_id, attribute_name, attribute_subname,
operator, splits.val
FROM DM$VDOC_SH_CLUS_SAMPLE a,
XMLTABLE( '/Element' passing a.value
columns
val varchar2(20) path '.') splits
where left_child_id is not NULL AND cluster_id < 5
ORDER BY cluster_id, val;
-- CENTROIDS FOR LEAF CLUSTERS
-- For cluster_id 1, this output lists all the attributes that
-- constitute the centroid, with the mean (for numericals) or
-- mode (for categoricals). Unlike K-Means, O-Cluster does not return
-- the variance for numeric attributes.
--
column mean format 9999999.999
column variance format 9999999.999
column attribute_value format a20
column mode_value format a20
SELECT cluster_id, attribute_name, attribute_subname, mean, variance,
mode_value
FROM DM$VAOC_SH_CLUS_SAMPLE
WHERE cluster_id = 1
ORDER BY attribute_name, attribute_subname;
-- HISTOGRAM FOR ATTRIBUTE OF A LEAF CLUSTER
-- For cluster 1, provide the histogram for the AGE attribute.
-- Histogram count is represented in frequency, rather than actual count.
column count format 9999.99
column bin_id format 9999999
column label format a20;
SELECT cluster_id, attribute_name, attribute_subname,
bin_id, label, count
FROM DM$VHOC_SH_CLUS_SAMPLE
WHERE cluster_id = 1 AND attribute_name = 'AGE'
ORDER BY bin_id;
-- RULES FOR LEAF CLUSTERS
-- See dmkmdemo.sql for explanation on output columns.
column numeric_value format 999999.999
column confidence format 999999.999
column rule_confidence format 999999.999
column support format 9999
column rule_support format 9999
SELECT distinct cluster_id, rule_support, rule_confidence
FROM DM$VROC_SH_CLUS_SAMPLE ORDER BY cluster_id;
-- RULE DETAILS FOR LEAF CLUSTERS
-- See dmkmdemo.sql for explanation on output columns.
SELECT cluster_id, attribute_name, attribute_subname, operator,
numeric_value, attribute_value, support, confidence
FROM DM$VROC_SH_CLUS_SAMPLE
WHERE cluster_id < 3
ORDER BY cluster_id, attribute_name, attribute_subname, operator,
numeric_value, attribute_value;
-----------------------------------------------------------------------
-- TEST THE MODEL
-----------------------------------------------------------------------
-- There is no specific set of testing parameters for Clustering.
-- Examination and analysis of clusters is the main method to prove
-- the efficacy of a clustering model.
--
-----------------------------------------------------------------------
-- APPLY THE MODEL
-----------------------------------------------------------------------
-- For a descriptive mining function like Clustering, "Scoring" involves
-- assigning the probability with which a given case belongs to a given
-- cluster.
-------------------------------------------------
-- SCORE NEW DATA USING SQL DATA MINING FUNCTIONS
--
------------------
-- BUSINESS CASE 1
-- List the clusters into which the customers in this
-- given dataset have been grouped.
--
SELECT CLUSTER_ID(oc_sh_clus_sample USING *) AS clus, COUNT(*) AS cnt
FROM mining_data_apply_v
GROUP BY CLUSTER_ID(oc_sh_clus_sample USING *)
ORDER BY cnt DESC;
-- See dmkmdemo.sql for more examples
------------------
-- BUSINESS CASE 2
-- Assign 5 customers to clusters, and provide explanations for the assingments.
--
set long 20000
set line 200
set pagesize 100
column cust_id format 999999999
SELECT cust_id,
cluster_details(oc_sh_clus_sample USING *) cluster_details
FROM mining_data_apply_v
WHERE cust_id <= 100005
ORDER BY cust_id;
|
IF EXISTS(SELECT * FROM sys.procedures WHERE NAME = 'B_ExchangeRate_history_process')
BEGIN
/****** Object: StoredProcedure [dbo].[B_ExchangeRate_history_process] Script Date: 10/12/2014 8:39:08 AM ******/
DROP PROCEDURE [dbo].[B_ExchangeRate_history_process]
END
GO
/****** Object: StoredProcedure [dbo].[B_ExchangeRate_history_process] Script Date: 10/12/2014 8:39:08 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <NAME>
-- Create date: 4-Jan-2015
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[B_ExchangeRate_history_process]
(
-- Add the parameters for the stored procedure here
@Currency nvarchar(3),
@Rate decimal(18,4),
@UserId int,
@Type int
)
AS
BEGIN
DECLARE @Action nvarchar(50)
DECLARE @OldRate decimal(18,4)
SET @Action = 'UNKNOWN'
SELECT @Action = CASE @Type
WHEN 1 THEN ('AddNew')
WHEN 2 THEN ('Modify')
WHEN 3 THEN ('Delete')
END
SELECT TOP 1 @OldRate = [Rate] FROM B_ExchangeRates WHERE Currency = @Currency
INSERT INTO [dbo].[B_ExchangeRates_History]
([Currency]
,[Rate]
,[Rate_New]
,[Actions]
,[CreatedDateTime]
,[CreatedBy])
VALUES
(@Currency
,@OldRate
,@Rate
,@Action
,GETDATE()
,@UserId)
Select 1
END
GO
|
CREATE TABLE fieldkit.archive_history (
id serial PRIMARY KEY,
archived timestamp NOT NULL DEFAULT now(),
old_device_id bytea NOT NULL,
new_device_id bytea NOT NULL
);
|
-- WL_SUMMONFB
UPDATE `char` c, `skill` s SET `c`.skill_point = `c`.skill_point + (`s`.lv - 2), `s`.lv = 2 WHERE `s`.id = 2222 AND `s`.lv > 2 AND `c`.char_id = `s`.char_id;
-- WL_SUMMONBL
UPDATE `char` c, `skill` s SET `c`.skill_point = `c`.skill_point + (`s`.lv - 2), `s`.lv = 2 WHERE `s`.id = 2223 AND `s`.lv > 2 AND `c`.char_id = `s`.char_id;
-- WL_SUMMONWB
UPDATE `char` c, `skill` s SET `c`.skill_point = `c`.skill_point + (`s`.lv - 2), `s`.lv = 2 WHERE `s`.id = 2224 AND `s`.lv > 2 AND `c`.char_id = `s`.char_id;
-- WL_SUMMONSTONE
UPDATE `char` c, `skill` s SET `c`.skill_point = `c`.skill_point + (`s`.lv - 2), `s`.lv = 2 WHERE `s`.id = 2229 AND `s`.lv > 2 AND `c`.char_id = `s`.char_id;
|
INSERT INTO burgers (burger_name) VALUES ('Cheeseburger');
INSERT INTO burgers (burger_name) VALUES ('Double bacon cheeseburger');
INSERT INTO burgers (burger_name) VALUES ('Lamb burger'); |
DELIMITER |
/* Création d'un utilisateur */
DROP PROCEDURE IF EXISTS addUser|
CREATE PROCEDURE addUser (
IN n VARCHAR(255),
IN m VARCHAR(255),
IN adr VARCHAR(255),
IN mdp VARCHAR(255),
IN isAdmin TINYINT(1),
INOUT id INT)
BEGIN
DECLARE existsAlready BOOLEAN;
START TRANSACTION;
IF EXISTS (SELECT * FROM utilisateur WHERE mail=m) THEN
/* get id of existing record with same mail */
SET id = (SELECT idutilisateur FROM utilisateur WHERE mail=m ORDER BY idutilisateur DESC LIMIT 1);
/* update record */
UPDATE utilisateur SET nom=n, mail=m, adresse=adr, mot_de_passe=mdp, admin=isAdmin WHERE idutilisateur=id;
ELSE
/* insert new user */
INSERT INTO utilisateur (nom, mail, adresse, mot_de_passe, admin) VALUES (n, m, adr, mdp, isAdmin);
/* get generated id */
SET id = (SELECT idutilisateur FROM utilisateur WHERE nom=n AND mail=m AND adresse=adr AND mot_de_passe=mdp AND admin=isAdmin ORDER BY idutilisateur DESC LIMIT 1);
END IF;
COMMIT;
END|
DROP PROCEDURE IF EXISTS editUser|
CREATE PROCEDURE editUser (
IN n VARCHAR(255),
IN m VARCHAR(255),
IN adr VARCHAR(255),
IN mdp VARCHAR(255),
IN isAdmin TINYINT(1),
IN id_ INT(11))
BEGIN
START TRANSACTION;
IF EXISTS (SELECT * FROM utilisateur WHERE idutilisateur=id_) THEN
UPDATE utilisateur SET nom=n, mail=m, adresse=adr, mot_de_passe=mdp, admin=isAdmin WHERE idutilisateur=id_;
END IF;
COMMIT;
END|
/* Récupération de l'ID d'un utilisateur */
DROP PROCEDURE IF EXISTS getUserId |
CREATE PROCEDURE getUserId (
IN m VARCHAR(255),
INOUT id INT)
BEGIN
/* get id of existing record with same mail */
SET id = (SELECT idutilisateur FROM utilisateur WHERE mail=m ORDER BY idutilisateur DESC LIMIT 1);
END|
/* Suppression d'un utilisateur */
DROP PROCEDURE IF EXISTS deleteUser|
CREATE PROCEDURE deleteUser (
IN id INT)
BEGIN
DECLARE existsAlready BOOLEAN;
START TRANSACTION;
IF EXISTS (SELECT * FROM utilisateur WHERE idutilisateur=id) THEN
/* get rid of user */
DELETE FROM utilisateur WHERE idutilisateur=id;
DELETE FROM achat WHERE id_utilisateur=id;
ELSE
/* throw error */
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'No user found for this id';
END IF;
COMMIT;
END|
/* Authentification d'un utilisateur */
DROP PROCEDURE IF EXISTS checkPassword|
CREATE PROCEDURE checkPassword (
IN mdp VARCHAR(255),
IN email VARCHAR(255),
INOUT ok BOOLEAN)
BEGIN
SET ok = (SELECT COUNT(*) FROM utilisateur WHERE mail=email AND mot_de_passe=mdp);
END|
DELIMITER ;
CALL addUser('<NAME>', '<EMAIL>', '2 rue de la source 54821 NULLPART', 'secret', 0, @id);
CALL addUser('<NAME>', '<EMAIL>', '4 impasse des muguets 15541 Champoux', 'ramos69', 0, @id);
CALL addUser('<NAME>', '<EMAIL>', '4bis rue du trefle 75421 Ferrache', 'chanceux77713', 0, @id);
CALL addUser('<NAME>', '<EMAIL>', '452 Hameaux des oliviers 22511 Cabords', 'rvb93', 0, @id);
CALL addUser('<NAME>', '<EMAIL>', '3 rue du tapis rouge 45121 Cannes', 'mimiche', 0, @id);
CALL addUser('admin', '<EMAIL>', '36 avenue guy de collongue 69130 Ecully', 'admin', 1, @id);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.