blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 3 276 | src_encoding stringclasses 33
values | length_bytes int64 23 9.61M | score float64 2.52 5.28 | int_score int64 3 5 | detected_licenses listlengths 0 44 | license_type stringclasses 2
values | text stringlengths 23 9.43M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
03db6d4d6747d3e44a9df8fc6e6ab54e69504e2c | SQL | jonamuen/sql-reduce | /test/sqlsmith/sqlite/3601.sql | UTF-8 | 514 | 3.015625 | 3 | [
"MIT"
] | permissive | select
subq_0.c1 as c0,
subq_0.c5 as c1,
subq_0.c3 as c2
from
(select
ref_0.name as c0,
ref_0.name as c1,
ref_0.name as c2,
ref_0.name as c3,
ref_0.id as c4,
ref_0.id as c5
from
main.t0 as ref_0
where 0
limit 111) as subq_0
where (((subq_0.c4 is not NULL)
and (subq_0.c0 is not NULL))
or ((subq_0.c3 is not NULL)
and ((subq_0.c3 is NULL)
and (0))))
and (subq_0.c1 is not NULL)
limit 135;
| true |
9b6ec8a770708e048d5e679a7e9f4d4e2561c074 | SQL | marianormuro/onto-wisbench | /wisonsin/benchmark/queries/join-on-simple.sql | UTF-8 | 3,342 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | -- JOIN condition ['unique1'] ----------------------
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1
WHERE t2.unique1 = 666;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1
WHERE t2.unique1 > 5000 AND t2.unique1 < 6000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1
WHERE t2.unique1 BETWEEN 5000 AND 6000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1
WHERE t2.unique1 > 20000 AND t2.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1
WHERE t2.unique1 BETWEEN 20000 AND 30000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1
WHERE t2.unique1 > 10000 AND t2.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1
WHERE t2.unique1 BETWEEN 10000 AND 30000;
-- JOIN condition ['unique1', 'unique2'] ----------------------
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1 AND t1.unique2 = t2.unique2
WHERE t2.unique1 = 666;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1 AND t1.unique2 = t2.unique2
WHERE t2.unique1 > 5000 AND t2.unique1 < 6000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1 AND t1.unique2 = t2.unique2
WHERE t2.unique1 BETWEEN 5000 AND 6000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1 AND t1.unique2 = t2.unique2
WHERE t2.unique1 > 20000 AND t2.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1 AND t1.unique2 = t2.unique2
WHERE t2.unique1 BETWEEN 20000 AND 30000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1 AND t1.unique2 = t2.unique2
WHERE t2.unique1 > 10000 AND t2.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.unique1 = t2.unique1 AND t1.unique2 = t2.unique2
WHERE t2.unique1 BETWEEN 10000 AND 30000;
-- JOIN condition ['stringu1'] ----------------------
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1
WHERE t2.unique1 = 666;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1
WHERE t2.unique1 > 5000 AND t2.unique1 < 6000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1
WHERE t2.unique1 BETWEEN 5000 AND 6000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1
WHERE t2.unique1 > 20000 AND t2.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1
WHERE t2.unique1 BETWEEN 20000 AND 30000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1
WHERE t2.unique1 > 10000 AND t1.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1
WHERE t2.unique1 BETWEEN 10000 AND 30000;
-- JOIN condition ['stringu1', 'stringu2'] ----------------------
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1 AND t1.stringu2 = t2.stringu2
WHERE t2.unique1 = 666;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1 AND t1.stringu2 = t2.stringu2
WHERE t2.unique1 > 5000 AND t2.unique1 < 6000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1 AND t1.stringu2 = t2.stringu2
WHERE t2.unique1 BETWEEN 5000 AND 6000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1 AND t1.stringu2 = t2.stringu2
WHERE t2.unique1 > 20000 AND t2.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1 AND t1.stringu2 = t2.stringu2
WHERE t2.unique1 BETWEEN 20000 AND 30000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1 AND t1.stringu2 = t2.stringu2
WHERE t2.unique1 > 10000 AND t2.unique1 < 30000;
SELECT * FROM t1 JOIN t2
ON t1.stringu1 = t2.stringu1 AND t1.stringu2 = t2.stringu2
WHERE t2.unique1 BETWEEN 10000 AND 30000;
| true |
11ab2c1ec89a58975f33687039cd46ea31b92e5a | SQL | radtek/abs3 | /sql/mmfo/bars/Table/nbur_dm_adl_doc_rpt_dtl_arch.sql | WINDOWS-1251 | 14,463 | 2.609375 | 3 | [] | no_license |
PROMPT =====================================================================================
PROMPT *** Run *** ========== Scripts /Sql/BARS/Table/NBUR_DM_ADL_DOC_RPT_DTL_ARCH.sql =====
PROMPT =====================================================================================
PROMPT *** ALTER_POLICY_INFO to NBUR_DM_ADL_DOC_RPT_DTL_ARCH ***
BEGIN
execute immediate
'begin
bpa.alter_policy_info(''NBUR_DM_ADL_DOC_RPT_DTL_ARCH'', ''CENTER'' , null, ''E'', ''E'', ''E'');
bpa.alter_policy_info(''NBUR_DM_ADL_DOC_RPT_DTL_ARCH'', ''FILIAL'' , ''M'', ''M'', ''E'', ''E'');
bpa.alter_policy_info(''NBUR_DM_ADL_DOC_RPT_DTL_ARCH'', ''WHOLE'' , null, null, null, null);
null;
end;
';
END;
/
PROMPT *** Create table NBUR_DM_ADL_DOC_RPT_DTL_ARCH ***
begin
execute immediate '
CREATE TABLE BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH
( REPORT_DATE DATE,
KF CHAR(6),
VERSION_ID NUMBER(38,0),
REF NUMBER(38,0),
D1#70 VARCHAR2(64),
D2#70 VARCHAR2(64),
D3#70 VARCHAR2(64),
D4#70 VARCHAR2(64),
D5#70 VARCHAR2(64),
D6#70 VARCHAR2(64),
D7#70 VARCHAR2(64),
D8#70 VARCHAR2(64),
D9#70 VARCHAR2(64),
DA#70 VARCHAR2(64),
DB#70 VARCHAR2(64),
DD#70 VARCHAR2(64),
D1#E2 VARCHAR2(64),
D6#E2 VARCHAR2(64),
D7#E2 VARCHAR2(64),
D8#E2 VARCHAR2(64),
D1#C9 VARCHAR2(64),
D6#C9 VARCHAR2(64),
DE#C9 VARCHAR2(64),
D1#D3 VARCHAR2(64),
D1#27 VARCHAR2(64),
D1#39 VARCHAR2(64),
D1#44 VARCHAR2(64),
D1#73 VARCHAR2(64),
D2#73 VARCHAR2(64),
D020 VARCHAR2(64),
BM__C VARCHAR2(64),
KURS VARCHAR2(64),
D1#2D VARCHAR2(64),
KOD_B VARCHAR2(64),
KOD_G VARCHAR2(64),
KOD_N VARCHAR2(64),
D1#E9 VARCHAR2(64),
D1#F1 VARCHAR2(64),
TRF_R VARCHAR2(64),
TRF_D VARCHAR2(64),
DOC_T VARCHAR2(64),
DOC_A VARCHAR2(64),
DOC_S VARCHAR2(64),
DOC_N VARCHAR2(64),
DOC_D VARCHAR2(64),
REZID VARCHAR2(64),
NATIO VARCHAR2(64),
OKPO VARCHAR2(64),
POKPO VARCHAR2(64),
OOKPO VARCHAR2(64)
) PCTFREE 0 PCTUSED 0 INITRANS 1 MAXTRANS 255
COMPRESS BASIC
TABLESPACE BRSBIGD
PARTITION BY RANGE (REPORT_DATE) INTERVAL (NUMTODSINTERVAL(1,''DAY''))
SUBPARTITION BY LIST (KF)
SUBPARTITION TEMPLATE (
SUBPARTITION SP_300465 VALUES ( ''300465'' ),
SUBPARTITION SP_302076 VALUES ( ''302076'' ),
SUBPARTITION SP_303398 VALUES ( ''303398'' ),
SUBPARTITION SP_304665 VALUES ( ''304665'' ),
SUBPARTITION SP_305482 VALUES ( ''305482'' ),
SUBPARTITION SP_311647 VALUES ( ''311647'' ),
SUBPARTITION SP_312356 VALUES ( ''312356'' ),
SUBPARTITION SP_313957 VALUES ( ''313957'' ),
SUBPARTITION SP_315784 VALUES ( ''315784'' ),
SUBPARTITION SP_322669 VALUES ( ''322669'' ),
SUBPARTITION SP_323475 VALUES ( ''323475'' ),
SUBPARTITION SP_324805 VALUES ( ''324805'' ),
SUBPARTITION SP_325796 VALUES ( ''325796'' ),
SUBPARTITION SP_326461 VALUES ( ''326461'' ),
SUBPARTITION SP_328845 VALUES ( ''328845'' ),
SUBPARTITION SP_331467 VALUES ( ''331467'' ),
SUBPARTITION SP_333368 VALUES ( ''333368'' ),
SUBPARTITION SP_335106 VALUES ( ''335106'' ),
SUBPARTITION SP_336503 VALUES ( ''336503'' ),
SUBPARTITION SP_337568 VALUES ( ''337568'' ),
SUBPARTITION SP_338545 VALUES ( ''338545'' ),
SUBPARTITION SP_351823 VALUES ( ''351823'' ),
SUBPARTITION SP_352457 VALUES ( ''352457'' ),
SUBPARTITION SP_353553 VALUES ( ''353553'' ),
SUBPARTITION SP_354507 VALUES ( ''354507'' ),
SUBPARTITION SP_356334 VALUES ( ''356334'' ) )
(PARTITION P_MINVALUE VALUES LESS THAN (TO_DATE('' 2016-01-01 00:00:00'', ''SYYYY-MM-DD HH24:MI:SS'', ''NLS_CALENDAR=GREGORIAN''))
PCTFREE 0 PCTUSED 0 INITRANS 1 MAXTRANS 255
TABLESPACE BRSBIGD
COMPRESS BASIC )
PARALLEL ';
exception when others then
if sqlcode=-955 then null; else raise; end if;
end;
/
PROMPT *** ALTER_POLICIES to NBUR_DM_ADL_DOC_RPT_DTL_ARCH ***
exec bpa.alter_policies('NBUR_DM_ADL_DOC_RPT_DTL_ARCH');
COMMENT ON TABLE BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D7#E2 IS '. #E2';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D8#E2 IS '. #E2';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#C9 IS '. #C9';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D6#C9 IS '. #C9';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DE#C9 IS '. #C9';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#D3 IS '. #D3';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#27 IS '. D#27 ( #27)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#39 IS '. D#39 ( #39)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#44 IS '. D#44 ( #44)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#73 IS '. D#73 ( #73)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D2#73 IS '. 73% ( #73)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D020 IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.BM__C IS '. ( )';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.KURS IS ' - ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#2D IS ' (#2D)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.KOD_B IS ' (1-) [BOPBANK.REGNUM]';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.KOD_G IS ' / (TAG="KOD_G","n") [BOPCOUNT.KODC]';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.KOD_N IS ' (1-) (TAG="KOD_N","N") [BOPCODE.TRANSCODE]';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#E9 IS ' / (KL_K040.K040)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#F1 IS '. ( #F1)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.TRF_R IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.TRF_D IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DOC_T IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DOC_A IS ', (issuing authority)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DOC_S IS 'i ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DOC_N IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DOC_D IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.REZID IS '/ (K030)';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.NATIO IS '';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.OKPO IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.POKPO IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.OOKPO IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.REPORT_DATE IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.KF IS ' ()';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.VERSION_ID IS 'Ii ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.REF IS ' ';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D2#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D3#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D4#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D5#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D6#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D7#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D8#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D9#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DA#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DB#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.DD#70 IS '. #70';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D1#E2 IS '. #E2';
COMMENT ON COLUMN BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH.D6#E2 IS '. #E2';
PROMPT *** Create constraint CC_DMADLDOCRPTDTLARCH_RPTDT_NN ***
begin
execute immediate '
ALTER TABLE BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH MODIFY (REPORT_DATE CONSTRAINT CC_DMADLDOCRPTDTLARCH_RPTDT_NN NOT NULL ENABLE)';
exception when others then
if sqlcode=-2260 or sqlcode=-2261 or sqlcode=-2264 or sqlcode=-2275 or sqlcode=-1442 then null; else raise; end if;
end;
/
PROMPT *** Create constraint CC_DMADLDOCRPTDTLARCH_KF_NN ***
begin
execute immediate '
ALTER TABLE BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH MODIFY (KF CONSTRAINT CC_DMADLDOCRPTDTLARCH_KF_NN NOT NULL ENABLE)';
exception when others then
if sqlcode=-2260 or sqlcode=-2261 or sqlcode=-2264 or sqlcode=-2275 or sqlcode=-1442 then null; else raise; end if;
end;
/
PROMPT *** Create constraint CC_DMADLDOCRPTDTLARCH_VRSN_NN ***
begin
execute immediate '
ALTER TABLE BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH MODIFY (VERSION_ID CONSTRAINT CC_DMADLDOCRPTDTLARCH_VRSN_NN NOT NULL ENABLE)';
exception when others then
if sqlcode=-2260 or sqlcode=-2261 or sqlcode=-2264 or sqlcode=-2275 or sqlcode=-1442 then null; else raise; end if;
end;
/
PROMPT *** Create constraint CC_DMADLDOCRPTDTLARCH_REF_NN ***
begin
execute immediate '
ALTER TABLE BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH MODIFY (REF CONSTRAINT CC_DMADLDOCRPTDTLARCH_REF_NN NOT NULL ENABLE)';
exception when others then
if sqlcode=-2260 or sqlcode=-2261 or sqlcode=-2264 or sqlcode=-2275 or sqlcode=-1442 then null; else raise; end if;
end;
/
PROMPT *** Create index UK_DMADLDOCRPTDTLARCH ***
begin
execute immediate '
CREATE UNIQUE INDEX BARS.UK_DMADLDOCRPTDTLARCH ON BARS.NBUR_DM_ADL_DOC_RPT_DTL_ARCH (REPORT_DATE, KF, VERSION_ID, REF)
PCTFREE 0 INITRANS 2 MAXTRANS 255
TABLESPACE BRSBIGI LOCAL
(PARTITION P_MINVALUE
PCTFREE 0 INITRANS 2 MAXTRANS 255
TABLESPACE BRSBIGI
( SUBPARTITION P_MINVALUE_SP_300465
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_302076
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_303398
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_304665
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_305482
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_311647
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_312356
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_313957
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_315784
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_322669
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_323475
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_324805
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_325796
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_326461
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_328845
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_331467
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_333368
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_335106
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_336503
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_337568
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_338545
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_351823
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_352457
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_353553
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_354507
TABLESPACE BRSBIGI ,
SUBPARTITION P_MINVALUE_SP_356334
TABLESPACE BRSBIGI ) ) COMPRESS 3 ';
exception when others then
if sqlcode=-955 then null; else raise; end if;
end;
/
PROMPT *** Create grants NBUR_DM_ADL_DOC_RPT_DTL_ARCH ***
grant SELECT on NBUR_DM_ADL_DOC_RPT_DTL_ARCH to BARSREADER_ROLE;
grant SELECT on NBUR_DM_ADL_DOC_RPT_DTL_ARCH to BARSUPL;
grant SELECT on NBUR_DM_ADL_DOC_RPT_DTL_ARCH to BARS_ACCESS_DEFROLE;
grant SELECT on NBUR_DM_ADL_DOC_RPT_DTL_ARCH to UPLD;
PROMPT =====================================================================================
PROMPT *** End *** ========== Scripts /Sql/BARS/Table/NBUR_DM_ADL_DOC_RPT_DTL_ARCH.sql =====
PROMPT =====================================================================================
| true |
686acda554c8dfd3a09cb7a6017303830ef9a6b0 | SQL | CUBRID/cubrid-testcases | /sql/_13_issues/_10_1h/cases/bug_442.sql | UTF-8 | 1,462 | 3.5625 | 4 | [
"BSD-3-Clause"
] | permissive | create table tbl_A (a int primary key, b int);
create table tbl_B (ba int primary key, a int);
alter table tbl_B add constraint tbl_B_fk
FOREIGN KEY(a) REFERENCES tbl_A(a) on delete no action on update no action;
insert into tbl_A values (1, 1);
insert into tbl_A values (2, 2);
insert into tbl_A values (3, 3);
insert into tbl_B values (1, 1);
insert into tbl_B values (2, 2);
insert into tbl_B values (3, 3);
delete from tbl_A where a=3;
DROP TABLE tbl_B;
DROP TABLE tbl_A;
create table tbl_A (a int primary key, b int);
create table tbl_C (ba int primary key, a int);
alter table tbl_C add constraint tbl_C_fk
FOREIGN KEY(a) REFERENCES tbl_A(a) on delete cascade;
insert into tbl_A values (1, 1);
insert into tbl_A values (2, 2);
insert into tbl_A values (3, 3);
insert into tbl_C values (1, 1);
insert into tbl_C values (2, 2);
insert into tbl_C values (3, 3);
delete from tbl_A where a=3;
select count(*) from tbl_A where a=3;
select count(*) from tbl_C where a=3;
DROP TABLE tbl_C;
DROP TABLE tbl_A;
create table tbl_A (a int primary key, b int);
create table tbl_D (ba int primary key, a int);
alter table tbl_D add constraint tbl_D_fk
FOREIGN KEY(a) REFERENCES tbl_A(a) on delete restrict;
insert into tbl_A values (1, 1);
insert into tbl_A values (2, 2);
insert into tbl_A values (3, 3);
insert into tbl_D values (1, 1);
insert into tbl_D values (2, 2);
insert into tbl_D values (3, 3);
delete from tbl_A where a=3;
DROP TABLE tbl_D;
DROP TABLE tbl_A; | true |
578ea46c0eaaf03001e96ec5f757f9644a45347f | SQL | i1i1/DMD_TDP | /src/queries/3.sql | UTF-8 | 537 | 4.34375 | 4 | [] | no_license | WITH Recent_appointment AS(
SELECT client_id, CAST(DATE_PART('day', appointment_date) - 1 AS int) / 7 AS week_num
FROM Appointment
WHERE DATE_PART('month',appointment_date) = DATE_PART('month',CURRENT_DATE - interval '1 month')),
Appointment_each_week AS(
SELECT client_id, week_num, count(Recent_appointment)
FROM Recent_appointment
GROUP BY client_id, week_num
HAVING COUNT(Recent_appointment) >= 2)
SELECT Client.name
FROM Appointment_each_week JOIN Client ON client_id = Client.id
GROUP BY Client.name
HAVING COUNT(Client.id) >= 4; | true |
934648774ae32160e2769f7e2e74d6c5d48c79a7 | SQL | bodiapz/cland | /db/clandestine_002.sql | UTF-8 | 1,730 | 3.40625 | 3 | [] | no_license | --
-- Database: `clandestine`
--
USE `clandestine`;
--
-- Drop statement for table `resources`, `roles`, `role_resources`
--
DROP TABLE resources;
DROP TABLE roles;
DROP TABLE role_resources;
--
-- Alter statement for table `packages`
--
ALTER TABLE `packages` DROP `user_id` ;
ALTER TABLE `packages` CHANGE `description` `description` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `name` ;
ALTER TABLE `packages` CHANGE `term` `term` INT( 11 ) NULL DEFAULT '0' AFTER `cost` ;
ALTER TABLE `packages` DROP `status` ;
ALTER TABLE `packages` ADD `disabled` TINYINT NULL ;
ALTER TABLE `payments` ADD `package_id` INT NOT NULL AFTER `id` ,
ADD INDEX ( `package_id` ) ;
--
-- Alter statement for table `payments`
--
ALTER TABLE `payments` CHANGE `user_id` `user_id` INT( 11 ) NULL DEFAULT NULL AFTER `package_id` ;
ALTER TABLE `payments` ADD INDEX ( `user_id` ) ;
ALTER TABLE `payments` CHANGE `user_id` `user_id` INT( 11 ) NOT NULL ;
ALTER TABLE `payments` CHANGE `method` `method` ENUM( 'bc', 'other' ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT 'bc' AFTER `amount` ;
ALTER TABLE `payments` CHANGE `status` `status` ENUM( 'received', 'pending' ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT 'pending' AFTER `method` ;
ALTER TABLE `payments` CHANGE `description` `description` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `status` ;
ALTER TABLE `payments` CHANGE `created_at` `created_at` DATETIME NULL DEFAULT NULL AFTER `next_due_date` ;
ALTER TABLE `payments` CHANGE `updated_at` `updated_at` DATETIME NULL DEFAULT NULL AFTER `created_at` ;
ALTER TABLE `payments` CHANGE `created_at` `created_at` DATETIME NOT NULL ; | true |
d072d071c891542ca595de1b4fc95f262a1da8cd | SQL | ewatryniszewska/Przychodnia-Leczewo | /sql/przychodnia_dev.sql | UTF-8 | 6,673 | 3.015625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Czas generowania: 17 Gru 2020, 02:16
-- Wersja serwera: 10.4.17-MariaDB
-- Wersja PHP: 8.0.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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 */;
--
-- Baza danych: `przychodnia`
--
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `admin`
--
CREATE TABLE `admin` (
`id` int(11) NOT NULL,
`email` varchar(255) COLLATE utf8_polish_ci NOT NULL,
`haslo` varchar(50) COLLATE utf8_polish_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `admin`
--
INSERT INTO `admin` (`id`, `email`, `haslo`) VALUES
(1, 'admin@leczewo.pl', '11111111');
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `lekarz`
--
CREATE TABLE `lekarz` (
`id` int(11) NOT NULL,
`imie` text COLLATE utf8_polish_ci NOT NULL,
`nazwisko` text COLLATE utf8_polish_ci NOT NULL,
`specjalizacja` text COLLATE utf8_polish_ci NOT NULL,
`telefon` int(11) NOT NULL,
`nr_gabinetu` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `lekarz`
--
INSERT INTO `lekarz` (`id`, `imie`, `nazwisko`, `specjalizacja`, `telefon`, `nr_gabinetu`) VALUES
(8, 'Poncjusz', 'Piłat', 'dentysta', 800500507, 7),
(9, 'Bartosz', 'Mocny', 'laryngolog', 800500508, 8),
(10, 'Alicja', 'Nowak', 'endokrynolog', 800500503, 3),
(11, 'Marta', 'Kora', 'laryngolog', 800500505, 5),
(12, 'Bianka', 'Kora', 'dentysta', 800500519, 19),
(13, 'Wojciech', 'Ulatowicz', 'dentysta', 800500502, 2),
(14, 'Marzena', 'Wypasik', 'endokrynolog', 800500506, 6);
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `pacjent`
--
CREATE TABLE `pacjent` (
`id` int(11) NOT NULL,
`imie` text COLLATE utf8_polish_ci NOT NULL,
`nazwisko` text COLLATE utf8_polish_ci NOT NULL,
`data_urodzenia` date NOT NULL,
`pesel` bigint(11) NOT NULL,
`miasto` text COLLATE utf8_polish_ci NOT NULL,
`adres` varchar(50) COLLATE utf8_polish_ci NOT NULL,
`haslo` varchar(50) COLLATE utf8_polish_ci NOT NULL,
`email` varchar(255) COLLATE utf8_polish_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `pacjent`
--
INSERT INTO `pacjent` (`id`, `imie`, `nazwisko`, `data_urodzenia`, `pesel`, `miasto`, `adres`, `haslo`, `email`) VALUES
(23, 'Bartłomiej', 'Nieziemski', '1991-07-25', 91072503545, 'Gdańsk', 'Michałówka 11', '11111111', 'bnieziemski@gmail.com'),
(24, 'Łukasz', 'Panda', '1975-09-22', 75092245789, 'Warszawa', 'Warszawska 12b/15', '11111111', 'pandalukasz@wp.pl'),
(25, 'Anna', 'Wesołowska', '1994-08-05', 94080512589, 'Łódź', 'Miłosierna 15', '11111111', 'awesolowska@interia.pl'),
(26, 'Bogumiła', 'Wariot', '1969-07-06', 69070612478, 'Mikołajewo', 'Wielka 14/9', '11111111', 'wariot@gmail.com');
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `rejestracja`
--
CREATE TABLE `rejestracja` (
`id` int(11) NOT NULL,
`id_pacjenta` int(11) DEFAULT NULL,
`specjalizacja` text CHARACTER SET utf8 COLLATE utf8_polish_ci DEFAULT NULL,
`dolegliwosci` text CHARACTER SET utf8 COLLATE utf8_polish_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=ucs2 COLLATE=ucs2_polish_ci;
--
-- Zrzut danych tabeli `rejestracja`
--
INSERT INTO `rejestracja` (`id`, `id_pacjenta`, `specjalizacja`, `dolegliwosci`) VALUES
(9, 24, 'dentysta', 'zielone zęby'),
(10, 24, 'endokrynolog', 'badanie kontrolne'),
(11, 25, 'laryngolog', 'ból uszu'),
(12, 26, 'laryngolog', 'przytępiony słuch'),
(13, 26, 'dentysta', 'ból, straszny ból'),
(14, 26, 'endokrynolog', 'boli');
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `wizyta`
--
CREATE TABLE `wizyta` (
`id` int(11) NOT NULL,
`id_pacjenta` int(11) DEFAULT NULL,
`id_lekarza` int(11) DEFAULT NULL,
`data_wizyty` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `wizyta`
--
INSERT INTO `wizyta` (`id`, `id_pacjenta`, `id_lekarza`, `data_wizyty`) VALUES
(18, 25, 12, '2020-08-13 11:15:00'),
(19, 25, 10, '2020-05-01 17:30:00'),
(20, 24, 11, '2019-06-28 09:00:00'),
(21, 26, 11, '2020-12-17 02:00:00'),
(23, 24, 14, '2021-01-01 17:30:00'),
(24, 26, 8, '2021-01-10 20:00:00'),
(25, 24, 8, '2020-12-03 10:15:00');
--
-- Indeksy dla zrzutów tabel
--
--
-- Indeksy dla tabeli `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`);
--
-- Indeksy dla tabeli `lekarz`
--
ALTER TABLE `lekarz`
ADD PRIMARY KEY (`id`);
--
-- Indeksy dla tabeli `pacjent`
--
ALTER TABLE `pacjent`
ADD PRIMARY KEY (`id`);
--
-- Indeksy dla tabeli `rejestracja`
--
ALTER TABLE `rejestracja`
ADD PRIMARY KEY (`id`),
ADD KEY `id_pacjenta` (`id_pacjenta`);
--
-- Indeksy dla tabeli `wizyta`
--
ALTER TABLE `wizyta`
ADD PRIMARY KEY (`id`),
ADD KEY `id_pacjenta` (`id_pacjenta`),
ADD KEY `id_lekarza` (`id_lekarza`);
--
-- AUTO_INCREMENT dla zrzuconych tabel
--
--
-- AUTO_INCREMENT dla tabeli `admin`
--
ALTER TABLE `admin`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT dla tabeli `lekarz`
--
ALTER TABLE `lekarz`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT dla tabeli `pacjent`
--
ALTER TABLE `pacjent`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
--
-- AUTO_INCREMENT dla tabeli `rejestracja`
--
ALTER TABLE `rejestracja`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT dla tabeli `wizyta`
--
ALTER TABLE `wizyta`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
--
-- Ograniczenia dla zrzutów tabel
--
--
-- Ograniczenia dla tabeli `rejestracja`
--
ALTER TABLE `rejestracja`
ADD CONSTRAINT `rejestracja_ibfk_1` FOREIGN KEY (`id_pacjenta`) REFERENCES `pacjent` (`id`) ON DELETE CASCADE;
--
-- Ograniczenia dla tabeli `wizyta`
--
ALTER TABLE `wizyta`
ADD CONSTRAINT `wizyta_ibfk_1` FOREIGN KEY (`id_pacjenta`) REFERENCES `pacjent` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `wizyta_ibfk_2` FOREIGN KEY (`id_lekarza`) REFERENCES `lekarz` (`id`) ON DELETE CASCADE;
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 */;
| true |
d459fad377cd605c0d49e0ed0457f92ab8d04b60 | SQL | ashleyhayjin/employeeTracker | /seed.sql | UTF-8 | 962 | 2.921875 | 3 | [] | no_license | USE employees_db;
INSERT INTO department (name)
VALUES ("HR");
INSERT INTO department (name)
VALUES ("Finance");
INSERT INTO department (name)
VALUES ("FrontEnd");
INSERT INTO department (name)
VALUES ("BackEnd");
INSERT INTO role (title, salary, department_id)
VALUES ("Finance Analyst", 85000, 1);
INSERT INTO role (title, salary, department_id)
VALUES ("HR Rep", 55000, 2);
INSERT INTO role (title, salary, department_id)
VALUES ("Front Developer", 105000, 3);
INSERT INTO role (title, salary, department_id)
VALUES ("Back End Developer", 125000, 4);
INSERT INTO employee (first_name, last_name, role_id, manager_id)
VALUES ("Ashley", "Lee", 4, 1);
INSERT INTO employee (first_name, last_name, role_id, manager_id)
VALUES ("Michael", "Ju", 3, 2);
INSERT INTO employee (first_name, last_name, role_id, manager_id)
VALUES ("Jessica", "Robertson", 2, 3);
INSERT INTO employee (first_name, last_name, role_id, manager_id)
VALUES ("Melissa", "Velasquez", 3, 1); | true |
e7fdd92ca5cf92a25d067ef5b2f3e3d5dfc41bf3 | SQL | poncheska/golang-examples | /databases/postgres/test-init.sql | UTF-8 | 572 | 2.625 | 3 | [] | no_license | INSERT INTO School(id, name) VALUES (0, 'Alfea'), (1, 'Hogwarts'), (2, 'New School'), (3,'Old School');
INSERT INTO Job(id, name) VALUES (0, 'Programmer'), (1, 'Cybersportsman'),
(2, 'Gym instructor'), (3, 'Gangster');
INSERT INTO Person(id, name, school_id) VALUES (0, 'Bob', 3), (1, 'Harry', 1), (2, 'Bloom', 0),
(3, 'Bib', 2), (4, 'Hardbass', 3), (5, 'Justin', 2), (6, 'Ivan', 1);
INSERT INTO JobLink(person_id, job_id) VALUES (0, 1), (0, 2), (0, 3), (1, 3), (2, 0), (2, 1),
(2, 2), (2, 3), (3, 2), (3, 3), (4, 0), (4, 1), (4, 3), (5, 0), (5, 2), (5, 3); | true |
8a9614f50dba8d75bac85b7e95b65ff407ecd118 | SQL | suyin12/jh-framword | /thinkphpSys/tpsys/thinkphpcms/thinkphpcms.sql | UTF-8 | 6,837 | 2.90625 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : 本地
Source Server Version : 50516
Source Host : localhost:3306
Source Database : thinkphpcms
Target Server Type : MYSQL
Target Server Version : 50516
File Encoding : 65001
Date: 2016-09-22 16:53:49
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `tpcms_admininfo`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_admininfo`;
CREATE TABLE `tpcms_admininfo` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_userName` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_password` varchar(50) COLLATE utf8_bin NOT NULL,
`tpcms_tel` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_qq` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_email` varchar(50) COLLATE utf8_bin NOT NULL,
`tpcms_createTime` datetime DEFAULT NULL,
`tpcms_status` int(5) NOT NULL,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_admininfo
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_login`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_login`;
CREATE TABLE `tpcms_login` (
`userName` varchar(20) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_login
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_menberinfo`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_menberinfo`;
CREATE TABLE `tpcms_menberinfo` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_name` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_password` varchar(50) COLLATE utf8_bin NOT NULL,
`tpcms_question` varchar(50) COLLATE utf8_bin NOT NULL,
`tpcms_answer` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_pID` varchar(30) COLLATE utf8_bin NOT NULL,
`tpcms_tel` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_qq` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_email` varchar(50) COLLATE utf8_bin NOT NULL,
`tpcms_address` varchar(200) COLLATE utf8_bin DEFAULT NULL,
`tpcms_money` float DEFAULT NULL,
`tpcms_blance` float DEFAULT NULL,
`tpcms_createTime` datetime DEFAULT NULL,
`tpcms_status` int(5) DEFAULT NULL,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_menberinfo
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_newsinfo`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_newsinfo`;
CREATE TABLE `tpcms_newsinfo` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_PID` int(10) NOT NULL,
`tpcms_title` varchar(200) COLLATE utf8_bin DEFAULT NULL,
`tpcms_intro` text COLLATE utf8_bin,
`tpcms_contents` text COLLATE utf8_bin,
`tpcms_hits` int(10) DEFAULT NULL,
`tpcms_createTime` datetime DEFAULT NULL,
`tpcms_status` int(5) DEFAULT NULL,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_newsinfo
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_newstype`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_newstype`;
CREATE TABLE `tpcms_newstype` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_parentID` int(10) NOT NULL,
`tpcms_name` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_intro` text COLLATE utf8_bin,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_newstype
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_orderinfo`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_orderinfo`;
CREATE TABLE `tpcms_orderinfo` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_num` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`tpcms_name` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`tpcms_nums` int(10) DEFAULT NULL,
`tpcms_money` float DEFAULT NULL,
`tpcms_taker` varchar(100) COLLATE utf8_bin DEFAULT NULL,
`tpcms_address` varchar(300) COLLATE utf8_bin DEFAULT NULL,
`tpcms_tel` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`tpcms_paymethod` int(5) DEFAULT NULL,
`tpcms_createTime` datetime DEFAULT NULL,
`tpcms_status` int(5) DEFAULT NULL,
`tpcms_remark` text COLLATE utf8_bin,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_orderinfo
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_orderproduct`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_orderproduct`;
CREATE TABLE `tpcms_orderproduct` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_num` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`tpcms_PID` int(11) DEFAULT NULL,
`tpcms_unitPrice` float DEFAULT NULL,
`tpcms_nums` int(11) DEFAULT NULL,
`tpcms_flod` float DEFAULT NULL,
`tpcms_price` float DEFAULT NULL,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_orderproduct
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_productinfo`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_productinfo`;
CREATE TABLE `tpcms_productinfo` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_PID` int(10) NOT NULL,
`tpcms_name` varchar(100) COLLATE utf8_bin NOT NULL,
`tpcms_model` varchar(300) COLLATE utf8_bin NOT NULL,
`tpcms_image` varchar(300) COLLATE utf8_bin NOT NULL,
`tpcms_intro` text COLLATE utf8_bin NOT NULL,
`tpcms_brand` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`tpcms_mPrice` float DEFAULT NULL,
`tpcms_vPrice` float DEFAULT NULL,
`tpcms_sellNum` int(20) DEFAULT NULL,
`tpcms_storeNum` int(20) DEFAULT NULL,
`tpcms_hist` int(11) DEFAULT NULL,
`tpcms_createTime` datetime DEFAULT NULL,
`tpcms_status` int(5) DEFAULT NULL,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_productinfo
-- ----------------------------
-- ----------------------------
-- Table structure for `tpcms_producttype`
-- ----------------------------
DROP TABLE IF EXISTS `tpcms_producttype`;
CREATE TABLE `tpcms_producttype` (
`tpcms_ID` int(10) NOT NULL AUTO_INCREMENT,
`tpcms_parentID` int(10) NOT NULL,
`tpcms_name` varchar(20) COLLATE utf8_bin NOT NULL,
`tpcms_intro` text COLLATE utf8_bin,
PRIMARY KEY (`tpcms_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tpcms_producttype
-- ----------------------------
| true |
7cc27e69ceec4c0b993a1c8c49913eecd2aa10dc | SQL | CUBRID/cubrid-testcases | /sql/_22_news_service_mysql_compatibility/_01_function_supporting/_01_addtime/cases/addtime_021.sql | UTF-8 | 1,552 | 3.25 | 3 | [
"BSD-3-Clause"
] | permissive | --TEST: exceptional cases whenuseing function as an argument
--TEST: argument of string type
select addtime(time_format('10:17:66', '%H:%i:%s'), time'23:59:59');
select addtime(to_char(datetime'1111-10-55 12:23:22.111'), time'23:59:59');
--TEST: argument of time type
select addtime(adddate(date'20/12/2010', 20), time'23:59:59');
select addtime(subdate(date'04/45/2010', 20), null, time'23:59:59');
select addtime(add_months(date'04/12/20105', -6), time'23:59:59');
select addtime(date('2001-10-188 10:14:25'), time'23:59:59');
select addtime(last_day('1898-15-06'), 100, time'23:59:59');
select addtime(str_to_date('a,b,c', '%m,%d,%y'), time'23:59:59');
select addtime(to_date(2000), time'23:59:59');
--TEST: argument of timestamp type
select addtime(to_timestamp('19:39:45 BM 12/12/2012'), time'23:59:59');
select addtime(to_timestamp('19:39:45 BM 12/12/2012'), least(to_date('2010-10-10'), '222222'), time'23:59:59');
--TEST: argument of datetime type
select addtime(timestamp('2010-10-28', 'abcabcabc'), time'23:59:59');
select addtime(to_datetime(123456), ifnull(null, null), time'23:59:59');
--TEST: server side
create table too(str1 int, str2 string);
insert into too values(1234, 'aabbcc');
select addtime(to_char(to_timestamp(str1)), time'23:59:59') from too;
select addtime(to_datetime(str1), time'23:59:59') from too;
select addtime(to_timestamp(str1), time'23:59:59') from too;
select addtime(to_time(str2), time'23:59:59') from too;
select addtime(time_format(str2, '%H:%i:%s'), time'23:59:59') from too;
drop table too;
| true |
69441fb1a42eaad9198fa5f1efeb6f7d24ce7e77 | SQL | saturnkr/tezis_Directory | /modules/core/build/db/30-thesis/update/postgres/13/130801-1300-updateChiefConstraints.sql | UTF-8 | 1,083 | 3.203125 | 3 | [] | no_license | --$Id: 130801-1300-updateChiefConstraints.sql 11856 2013-09-17 08:02:33Z kalashnikov $
--$Description: updates constraints for department chiefs to allow see own cards even the do not have a department
update SEC_CONSTRAINT
set WHERE_CLAUSE = '{E}.id = acl.card.id and (acl.department.id in (:session$departmentIds) or acl.user.id = :session$userId)'
where ENTITY_NAME = 'tm$Task'
and GROUP_ID in ('8d9ba07c-9ffa-11e1-b99d-8fc5b41c7fbb', '9fa89a54-9ffa-11e1-b13e-9f4a54bff17e')
and JOIN_CLAUSE = ', ts$CardAcl acl'
;
update SEC_CONSTRAINT
set WHERE_CLAUSE = '{E}.id = acl.card.id and (acl.user.id = :session$userId or acl.department.id in (:session$departmentIds) or acl.global = true or {E}.department.id in (:session$departmentIds))'
where ENTITY_NAME in ('df$Doc', 'df$SimpleDoc', 'df$Contract')
and GROUP_ID in ('8d9ba07c-9ffa-11e1-b99d-8fc5b41c7fbb', '9fa89a54-9ffa-11e1-b13e-9f4a54bff17e')
and JOIN_CLAUSE = ', ts$CardAcl acl'
and WHERE_CLAUSE = '{E}.id = acl.card.id and (acl.user.id in (:session$departmentMembersIds) or acl.global = true)'
;
| true |
f51cfc6b13ffff375fc883b049a9dbb1d30376bf | SQL | iagosilvamelo/material_curso_tecnico | /Info 6 (Java 2)/Dump20160511/escola_professor.sql | UTF-8 | 2,368 | 2.828125 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS `escola` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `escola`;
-- MySQL dump 10.13 Distrib 5.6.11, for Win64 (x86_64)
--
-- Host: localhost Database: escola
-- ------------------------------------------------------
-- Server version 5.6.11-log
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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 */;
--
-- Table structure for table `professor`
--
DROP TABLE IF EXISTS `professor`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `professor` (
`codprofessor` int(10) NOT NULL DEFAULT '0',
`nomprofessor` varchar(60) NOT NULL DEFAULT '',
PRIMARY KEY (`codprofessor`),
KEY `nomprofessor` (`nomprofessor`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='mantém informações do professor';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `professor`
--
LOCK TABLES `professor` WRITE;
/*!40000 ALTER TABLE `professor` DISABLE KEYS */;
INSERT INTO `professor` VALUES (12,'jonatan'),(2,'Mauricio'),(3,'Daniele'),(4,'Joao'),(5,'Mauricio'),(6,'Ricardo'),(9,'professor9'),(10,'Deivis Masters'),(11,'Rafael Camargo'),(15,'jonatan'),(21,'Victor'),(13,'jonatan'),(22,'Sandro1'),(23,'Sandro2'),(666,'teste');
/*!40000 ALTER TABLE `professor` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2016-05-11 19:50:50
| true |
037a746e121076bd6add806df51a844393aa5e77 | SQL | HAHARURU/springboot | /springboot.sql | UTF-8 | 4,233 | 3.34375 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : haru
Source Server Version : 50717
Source Host : localhost:3306
Source Database : springboot
Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2018-07-30 14:21:38
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for base_entity
-- ----------------------------
DROP TABLE IF EXISTS `base_entity`;
CREATE TABLE `base_entity` (
`dtype` varchar(31) NOT NULL,
`id` varchar(255) NOT NULL,
`create_time` datetime DEFAULT NULL,
`valid` bit(1) DEFAULT NULL,
`version` int(11) NOT NULL,
`code` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`state` int(11) DEFAULT NULL,
`city_name` varchar(255) DEFAULT NULL,
`country` tinyblob,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of base_entity
-- ----------------------------
INSERT INTO `base_entity` VALUES ('Country', '4a937e7c-c988-4b23-94c0-0cac9df568b3', '2018-07-17 15:17:58', '', '0', 'UK', '英国', '0', null, null, null);
-- ----------------------------
-- Table structure for city
-- ----------------------------
DROP TABLE IF EXISTS `city`;
CREATE TABLE `city` (
`id` varchar(40) NOT NULL COMMENT '城市id',
`country_id` varchar(40) DEFAULT NULL COMMENT '国家',
`city_name` varchar(25) DEFAULT NULL COMMENT '城市名称',
`description` varchar(25) DEFAULT NULL COMMENT '描述',
`create_time` datetime DEFAULT NULL,
`valid` bit(1) NOT NULL,
`version` int(11) NOT NULL,
`country` tinyblob,
PRIMARY KEY (`id`),
KEY `FK_COUNTRY` (`country_id`),
CONSTRAINT `FK_COUNTRY` FOREIGN KEY (`country_id`) REFERENCES `country` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of city
-- ----------------------------
INSERT INTO `city` VALUES ('38afeba0-9fbb-45fa-be7d-51c810593a1b', '38afeba0-9fbb-45fa-be7d-51c810593a1a', '上海', '谁知道', '2018-07-11 17:46:10', '', '1', null);
INSERT INTO `city` VALUES ('42e5bebb-5c2e-430a-890e-9a6944797bec', '4299902d-ceb1-4f1d-820a-a6df2f3c8c1c', '东京', 'otaku', '2018-07-12 16:51:14', '', '1', null);
INSERT INTO `city` VALUES ('e0527c9b-7c0f-4ce0-b052-600769a087b0', '4a937e7c-c988-4b23-94c0-0cac9df568b2', '华盛顿', null, '2018-07-12 17:45:36', '', '1', null);
INSERT INTO `city` VALUES ('ffad506d-c82b-4b2d-9c45-7ab357496dde', '4a937e7c-c988-4b23-94c0-0cac9df568b2', '纽约', 'NY', '2018-07-12 17:45:36', '', '1', null);
-- ----------------------------
-- Table structure for country
-- ----------------------------
DROP TABLE IF EXISTS `country`;
CREATE TABLE `country` (
`id` varchar(40) NOT NULL,
`name` varchar(20) DEFAULT NULL,
`code` varchar(20) DEFAULT NULL,
`create_time` datetime DEFAULT NULL,
`valid` bit(1) NOT NULL,
`state` varchar(20) DEFAULT NULL,
`version` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of country
-- ----------------------------
INSERT INTO `country` VALUES ('364b4734-6b7c-49dc-9b8a-e8a82ba0a8bf', '英国', 'UK', '2018-07-17 16:45:41', '', '启用', '0');
INSERT INTO `country` VALUES ('38afeba0-9fbb-45fa-be7d-51c810593a1a', '中华', 'CN', '2018-07-16 14:17:58', '', '启用', '3');
INSERT INTO `country` VALUES ('4299902d-ceb1-4f1d-820a-a6df2f3c8c1c', '日本', 'JP', '2018-07-12 16:51:05', '', '启用', '0');
INSERT INTO `country` VALUES ('4a937e7c-c988-4b23-94c0-0cac9df568b2', '美国', 'USA', '2018-07-16 14:17:58', '\0', '启用', '3');
INSERT INTO `country` VALUES ('4a937e7c-c988-4b23-94c0-0cac9df568b3', '德国', 'GM', '2018-07-17 15:17:58', '', '启用', '0');
-- ----------------------------
-- Table structure for visitor
-- ----------------------------
DROP TABLE IF EXISTS `visitor`;
CREATE TABLE `visitor` (
`id` varchar(40) NOT NULL COMMENT '城市id',
`create_time` datetime DEFAULT NULL,
`valid` bit(1) NOT NULL,
`version` int(11) NOT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of visitor
-- ----------------------------
| true |
3bd46de2b53ec0dc77953fb83766a91eb19e0694 | SQL | DeviantBadge/ComputationalGraph | /src/main/resources/test.sql | UTF-8 | 6,747 | 3.46875 | 3 | [] | no_license | --odps sql
--********************************************************************--
--author:孟森
--create time:2019-05-15 16:29:17
--********************************************************************--
CREATE TABLE IF NOT EXISTS ae_ru_merchant_center_report
(
id BIGINT COMMENT 'unique report line ID',
gmt_create BIGINT COMMENT 'create timestamp, unixtime',
gmt_modified BIGINT COMMENT 'update timestamp, unixtime',
document_date BIGINT COMMENT 'report generation date',
seller_account_id STRING COMMENT 'seller account id',
seller_admin_seq BIGINT COMMENT 'seller admin seq',
order_id BIGINT COMMENT 'parent order id',
product_id BIGINT COMMENT 'item id',
product_name STRING COMMENT 'item name (English)',
barcode STRING COMMENT 'barcode',
quantity BIGINT COMMENT 'items bought quantity',
totally_paid BIGINT COMMENT 'money amount in rub x100',
discount BIGINT COMMENT 'money amount in rub x100',
refund BIGINT COMMENT 'money amount in rub x100',
paid_for_product BIGINT COMMENT 'money amount in rub x100',
paid_for_delivery BIGINT COMMENT 'money amount in rub x100',
totally_receive BIGINT COMMENT 'money amount in rub x100',
commission_rate_product DECIMAL COMMENT 'commission rate [0.0, 1.0]',
commission_rate_delivery DECIMAL COMMENT 'commission rate [0.0, 1.0]',
commission BIGINT COMMENT 'money amount in rub x100'
)
COMMENT 'ae_ru_merchant_center_report'
PARTITIONED BY (report_month BIGINT COMMENT 'reporting period: yyyymm') LIFECYCLE 366;
-- Report https://yuque.antfin-inc.com/hrgg9e/wt9glq/qmszkl#Report
INSERT OVERWRITE TABLE ae_ru_merchant_center_report PARTITION (report_month)
SELECT /*+ mapjoin(s) */
c.order_id as id,
unix_timestamp(getdate()) as gmt_create,
unix_timestamp(getdate()) as gmt_modified,
cast('${sysdate}' as bigint) as document_date,
c.seller_admin_id as seller_account_id,
c.seller_admin_seq as seller_admin_seq,
c.parent_order_id as order_id,
c.item_id as product_id,
c.item_name as product_name,
d.bar_code as barcode,
c.unit_num as quantity,
a.gmv_amt + d.discount_fee + (d.pay_amt_itm - gmv_amt) as totally_paid,
d.discount_fee as discount,
case when c.refund_create_time is not null and c.is_send_goods = 'Y' then d.pay_amt_itm - gmv_amt end as refund,
a.gmv_amt as paid_for_product,
d.pay_amt_logis as paid_for_delivery,
a.gmv_amt + d.pay_amt_logis as totally_receive,
round(d.orderfeerate, 6) as commission_rate_product,
round(d.logisticsfeerate, 6) as commission_rate_delivery,
a.escrow_fee_amt as commission,
cast(substr(a.fin_date, 1, 6) as bigint) as report_month
FROM (
select ds,
order_id,
fin_date,
gmv_amt,
gmv_amt_usd,
escrow_fee_amt,
seller_aliid
from aebi.adm_ae_fin_trans_df
where substr(fin_date, 1, 6) =
to_char(dateadd(datetrunc(to_date('${sysdate}', 'yyyymmdd'), 'month'), -1, 'dd'), 'yyyymm')
and ds = '${sysdate}'
and trans_type = 'Gaap'
and trd_end_reason not in
('buyer_cancel_order_in_risk', 'cancel_order_close_trade', 'seller_send_goods_timeout')
) a
inner join
ae_seller_center.ae_merchant_seller_relation b
on a.seller_aliid = b.seller_id and b.ds = a.ds
inner join (
-- all Russian L2L sellers
select seller_id,
seller_seq,
seller_admin_seq,
seller_start_time,
store_name
FROM aecdm.dim_ae_slr
where seller_status = 'enabled'
AND register_country_id = 'RU'
AND local_seller_account_unit = 'RUB'
AND is_admin_seller = 'Y'
AND ds = to_char(dateadd(datetrunc(to_date('${sysdate}', 'yyyymmdd'), 'month'), -1, 'dd'), 'yyyymmdd')
) s
on s.seller_admin_seq = a.seller_aliid
left outer join (
select ds,
seller_admin_id,
seller_admin_seq,
parent_order_id,
item_id,
item_name,
unit_num,
order_id,
--money
div_refund_ord_amt,
--statuses
is_send_goods,
refund_create_time,
gmt_pay_order_time
from aecdm.dwd_ae_trd_all_df t
) c
ON c.order_id = a.order_id and c.ds = a.ds
left outer join (
select
--money
seller_admin_seq,
logisticsfeerate,
bar_code,
orderfeerate,
cast(discount_fee * 100 as bigint) as discount_fee,
cast(pay_amt_itm * 100 as bigint) as pay_amt_itm,
order_id,
cast(pay_amt_logis * 100 as bigint) as pay_amt_logis,
--statuses
end_reason
from aebi.adm_ae_local_trd_ru_df
) d
ON a.order_id = d.order_id; | true |
adc327f3b2f3c03b4072d8a26b2e7c1512ab2f22 | SQL | carryaway91/L2C-KE-PHP-CMS | /resources/database.sql | UTF-8 | 691 | 2.78125 | 3 | [] | no_license | CREATE DATABASE IF NOT EXISTS L2C_KE_PHP_CMS;
CREATE TABLE Users (
ID Int AUTO_INCREMENT,
email varchar(256),
password varchar(64),
nickname varchar(128),
PRIMARY KEY (ID)
);
CREATE TABLE Pages (
ID int AUTO_INCREMENT,
title varchar(128),
content TEXT,
User_ID int,
menu_label varchar(128),
menu_order int,
PRIMARY KEY (ID),
FOREIGN KEY (User_ID) REFERENCES Users(ID) ON DELETE CASCADE
);
INSERT INTO Users (nickname) VALUES ('carry');
INSERT INTO Pages (title, content, User_ID, menu_label, menu_order) VALUES ('Welcome',
'lorem_ipsum', 1, 'welcome', 0);
INSERT INTO Pages (title, content, User_ID, menu_label, menu_order) VALUES ('Welcome',
'lorem_ipsum', 1, 'welcome', 0); | true |
d5ff15832cee79c0c9c93c2b7b7e1cc461ff952d | SQL | woliveirac/deliver | /db/init.sql | UTF-8 | 431 | 2.5625 | 3 | [] | no_license | CREATE TABLE bills_to_pay (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
original_value decimal(10,2) NOT NULL,
fine_applied decimal(10,2) NOT NULL,
fees_day decimal(10,2) NOT NULL,
duedate date NOT NULL,
payday date NOT NULL,
created_at timestamp NOT NULL,
updated_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4; | true |
5b2e28798c9b5660180dcb61fa0162286cca9ba9 | SQL | mdonknyc/Queries | /PSAT/PSAT SAT Max Score For Tableau.sql | UTF-8 | 5,129 | 4 | 4 | [] | no_license | /*
Title: PSAT SAT Max Score For Tableau
Created By: Unkwown
Last Updated: 10/22/18
Summary: Pulls highest scores achieved on SAT Critical Reading and Math results, along with student demographics.
*/
Select
S.SystemStudentID,
S.FullName,
S.PrimaryEthnicity,
S.Gender,
S.GradeLevel,
S.LunchStatus,
S.PrimaryDisability,
S.LanguageFluency,
S.Cohort,
S.EnrollmentStatus,
CS.Enroll_Status,
CS.Graduated_SchoolID,
T.TestSubType,
CASE
WHEN T.TestName='Math' then 'SAT Math'
WHEN T.TestName='EBRW' then 'SAT Critical Reading'
ELSE T.TestName END As TestName,
T.TestSubjectGroup,
Max(TS.TestScore)as MaxScore,
PSATMax.PSATMaxScore,
MAPR.MAPReadingMax,
MAPM.MAPMathMax,
NYSELA.ProfRating as NYSELA8,
NYSMath.ProfRating as NYSMath8,
CASE
WHEN T.TestName='SAT Critical Reading' and Max(TS.TestScore)>=500 THEN 'Reading 500+'
WHEN T.TestName='SAT Critical Reading' and Max(TS.TestScore)< 500 THEN 'Reading Below 500'
ELSE 'NA' END AS ReadingAtAbove500,
CASE
WHEN T.TestName='SAT Math' and Max(TS.TestScore)>=500 THEN 'Math 500+'
WHEN T.TestName='SAT Math' and Max(TS.TestScore)< 500 THEN 'Math Below 500'
ELSE 'NA' END AS MathAtAbove500
From
dw.DW_factTestScores TS
LEFT JOIN dw.DW_dimTest T ON (T.TestKEY = TS.TestKEY)
LEFT JOIN dw.DW_dimStudent S ON (S.StudentKEY = TS.StudentKEY)
LEFT JOIN custom.custom_dimStudent CS ON (CS.StudentKEY =TS.StudentKEY)
LEFT JOIN
(Select
SL.SystemStudentID,
T.TestGradeLevel AS TestGradeLevel,
TPL.ProficiencyLevel AS PerfLevel,
TS.ProficiencyLevelScore AS ProfRating,
TS.PercentileScore AS GrowthPercentile,
TS.ScaleScore AS ScaleScore
FROM
dw.DW_factTestScores TS
LEFT JOIN dw.DW_dimSchool SCH ON (SCH.SchoolKEY= TS.SchoolKEY)
LEFT JOIN dw.DW_dimTest T ON (T.TestKEY = TS.TestKEY)
LEFT JOIN dw.DW_dimTestProficiencyLevel TPL ON (TPL.TestProficiencyLevelKEY = TS.TestProficiencyLevelKEY)
LEFT JOIN dw.DW_dimStudent SL ON (SL.StudentKEY = TS.StudentKEY)
LEFT JOIN dw.DW_dimSchoolCalendar SCAL ON (SCAL.SchoolCalendarKEY = TS.SchoolCalendarKEY)
LEFT JOIN custom.custom_dimStudent CS ON (CS.StudentKEY=TS.StudentKEY)
Where
T.TestSubType='NYSA' and T.TestGradeLevel='8th' and T.TestSubject='ELA')NYSELA on (NYSELA.SystemStudentID=S.SystemStudentID)
LEFT JOIN
(Select
SL.SystemStudentID,
T.TestGradeLevel AS TestGradeLevel,
TPL.ProficiencyLevel AS PerfLevel,
TS.ProficiencyLevelScore AS ProfRating,
TS.PercentileScore AS GrowthPercentile,
TS.ScaleScore AS ScaleScore
FROM
dw.DW_factTestScores TS
LEFT JOIN dw.DW_dimSchool SCH ON (SCH.SchoolKEY= TS.SchoolKEY)
LEFT JOIN dw.DW_dimTest T ON (T.TestKEY = TS.TestKEY)
LEFT JOIN dw.DW_dimTestProficiencyLevel TPL ON (TPL.TestProficiencyLevelKEY = TS.TestProficiencyLevelKEY)
LEFT JOIN dw.DW_dimStudent SL ON (SL.StudentKEY = TS.StudentKEY)
LEFT JOIN dw.DW_dimSchoolCalendar SCAL ON (SCAL.SchoolCalendarKEY = TS.SchoolCalendarKEY)
LEFT JOIN custom.custom_dimStudent CS ON (CS.StudentKEY=TS.StudentKEY)
Where
T.TestSubType='NYSA' and T.TestGradeLevel='8th' and T.TestSubject='Math')NYSMath on (NYSMath.SystemStudentID=S.SystemStudentID)
LEFT JOIN
(SELECT
MAPR.StudentID
,Max(MAPR.TestRITScore) as MAPReadingMax
FROM
test_nweamap.Test_NWEAMAP_MAPRawData MAPR
WHERE
MAPR.Grade='8' and MAPR.TermName LIKE 'Spring%' and MAPR.MeasurementScale ='Reading'
GROUP BY
MAPR.StudentID)MAPR ON (S.SystemStudentID=MAPR.StudentID)
LEFT JOIN
(SELECT
MAPM.StudentID
,Max(MAPM.TestRITScore) as MAPMathMax
FROM
test_nweamap.Test_NWEAMAP_MAPRawData MAPM
WHERE
MAPM.Grade='8' and MAPM.TermName LIKE 'Spring%' and MAPM.MeasurementScale ='Mathematics'
GROUP BY
MAPM.StudentID)MAPM ON (S.SystemStudentID=MAPM.StudentID)
LEFT JOIN
(Select
S.SystemStudentID,
T.TestName,
TestSubjectGroup,
Max(TS.TestScore)as PSATMaxScore
From
dw.DW_factTestScores TS
LEFT JOIN dw.DW_dimTest T ON (T.TestKEY = TS.TestKEY)
LEFT JOIN dw.DW_dimStudent S ON (S.StudentKEY = TS.StudentKEY)
Where
T.TestSubType ='PSAT' and S.Cohort<>'2013' and (T.TestName='PSAT Critical Reading' or T.TestName='PSAT Math')
or T.TestSubType ='PSAT' and S.Cohort>='2013' and (T.TestName='EBRW' or T.TestName='Math')
GROUP BY
S.SystemStudentID,
T.TestName,
TestSubjectGroup)PSATMax on (PSATMax.SystemStudentID=S.SystemStudentID and PSATMax.TestSubjectGroup=T.TestSubjectGroup)
Where
TestSubType ='SAT' AND S.Cohort<>'2013' and (T.TestName='SAT Critical Reading' or T.TestName='SAT Math')
or T.TestSubType ='SAT' and S.Cohort>='2013' and (T.TestName='EBRW' or T.TestName='Math')
--(T.TestName='SAT Math' or
--T.TestName='SAT Writing' or
--T.TestName='SAT Critical Reading' or
--T. TestName='SAT Reading and Math' or
--T.TestName='SAT Composite' or
--T.TestName='SAT Writing Multiple Choice' or
--T.TestName='SAT Writing Essay' or
--T.TestName='Math'or
--T.TestName='EBRW')
GROUP BY
S.SystemStudentID,
S.FullName,
S.PrimaryEthnicity,
S.Gender,
S.GradeLevel,
S.LunchStatus,
S.PrimaryDisability,
S.LanguageFluency,
S.Cohort,
S.EnrollmentStatus,
CS.Enroll_Status,
CS.Graduated_SchoolID,
T.TestSubType,
T.TestName,
T.TestSubjectGroup,
PSATMax.PSATMaxScore,
MAPR.MAPReadingMax,
MAPM.MAPMathMax,
NYSELA.ProfRating,
NYSMath.ProfRating | true |
2a6d2b78afae286bad1fa699784608a8ad226c63 | SQL | MdShihabAli/Implementing-Naive-Bayes-Classification-algorithm-into-PHP | /naivebayes.sql | UTF-8 | 9,431 | 3.015625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 27, 2018 at 02:32 PM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 5.6.30
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: `naivebayes`
--
-- --------------------------------------------------------
--
-- Table structure for table `trainingset`
--
CREATE TABLE `trainingset` (
`S_NO` int(11) NOT NULL,
`document` text NOT NULL,
`category` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `trainingset`
--
INSERT INTO `trainingset` (`S_NO`, `document`, `category`) VALUES
(21, 'Sport in Bangladesh is a popular form of entertainment as well as an essential part of Bangladeshi culture', 'Sports'),
(22, 'Sport can play a role in improving the lives of not only individuals but whole communities', 'Sports'),
(23, 'Financial risk protection and equity are major components of universal health coverage which is defined as ensuring access to health services for all citizens without any undue financial burden', 'Finance'),
(24, 'Secularism is established in Bangladesh and freedom of religion is guaranteed by constitution', 'Religion'),
(25, 'Bangladesh religious minorities have been facing attacks since the 2014 national election', 'Religion'),
(26, 'Sport in Bangladesh is a popular form of entertainment as well as an essential part of Bangladeshi culture', 'Sports'),
(27, 'Sport can play a role in improving the lives of not only individuals but whole communities', 'Sports'),
(28, 'Financial risk protection and equity are major components of universal health coverage which is defined as ensuring access to health services for all citizens without any undue financial burden', 'Finance'),
(29, 'Secularism is established in Bangladesh and freedom of religion is guaranteed by constitution', 'Religion'),
(30, 'Bangladesh religious minorities have been facing attacks since the 2014 national election', 'Religion'),
(31, 'The politics regarding the bargaining of the students for their sports games interest with the university authority is called student politics', 'Politics'),
(32, 'A key risk related to the violence in Bangladesh from a rating perspective is that at some stage safety issues could deter foreigners from doing business there', 'Politics'),
(33, 'Sport in Bangladesh is a popular form of entertainment as well as an essential part of Bangladeshi culture', 'Sports'),
(34, 'Sport can play a role in improving the lives of not only individuals but whole communities', 'Sports'),
(35, 'Financial risk protection and equity are major components of universal health coverage which is defined as ensuring access to health services for all citizens without any undue financial burden', 'Finance'),
(36, 'Secularism is established in Bangladesh and freedom of religion is guaranteed by constitution', 'Religion'),
(37, 'Bangladesh religious minorities have been facing attacks since the 2014 national election', 'Religion'),
(38, 'The politics regarding the bargaining of the students for their sports games interest with the university authority is called student politics', 'Politics'),
(39, 'A key risk related to the violence in Bangladesh from a rating perspective is that at some stage safety issues could deter foreigners from doing business there', 'Politics'),
(40, 'Sport in Bangladesh is a popular form of entertainment as well as an essential part of Bangladeshi culture', 'Sports'),
(41, 'Sport can play a role in improving the lives of not only individuals but whole communities', 'Sports'),
(42, 'Financial risk protection and equity are major components of universal health coverage which is defined as ensuring access to health services for all citizens without any undue financial burden', 'Finance'),
(43, 'Secularism is established in Bangladesh and freedom of religion is guaranteed by constitution', 'Religion'),
(44, 'Bangladesh religious minorities have been facing attacks since the 2014 national election', 'Religion'),
(45, 'The politics regarding the bargaining of the students for their sports games interest with the university authority is called student politics', 'Politics'),
(46, 'A key risk related to the violence in Bangladesh from a rating perspective is that at some stage safety issues could deter foreigners from doing business there', 'Politics'),
(47, 'Sport in Bangladesh is a popular form of entertainment as well as an essential part of Bangladeshi culture', 'Sports'),
(48, 'Sport can play a role in improving the lives of not only individuals but whole communities', 'Sports'),
(49, 'Financial risk protection and equity are major components of universal health coverage which is defined as ensuring access to health services for all citizens without any undue financial burden', 'Finance'),
(50, 'Secularism is established in Bangladesh and freedom of religion is guaranteed by constitution', 'Religion'),
(51, 'Bangladesh religious minorities have been facing attacks since the 2014 national election', 'Religion'),
(52, 'The politics regarding the bargaining of the students for their sports games interest with the university authority is called student politics', 'Politics'),
(53, 'A key risk related to the violence in Bangladesh from a rating perspective is that at some stage safety issues could deter foreigners from doing business there', 'Politics');
-- --------------------------------------------------------
--
-- Table structure for table `wordfrequency`
--
CREATE TABLE `wordfrequency` (
`S_NO` int(11) NOT NULL,
`word` varchar(255) NOT NULL,
`count` int(11) NOT NULL,
`category` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `wordfrequency`
--
INSERT INTO `wordfrequency` (`S_NO`, `word`, `count`, `category`) VALUES
(33, 'sport', 10, 'Sports'),
(34, 'bangladesh', 17, 'Sports'),
(35, 'popular', 5, 'Sports'),
(36, 'form', 5, 'Sports'),
(37, 'entertainment', 5, 'Sports'),
(38, 'well', 5, 'Sports'),
(39, 'essential', 5, 'Sports'),
(40, 'part', 5, 'Sports'),
(41, 'bangladeshi', 5, 'Sports'),
(42, 'culture', 5, 'Sports'),
(43, 'play', 5, 'Sports'),
(44, 'role', 5, 'Sports'),
(45, 'improving', 5, 'Sports'),
(46, 'lives', 5, 'Sports'),
(47, 'only', 5, 'Sports'),
(48, 'individuals', 5, 'Sports'),
(49, 'whole', 5, 'Sports'),
(50, 'communities', 5, 'Sports'),
(51, 'financial', 10, 'Finance'),
(52, 'risk', 8, 'Finance'),
(53, 'protection', 5, 'Finance'),
(54, 'equity', 5, 'Finance'),
(55, 'major', 5, 'Finance'),
(56, 'components', 5, 'Finance'),
(57, 'universal', 5, 'Finance'),
(58, 'health', 10, 'Finance'),
(59, 'coverage', 5, 'Finance'),
(60, 'which', 5, 'Finance'),
(61, 'defined', 5, 'Finance'),
(62, 'ensuring', 5, 'Finance'),
(63, 'access', 5, 'Finance'),
(64, 'services', 5, 'Finance'),
(65, 'all', 5, 'Finance'),
(66, 'citizens', 5, 'Finance'),
(67, 'without', 5, 'Finance'),
(68, 'any', 5, 'Finance'),
(69, 'undue', 5, 'Finance'),
(70, 'burden', 5, 'Finance'),
(71, 'secularism', 5, 'Religion'),
(72, 'established', 5, 'Religion'),
(73, 'bangladesh', 17, 'Religion'),
(74, 'freedom', 5, 'Religion'),
(75, 'religion', 5, 'Religion'),
(76, 'guaranteed', 5, 'Religion'),
(77, 'constitution', 5, 'Religion'),
(78, 'religious', 5, 'Religion'),
(79, 'minorities', 5, 'Religion'),
(80, 'been', 5, 'Religion'),
(81, 'facing', 5, 'Religion'),
(82, 'attacks', 5, 'Religion'),
(83, 'since', 5, 'Religion'),
(84, '2014', 5, 'Religion'),
(85, 'national', 5, 'Religion'),
(86, 'election', 5, 'Religion'),
(87, 'politics', 8, 'Politics'),
(88, 'regarding', 4, 'Politics'),
(89, 'bargaining', 4, 'Politics'),
(90, 'students', 4, 'Politics'),
(91, 'sports', 4, 'Politics'),
(92, 'games', 4, 'Politics'),
(93, 'interest', 4, 'Politics'),
(94, 'with', 4, 'Politics'),
(95, 'university', 4, 'Politics'),
(96, 'authority', 4, 'Politics'),
(97, 'called', 4, 'Politics'),
(98, 'student', 4, 'Politics'),
(99, 'key', 4, 'Politics'),
(100, 'risk', 7, 'Politics'),
(101, 'related', 4, 'Politics'),
(102, 'violence', 4, 'Politics'),
(103, 'bangladesh', 13, 'Politics'),
(104, 'rating', 4, 'Politics'),
(105, 'perspective', 4, 'Politics'),
(106, 'some', 4, 'Politics'),
(107, 'stage', 4, 'Politics'),
(108, 'safety', 4, 'Politics'),
(109, 'issues', 4, 'Politics'),
(110, 'deter', 4, 'Politics'),
(111, 'foreigners', 4, 'Politics'),
(112, 'doing', 4, 'Politics'),
(113, 'business', 4, 'Politics');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `trainingset`
--
ALTER TABLE `trainingset`
ADD PRIMARY KEY (`S_NO`);
--
-- Indexes for table `wordfrequency`
--
ALTER TABLE `wordfrequency`
ADD PRIMARY KEY (`S_NO`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `trainingset`
--
ALTER TABLE `trainingset`
MODIFY `S_NO` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=54;
--
-- AUTO_INCREMENT for table `wordfrequency`
--
ALTER TABLE `wordfrequency`
MODIFY `S_NO` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=114;
/*!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 */;
| true |
c889af44bb5edc9ef011a7265316a69f4fbb2555 | SQL | micmor-m/BootcampX | /4_queries/4_avg_time_complete_assignment.sql | UTF-8 | 150 | 2.578125 | 3 | [] | no_license | -- Get the average time of an assistance request.
SELECT AVG(completed_at-started_at) as average_assistance_request_duration
FROM assistance_requests; | true |
a4cb2a793755dcdef86cc82108c9b603d5948036 | SQL | rasanka/shoppingcart | /db/phonerepairpartsdb.sql | UTF-8 | 8,543 | 3.109375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 11, 2018 at 09:55 AM
-- Server version: 5.7.14
-- PHP Version: 5.6.25
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: `phonerepairpartsdb`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_brands`
--
DROP TABLE IF EXISTS `tbl_brands`;
CREATE TABLE `tbl_brands` (
`brand_id` varchar(100) NOT NULL,
`brand_name` varchar(100) NOT NULL,
`cat_id` varchar(100) NOT NULL,
`created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_cart`
--
DROP TABLE IF EXISTS `tbl_cart`;
CREATE TABLE `tbl_cart` (
`cart_id` varchar(100) NOT NULL,
`user_id` varchar(100) NOT NULL,
`total_price` decimal(20,2) NOT NULL,
`ip_addr` varchar(100) NOT NULL,
`cart_status` varchar(100) NOT NULL,
`created_datetime` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_cart_items`
--
DROP TABLE IF EXISTS `tbl_cart_items`;
CREATE TABLE `tbl_cart_items` (
`cart_id` varchar(100) NOT NULL,
`prod_id` varchar(100) NOT NULL,
`qty` int(10) NOT NULL,
`unit_price` decimal(20,2) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_categories`
--
DROP TABLE IF EXISTS `tbl_categories`;
CREATE TABLE `tbl_categories` (
`cat_id` varchar(100) NOT NULL,
`cat_name` varchar(200) NOT NULL,
`created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_items`
--
DROP TABLE IF EXISTS `tbl_items`;
CREATE TABLE `tbl_items` (
`item_id` varchar(100) NOT NULL,
`item_name` varchar(500) NOT NULL,
`short_desc` text,
`item_desc` text NOT NULL,
`item_prod` varchar(100) NOT NULL,
`item_price` decimal(20,2) NOT NULL,
`item_stock` int(10) NOT NULL,
`ref_id` varchar(100) NOT NULL,
`delivery` double(20,2) DEFAULT '0.00',
`item_keywords` varchar(100) NOT NULL,
`status` varchar(10) NOT NULL,
`rating` int(10) NOT NULL DEFAULT '5',
`badge` varchar(10) NOT NULL DEFAULT 'NEW',
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_item_images`
--
DROP TABLE IF EXISTS `tbl_item_images`;
CREATE TABLE `tbl_item_images` (
`item_id` varchar(100) NOT NULL,
`seq_id` int(100) NOT NULL,
`image_name` varchar(100) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_newsletter_signup`
--
DROP TABLE IF EXISTS `tbl_newsletter_signup`;
CREATE TABLE `tbl_newsletter_signup` (
`email` varchar(200) NOT NULL,
`added_date` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_orders`
--
DROP TABLE IF EXISTS `tbl_orders`;
CREATE TABLE `tbl_orders` (
`order_id` varchar(100) NOT NULL,
`cart_id` varchar(100) NOT NULL,
`user_id` varchar(100) NOT NULL,
`cart_total` decimal(20,2) NOT NULL,
`delivery_amount` decimal(20,2) NOT NULL,
`order_total` decimal(20,2) NOT NULL,
`billing_name` varchar(200) NOT NULL,
`billing_company` varchar(200) DEFAULT NULL,
`billing_email` varchar(200) NOT NULL,
`billing_contact` varchar(20) NOT NULL,
`billing_address` varchar(500) NOT NULL,
`delivery_name` varchar(200) NOT NULL,
`delivery_company` varchar(200) DEFAULT NULL,
`delivery_email` varchar(200) NOT NULL,
`delivery_contact` varchar(20) NOT NULL,
`delivery_address` varchar(500) NOT NULL,
`delivery_note` varchar(200) DEFAULT NULL,
`payment_method` varchar(100) NOT NULL,
`order_datetime` datetime NOT NULL,
`order_status` varchar(100) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_products`
--
DROP TABLE IF EXISTS `tbl_products`;
CREATE TABLE `tbl_products` (
`prod_id` varchar(100) NOT NULL,
`prod_name` varchar(500) NOT NULL,
`prod_cat` varchar(100) NOT NULL,
`prod_brand` varchar(100) NOT NULL,
`ref_id` varchar(100) NOT NULL,
`status` varchar(10) NOT NULL,
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_product_images`
--
DROP TABLE IF EXISTS `tbl_product_images`;
CREATE TABLE `tbl_product_images` (
`prod_id` varchar(100) NOT NULL,
`seq_id` int(100) NOT NULL,
`image_name` varchar(100) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_product_reviews`
--
DROP TABLE IF EXISTS `tbl_product_reviews`;
CREATE TABLE `tbl_product_reviews` (
`review_id` varchar(100) NOT NULL,
`prod_id` varchar(100) NOT NULL,
`rating` int(100) NOT NULL,
`review` text NOT NULL,
`name` varchar(200) NOT NULL,
`email` varchar(200) NOT NULL,
`review_date` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_users`
--
DROP TABLE IF EXISTS `tbl_users`;
CREATE TABLE `tbl_users` (
`user_id` varchar(100) NOT NULL,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`contact_no` varchar(50) NOT NULL,
`password` varchar(100) NOT NULL,
`billing_house_no` varchar(50) DEFAULT NULL,
`billing_street` varchar(100) DEFAULT NULL,
`billing_city` varchar(100) DEFAULT NULL,
`billing_region` varchar(100) DEFAULT NULL,
`billing_postal_code` varchar(50) DEFAULT NULL,
`billing_country` text,
`registered_date` datetime NOT NULL,
`user_status` varchar(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_web_inquiry`
--
DROP TABLE IF EXISTS `tbl_web_inquiry`;
CREATE TABLE `tbl_web_inquiry` (
`inq_id` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`email` varchar(200) NOT NULL,
`company` varchar(200) DEFAULT NULL,
`subject` varchar(500) NOT NULL,
`message` text NOT NULL,
`inq_date` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_wishlist`
--
DROP TABLE IF EXISTS `tbl_wishlist`;
CREATE TABLE `tbl_wishlist` (
`user_id` varchar(100) NOT NULL,
`prod_id` varchar(100) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tbl_brands`
--
ALTER TABLE `tbl_brands`
ADD PRIMARY KEY (`brand_id`);
--
-- Indexes for table `tbl_cart`
--
ALTER TABLE `tbl_cart`
ADD PRIMARY KEY (`cart_id`);
--
-- Indexes for table `tbl_categories`
--
ALTER TABLE `tbl_categories`
ADD PRIMARY KEY (`cat_id`);
--
-- Indexes for table `tbl_items`
--
ALTER TABLE `tbl_items`
ADD PRIMARY KEY (`item_id`);
--
-- Indexes for table `tbl_newsletter_signup`
--
ALTER TABLE `tbl_newsletter_signup`
ADD PRIMARY KEY (`email`);
--
-- Indexes for table `tbl_orders`
--
ALTER TABLE `tbl_orders`
ADD PRIMARY KEY (`order_id`);
--
-- Indexes for table `tbl_products`
--
ALTER TABLE `tbl_products`
ADD PRIMARY KEY (`prod_id`);
--
-- Indexes for table `tbl_product_reviews`
--
ALTER TABLE `tbl_product_reviews`
ADD PRIMARY KEY (`review_id`);
--
-- Indexes for table `tbl_users`
--
ALTER TABLE `tbl_users`
ADD PRIMARY KEY (`user_id`);
--
-- Indexes for table `tbl_web_inquiry`
--
ALTER TABLE `tbl_web_inquiry`
ADD PRIMARY KEY (`inq_id`);
/*!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 */;
| true |
b46c8042da02be4a59eb027b88d4cfcb9cdcf0fb | SQL | Lee-Gelgel/education | /oracle/day20/chp7_source.sql | UHC | 5,064 | 4.21875 | 4 | [] | no_license |
-- Distinct all
SELECT DISTINCT employee_id
FROM employees;
SELECT DISTINCT department_id
FROM employees;
SELECT DISTINCT department_id, employee_id
FROM employees;
SELECT ALL department_id
FROM employees;
-- Լ
SELECT COUNT(*)
FROM employees;
SELECT COUNT(*) col1,
COUNT(employee_id) col2
FROM employees;
SELECT COUNT(ALL employee_id)
FROM employees;
SELECT COUNT( ALL employee_id),
COUNT( ALL first_name)
FROM employees;
SELECT COUNT( DISTINCT employee_id),
COUNT( DISTINCT first_name)
FROM employees;
SELECT COUNT(department_id),
COUNT( DISTINCT department_id)
FROM employees;
-- SUM
SELECT SUM(salary)
FROM EMPLOYEES;
CREATE TABLE sum_test (
Col1 varchar2(10),
Col2 number);
INSERT INTO sum_test VALUES('100', 100);
INSERT INTO sum_test VALUES('200', 200);
INSERT INTO sum_test VALUES('300', 300);
INSERT INTO sum_test VALUES('400', 400);
SELECT SUM(col1),
SUM(col2)
FROM sum_test;
SELECT SUM(DISTINCT salary),
SUM(salary)
FROM employees;
-- MAX MIN
SELECT MAX(salary), MIN(salary)
FROM employees;
SELECT employee_id, first_name, last_name,
job_id, salary
FROM employees
WHERE salary in ( 24000, 2100 );
SELECT employee_id, first_name, last_name,
job_id, salary
FROM employees
WHERE salary = MAX(salary);
SELECT MAX(salary),
MAX(DISTINCT salary),
MIN(salary),
MIN(DISTINCT salary)
FROM employees;
-- AVG
SELECT AVG(salary)
FROM employees;
SELECT AVG(DISTINCT salary)
FROM employees;
SELECT AVG(salary) avg1,
SUM(salary) / COUNT(salary) avg2
FROM employees;
-- STDDEV VARIANCE
SELECT STDDEV(salary),
VARIANCE(salary)
FROM employees;
-- GROUP BY
SELECT department_id
FROM employees
GROUP BY department_id;
SELECT department_id, SUM(salary)
FROM employees
GROUP BY department_id;
SELECT department_id, SUM(salary), COUNT(salary), AVG(salary)
FROM employees
GROUP BY department_id;
SELECT department_id, job_id,
SUM(salary), AVG(salary)
FROM employees
GROUP BY department_id;
SELECT department_id, job_id,
SUM(salary), AVG(salary)
FROM employees
GROUP BY department_id, job_id;
SELECT department_id, job_id,
SUM(salary), AVG(salary)
FROM employees
GROUP BY department_id, job_id
ORDER BY department_id, job_id;
SELECT 'ORACEL' company,
department_id, job_id,
TO_CHAR( SUM(salary), '999,999') tot_sal,
TO_CHAR(SUM(salary), '999,999') avg_sal
FROM employees
GROUP BY department_id, job_id
ORDER BY department_id, job_id;
SELECT ROWNUM, department_id,
COUNT(*)
FROM employees
GROUP BY ROWNUM, department_id
ORDER BY ROWNUM;
SELECT job_id,
TO_CHAR(SUM(salary), '999,999') tot_sal,
TO_CHAR(SUM(salary), '999,999') avg_sal
FROM employees
WHERE department_id = 80
GROUP BY job_id
ORDER BY job_id;
-- HAVING
SELECT department_id,
COUNT(*)
FROM EMPLOYEES
WHERE department_id IS NOT NULL
GROUP BY department_id
ORDER BY department_id;
SELECT department_id,
COUNT(*)
FROM EMPLOYEES
WHERE department_id IS NOT NULL]
AND COUNT(*) <= 5
GROUP BY department_id
ORDER BY department_id;
SELECT department_id,
COUNT(*)
FROM EMPLOYEES
WHERE department_id IS NOT NULL
GROUP BY department_id
HAVING COUNT(*) <= 5
ORDER BY department_id;
SELECT COUNT(*)
FROM employees
HAVING COUNT(*) < 10;
SELECT department_id,
COUNT(*)
FROM employees
WHERE department_id IS NOT NULL
GROUP BY department_id
HAVING department_id > 30;
-- ROLLUP CUBE
SELECT c.city, b.department_name, a.job_id,
COUNT(*) persons, SUM(a.salary) tot_sal
FROM employees a,
departments b,
locations c
WHERE a.department_id = b.department_id
AND b.location_id = c.location_id
GROUP BY c.city, b.department_name, a.job_id
ORDER BY c.city, b.department_name, a.job_id;
SELECT c.city, b.department_name, a.job_id,
COUNT(*) persons,
TO_CHAR(SUM(a.salary),'999,999') tot_sal
FROM employees a,
departments b,
locations c
WHERE a.department_id = b.department_id
AND b.location_id = c.location_id
GROUP BY ROLLUP(c.city, b.department_name, a.job_id)
ORDER BY c.city, b.department_name, a.job_id;
SELECT c.city, b.department_name, a.job_id,
COUNT(*) persons,
TO_CHAR(SUM(a.salary),'999,999') tot_sal
FROM employees a,
departments b,
locations c
WHERE a.department_id = b.department_id
AND b.location_id = c.location_id
GROUP BY CUBE(c.city, b.department_name, a.job_id)
ORDER BY c.city, b.department_name, a.job_id;
SELECT c.city, b.department_name, a.job_id,
COUNT(*) persons,
TO_CHAR(SUM(a.salary),'999,999') tot_sal
FROM employees a,
departments b,
locations c
WHERE a.department_id = b.department_id
AND b.location_id = c.location_id
AND c.city = ''
GROUP BY CUBE(c.city, b.department_name, a.job_id)
ORDER BY c.city, b.department_name, a.job_id;
| true |
cf87239122e3dc5d28a1c2cc6c0b067f41f1484c | SQL | KonstantinNovizky/testPaypal | /selectivetrade (1).sql | UTF-8 | 13,496 | 2.859375 | 3 | [
"MIT"
] | permissive | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 20, 2021 at 02:32 AM
-- Server version: 10.4.13-MariaDB
-- PHP Version: 7.4.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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: `selectivetrade`
--
-- --------------------------------------------------------
--
-- Table structure for table `data`
--
CREATE TABLE `data` (
`Username` text COLLATE utf8mb4_unicode_ci NOT NULL,
`Message` text COLLATE utf8mb4_unicode_ci NOT NULL,
`Time` text COLLATE utf8mb4_unicode_ci NOT NULL,
`ID_Number` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `failed_jobs`
--
CREATE TABLE `failed_jobs` (
`id` bigint(20) UNSIGNED NOT NULL,
`uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
`queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `memberships`
--
CREATE TABLE `memberships` (
`id` int(11) NOT NULL,
`month` int(11) NOT NULL,
`amount` float(15,2) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `memberships`
--
INSERT INTO `memberships` (`id`, `month`, `amount`, `created_at`, `updated_at`) VALUES
(1, 1, 30.00, '2021-02-18 01:39:08', '2021-02-18 10:06:57'),
(4, 4, 100.00, '2021-02-18 08:59:25', '2021-02-18 08:59:25');
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE `migrations` (
`id` int(10) UNSIGNED NOT NULL,
`migration` varchar(255) 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
(40, '2014_10_12_000000_create_users_table', 1),
(41, '2014_10_12_100000_create_password_resets_table', 1),
(42, '2019_08_19_000000_create_failed_jobs_table', 1),
(43, '2020_12_15_133452_add_status_to_users_table', 1),
(44, '2020_12_16_114740_create_roles_table', 1),
(45, '2020_12_16_114921_add_role_id_to_users_table', 1),
(46, '2021_01_05_103230_create_trades_table', 2),
(47, '2021_01_14_060246_create_subscriptions_table', 3);
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(255) 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 `roles`
--
CREATE TABLE `roles` (
`id` bigint(20) UNSIGNED NOT NULL,
`role` varchar(255) COLLATE utf8mb4_unicode_ci 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 `roles`
--
INSERT INTO `roles` (`id`, `role`, `created_at`, `updated_at`) VALUES
(1, 'user', '2020-12-16 07:15:09', '2020-12-16 07:15:09'),
(2, 'admin', '2020-12-16 07:15:29', '2020-12-16 07:15:29');
-- --------------------------------------------------------
--
-- Table structure for table `subscriptions`
--
CREATE TABLE `subscriptions` (
`id` bigint(20) UNSIGNED NOT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL,
`price` int(11) NOT NULL DEFAULT 1,
`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 `subscriptions`
--
INSERT INTO `subscriptions` (`id`, `user_id`, `price`, `created_at`, `updated_at`) VALUES
(1, 24, 1, '2021-01-18 19:00:00', NULL),
(2, 49, 5, '2021-01-18 19:00:00', NULL);
-- --------------------------------------------------------
--
-- Table structure for table `trades`
--
CREATE TABLE `trades` (
`id` bigint(20) UNSIGNED NOT NULL,
`s_no` text COLLATE utf8mb4_unicode_ci NOT NULL,
`buy_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`qty` int(11) NOT NULL,
`symbol` text COLLATE utf8mb4_unicode_ci NOT NULL,
`expiration_date` timestamp NOT NULL DEFAULT current_timestamp(),
`callput` text COLLATE utf8mb4_unicode_ci NOT NULL,
`strike_price` double(8,2) NOT NULL,
`stock_price` double(8,2) NOT NULL,
`stock_stoploss` double(8,2) NOT NULL,
`stock_resistance` double(8,2) NOT NULL,
`buy_price` double(8,2) NOT NULL,
`sell_price` double(8,2) NOT NULL,
`sell_date` text COLLATE utf8mb4_unicode_ci NOT NULL,
`net` double(8,2) NOT NULL,
`profit` int(11) NOT NULL,
`current_price` int(11) NOT NULL,
`days_to_expire` int(11) NOT NULL,
`status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'hold',
`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 `trades`
--
INSERT INTO `trades` (`id`, `s_no`, `buy_date`, `qty`, `symbol`, `expiration_date`, `callput`, `strike_price`, `stock_price`, `stock_stoploss`, `stock_resistance`, `buy_price`, `sell_price`, `sell_date`, `net`, `profit`, `current_price`, `days_to_expire`, `status`, `created_at`, `updated_at`) VALUES
(1, '#sdfsdfsdf', '2021-01-05 12:46:43', 5, '#sdfsafs dafsa f', '2021-01-05 12:46:43', 'PUT', 500.00, 400.00, 30.00, 20.00, 380.00, 500.00, '2020-1-1', 43.00, 20, 380, 30, 'hold', NULL, NULL),
(6, '1', '2021-01-05 12:46:43', 1, '1', '2021-01-05 12:46:43', 'PUT', 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, '2021-01-05 19:46:43', 1.00, 1, 1, 1, 'hold', '2021-02-10 11:40:49', '2021-02-10 11:40:49'),
(7, '2', '2021-01-05 12:46:43', 2, '2', '2021-01-05 12:46:43', 'PUT', 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, '2021-01-05 19:46:43', 2.00, 2, 2, 2, 'hold', '2021-02-10 11:40:49', '2021-02-10 11:40:49'),
(8, '3', '2021-01-05 12:46:43', 3, '3', '2021-01-05 12:46:43', 'PUT', 3.00, 3.00, 3.00, 3.00, 3.00, 3.00, '2021-01-05 19:46:43', 3.00, 3, 3, 3, 'hold', '2021-02-10 11:40:49', '2021-02-10 11:40:49');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL,
`first_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`last_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`telegram_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`twitter_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) 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,
`status` tinyint(4) NOT NULL DEFAULT 0,
`role_id` bigint(20) UNSIGNED NOT NULL,
`ip` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `first_name`, `last_name`, `email`, `phone`, `telegram_id`, `twitter_id`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `status`, `role_id`, `ip`) VALUES
(24, 'hussain', NULL, 'admin@admin.com', '3429616625', NULL, NULL, NULL, '$2y$10$mSdiMB22tbZPTESW8/bPX.6EhLhfths9m7o9I152qpkxI5hdeGt1S', NULL, '2021-01-05 02:17:30', '2021-01-19 01:51:50', 1, 2, NULL),
(49, 'hussain', NULL, 'user@user.com', '3429616625', NULL, NULL, NULL, '$2y$10$OWG4U8xyHmZpb5WQUZJig.rkLw6OJlG3OUmXYmRfjukjwMioR/Y4e', NULL, '2021-01-05 02:17:30', '2021-01-19 01:51:50', 1, 1, NULL),
(50, 'Shakir', 'Abbas', 'Malikshakir35@gmail.com', '3087021312', NULL, NULL, NULL, '$2y$10$184DFmE7joYKT/Lvea/1l.AlMbOWhPoTwD4SbytILsniJV2lLIRX6', NULL, '2021-01-29 11:21:03', '2021-01-29 11:21:03', 0, 1, NULL),
(51, 'ahmad', 'ali', 'hussainalisdfgdfgdfg@gmail.com', '3429616625', NULL, NULL, NULL, '$2y$10$I61acZYguBm7YGQsnFb65.IsdHZ/8VzP6vlhf9VP/pEBaKjhCH6lS', NULL, '2021-01-29 11:21:03', '2021-01-29 11:21:03', 0, 1, NULL),
(52, 'Shakir', 'Abbas', 'shakirabbas210sacasdc@gmail.com', '03087021312', NULL, NULL, NULL, '$2y$10$JL2EK.79RViPKrn6Yq7xWOHvjiH.T/GQgwkSn8GkqnywbRmyUjVeC', NULL, '2021-01-29 11:25:06', '2021-01-29 11:25:06', 0, 1, NULL),
(53, 'Srinivasa', 'v', 'usa.srao@gmail.com', '4123529956', NULL, NULL, NULL, '$2y$10$KPrDPdGEy2jjK40/kaf.uOHBTZ9WZhnLQXUaDk0CcX8/cSP80LEYm', NULL, '2021-01-29 12:46:15', '2021-01-29 12:46:15', 0, 1, NULL),
(54, 'Shakir', 'abbas', 'shakirabbas210@gmail.com', '03087021312', NULL, NULL, NULL, '$2y$10$dt9idwajvA6dHIg2y/uWWOh7msUl92Aeht1RhvUUDQvfRag.KBfGS', NULL, '2021-01-30 12:26:36', '2021-01-30 12:26:36', 0, 1, NULL),
(55, 'Shashi', 'Singh', 'shashi.bhushan@gmail.com', '4087865200', NULL, NULL, NULL, '$2y$10$6R0pFeeQzl7eCdJAV9e9L.G9qJILiSY3g7.S0BhgJTdkD.hd4zV7q', NULL, '2021-01-30 16:46:48', '2021-01-30 16:46:48', 0, 1, NULL),
(56, 'adid', NULL, 'adibonchis@gmail.com', '+1-45674987984848', NULL, NULL, NULL, '$2y$10$z9eUQLSS1nCwVfkD21oeOuxH5gfMiTxFXAoncvMdvTwhf1tMrH5S2', NULL, '2021-02-09 10:26:53', '2021-02-10 11:35:37', 0, 1, NULL),
(58, 'john', NULL, 'johnran@gmail.com', '+49-809890898', NULL, NULL, NULL, '$2y$10$UZAv9x05EOzf3JJVhesSKuzk6HB5Ka8Hr2n8/Y0k4WqGoUj6hDhIW', NULL, '2021-02-10 11:39:43', '2021-02-10 11:39:43', 0, 1, NULL),
(63, 'qqq', NULL, 'qqq@gmail.com', '+1-234234', NULL, NULL, NULL, '$2y$10$FAb552uhp87d5c6oKPqc2exe59wkitHpuhlozls9KRF3FfdarPhbS', NULL, '2021-02-18 11:05:04', '2021-02-18 11:05:04', 0, 1, NULL),
(64, 'www', NULL, 'www@gmail.com', '+10-www', NULL, NULL, NULL, '$2y$10$j722q1rbMr63QFS7QZ3X4ec1NMqBZk.HCgDQ94zeeKS3I0uB2CqIK', NULL, '2021-02-18 11:06:42', '2021-02-18 11:06:42', 0, 1, NULL),
(65, 'rrr', NULL, 'rrr@gmail.com', '+1-2334242', NULL, NULL, NULL, '$2y$10$kjkCAVNdX6Tbe6qguQbvnOZB0H7iiWLX5VjiXa2goEdzWHBBhxphy', NULL, '2021-02-18 11:18:17', '2021-02-18 11:18:17', 0, 1, NULL);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);
--
-- Indexes for table `memberships`
--
ALTER TABLE `memberships`
ADD PRIMARY KEY (`id`);
--
-- 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 `roles`
--
ALTER TABLE `roles`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `roles_role_unique` (`role`);
--
-- Indexes for table `subscriptions`
--
ALTER TABLE `subscriptions`
ADD PRIMARY KEY (`id`),
ADD KEY `subscriptions_user_id_foreign` (`user_id`);
--
-- Indexes for table `trades`
--
ALTER TABLE `trades`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`),
ADD KEY `users_role_id_foreign` (`role_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `memberships`
--
ALTER TABLE `memberships`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48;
--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `subscriptions`
--
ALTER TABLE `subscriptions`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `trades`
--
ALTER TABLE `trades`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=66;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `subscriptions`
--
ALTER TABLE `subscriptions`
ADD CONSTRAINT `subscriptions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `users_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
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 */;
| true |
b3baa1ffc5f586d51c3e98b531ccf3258b43d04b | SQL | Rune-Status/hikilaka-rscemulation | /database/rsce_logs.sql | UTF-8 | 33,639 | 3.015625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Aug 02, 2017 at 11:46 PM
-- Server version: 5.5.52-MariaDB
-- PHP Version: 7.0.18
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: `rscunity_logs`
--
-- --------------------------------------------------------
--
-- Table structure for table `game_bans`
--
CREATE TABLE `game_bans` (
`id` int(10) NOT NULL,
`account` int(11) NOT NULL,
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`player` varchar(40) NOT NULL,
`reason` mediumtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_chat`
--
CREATE TABLE `game_chat` (
`user` varchar(40) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`message` varchar(255) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_collect`
--
CREATE TABLE `game_collect` (
`user` bigint(20) NOT NULL,
`account` int(11) NOT NULL,
`time` int(11) NOT NULL,
`ip` varchar(15) NOT NULL,
`amount` bigint(11) NOT NULL,
`id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_connect`
--
CREATE TABLE `game_connect` (
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_death`
--
CREATE TABLE `game_death` (
`user` varchar(40) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL DEFAULT '0.0.0.0',
`time` int(10) NOT NULL,
`x` int(4) NOT NULL,
`y` int(4) NOT NULL,
`id` int(6) NOT NULL,
`item1_id` int(4) DEFAULT NULL,
`item1_amount` int(4) DEFAULT NULL,
`item2_id` int(4) DEFAULT NULL,
`item2_amount` int(4) DEFAULT NULL,
`item3_id` int(4) DEFAULT NULL,
`item3_amount` int(4) DEFAULT NULL,
`item4_id` int(4) DEFAULT NULL,
`item4_amount` int(4) DEFAULT NULL,
`item5_id` int(4) DEFAULT NULL,
`item5_amount` int(4) DEFAULT NULL,
`item6_id` int(4) DEFAULT NULL,
`item6_amount` int(4) DEFAULT NULL,
`item7_id` int(4) DEFAULT NULL,
`item7_amount` int(4) DEFAULT NULL,
`item8_id` int(4) DEFAULT NULL,
`item8_amount` int(4) DEFAULT NULL,
`item9_id` int(4) DEFAULT NULL,
`item9_amount` int(4) DEFAULT NULL,
`item10_id` int(4) DEFAULT NULL,
`item10_amount` int(4) DEFAULT NULL,
`item11_id` int(4) DEFAULT NULL,
`item11_amount` int(4) DEFAULT NULL,
`item12_id` int(4) DEFAULT NULL,
`item12_amount` int(4) DEFAULT NULL,
`item13_id` int(4) DEFAULT NULL,
`item13_amount` int(4) DEFAULT NULL,
`item14_id` int(4) DEFAULT NULL,
`item14_amount` int(4) DEFAULT NULL,
`item15_id` int(4) DEFAULT NULL,
`item15_amount` int(4) DEFAULT NULL,
`item16_id` int(4) DEFAULT NULL,
`item16_amount` int(4) DEFAULT NULL,
`item17_id` int(4) DEFAULT NULL,
`item17_amount` int(4) DEFAULT NULL,
`item18_id` int(4) DEFAULT NULL,
`item18_amount` int(4) DEFAULT NULL,
`item19_id` int(4) DEFAULT NULL,
`item19_amount` int(4) DEFAULT NULL,
`item20_id` int(4) DEFAULT NULL,
`item20_amount` int(4) DEFAULT NULL,
`item21_id` int(4) DEFAULT NULL,
`item21_amount` int(4) DEFAULT NULL,
`item22_id` int(4) DEFAULT NULL,
`item22_amount` int(4) DEFAULT NULL,
`item23_id` int(4) DEFAULT NULL,
`item23_amount` int(4) DEFAULT NULL,
`item24_id` int(4) DEFAULT NULL,
`item24_amount` int(4) DEFAULT NULL,
`item25_id` int(4) DEFAULT NULL,
`item25_amount` int(4) DEFAULT NULL,
`item26_id` int(4) DEFAULT NULL,
`item26_amount` int(4) DEFAULT NULL,
`item27_id` int(4) DEFAULT NULL,
`item27_amount` int(4) DEFAULT NULL,
`item28_id` int(4) DEFAULT NULL,
`item28_amount` int(4) DEFAULT NULL,
`item29_id` int(4) DEFAULT NULL,
`item29_amount` int(4) DEFAULT NULL,
`item30_id` int(4) DEFAULT NULL,
`item30_amount` int(4) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_drop`
--
CREATE TABLE `game_drop` (
`user` varchar(40) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL,
`x` int(4) NOT NULL,
`y` int(4) NOT NULL,
`item` int(4) NOT NULL,
`amount` int(10) NOT NULL,
`time` int(10) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_duel`
--
CREATE TABLE `game_duel` (
`user1` varchar(40) NOT NULL,
`account1` int(11) DEFAULT NULL,
`user1_ip` varchar(15) NOT NULL,
`user2` varchar(40) NOT NULL,
`account2` int(11) DEFAULT NULL,
`user2_ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`no_retreating` tinyint(1) NOT NULL,
`no_prayer` tinyint(1) NOT NULL,
`no_magic` tinyint(1) NOT NULL,
`no_weapons` tinyint(1) NOT NULL,
`id` int(10) NOT NULL,
`user1_item1` int(4) DEFAULT NULL,
`user1_amount1` int(10) DEFAULT NULL,
`user1_item2` int(4) DEFAULT NULL,
`user1_amount2` int(10) DEFAULT NULL,
`user1_item3` int(4) DEFAULT NULL,
`user1_amount3` int(10) DEFAULT NULL,
`user1_item4` int(4) DEFAULT NULL,
`user1_amount4` int(10) DEFAULT NULL,
`user1_item5` int(4) DEFAULT NULL,
`user1_amount5` int(10) DEFAULT NULL,
`user1_item6` int(4) DEFAULT NULL,
`user1_amount6` int(10) DEFAULT NULL,
`user1_item7` int(4) DEFAULT NULL,
`user1_amount7` int(10) DEFAULT NULL,
`user1_item8` int(4) DEFAULT NULL,
`user1_amount8` int(10) DEFAULT NULL,
`user2_item1` int(4) DEFAULT NULL,
`user2_amount1` int(10) DEFAULT NULL,
`user2_item2` int(4) DEFAULT NULL,
`user2_amount2` int(10) DEFAULT NULL,
`user2_item3` int(4) DEFAULT NULL,
`user2_amount3` int(10) DEFAULT NULL,
`user2_item4` int(4) DEFAULT NULL,
`user2_amount4` int(10) DEFAULT NULL,
`user2_item5` int(4) DEFAULT NULL,
`user2_amount5` int(10) DEFAULT NULL,
`user2_item6` int(4) DEFAULT NULL,
`user2_amount6` int(10) DEFAULT NULL,
`user2_item7` int(4) DEFAULT NULL,
`user2_amount7` int(10) DEFAULT NULL,
`user2_item8` int(4) DEFAULT NULL,
`user2_amount8` int(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_error`
--
CREATE TABLE `game_error` (
`user` varchar(40) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`error` varchar(255) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_event`
--
CREATE TABLE `game_event` (
`id` int(10) NOT NULL,
`user` varchar(40) NOT NULL,
`account` int(11) NOT NULL,
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`message` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_exploit`
--
CREATE TABLE `game_exploit` (
`user` bigint(20) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`exploit` varchar(500) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_generic`
--
CREATE TABLE `game_generic` (
`message` varchar(255) NOT NULL,
`time` int(10) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_global`
--
CREATE TABLE `game_global` (
`user` varchar(40) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`message` varchar(255) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_login`
--
CREATE TABLE `game_login` (
`user` varchar(40) NOT NULL,
`account` int(11) DEFAULT NULL,
`uid` int(8) DEFAULT NULL,
`time` int(10) NOT NULL,
`ip` varchar(15) NOT NULL DEFAULT '0.0.0.0',
`id` int(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_pickup`
--
CREATE TABLE `game_pickup` (
`user` varchar(40) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL,
`x` int(4) NOT NULL,
`y` int(4) NOT NULL,
`item` int(4) NOT NULL,
`amount` int(10) NOT NULL,
`time` int(10) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_pm`
--
CREATE TABLE `game_pm` (
`sender` varchar(40) NOT NULL,
`sender_account` int(11) DEFAULT NULL,
`sender_ip` varchar(15) NOT NULL,
`reciever` varchar(40) NOT NULL,
`reciever_account` int(11) DEFAULT NULL,
`reciever_ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`message` varchar(255) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_redeem`
--
CREATE TABLE `game_redeem` (
`user` bigint(20) NOT NULL,
`account` int(11) NOT NULL,
`time` int(11) NOT NULL,
`ip` varchar(15) NOT NULL,
`id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_report`
--
CREATE TABLE `game_report` (
`id` int(10) NOT NULL,
`user` bigint(20) NOT NULL,
`account` int(11) DEFAULT NULL,
`ip` varchar(15) NOT NULL,
`reported` bigint(20) NOT NULL,
`reported_account` int(11) DEFAULT NULL,
`reported_ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`rule` smallint(2) NOT NULL,
`resolved_by` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_report_actions`
--
CREATE TABLE `game_report_actions` (
`id` int(10) NOT NULL,
`report_id` int(10) NOT NULL,
`account` int(10) NOT NULL,
`time` int(10) NOT NULL,
`action` tinyint(3) NOT NULL,
`duration` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_report_comments`
--
CREATE TABLE `game_report_comments` (
`id` int(10) NOT NULL,
`report_id` int(10) NOT NULL,
`account` int(10) NOT NULL,
`date` int(10) NOT NULL,
`message` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_script`
--
CREATE TABLE `game_script` (
`id` int(11) UNSIGNED NOT NULL,
`user` bigint(20) NOT NULL,
`account` int(11) NOT NULL,
`ip` varchar(15) NOT NULL,
`time` int(11) NOT NULL,
`script` varchar(15) NOT NULL,
`target` bigint(20) NOT NULL,
`status` tinyint(1) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_shop`
--
CREATE TABLE `game_shop` (
`user` bigint(30) NOT NULL,
`ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`account` int(10) NOT NULL,
`item_id` int(11) NOT NULL,
`item_amount` int(11) NOT NULL,
`action` int(11) NOT NULL,
`id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `game_trade`
--
CREATE TABLE `game_trade` (
`user1` varchar(40) NOT NULL,
`account1` int(11) DEFAULT NULL,
`user1_ip` varchar(15) NOT NULL,
`user2` varchar(40) NOT NULL,
`account2` int(11) DEFAULT NULL,
`user2_ip` varchar(15) NOT NULL,
`time` int(10) NOT NULL,
`id` int(10) NOT NULL,
`user1_item1` int(4) DEFAULT NULL,
`user1_amount1` int(10) DEFAULT NULL,
`user1_item2` int(4) DEFAULT NULL,
`user1_amount2` int(10) DEFAULT NULL,
`user1_item3` int(4) DEFAULT NULL,
`user1_amount3` int(10) DEFAULT NULL,
`user1_item4` int(4) DEFAULT NULL,
`user1_amount4` int(10) DEFAULT NULL,
`user1_item5` int(4) DEFAULT NULL,
`user1_amount5` int(10) DEFAULT NULL,
`user1_item6` int(4) DEFAULT NULL,
`user1_amount6` int(10) DEFAULT NULL,
`user1_item7` int(4) DEFAULT NULL,
`user1_amount7` int(10) DEFAULT NULL,
`user1_item8` int(4) DEFAULT NULL,
`user1_amount8` int(10) DEFAULT NULL,
`user1_item9` int(4) DEFAULT NULL,
`user1_amount9` int(10) DEFAULT NULL,
`user1_item10` int(4) DEFAULT NULL,
`user1_amount10` int(10) DEFAULT NULL,
`user1_item11` int(4) DEFAULT NULL,
`user1_amount11` int(10) DEFAULT NULL,
`user1_item12` int(4) DEFAULT NULL,
`user1_amount12` int(10) DEFAULT NULL,
`user2_item1` int(4) DEFAULT NULL,
`user2_amount1` int(10) DEFAULT NULL,
`user2_item2` int(4) DEFAULT NULL,
`user2_amount2` int(10) DEFAULT NULL,
`user2_item3` int(4) DEFAULT NULL,
`user2_amount3` int(10) DEFAULT NULL,
`user2_item4` int(4) DEFAULT NULL,
`user2_amount4` int(10) DEFAULT NULL,
`user2_item5` int(4) DEFAULT NULL,
`user2_amount5` int(10) DEFAULT NULL,
`user2_item6` int(4) DEFAULT NULL,
`user2_amount6` int(10) DEFAULT NULL,
`user2_item7` int(4) DEFAULT NULL,
`user2_amount7` int(10) DEFAULT NULL,
`user2_item8` int(4) DEFAULT NULL,
`user2_amount8` int(10) DEFAULT NULL,
`user2_item9` int(4) DEFAULT NULL,
`user2_amount9` int(10) DEFAULT NULL,
`user2_item10` int(4) DEFAULT NULL,
`user2_amount10` int(10) DEFAULT NULL,
`user2_item11` int(4) DEFAULT NULL,
`user2_amount11` int(10) DEFAULT NULL,
`user2_item12` int(4) DEFAULT NULL,
`user2_amount12` int(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `loader_error`
--
CREATE TABLE `loader_error` (
`id` int(10) NOT NULL,
`message` text NOT NULL,
`os` varchar(255) NOT NULL,
`os_version` varchar(255) NOT NULL,
`java_vendor` varchar(255) NOT NULL,
`java_version` varchar(255) NOT NULL,
`ip` varchar(15) NOT NULL,
`timestamp` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_bank_wipe_recovery`
--
CREATE TABLE `web_bank_wipe_recovery` (
`owner` int(6) NOT NULL,
`id` smallint(4) NOT NULL,
`amount` int(10) NOT NULL DEFAULT '1',
`slot` smallint(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `web_create`
--
CREATE TABLE `web_create` (
`id` int(6) NOT NULL,
`user` varchar(25) NOT NULL,
`owner` int(6) NOT NULL,
`date` int(10) NOT NULL,
`ip` varchar(15) NOT NULL DEFAULT '0.0.0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_delete`
--
CREATE TABLE `web_delete` (
`id` int(4) NOT NULL,
`user` varchar(25) NOT NULL,
`owner` int(6) NOT NULL,
`date` int(10) NOT NULL,
`ip` varchar(15) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_highscores`
--
CREATE TABLE `web_highscores` (
`id` int(11) NOT NULL,
`user` varchar(25) CHARACTER SET latin1 NOT NULL,
`owner` int(6) NOT NULL,
`date` int(10) NOT NULL,
`ip` varchar(15) CHARACTER SET latin1 NOT NULL DEFAULT '0.0.0.0',
`hs_pref` varchar(255) CHARACTER SET latin1 NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `web_inv_wipe_recovery`
--
CREATE TABLE `web_inv_wipe_recovery` (
`user` varchar(40) NOT NULL,
`id` smallint(4) NOT NULL,
`amount` int(10) NOT NULL DEFAULT '1',
`wielded` tinyint(1) NOT NULL DEFAULT '0',
`slot` tinyint(2) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `web_legacy_transfer`
--
CREATE TABLE `web_legacy_transfer` (
`id` int(11) NOT NULL,
`transfer_date` varchar(20) NOT NULL,
`transfer_ip` varchar(20) NOT NULL,
`transfer_session_id` varchar(255) NOT NULL,
`transferStartTime` varchar(20) NOT NULL,
`transferAuthMethod` varchar(50) NOT NULL,
`transferGameVersion` varchar(50) NOT NULL,
`transferCharacterId` varchar(100) DEFAULT NULL,
`transferForumId` varchar(100) DEFAULT NULL,
`newOwnerId` varchar(100) NOT NULL,
`characterToTransferId` varchar(100) NOT NULL,
`newUsername` varchar(255) NOT NULL,
`newEncodedUsername` varchar(255) NOT NULL,
`transferKey` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `web_login`
--
CREATE TABLE `web_login` (
`ip` varchar(15) NOT NULL,
`count` int(5) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_logins`
--
CREATE TABLE `web_logins` (
`account` int(10) NOT NULL,
`ip` varchar(15) NOT NULL DEFAULT '0.0.0.0',
`time` int(10) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_password`
--
CREATE TABLE `web_password` (
`id` int(11) NOT NULL,
`user` varchar(25) NOT NULL,
`owner` int(6) NOT NULL,
`date` int(10) NOT NULL,
`ip` varchar(15) NOT NULL DEFAULT '0.0.0.0',
`password` varchar(32) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_recovery`
--
CREATE TABLE `web_recovery` (
`account` int(10) NOT NULL,
`ip` varchar(15) NOT NULL,
`date` int(10) NOT NULL,
`id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_reduce`
--
CREATE TABLE `web_reduce` (
`user` bigint(23) NOT NULL,
`time` int(10) NOT NULL,
`xp_before` int(10) NOT NULL,
`xp_after` int(10) NOT NULL,
`stat` varchar(20) NOT NULL,
`id` int(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_rename`
--
CREATE TABLE `web_rename` (
`id` int(10) NOT NULL,
`owner` int(10) NOT NULL,
`date` int(10) NOT NULL,
`ip` varchar(15) NOT NULL,
`old_hash` varchar(255) NOT NULL,
`new_hash` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `web_rename_old`
--
CREATE TABLE `web_rename_old` (
`id` int(10) NOT NULL,
`user_id` int(10) NOT NULL,
`old` varchar(12) NOT NULL,
`old_hash` bigint(20) NOT NULL,
`new` varchar(12) NOT NULL,
`new_hash` bigint(20) NOT NULL,
`time` int(10) NOT NULL,
`account` int(10) NOT NULL,
`ip` varchar(15) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_staff_actions`
--
CREATE TABLE `web_staff_actions` (
`id` int(10) NOT NULL,
`owner` int(10) NOT NULL,
`user` varchar(40) NOT NULL,
`staff_id` int(10) NOT NULL,
`ip` varchar(15) CHARACTER SET latin1 NOT NULL DEFAULT '0.0.0.0',
`action_type` varchar(255) CHARACTER SET latin1 NOT NULL,
`action_date` varchar(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `web_statistics`
--
CREATE TABLE `web_statistics` (
`id` int(10) NOT NULL,
`time` int(10) NOT NULL,
`total_accounts` int(6) NOT NULL,
`accounts_today` int(4) NOT NULL,
`total_characters` int(6) NOT NULL,
`characters_today` int(4) NOT NULL,
`online` int(3) NOT NULL,
`online_unique` int(4) NOT NULL,
`online_today` int(4) NOT NULL,
`online_today_unique` int(4) NOT NULL,
`total_topics` int(6) NOT NULL,
`topics_today` int(4) NOT NULL,
`total_posts` int(6) NOT NULL,
`posts_today` int(4) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_transfer`
--
CREATE TABLE `web_transfer` (
`id` int(4) NOT NULL,
`user` varchar(25) NOT NULL,
`date` int(10) NOT NULL,
`ip` varchar(15) NOT NULL,
`from` int(6) NOT NULL,
`to` int(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_v1transfer`
--
CREATE TABLE `web_v1transfer` (
`id` int(4) NOT NULL,
`user` varchar(25) NOT NULL,
`date` int(10) NOT NULL,
`ip` varchar(15) NOT NULL,
`from` int(6) NOT NULL,
`to` int(6) NOT NULL,
`transfer_log` text NOT NULL,
`new_username` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `web_visit`
--
CREATE TABLE `web_visit` (
`id` int(11) NOT NULL,
`ip` varchar(15) NOT NULL DEFAULT '0.0.0.0',
`time` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `game_bans`
--
ALTER TABLE `game_bans`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `game_chat`
--
ALTER TABLE `game_chat`
ADD PRIMARY KEY (`id`),
ADD KEY `message` (`message`),
ADD KEY `ip` (`ip`),
ADD KEY `user` (`user`);
--
-- Indexes for table `game_collect`
--
ALTER TABLE `game_collect`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`,`account`);
--
-- Indexes for table `game_connect`
--
ALTER TABLE `game_connect`
ADD PRIMARY KEY (`id`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `game_death`
--
ALTER TABLE `game_death`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `game_drop`
--
ALTER TABLE `game_drop`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `ip` (`ip`),
ADD KEY `item` (`item`),
ADD KEY `amount` (`amount`);
--
-- Indexes for table `game_duel`
--
ALTER TABLE `game_duel`
ADD PRIMARY KEY (`id`),
ADD KEY `user1` (`user1`),
ADD KEY `user1_ip` (`user1_ip`),
ADD KEY `user2` (`user2`),
ADD KEY `user2_ip` (`user2_ip`);
--
-- Indexes for table `game_error`
--
ALTER TABLE `game_error`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `game_event`
--
ALTER TABLE `game_event`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `game_exploit`
--
ALTER TABLE `game_exploit`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`);
--
-- Indexes for table `game_generic`
--
ALTER TABLE `game_generic`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `game_global`
--
ALTER TABLE `game_global`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `ip` (`ip`),
ADD KEY `message` (`message`);
--
-- Indexes for table `game_login`
--
ALTER TABLE `game_login`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `game_pickup`
--
ALTER TABLE `game_pickup`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `ip` (`ip`),
ADD KEY `item` (`item`),
ADD KEY `amount` (`amount`);
--
-- Indexes for table `game_pm`
--
ALTER TABLE `game_pm`
ADD PRIMARY KEY (`id`),
ADD KEY `sender` (`sender`),
ADD KEY `sender_ip` (`sender_ip`),
ADD KEY `reciever` (`reciever`),
ADD KEY `reciever_ip` (`reciever_ip`),
ADD KEY `message` (`message`);
--
-- Indexes for table `game_redeem`
--
ALTER TABLE `game_redeem`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`,`account`);
--
-- Indexes for table `game_report`
--
ALTER TABLE `game_report`
ADD PRIMARY KEY (`id`),
ADD KEY `rule` (`rule`),
ADD KEY `reported` (`reported`),
ADD KEY `user` (`user`),
ADD KEY `reported_ip` (`reported_ip`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `game_report_actions`
--
ALTER TABLE `game_report_actions`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `game_report_comments`
--
ALTER TABLE `game_report_comments`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `game_script`
--
ALTER TABLE `game_script`
ADD PRIMARY KEY (`id`),
ADD KEY `id` (`id`);
--
-- Indexes for table `game_shop`
--
ALTER TABLE `game_shop`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`);
--
-- Indexes for table `game_trade`
--
ALTER TABLE `game_trade`
ADD PRIMARY KEY (`id`),
ADD KEY `user1` (`user1`),
ADD KEY `user1_ip` (`user1_ip`),
ADD KEY `user2` (`user2`),
ADD KEY `user2_ip` (`user2_ip`);
--
-- Indexes for table `loader_error`
--
ALTER TABLE `loader_error`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `web_bank_wipe_recovery`
--
ALTER TABLE `web_bank_wipe_recovery`
ADD KEY `owner` (`owner`),
ADD KEY `id` (`id`);
--
-- Indexes for table `web_create`
--
ALTER TABLE `web_create`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `owner` (`owner`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `web_delete`
--
ALTER TABLE `web_delete`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `web_highscores`
--
ALTER TABLE `web_highscores`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `owner` (`owner`),
ADD KEY `ip` (`ip`),
ADD KEY `hs_pref` (`hs_pref`);
--
-- Indexes for table `web_inv_wipe_recovery`
--
ALTER TABLE `web_inv_wipe_recovery`
ADD KEY `user` (`user`);
--
-- Indexes for table `web_legacy_transfer`
--
ALTER TABLE `web_legacy_transfer`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `web_login`
--
ALTER TABLE `web_login`
ADD KEY `ip` (`ip`),
ADD KEY `count` (`count`),
ADD KEY `ip_2` (`ip`);
--
-- Indexes for table `web_logins`
--
ALTER TABLE `web_logins`
ADD PRIMARY KEY (`id`),
ADD KEY `account` (`account`);
--
-- Indexes for table `web_password`
--
ALTER TABLE `web_password`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`),
ADD KEY `owner` (`owner`),
ADD KEY `ip` (`ip`),
ADD KEY `password` (`password`);
--
-- Indexes for table `web_recovery`
--
ALTER TABLE `web_recovery`
ADD PRIMARY KEY (`id`),
ADD KEY `account` (`account`,`ip`,`date`);
--
-- Indexes for table `web_reduce`
--
ALTER TABLE `web_reduce`
ADD PRIMARY KEY (`id`),
ADD KEY `user` (`user`,`time`);
--
-- Indexes for table `web_rename`
--
ALTER TABLE `web_rename`
ADD PRIMARY KEY (`id`),
ADD KEY `id` (`id`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `web_rename_old`
--
ALTER TABLE `web_rename_old`
ADD PRIMARY KEY (`id`),
ADD KEY `user_id` (`user_id`),
ADD KEY `id` (`id`),
ADD KEY `user_id_2` (`user_id`),
ADD KEY `old` (`old`),
ADD KEY `old_hash` (`old_hash`),
ADD KEY `new` (`new`),
ADD KEY `new_hash` (`new_hash`),
ADD KEY `account` (`account`),
ADD KEY `ip` (`ip`);
--
-- Indexes for table `web_staff_actions`
--
ALTER TABLE `web_staff_actions`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `web_statistics`
--
ALTER TABLE `web_statistics`
ADD PRIMARY KEY (`id`),
ADD KEY `time` (`time`);
--
-- Indexes for table `web_transfer`
--
ALTER TABLE `web_transfer`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `web_v1transfer`
--
ALTER TABLE `web_v1transfer`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `web_visit`
--
ALTER TABLE `web_visit`
ADD PRIMARY KEY (`id`),
ADD KEY `ip` (`ip`),
ADD KEY `ip_2` (`ip`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `game_bans`
--
ALTER TABLE `game_bans`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `game_chat`
--
ALTER TABLE `game_chat`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2714890;
--
-- AUTO_INCREMENT for table `game_collect`
--
ALTER TABLE `game_collect`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=90;
--
-- AUTO_INCREMENT for table `game_connect`
--
ALTER TABLE `game_connect`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `game_death`
--
ALTER TABLE `game_death`
MODIFY `id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1007128;
--
-- AUTO_INCREMENT for table `game_drop`
--
ALTER TABLE `game_drop`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=496013;
--
-- AUTO_INCREMENT for table `game_duel`
--
ALTER TABLE `game_duel`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=551932;
--
-- AUTO_INCREMENT for table `game_error`
--
ALTER TABLE `game_error`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33536;
--
-- AUTO_INCREMENT for table `game_event`
--
ALTER TABLE `game_event`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=382368;
--
-- AUTO_INCREMENT for table `game_exploit`
--
ALTER TABLE `game_exploit`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13756616;
--
-- AUTO_INCREMENT for table `game_generic`
--
ALTER TABLE `game_generic`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=36780;
--
-- AUTO_INCREMENT for table `game_global`
--
ALTER TABLE `game_global`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=478867;
--
-- AUTO_INCREMENT for table `game_login`
--
ALTER TABLE `game_login`
MODIFY `id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4182434;
--
-- AUTO_INCREMENT for table `game_pickup`
--
ALTER TABLE `game_pickup`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3375365;
--
-- AUTO_INCREMENT for table `game_pm`
--
ALTER TABLE `game_pm`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11725351;
--
-- AUTO_INCREMENT for table `game_redeem`
--
ALTER TABLE `game_redeem`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=206;
--
-- AUTO_INCREMENT for table `game_report`
--
ALTER TABLE `game_report`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `game_report_actions`
--
ALTER TABLE `game_report_actions`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `game_report_comments`
--
ALTER TABLE `game_report_comments`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `game_script`
--
ALTER TABLE `game_script`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `game_shop`
--
ALTER TABLE `game_shop`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=75549;
--
-- AUTO_INCREMENT for table `game_trade`
--
ALTER TABLE `game_trade`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2333814;
--
-- AUTO_INCREMENT for table `loader_error`
--
ALTER TABLE `loader_error`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `web_create`
--
ALTER TABLE `web_create`
MODIFY `id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=89367;
--
-- AUTO_INCREMENT for table `web_delete`
--
ALTER TABLE `web_delete`
MODIFY `id` int(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11249;
--
-- AUTO_INCREMENT for table `web_highscores`
--
ALTER TABLE `web_highscores`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=43586;
--
-- AUTO_INCREMENT for table `web_legacy_transfer`
--
ALTER TABLE `web_legacy_transfer`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `web_logins`
--
ALTER TABLE `web_logins`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `web_password`
--
ALTER TABLE `web_password`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14842;
--
-- AUTO_INCREMENT for table `web_recovery`
--
ALTER TABLE `web_recovery`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `web_reduce`
--
ALTER TABLE `web_reduce`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `web_rename`
--
ALTER TABLE `web_rename`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2152;
--
-- AUTO_INCREMENT for table `web_rename_old`
--
ALTER TABLE `web_rename_old`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1443;
--
-- AUTO_INCREMENT for table `web_staff_actions`
--
ALTER TABLE `web_staff_actions`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9438;
--
-- AUTO_INCREMENT for table `web_statistics`
--
ALTER TABLE `web_statistics`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `web_transfer`
--
ALTER TABLE `web_transfer`
MODIFY `id` int(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1274;
--
-- AUTO_INCREMENT for table `web_v1transfer`
--
ALTER TABLE `web_v1transfer`
MODIFY `id` int(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8271;
--
-- AUTO_INCREMENT for table `web_visit`
--
ALTER TABLE `web_visit`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=156415;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 */;
| true |
37b4908ce0d87d08663f51edaf0985ca5842ae7a | SQL | PierrickJACQUETTE/Theatre-du-Chrysanteme | /createTable.sql | UTF-8 | 2,976 | 3.53125 | 4 | [] | no_license | DROP TABLE IF EXISTS ContratDeVentes ;
DROP TABLE IF EXISTS CoutProds ;
DROP TABLE IF EXISTS Reservations;
DROP TABLE IF EXISTS Vendus;
DROP TABLE IF EXISTS Tickets ;
DROP TABLE IF EXISTS Tarifs;
DROP TABLE IF EXISTS Representations ;
DROP TABLE IF EXISTS Subventions ;
DROP TABLE IF EXISTS SpectaclesCres ;
DROP TABLE IF EXISTS SpectaclesAchetes ;
DROP TABLE IF EXISTS Spectacles ;
DROP TABLE IF EXISTS Salles ;
DROP TABLE IF EXISTS Organismes ;
DROP TABLE IF EXISTS DateCourante ;
DROP TYPE IF EXISTS EnumActions ;
CREATE TABLE DateCourante (
date TIMESTAMP NOT NULL
);
CREATE TYPE EnumActions AS ENUM ('creation', 'accueil');
CREATE TABLE Organismes (
idOrganisme SERIAL PRIMARY KEY,
nom VARCHAR(50) NOT NULL UNIQUE,
ville VARCHAR(50) NOT NULL,
departement VARCHAR(50) NOT NULL,
pays VARCHAR(50) NOT NULL
);
CREATE TABLE Salles (
idSalle SERIAL PRIMARY KEY,
capacite INTEGER NOT NULL CHECK (capacite > 0),
nom VARCHAR(50) UNIQUE NOT NULL,
ville VARCHAR(50) NOT NULL,
departement VARCHAR(50) NOT NULL,
pays VARCHAR(50) NOT NULL
);
CREATE TABLE Spectacles (
idSpectacle SERIAL PRIMARY KEY,
nom VARCHAR(50) UNIQUE NOT NULL
);
CREATE TABLE SpectaclesAchetes (
idSpectacle SERIAL PRIMARY KEY REFERENCES Spectacles,
prix INTEGER NOT NULL CHECK (prix > 0),
date TIMESTAMP,
idSalle SERIAL REFERENCES Salles
);
CREATE TABLE SpectaclesCres (
idSpectacle SERIAL PRIMARY KEY REFERENCES Spectacles
);
CREATE TABLE CoutProds (
idCoutProd SERIAL PRIMARY KEY,
prix INTEGER NOT NULL CHECK (prix > 0),
date TIMESTAMP,
idSpectacle SERIAL REFERENCES SpectaclesCres
);
CREATE TABLE ContratDeVentes (
idContratDeVente SERIAL PRIMARY KEY,
prix INTEGER NOT NULL CHECK (prix > 0),
date TIMESTAMP,
idSpectacle SERIAL REFERENCES SpectaclesCres,
idSalle SERIAL REFERENCES Salles
);
CREATE TABLE Subventions (
action EnumActions NOT NULL,
date TIMESTAMP,
prix INTEGER NOT NULL CHECK (prix > 0),
idOrganisme SERIAL REFERENCES Organismes,
idSpectacle SERIAL REFERENCES Spectacles,
PRIMARY KEY (idOrganisme, idSpectacle)
);
CREATE TABLE Representations (
idRepresentation SERIAL PRIMARY KEY,
date TIMESTAMP,
dateVente TIMESTAMP,
lieu VARCHAR(50) NOT NULL,
nbPlaces Integer NOT NULL CHECK (nbPlaces > 0),
idSpectacle SERIAL REFERENCES Spectacles
);
CREATE TABLE Tarifs (
idTarif SERIAL PRIMARY KEY,
nom VARCHAR(50) NOT NULL,
prix INTEGER CHECK (prix >= 0),
reduction INTEGER CHECK (reduction >= 0 AND reduction <= 100 ),
support VARCHAR(50),
nombre INTEGER,
idRepresentation SERIAL REFERENCES Representations
);
CREATE TABLE Tickets (
idTicket SERIAL PRIMARY KEY,
nom VARCHAR(50) NOT NULL,
idReference SERIAL NOT NULL,
idRepresentation SERIAL REFERENCES Representations,
idTarif SERIAL REFERENCES Tarifs
);
CREATE TABLE Reservations (
idTicket SERIAL PRIMARY KEY REFERENCES Tickets,
dateLimite TIMESTAMP
);
CREATE TABLE Vendus (
idTicket SERIAL PRIMARY KEY REFERENCES Tickets
);
| true |
4cbec2e9ddaed1d9a2807a723dadcf51fb6722f3 | SQL | Yuri063/rtk-de-project | /SQL/dimensions/report_dim_billing_year.sql | UTF-8 | 380 | 3.296875 | 3 | [] | no_license | -- 8.2.1 INSERT INTO DEMENSION TABLEs REPORT_DIM_BILLING_YEAR
insert into {{ params.prefix }}_report_dim_billing_year(billing_year_key)
select distinct billing_year as billing_year_key
from {{ params.prefix }}_report_tmp_{{ execution_date.year }} a
left join {{ params.prefix }}_report_dim_billing_year b on b.billing_year_key = a.billing_year
where b.billing_year_key is null;
| true |
1638acfdecf15a0c702f302305cea152ba13efdf | SQL | johanv/iwwa-export | /queries/pubs-phone.sql | UTF-8 | 223 | 3.203125 | 3 | [
"MIT"
] | permissive | SELECT contact_id, location_type_id, is_primary, phone, phone_ext, phone_numeric, phone_type_id
FROM civicrm_phone p JOIN civicrm_contact c ON p.contact_id = c.id
WHERE c.contact_sub_type LIKE '%caf%' AND c.is_deleted = 0; | true |
461e9b19043ec2065dd2dbe20fb706eef8fea62e | SQL | kushalasn/sql-queries | /salesperson.sql | UTF-8 | 350 | 3.359375 | 3 | [] | no_license |
SELECT name
from salesperson
where sales_id not in (select o.sales_id
from orders as o
join company as c
on o.com_id=c.com_id
where c.name='RED'
)
| true |
e97031a681b779d9421d1659b5f2c40d254b4485 | SQL | CBIIT/kunkelm_adhoc | /dtp_datasystem/DataSystemBuilder/trunk/schema-create.sql | UTF-8 | 13,699 | 3.15625 | 3 | [] | no_license |
create table AD_HOC_CMPD (
ID BIGINT not null,
CMPD_OWNER CHARACTER VARYING(1024) not null,
AD_HOC_CMPD_ID BIGINT unique,
NAME CHARACTER VARYING(1024),
ORIGINAL_AD_HOC_CMPD_ID BIGINT,
AD_HOC_CMPD_PARENT_FRAGMENT_FK BIGINT unique,
primary key (ID)
);
create table AD_HOC_CMPD_FRAGMENT (
ID BIGINT not null,
AD_HOC_CMPD_FRAGMENT_P_CHEM_FK BIGINT unique,
AD_HOC_CMPD_FRAGMENT_STRUCT_FK BIGINT unique,
AD_HOC_CMPD_FK BIGINT,
primary key (ID)
);
create table AD_HOC_CMPD_FRAGMENT_P_CHEM (
ID BIGINT not null,
MW DOUBLE PRECISION,
MF CHARACTER VARYING(1024),
ALOGP DOUBLE PRECISION,
LOGD DOUBLE PRECISION,
HBA INTEGER,
HBD INTEGER,
SA DOUBLE PRECISION,
PSA DOUBLE PRECISION,
primary key (ID)
);
create table AD_HOC_CMPD_FRAGMENT_STRUCTURE (
ID BIGINT not null,
SMILES CHARACTER VARYING(1024),
INCHI CHARACTER VARYING(1024),
MOL CHARACTER VARYING(1024),
INCHI_AUX CHARACTER VARYING(1024),
CTAB TEXT,
primary key (ID)
);
create table CMPD (
ID BIGINT not null,
primary key (ID)
);
create table CMPD_ALIAS (
ID BIGINT not null,
ALIAS CHARACTER VARYING(1024) not null,
CMPD_ALIAS_TYPE_FK BIGINT not null,
primary key (ID)
);
create table CMPD_ALIASES2NSC_CMPDS (
NSC_CMPDS_FK BIGINT not null,
CMPD_ALIASES_FK BIGINT not null,
primary key (NSC_CMPDS_FK, CMPD_ALIASES_FK)
);
create table CMPD_ALIAS_TYPE (
ID BIGINT not null,
ALIAS_TYPE CHARACTER VARYING(1024) not null unique,
primary key (ID)
);
create table CMPD_BIO_ASSAY (
ID BIGINT not null,
NCI60 INTEGER,
HF INTEGER,
XENO INTEGER,
primary key (ID)
);
create table CMPD_FRAGMENT (
ID BIGINT not null,
CMPD_FRAGMENT_STRUCTURE_FK BIGINT unique,
CMPD_KNOWN_SALT_FK BIGINT,
CMPD_FRAGMENT_P_CHEM_FK BIGINT unique,
NSC_CMPD_FK BIGINT,
primary key (ID)
);
create table CMPD_FRAGMENT_P_CHEM (
ID BIGINT not null,
MW DOUBLE PRECISION,
MF CHARACTER VARYING(1024),
ALOGP DOUBLE PRECISION,
LOGD DOUBLE PRECISION,
HBA INTEGER,
HBD INTEGER,
SA DOUBLE PRECISION,
PSA DOUBLE PRECISION,
primary key (ID)
);
create table CMPD_FRAGMENT_STRUCTURE (
ID BIGINT not null,
SMILES CHARACTER VARYING(1024),
INCHI CHARACTER VARYING(1024),
MOL CHARACTER VARYING(1024),
INCHI_AUX CHARACTER VARYING(1024),
CTAB TEXT,
primary key (ID)
);
create table CMPD_INVENTORY (
ID BIGINT not null,
INVENTORY DOUBLE PRECISION,
NSC_CMPD_FK BIGINT,
primary key (ID)
);
create table CMPD_KNOWN_SALT (
ID BIGINT not null,
MOL CHARACTER VARYING(1024) not null,
SMILES CHARACTER VARYING(1024) not null,
SALT_NAME CHARACTER VARYING(1024) not null,
primary key (ID)
);
create table CMPD_LIST (
ID BIGINT not null,
LIST_NAME CHARACTER VARYING(1024) not null,
DATE_CREATED TIMESTAMP WITHOUT TIME ZONE not null,
LIST_OWNER CHARACTER VARYING(1024) not null,
SHARE_WITH CHARACTER VARYING(1024) not null,
CMPD_LIST_ID BIGINT unique,
COUNT_LIST_MEMBERS INTEGER,
primary key (ID)
);
create table CMPD_LIST_MEMBER (
ID BIGINT not null,
CMPD_FK BIGINT not null,
CMPD_LIST_FK BIGINT not null,
primary key (ID)
);
create table CMPD_PLATE (
ID BIGINT not null,
PLATE_NAME CHARACTER VARYING(1024) not null,
PLATE_ROW CHARACTER VARYING(1024) not null,
PLATE_COLUMN CHARACTER VARYING(1024) not null,
primary key (ID)
);
create table CMPD_PLATES2NSC_CMPDS (
NSC_CMPDS_FK BIGINT not null,
CMPD_PLATES_FK BIGINT not null,
primary key (NSC_CMPDS_FK, CMPD_PLATES_FK)
);
create table CMPD_PROJECT (
ID BIGINT not null,
PROJECT_CODE CHARACTER VARYING(1024) not null unique,
PROJECT_NAME CHARACTER VARYING(1024) not null unique,
primary key (ID)
);
create table CMPD_PROJECTS2NSC_CMPDS (
NSC_CMPDS_FK BIGINT not null,
CMPD_PROJECTS_FK BIGINT not null,
primary key (NSC_CMPDS_FK, CMPD_PROJECTS_FK)
);
create table CMPD_PUB_CHEM_SID (
ID BIGINT not null,
SID BIGINT,
primary key (ID)
);
create table CMPD_PUB_CHEM_SIDS2NSC_CMPDS (
NSC_CMPDS_FK BIGINT not null,
CMPD_PUB_CHEM_SIDS_FK BIGINT not null,
primary key (NSC_CMPDS_FK, CMPD_PUB_CHEM_SIDS_FK)
);
create table CMPD_RELATED (
ID BIGINT not null,
NSC_CMPD_FK BIGINT not null unique,
CMPD_RELATION_TYPE_FK BIGINT not null unique,
primary key (ID)
);
create table CMPD_RELATION_TYPE (
ID BIGINT not null,
RELATION_TYPE CHARACTER VARYING(1024) not null unique,
primary key (ID)
);
create table CMPD_SET (
ID BIGINT not null,
SET_NAME CHARACTER VARYING(1024) not null,
primary key (ID)
);
create table CMPD_SETS2NSC_CMPDS (
NSC_CMPDS_FK BIGINT not null,
CMPD_SETS_FK BIGINT not null,
primary key (NSC_CMPDS_FK, CMPD_SETS_FK)
);
create table CMPD_TARGET (
ID BIGINT not null,
TARGET CHARACTER VARYING(1024) not null,
primary key (ID)
);
create table CMPD_TARGETS2NSC_CMPDS (
NSC_CMPDS_FK BIGINT not null,
CMPD_TARGETS_FK BIGINT not null,
primary key (NSC_CMPDS_FK, CMPD_TARGETS_FK)
);
create table CMPD_VIEW (
ID BIGINT not null,
MW DOUBLE PRECISION,
MF CHARACTER VARYING(1024),
ALOGP DOUBLE PRECISION,
LOGD DOUBLE PRECISION,
HBA INTEGER,
HBD INTEGER,
SA DOUBLE PRECISION,
PSA DOUBLE PRECISION,
SMILES CHARACTER VARYING(1024),
INCHI CHARACTER VARYING(1024),
MOL CHARACTER VARYING(1024),
INCHI_AUX CHARACTER VARYING(1024),
NAME CHARACTER VARYING(1024),
NSC_CMPD_ID BIGINT unique,
PREFIX CHARACTER VARYING(1024),
NSC INTEGER unique,
CONF CHARACTER VARYING(1024),
DISTRIBUTION CHARACTER VARYING(1024),
CAS CHARACTER VARYING(1024),
NCI60 INTEGER,
HF INTEGER,
XENO INTEGER,
CMPD_OWNER CHARACTER VARYING(1024),
AD_HOC_CMPD_ID BIGINT unique,
FORMATTED_TARGETS_STRING CHARACTER VARYING(1024),
FORMATTED_SETS_STRING CHARACTER VARYING(1024),
FORMATTED_PROJECTS_STRING CHARACTER VARYING(1024),
FORMATTED_PLATES_STRING CHARACTER VARYING(1024),
FORMATTED_ALIASES_STRING CHARACTER VARYING(1024),
primary key (ID)
);
create table nsc_cmpd (
id bigint not null,
name character varying(1024),
nsc_cmpd_id bigint unique,
prefix character varying(1024) not null,
nsc integer unique,
conf character varying(1024) not null,
distribution character varying(1024) not null,
cas character varying(1024),
pseudo_atoms character varying(1024),
salt_name character varying(1024),
salt_smiles character varying(1024),
salt_id bigint,
cmpd_parent_fragment_fk bigint unique,
cmpd_bio_assay_fk bigint unique,
primary key (id)
);
create table RDKIT_MOL (
ID BIGINT not null,
NSC INTEGER,
MOL CHARACTER VARYING(1024) not null,
primary key (ID)
);
alter table AD_HOC_CMPD
add constraint AD_HOC_CMPDIFKC
foreign key (ID)
references CMPD;
alter table AD_HOC_CMPD
add constraint AD_HOC_CMPD_AD_HOC_CMPD_PARENC
foreign key (AD_HOC_CMPD_PARENT_FRAGMENT_FK)
references AD_HOC_CMPD_FRAGMENT;
alter table AD_HOC_CMPD_FRAGMENT
add constraint AD_HOC_CMPD_FRAGMENT_AD_HOC_CH
foreign key (AD_HOC_CMPD_FRAGMENT_STRUCT_FK)
references AD_HOC_CMPD_FRAGMENT_STRUCTURE;
alter table AD_HOC_CMPD_FRAGMENT
add constraint AD_HOC_CMPD_FRAGMENT_AD_HOC_CC
foreign key (AD_HOC_CMPD_FRAGMENT_P_CHEM_FK)
references AD_HOC_CMPD_FRAGMENT_P_CHEM;
alter table AD_HOC_CMPD_FRAGMENT
add constraint AD_HOC_CMPD_FRAGMENT_AD_HOC_CD
foreign key (AD_HOC_CMPD_FK)
references AD_HOC_CMPD;
alter table CMPD_ALIAS
add constraint CMPD_ALIAS_CMPD_ALIAS_TYPE_FKC
foreign key (CMPD_ALIAS_TYPE_FK)
references CMPD_ALIAS_TYPE;
alter table CMPD_ALIASES2NSC_CMPDS
add constraint CMPD_ALIAS_NSC_CMPDS_FKC
foreign key (NSC_CMPDS_FK)
references NSC_CMPD;
alter table CMPD_ALIASES2NSC_CMPDS
add constraint NSC_CMPD_CMPD_ALIASES_FKC
foreign key (CMPD_ALIASES_FK)
references CMPD_ALIAS;
alter table CMPD_FRAGMENT
add constraint CMPD_FRAGMENT_NSC_CMPD_FKC
foreign key (NSC_CMPD_FK)
references NSC_CMPD;
alter table CMPD_FRAGMENT
add constraint CMPD_FRAGMENT_CMPD_KNOWN_SALTC
foreign key (CMPD_KNOWN_SALT_FK)
references CMPD_KNOWN_SALT;
alter table CMPD_FRAGMENT
add constraint CMPD_FRAGMENT_CMPD_FRAGMENT_SC
foreign key (CMPD_FRAGMENT_STRUCTURE_FK)
references CMPD_FRAGMENT_STRUCTURE;
alter table CMPD_FRAGMENT
add constraint CMPD_FRAGMENT_CMPD_FRAGMENT_PC
foreign key (CMPD_FRAGMENT_P_CHEM_FK)
references CMPD_FRAGMENT_P_CHEM;
alter table CMPD_INVENTORY
add constraint CMPD_INVENTORY_NSC_CMPD_FKC
foreign key (NSC_CMPD_FK)
references NSC_CMPD;
alter table CMPD_LIST_MEMBER
add constraint CMPD_LIST_MEMBER_CMPD_LIST_FKC
foreign key (CMPD_LIST_FK)
references CMPD_LIST;
alter table CMPD_LIST_MEMBER
add constraint CMPD_LIST_MEMBER_CMPD_FKC
foreign key (CMPD_FK)
references CMPD;
alter table CMPD_PLATES2NSC_CMPDS
add constraint CMPD_PLATE_NSC_CMPDS_FKC
foreign key (NSC_CMPDS_FK)
references NSC_CMPD;
alter table CMPD_PLATES2NSC_CMPDS
add constraint NSC_CMPD_CMPD_PLATES_FKC
foreign key (CMPD_PLATES_FK)
references CMPD_PLATE;
alter table CMPD_PROJECTS2NSC_CMPDS
add constraint CMPD_PROJECT_NSC_CMPDS_FKC
foreign key (NSC_CMPDS_FK)
references NSC_CMPD;
alter table CMPD_PROJECTS2NSC_CMPDS
add constraint NSC_CMPD_CMPD_PROJECTS_FKC
foreign key (CMPD_PROJECTS_FK)
references CMPD_PROJECT;
alter table CMPD_PUB_CHEM_SIDS2NSC_CMPDS
add constraint CMPD_PUB_CHEM_SID_NSC_CMPDS_FC
foreign key (NSC_CMPDS_FK)
references NSC_CMPD;
alter table CMPD_PUB_CHEM_SIDS2NSC_CMPDS
add constraint NSC_CMPD_CMPD_PUB_CHEM_SIDS_FC
foreign key (CMPD_PUB_CHEM_SIDS_FK)
references CMPD_PUB_CHEM_SID;
alter table CMPD_RELATED
add constraint CMPD_RELATED_NSC_CMPD_FKM
foreign key (NSC_CMPD_FK)
references NSC_CMPD;
alter table CMPD_RELATED
add constraint CMPD_RELATED_CMPD_RELATION_TYC
foreign key (CMPD_RELATION_TYPE_FK)
references CMPD_RELATION_TYPE;
alter table CMPD_SETS2NSC_CMPDS
add constraint CMPD_SET_NSC_CMPDS_FKC
foreign key (NSC_CMPDS_FK)
references NSC_CMPD;
alter table CMPD_SETS2NSC_CMPDS
add constraint NSC_CMPD_CMPD_SETS_FKC
foreign key (CMPD_SETS_FK)
references CMPD_SET;
create index cmpd_target_target_idx on CMPD_TARGET (TARGET);
alter table CMPD_TARGETS2NSC_CMPDS
add constraint CMPD_TARGET_NSC_CMPDS_FKC
foreign key (NSC_CMPDS_FK)
references NSC_CMPD;
alter table CMPD_TARGETS2NSC_CMPDS
add constraint NSC_CMPD_CMPD_TARGETS_FKC
foreign key (CMPD_TARGETS_FK)
references CMPD_TARGET;
alter table NSC_CMPD
add constraint NSC_CMPDIFKC
foreign key (ID)
references CMPD;
alter table NSC_CMPD
add constraint NSC_CMPD_CMPD_PARENT_FRAGMENTC
foreign key (CMPD_PARENT_FRAGMENT_FK)
references CMPD_FRAGMENT;
alter table NSC_CMPD
add constraint NSC_CMPD_CMPD_BIO_ASSAY_FKC
foreign key (CMPD_BIO_ASSAY_FK)
references CMPD_BIO_ASSAY;
create index rdkit_mol_nsc_idx on RDKIT_MOL (NSC);
create sequence AD_HOC_CMPD_FRAGMENT_P_CHE_SEQ;
create sequence AD_HOC_CMPD_FRAGMENT_SEQ;
create sequence AD_HOC_CMPD_FRAGMENT_STRUC_SEQ;
create sequence CMPD_ALIAS_SEQ;
create sequence CMPD_ALIAS_TYPE_SEQ;
create sequence CMPD_BIO_ASSAY_SEQ;
create sequence CMPD_FRAGMENT_P_CHEM_SEQ;
create sequence CMPD_FRAGMENT_SEQ;
create sequence CMPD_FRAGMENT_STRUCTURE_SEQ;
create sequence CMPD_INVENTORY_SEQ;
create sequence CMPD_KNOWN_SALT_SEQ;
create sequence CMPD_LIST_MEMBER_SEQ;
create sequence CMPD_LIST_SEQ;
create sequence CMPD_PLATE_SEQ;
create sequence CMPD_PROJECT_SEQ;
create sequence CMPD_PUB_CHEM_SID_SEQ;
create sequence CMPD_RELATED_SEQ;
create sequence CMPD_RELATION_TYPE_SEQ;
create sequence CMPD_SEQ;
create sequence CMPD_SET_SEQ;
create sequence CMPD_TARGET_SEQ;
create sequence hibernate_sequence;
| true |
60bcab96e49a560e036247064589267a729455e4 | SQL | yzh1024/employee_system | /mysql/employee_system.sql | UTF-8 | 3,691 | 3.25 | 3 | [] | no_license | /*
Navicat Premium Data Transfer
Source Server : yzh1024
Source Server Type : MySQL
Source Server Version : 50562
Source Host : localhost:3306
Source Schema : employee_system
Target Server Type : MySQL
Target Server Version : 50562
File Encoding : 65001
Date: 12/07/2020 16:05:43
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for department
-- ----------------------------
DROP TABLE IF EXISTS `department`;
CREATE TABLE `department` (
`ID` int(11) NOT NULL,
`部门名称` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL,
`备注` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL,
`操作` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of department
-- ----------------------------
INSERT INTO `department` VALUES (1, '产品团队', NULL, NULL);
INSERT INTO `department` VALUES (2, '研发团队', NULL, NULL);
INSERT INTO `department` VALUES (3, '项目销售', NULL, NULL);
INSERT INTO `department` VALUES (4, '项目管理', NULL, NULL);
INSERT INTO `department` VALUES (5, '成本结算', NULL, NULL);
INSERT INTO `department` VALUES (6, '主管团队', NULL, NULL);
-- ----------------------------
-- Table structure for job
-- ----------------------------
DROP TABLE IF EXISTS `job`;
CREATE TABLE `job` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`岗位名称` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL,
`所属部门` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL,
`备注` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL,
`操作` varchar(255) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of job
-- ----------------------------
INSERT INTO `job` VALUES (1, 'Java工程师', '2', NULL, NULL);
INSERT INTO `job` VALUES (2, '产品工程师', '2', NULL, NULL);
INSERT INTO `job` VALUES (3, 'C++工程师', '2', NULL, NULL);
INSERT INTO `job` VALUES (4, 'Android工程师', '2', NULL, NULL);
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(255) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`num` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`depar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`job` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`role` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 235 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, '张三', '123', '研发部', 'Java工程师', '团队同事', '123333333');
INSERT INTO `user` VALUES (2, '李四', '120', '管理部', '副经理', 'C#工程师', '13577554587');
INSERT INTO `user` VALUES (123, '阿萨德', 'aqwsd', 'as', 'asd', 'asd', 'sad');
SET FOREIGN_KEY_CHECKS = 1;
| true |
c8e51b1f07a6c0cc3cdbf9880535270289bb873f | SQL | tarikhero/TrabalhoWeb | /TrabalhoWeb/SQL Files/Creates.sql | UTF-8 | 2,961 | 3.90625 | 4 | [] | no_license | SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
DROP DATABASE IF EXISTS `TrabalhoWeb`;
CREATE DATABASE `TrabalhoWeb`;
USE `TrabalhoWeb`;
-- Estrutura da tabela `usuario`
CREATE TABLE `usuario` (
`id` int(11) NOT NULL PRIMARY KEY auto_increment,
`nome` varchar(100) NOT NULL,
`telefone` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`cod_grupo` int(11) NOT NULL,
`detalhes` text NOT NULL,
`foto` text NOT NULL,
`login` varchar(50) NOT NULL UNIQUE,
`senha` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Estrutura da tabela `grupo`
CREATE TABLE `grupo` (
`id` int(11) NOT NULL PRIMARY KEY auto_increment,
`nome` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Estrutura da tabela `postagem`
CREATE TABLE `postagem` (
`id` int(11) NOT NULL PRIMARY KEY auto_increment,
`id_usuario` int(11) NOT NULL,
`conteudo` varchar(100) NOT NULL ,
`foto` text NOT NULL,
`data` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `postagem` ADD CONSTRAINT `id_usuario` FOREIGN KEY ( `id_usuario` ) REFERENCES `usuario` ( `id` ) ;
-- Estrutura da tabela `comentario`
CREATE TABLE `comentario` (
`id` int(11) NOT NULL PRIMARY KEY auto_increment,
`id_postagem_coment` int(11) NOT NULL,
`id_usuario_coment` int(11) NOT NULL,
`conteudo` varchar(100) NOT NULL ,
`data` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `comentario` ADD CONSTRAINT `id_postagem_coment` FOREIGN KEY ( `id_postagem_coment` ) REFERENCES `postagem` ( `id` ) ;
ALTER TABLE `comentario` ADD CONSTRAINT `id_usuario_coment` FOREIGN KEY ( `id_usuario_coment` ) REFERENCES `usuario` ( `id` ) ;
-- Estrutura da tabela `curtida`
CREATE TABLE `curtida` (
`id` int(11) NOT NULL PRIMARY KEY auto_increment,
`id_postagem_curtida`int(11) NOT NULL,
`id_usuario_curtida` int(11) NOT NULL,
`quantidade` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `curtida` ADD CONSTRAINT `id_postagem_curtida` FOREIGN KEY ( `id_postagem_curtida` ) REFERENCES `comentario` ( `id` );
ALTER TABLE `curtida` ADD CONSTRAINT `id_usuario_curtida` FOREIGN KEY ( `id_usuario_curtida` ) REFERENCES `usuario` ( `id` ) ;
-- Estrutura da tabela `amizade`
CREATE TABLE `amizade` (
`id_usuario1` int(11) NOT NULL,
`id_usuario2` int(11) NOT NULL,
`data` datetime not null
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- Estrutura da tabela `solicitacao_amizade`
CREATE TABLE `solicitacao_amizade` (
`id` int(11) NOT NULL PRIMARY KEY auto_increment,
`id_usuario_solicitante` int(11) NOT NULL,
`id_usuario_solicitado` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `solicitacao_amizade` ADD CONSTRAINT `id_usuario_solicitante` FOREIGN KEY ( `id_usuario_solicitante` ) REFERENCES `usuario` ( `id` ) ;
ALTER TABLE `solicitacao_amizade` ADD CONSTRAINT `id_usuario_solicitado` FOREIGN KEY ( `id_usuario_solicitado` ) REFERENCES `usuario` ( `id` ) ; | true |
4803e0367f1bf3c8b730f896c2211e1254e8836b | SQL | trmcnealy/EngineeringToolsServer | /Services/OilGasQueries/MinMaxMonthlyProduction.sql | UTF-8 | 186 | 2.953125 | 3 | [] | no_license | SELECT min("MonthlyProduction"."OilVolume") AS "min", max("MonthlyProduction"."OilVolume") AS "max"
FROM "Well"
INNER JOIN "MonthlyProduction"
ON "Well"."Id"="MonthlyProduction"."WellId" | true |
312d75ad51e4c2acbcb3fedeaef5189d2c7175a7 | SQL | huangyk/MySQL_Development_Skills | /在子查询中匹配两个值/避免由于子查询中的数据产生的重复.sql | UTF-8 | 1,055 | 4.5625 | 5 | [] | no_license | SELECT user_name
FROM user1
WHERE id IN (SELECT user_id
FROM user_kills);
SELECT *
FROM user_kills;
# 子查询去重 DISTINCT
SELECT DISTINCT a.user_name
FROM user1 a
JOIN user_kills b ON a.id = b.user_id;
# 多列过滤的使用场景
# 查询出每一个取经人打怪最多的日期,并列出取经人的姓名,打怪最多的日期和打怪的数量
SELECT
user_id,
max(kills) AS cnt
FROM user_kills
GROUP BY user_id;
# 普通方法
SELECT
a.user_name,
b.timestr,
kills
FROM user1 a
JOIN user_kills b ON a.id = b.user_id
JOIN (SELECT
user_id,
max(kills) AS cnt
FROM user_kills
GROUP BY user_id) c ON b.user_id = c.user_id AND b.kills = c.cnt;
# 多列过滤
SELECT
a.user_name,
b.timestr,
kills
FROM user1 a
JOIN user_kills b ON a.id = b.user_id
WHERE (b.user_id, b.kills) IN (SELECT
user_id,
max(kills)
FROM user_kills
GROUP BY user_id);
| true |
94adcfefe95a1e81871e57b69a2437ee1cc8c909 | SQL | Sanyyouisf/chinook--SanyYousif- | /8-Total_invoices_{2011}.sql | UTF-8 | 150 | 3.015625 | 3 | [] | no_license | /*8-How many Invoices were there in 2011?*/
select count (invoiceDate) As InvoicesIn2011
from Invoice
where strftime('%Y', InvoiceDate) = '2011' | true |
a8298e698d1dd07b88dd9c0bdb23c4147832766e | SQL | DimolSPA/Dimol-Fix-Carteras | /Dimol.Carteras/Dimol.Carteras.Database/dbo/Stored Procedures/Procs2/Delete_Profesores.sql | UTF-8 | 213 | 2.515625 | 3 | [] | no_license |
Create Procedure Delete_Profesores(@prf_codemp integer, @prf_prfid integer) as
DELETE FROM profesores
WHERE ( profesores.prf_codemp = @prf_codemp ) AND
( profesores.prf_prfid = @prf_prfid )
| true |
7929cad0408fafd0fede16445f1fd195b7b5e50c | SQL | HristoShabanakov/Databases-Basics-MS-SQL-Server-September-2019 | /MS SQL Server - September 2019/09.Exam Preparation/ExamPreparation I/07.Passenger Trips.sql | UTF-8 | 261 | 3.578125 | 4 | [] | no_license | SELECT CONCAT(p.FirstName, ' ' , p.LastName) AS [Full Name],
f.Origin,
f.Destination
FROM Passengers AS p
JOIN Tickets AS t
ON t.PassengerId = p.Id
JOIN Flights AS f
ON t.FlightId = f.Id
ORDER BY [Full Name], f.Origin, f.Destination
| true |
fd05140bdc88c93a722d8c267e99db80e3f13298 | SQL | a740485/shopBackend | /shop.sql | UTF-8 | 4,521 | 3.078125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- 主機: 127.0.0.1
-- 產生時間:
-- 伺服器版本: 10.1.38-MariaDB
-- PHP 版本: 7.3.2
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 */;
--
-- 資料庫: `shop`
--
-- --------------------------------------------------------
--
-- 資料表結構 `cart`
--
CREATE TABLE `cart` (
`user_id` varchar(20) NOT NULL,
`product_id` varchar(20) NOT NULL,
`create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- 傾印資料表的資料 `cart`
--
INSERT INTO `cart` (`user_id`, `product_id`, `create_at`) VALUES
('1', '5', '2020-10-08 06:34:49'),
('1', '6', '2020-10-23 05:35:28'),
('1', '7', '2020-10-08 06:22:04');
-- --------------------------------------------------------
--
-- 資料表結構 `product`
--
CREATE TABLE `product` (
`id` int(20) NOT NULL,
`user_id` int(20) NOT NULL,
`title` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`img` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL,
`price` int(5) DEFAULT NULL,
`amount` int(5) DEFAULT NULL,
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- 傾印資料表的資料 `product`
--
INSERT INTO `product` (`id`, `user_id`, `title`, `img`, `price`, `amount`, `update_time`) VALUES
(5, 1, 'MINI液晶行動電源 10000mAh 迷你行動電源 方便攜帶 智能晶片 大容量小體積 LED數據 【蝦皮團購】', 'https://cf.shopee.tw/file/4e93e07490f24b76d625a15d830a8992_tn', 100, 10, '2020-10-18 07:28:26'),
(6, 1, '【買到戀愛】韓系文青ins純色V領外搭針織背心【M8121】', 'https://cf.shopee.tw/file/1b5295ed91100c4c29d629af25186b24_tn', 50, 40, '2020-10-18 07:26:18'),
(7, 1, '7-11 海底撈 台灣製 懶人火鍋 自煮火鍋 火鍋 自熱火鍋 火鍋控 麻辣鍋 麻辣火鍋 火鍋湯底 小火鍋 懶人鍋', 'https://cf.shopee.tw/file/87ba50b5c6a67f524b6ee1609138f46b_tn', 150, 50, '2020-10-18 07:27:16'),
(8, 2, '【全賣場最低 附發票】簡約地毯 客廳 沙發 茶几毯 卧室 家用 地毯 床邊毯 毛地毯 地毯 地墊 北歐風地毯 墊子', 'https://cf.shopee.tw/file/8260fa55d1f4770dfd52126fc6e5d711_tn', 300, 2, '2020-10-18 07:31:15'),
(9, 1, '7-11 海底撈 台灣製', 'https://cf.shopee.tw/file/8260fa55d1f4770dfd52126fc6e5d711_tn', 499, 100, '2020-10-23 05:09:06');
-- --------------------------------------------------------
--
-- 資料表結構 `user`
--
CREATE TABLE `user` (
`id` int(20) NOT NULL,
`username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`phone` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`address` varchar(11) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `user`
--
INSERT INTO `user` (`id`, `username`, `password`, `phone`, `email`, `address`, `create_at`, `update_at`) VALUES
(1, '1', '1', '', '', '', '2020-10-01 02:52:18', '2020-10-01 02:52:18');
--
-- 已傾印資料表的索引
--
--
-- 資料表索引 `cart`
--
ALTER TABLE `cart`
ADD PRIMARY KEY (`user_id`,`product_id`);
--
-- 資料表索引 `product`
--
ALTER TABLE `product`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`);
--
-- 在傾印的資料表使用自動增長(AUTO_INCREMENT)
--
--
-- 使用資料表自動增長(AUTO_INCREMENT) `product`
--
ALTER TABLE `product`
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- 使用資料表自動增長(AUTO_INCREMENT) `user`
--
ALTER TABLE `user`
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
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 */;
| true |
5d0394ec99dcd18b449e16ad4f51c5ed9cdfd490 | SQL | lanicon/Entities | /Src/Entity.Database/EntityCode/Views/LocationTimeRecurring.sql | UTF-8 | 768 | 3.796875 | 4 | [
"Apache-2.0"
] | permissive | Create VIEW [EntityCode].[LocationTimeRecurring]
AS
Select LTA.LocationTimeRecurringId As [Id],
LTA.LocationTimeRecurringKey As [Key],
L.LocationKey,
L.LocationName,
L.LocationDescription,
TA.BeginDay,
TA.EndDay,
TA.BeginTime,
TA.EndTime,
TA.Interval,
IsNull(LTA.TimeTypeKey, '00000000-0000-0000-0000-000000000000') As [TimeTypeKey],
LTA.CreatedDate,
LTA.ModifiedDate
From [Entity].[LocationTimeRecurring] LTA
Join [Entity].[Location] L On LTA.LocationKey = L.LocationKey
Join [Entity].[TimeRecurring] TA On LTA.TimeRecurringKey = TA.TimeRecurringKey
Where LTA.RecordStateKey <> '081C6A5B-0817-4161-A3AD-AD7924BEA874' | true |
2cef5d0c1f196add0bf7df8d0b3107b97bf319fa | SQL | weichaoit/thinkphp3-schedule | /site_calendar.sql | UTF-8 | 1,956 | 2.9375 | 3 | [] | no_license | /*
Navicat MySQL Data Transfer
Source Server : 我是新的
Source Server Version : 50626
Source Host : localhost:3306
Source Database : 361jiaoyu
Target Server Type : MYSQL
Target Server Version : 50626
File Encoding : 65001
Date: 2016-10-17 15:55:32
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `site_calendar`
-- ----------------------------
DROP TABLE IF EXISTS `site_calendar`;
CREATE TABLE `site_calendar` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`starttime` int(11) NOT NULL,
`endtime` int(11) DEFAULT NULL,
`allday` tinyint(1) NOT NULL DEFAULT '0',
`color` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of site_calendar
-- ----------------------------
INSERT INTO `site_calendar` VALUES ('1', '的发生', '1476748800', '0', '1', '#06c');
INSERT INTO `site_calendar` VALUES ('2', '发大水发大水', '1476748800', '1476763200', '0', '#f30');
INSERT INTO `site_calendar` VALUES ('3', '发送发的撒的发生', '1476855600', '1476864000', '0', '#360');
INSERT INTO `site_calendar` VALUES ('4', '77777', '1476921600', '1476936000', '0', '#360');
INSERT INTO `site_calendar` VALUES ('5', '发送到', '1476720000', '0', '1', '#360');
INSERT INTO `site_calendar` VALUES ('6', '发大水', '1476720000', '0', '1', '#06c');
INSERT INTO `site_calendar` VALUES ('7', '发生的发生', '1476720000', '0', '1', '#06c');
INSERT INTO `site_calendar` VALUES ('8', '发生的发大水发大水', '1476720000', '0', '1', '#f30');
INSERT INTO `site_calendar` VALUES ('9', '77777', '1474934400', '1474948800', '0', '#06c');
INSERT INTO `site_calendar` VALUES ('10', '法师打发沙发沙发沙发', '1476633600', '0', '1', '#06c');
INSERT INTO `site_calendar` VALUES ('11', '规定是否打算', '1476144000', '1476158400', '0', '#f30');
| true |
de524de1958cc2e9dbc949dabaf6e8c0052d2c58 | SQL | etulupov/training-database | /MySQL/create_procedure.sql | UTF-8 | 2,354 | 4.1875 | 4 | [] | no_license | -- Splits string
-- '1;2;3;4' => {'1', '2', '3', '4'}
DROP FUNCTION IF EXISTS SPLIT_STR;
CREATE FUNCTION SPLIT_STR(
X VARCHAR(255),
pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(X, ';', pos),
LENGTH(SUBSTRING_INDEX(X, ';', pos -1)) + 1),
';', '');
-- Adds new book instance to library
DROP PROCEDURE IF EXISTS ADD_BOOK;
DELIMITER // ;
CREATE PROCEDURE ADD_BOOK ( IN bookTitle VARCHAR(100),
IN authorList VARCHAR(100),
IN publisherList VARCHAR(100),
IN yearList VARCHAR(100),
IN isbnList VARCHAR(100))
BEGIN
DECLARE bookId INT;
DECLARE authorId INT;
DECLARE authorListId INT;
DECLARE i INT;
DECLARE author VARCHAR(100);
DECLARE publisher VARCHAR(100);
DECLARE publisherId INT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
START TRANSACTION;
INSERT INTO Book (title) VALUES (bookTitle);
SET bookId = LAST_INSERT_ID();
SET i = 1;
REPEAT
SET author = SPLIT_STR(authorList, i);
IF (LENGTH(author) > 0) THEN
INSERT INTO Author (`name`) VALUES (author);
SET authorId = LAST_INSERT_ID();
INSERT INTO BookAuthor (book_id, author_id) VALUES (bookId, authorId);
SET i = i + 1;
END IF;
UNTIL LENGTH(author) = 0
END REPEAT;
SET i = 1;
REPEAT
SET publisher = SPLIT_STR(publisherList, i);
IF (LENGTH(publisher) > 0) THEN
SET publisherId = (SELECT id FROM Publisher WHERE `name` = publisher);
IF (publisherId IS NULL) THEN
INSERT INTO Publisher (`name`) VALUES (publisher);
SET publisherId = LAST_INSERT_ID();
END IF;
INSERT INTO BookInstance (book_id, publisher_id, `year`, isbn) VALUES (bookId, publisherId, SPLIT_STR(yearList, i), SPLIT_STR(isbnList, i));
SET i = i + 1;
END IF;
UNTIL LENGTH(publisher) = 0
END REPEAT;
COMMIT;
END//
DELIMITER ; //
CALL ADD_BOOK('The C Programming Language', 'Dennis Ritchie;Brian Kernighan', 'Osborne;Prentice Hall;Addison-Wesley Professional', '1999;2000;2001','1;2;3');
SELECT Book.id, Book.title, Author.name, Publisher.name, BookInstance.year, BookInstance.isbn FROM Book
INNER JOIN Publisher
INNER JOIN BookInstance
INNER JOIN BookAuthor
INNER JOIN Author
ON BookInstance.book_id = BookAuthor.book_id AND BookInstance.book_id = Book.id AND BookAuthor.author_id = Author.id AND BookInstance.publisher_id = Publisher.id ;
| true |
e20f047abd2b6cca9f9fc6bf6ad3cb5e871de69e | SQL | jtruman88/FortStats | /schema.sql | UTF-8 | 1,641 | 3.453125 | 3 | [] | no_license | CREATE TABLE players (
id serial PRIMARY KEY,
username text NOT NULL UNIQUE,
pass text NOT NULL,
question text NOT NULL,
admin boolean NOT NULL DEFAULT false
);
CREATE TABLE match_types (
id serial PRIMARY KEY,
match_type text NOT NULL
);
CREATE TABLE seasons (
id serial PRIMARY KEY,
season int NOT NULL,
active boolean NOT NULL DEFAULT false
);
CREATE TABLE matches (
id serial PRIMARY KEY,
player_id int NOT NULL REFERENCES players (id),
match_type_id int NOT NULL REFERENCES match_types (id),
season_id int NOT NULL REFERENCES seasons (id),
place_points int NOT NULL,
elim_points int NOT NULL,
place int NOT NULL,
elims int DEFAULT 0,
date_played timestamp DEFAULT NOW()
);
CREATE TABLE elim_points (
id serial PRIMARY KEY,
point_value int NOT NULL
);
CREATE TABLE place_points (
id serial PRIMARY KEY,
place int4range NOT NULL,
point_value int NOT NULL
);
INSERT INTO place_points (place, point_value) VALUES
('[1,1]', 100), ('[2,2]', 94), ('[3,3]', 91),
('[4,4]', 88), ('[5,5]', 85), ('[6,6]', 80),
('[7,7]', 75), ('[8,8]', 70), ('[9,9]', 65),
('[10,10]', 60), ('[11,15]', 55), ('[16,20]', 50),
('[21,30]', 45), ('[31,40]', 40), ('[41,50]', 35),
('[51,75]', 30), ('[76,100]', 25);
INSERT INTO elim_points (point_value) VALUES (10);
INSERT INTO match_types (match_type) VALUES
('solo'), ('duo'), ('squad');
INSERT INTO seasons (season, active) VALUES (4, true);
INSERT INTO players (username, pass, question, admin) VALUES
('JoLTsolo', '$2a$10$0y2uSTy2K/cquz5v2s.OxeRMJKljiNSmKaJS0oRY6adFYeupwJuo2',
'$2a$10$QkF3brZa9M3vmSc28RMXJe0Kyof0LoWM9Ldnsg2ng4tgdoccQaJHq', true); | true |
1f63617d7e5a5abb1dd00abb21a60c3de1412caa | SQL | ZakStr/TaxiPark | /db/taxipark.sql | UTF-8 | 4,084 | 3.015625 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: 192.168.10.25 Database: taxipark
-- ------------------------------------------------------
-- Server version 5.7.17-log
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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 */;
--
-- Table structure for table `car`
--
DROP TABLE IF EXISTS `car`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `car` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`carBrand` varchar(15) NOT NULL,
`mark` varchar(15) NOT NULL,
`price` int(11) NOT NULL,
`carClass` varchar(10) NOT NULL,
`power` double NOT NULL,
`fuelConsumption` double NOT NULL,
`carNumber` varchar(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `car`
--
LOCK TABLES `car` WRITE;
/*!40000 ALTER TABLE `car` DISABLE KEYS */;
INSERT INTO `car` VALUES (1,'BMW','X6',150000,'C',125,3.6,'AA4785BB'),(2,'MERCEDES','Benz',900000,'B',150,4.6,'AE9999CB'),(3,'KIA','Rio',350000,'A',100,6,'CE3219EB');
/*!40000 ALTER TABLE `car` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `driver`
--
DROP TABLE IF EXISTS `driver`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `driver` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(11) NOT NULL,
`surname` varchar(15) NOT NULL,
`age` int(11) NOT NULL,
`rights` varchar(45) NOT NULL,
`workExperience` int(11) NOT NULL,
`rightsNumber` varchar(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `driver`
--
LOCK TABLES `driver` WRITE;
/*!40000 ALTER TABLE `driver` DISABLE KEYS */;
INSERT INTO `driver` VALUES (1,'Pavlo','Zakusilkin',25,'B;C',7,'AAB356123'),(2,'Vladimir','Kozachenko',43,'B',25,'ABB365241'),(3,'Vasya','Pupkin',31,'A;B;C',10,'CCA695326');
/*!40000 ALTER TABLE `driver` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `taxi`
--
DROP TABLE IF EXISTS `taxi`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `taxi` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_car` int(11) NOT NULL,
`id_driver` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `id_car_idx` (`id_car`),
KEY `id_driver_idx` (`id_driver`),
CONSTRAINT `id_car` FOREIGN KEY (`id_car`) REFERENCES `car` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `id_driver` FOREIGN KEY (`id_driver`) REFERENCES `driver` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `taxi`
--
LOCK TABLES `taxi` WRITE;
/*!40000 ALTER TABLE `taxi` DISABLE KEYS */;
INSERT INTO `taxi` VALUES (1,1,3),(2,2,1),(3,3,2);
/*!40000 ALTER TABLE `taxi` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-04-16 10:50:01
| true |
c2ba17c2565d03a9106d5058185595cf6e9cc54e | SQL | Namratad88/Medical-Appointment-System | /Mysql/medical_personinfo.sql | UTF-8 | 2,305 | 2.875 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: medical
-- ------------------------------------------------------
-- Server version 5.7.19-log
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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 */;
--
-- Table structure for table `personinfo`
--
DROP TABLE IF EXISTS `personinfo`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `personinfo` (
`UserID` varchar(20) NOT NULL,
`Pass` varchar(45) NOT NULL,
`Fname` varchar(45) DEFAULT NULL,
`Lname` varchar(45) DEFAULT NULL,
`Gender` varchar(10) DEFAULT NULL,
`dob` date DEFAULT NULL,
`phone` double DEFAULT NULL,
PRIMARY KEY (`UserID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `personinfo`
--
LOCK TABLES `personinfo` WRITE;
/*!40000 ALTER TABLE `personinfo` DISABLE KEYS */;
INSERT INTO `personinfo` VALUES ('100','password123','Kruthi','Ram','F','1996-09-13',9875483475),('101','password123','George','Richard','M','1990-12-18',9485738475),('103','hello123','Jasmine','Khan','F','2017-12-20',9485768576);
/*!40000 ALTER TABLE `personinfo` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-12-08 11:47:56
| true |
082f157c32e3a8a5565edc95a016a7adedf48dcf | SQL | vazzanag/DOS_INL | /GTTS/INLDB/training/Views/KeyActivitesAtBusinessUnitView.sql | UTF-8 | 447 | 3.71875 | 4 | [] | no_license | CREATE VIEW [training].[KeyActivitesAtBusinessUnitView]
AS
SELECT ka.KeyActivityID, ka.Code AS Code, kb.BusinessUnitID, b.Acronym, b.BusinessUnitName,
b.IsActive AS BusinessUnitActive, kb.IsActive AS KeyActivityBusinessUnitActive
FROM training.KeyActivities ka
INNER JOIN training.KeyActivitiesAtBusinessUnit kb ON ka.KeyActivityID = kb.KeyActivityID
INNER JOIN users.BusinessUnits b ON kb.BusinessUnitID = b.BusinessUnitID;
| true |
9921f598546b2da9ea35c463a7475d541c6a99de | SQL | lukevers/seal | /server/migrations/2_create_posts_table.up.sql | UTF-8 | 3,102 | 4.15625 | 4 | [] | no_license | CREATE TABLE `posts` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`route` varchar(255) NOT NULL,
`template` varchar(32) NOT NULL,
`content` mediumtext,
`markdown` mediumtext,
`html` mediumtext,
`description` varchar(255) DEFAULT NULL,
`read_time` varchar(255) DEFAULT NULL,
`cover_image` varchar(255) DEFAULT NULL,
`status` ENUM('draft', 'published', 'deleted') NOT NULL DEFAULT 'draft',
`published_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` timestamp NULL DEFAULT NULL,
`owned_by_id` int(10) unsigned NOT NULL,
`created_by_id` int(10) unsigned NOT NULL,
`updated_by_id` int(10) unsigned NOT NULL,
`deleted_by_id` int(10) unsigned DEFAULT NULL,
KEY `posts_owned_by_foreign_key` (`owned_by_id`),
KEY `posts_created_by_foreign_key` (`created_by_id`),
KEY `posts_updated_by_foreign_key` (`updated_by_id`),
KEY `posts_deleted_by_foreign_key` (`deleted_by_id`),
CONSTRAINT `posts_owned_by_foreign_key` FOREIGN KEY (`owned_by_id`) REFERENCES `teams` (`id`) ON DELETE RESTRICT,
CONSTRAINT `posts_created_by_foreign_key` FOREIGN KEY (`created_by_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT,
CONSTRAINT `posts_updated_by_foreign_key` FOREIGN KEY (`updated_by_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT,
CONSTRAINT `posts_deleted_by_foreign_key` FOREIGN KEY (`deleted_by_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT,
UNIQUE KEY `posts_unique_route_owned_by_id` (`owned_by_id`, `route`),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `post_history` LIKE `posts`;
ALTER TABLE `post_history` MODIFY COLUMN `id` int(10) unsigned NOT NULL, DROP PRIMARY KEY;
ALTER TABLE `post_history` ADD COLUMN `action` ENUM ('insert', 'update', 'delete') NOT NULL DEFAULT 'insert' FIRST;
ALTER TABLE `post_history` ADD COLUMN `revision` INT(6) NOT NULL AFTER `action`;
ALTER TABLE `post_history` ADD COLUMN `revised_at` timestamp NOT NULL AFTER `revision`;
ALTER TABLE `post_history` ADD PRIMARY KEY (`id`, `revision`);
ALTER TABLE `post_history` DROP INDEX `posts_unique_route_owned_by_id`;
CREATE TRIGGER `posts_history_trigger_insert` AFTER INSERT ON `posts` FOR EACH ROW
INSERT INTO `post_history` SELECT 'insert', (SELECT IFNULL(COUNT(revision)+1, 1) FROM `post_history` as h WHERE h.id = p.id), NOW(), p.* FROM `posts` AS p WHERE p.id = NEW.id;
CREATE TRIGGER `posts_history_trigger_update` AFTER UPDATE ON `posts` FOR EACH ROW
INSERT INTO `post_history` SELECT 'update', (SELECT IFNULL(COUNT(revision)+1, 1) FROM `post_history` as h WHERE h.id = p.id), NOW(), p.* FROM `posts` AS p WHERE p.id = NEW.id;
CREATE TRIGGER `posts_history_trigger_delete` AFTER DELETE ON `posts` FOR EACH ROW
INSERT INTO `post_history` SELECT 'delete', (SELECT IFNULL(COUNT(revision)+1, 1) FROM `post_history` as h WHERE h.id = p.id), NOW(), p.* FROM `posts` AS p WHERE p.id = OLD.id;
| true |
f6b0584e11886859b6f02447502b253cb5d4688b | SQL | jsmadja/give | /conf/evolutions/default/1.sql | UTF-8 | 3,257 | 3.453125 | 3 | [] | no_license | # --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table contacts (
id bigint auto_increment not null,
inviter_id bigint,
invitee_id bigint,
type integer,
created_at datetime not null,
updated_at datetime not null,
constraint ck_contacts_type check (type in (0,1,2)),
constraint pk_contacts primary key (id))
;
create table gifts (
id bigint auto_increment not null,
name varchar(255),
photo_base64 longtext,
giver_id bigint,
given tinyint(1) default 0,
created_at datetime not null,
updated_at datetime not null,
constraint pk_gifts primary key (id))
;
create table linked_accounts (
id bigint auto_increment not null,
user_id bigint,
provider_user_id varchar(255),
provider_key varchar(255),
constraint pk_linked_accounts primary key (id))
;
create table requests (
id bigint auto_increment not null,
requester_id bigint,
gift_id bigint,
created_at datetime not null,
updated_at datetime not null,
constraint pk_requests primary key (id))
;
create table users (
id bigint auto_increment not null,
email varchar(255),
name varchar(255),
active tinyint(1) default 0,
email_validated tinyint(1) default 0,
created_at datetime not null,
updated_at datetime not null,
constraint pk_users primary key (id))
;
alter table contacts add constraint fk_contacts_inviter_1 foreign key (inviter_id) references users (id) on delete restrict on update restrict;
create index ix_contacts_inviter_1 on contacts (inviter_id);
alter table contacts add constraint fk_contacts_invitee_2 foreign key (invitee_id) references users (id) on delete restrict on update restrict;
create index ix_contacts_invitee_2 on contacts (invitee_id);
alter table gifts add constraint fk_gifts_giver_3 foreign key (giver_id) references users (id) on delete restrict on update restrict;
create index ix_gifts_giver_3 on gifts (giver_id);
alter table linked_accounts add constraint fk_linked_accounts_user_4 foreign key (user_id) references users (id) on delete restrict on update restrict;
create index ix_linked_accounts_user_4 on linked_accounts (user_id);
alter table requests add constraint fk_requests_requester_5 foreign key (requester_id) references users (id) on delete restrict on update restrict;
create index ix_requests_requester_5 on requests (requester_id);
alter table requests add constraint fk_requests_gift_6 foreign key (gift_id) references gifts (id) on delete restrict on update restrict;
create index ix_requests_gift_6 on requests (gift_id);
# --- !Downs
SET FOREIGN_KEY_CHECKS=0;
drop table contacts;
drop table gifts;
drop table linked_accounts;
drop table requests;
drop table users;
SET FOREIGN_KEY_CHECKS=1;
| true |
ae30992948b98fdf9deedb9cbe5570b8f9a12276 | SQL | ktaranov/sqlops-mssql-db-insights | /src/sql/mssql-db-spaceused-detail.sql | UTF-8 | 970 | 3.71875 | 4 | [
"MIT"
] | permissive | --
-- Author: Matticusau
-- Purpose: Provides detailed data for the DB Space Used Insights Widget
-- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE
--
-- When Who What
-- 2018-06-27 Matticusau Friendly column names
--
SELECT file_id [File Id]
, name [Logical Name]
, type_desc [Type]
, physical_name [Physical Name]
, CONVERT(decimal(18,2), size/128.0) [File Size Mb]
, CONVERT(decimal(18,2), max_size/128.0) [Max Growth Size Mb]
, CONVERT(decimal(18,2), FILEPROPERTY(name, 'SpaceUsed')/128.0) [Used Mb]
, CONVERT(decimal(18,2), size/128.0) - CONVERT(decimal(18,2), FILEPROPERTY(name,'SpaceUsed')/128.0) AS [Free Mb]
, CONVERT(decimal(18,2), (FILEPROPERTY(name, 'SpaceUsed')/128.0) / (size/128.0) * 100) [% Used]
, 100 - CONVERT(decimal(18,2), (FILEPROPERTY(name, 'SpaceUsed')/128.0) / (size/128.0) * 100) AS [% Free]
FROM sys.database_files
ORDER BY type_desc
, file_id | true |
394f09c0c5e7e4d0bc7e38dd07dcfbd90cc570a9 | SQL | MrD0079/portal | /sql/a1607lj_report_a_tp.sql | UTF-8 | 1,061 | 2.890625 | 3 | [] | no_license | /* Formatted on 29/01/2015 12:13:22 (QP5 v5.227.12220.39724) */
SELECT a1607lj.tab_num,
st.fio fio_ts,
a1607lj.fio_eta,
a1607lj.tp_ur,
a1607lj.tp_addr,
a1607lj.tp_kod,
a1607ljtps.contact_lpr
FROM a1607lj_tp_select a1607ljtps, a1607lj, user_list st
WHERE a1607lj.tab_num = st.tab_num
AND ( st.tn IN (SELECT slave
FROM full
WHERE master = :tn)
OR (SELECT NVL (is_traid, 0)
FROM user_list
WHERE tn = :tn) = 1)
AND a1607lj.tp_kod = a1607ljtps.tp_kod
AND st.dpt_id = :dpt_id and st.is_spd=1
AND DECODE (:eta_list, '', a1607lj.h_fio_eta, :eta_list) =
a1607lj.h_fio_eta
GROUP BY a1607lj.tab_num,
st.fio,
a1607lj.fio_eta,
a1607lj.tp_ur,
a1607lj.tp_addr,
a1607lj.tp_kod,
a1607ljtps.contact_lpr
ORDER BY st.fio,
a1607lj.fio_eta,
a1607lj.tp_ur,
a1607lj.tp_addr | true |
0c113d3acfc9c89906605862ef79914792c88c14 | SQL | Lince99/Websites | /Esercizio_esame_2013/backend/sql/select_durata_media_controlli.sql | UTF-8 | 579 | 3.390625 | 3 | [
"Unlicense",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- Selezione dei controlli nelle dogane
SELECT Dogana.Nome,
Controllo.Data_inizio,
Controllo.Data_fine
FROM Controllo, Dogana
WHERE Controllo.Dogana = Dogana.ID;
-- Selezione della durata dei controlli
SELECT controlli_dogane_time.Nome AS `Nome_dogana`,
DATEDIFF(controlli_dogane_time.Data_fine, controlli_dogane_time.Data_inizio) AS `Durata_totale`
FROM (SELECT Dogana.Nome,
Controllo.Data_inizio,
Controllo.Data_fine
FROM Controllo, Dogana
WHERE Controllo.Dogana = Dogana.ID) AS `controlli_dogane_time`;
-- Selezione della durata media dei controlli
-- TODO
| true |
838f1f85b09a847612086c6a809e8c4aaddec595 | SQL | as2019a/oracle | /example/ch11_shopping.sql | UTF-8 | 1,025 | 3.640625 | 4 | [] | no_license | create table company(
id number primary key,
name varchar2(50) not null,
phone varchar2(50)
);
select * from company;
create table product(
id number primary key,
price number,
company_id number references company(id)
);
select * from product;
create table users(
id number primary key,
name varchar2(50) not null,
email varchar2(50) not null,
regdate timestamp not null,
point number(10)
);
select * from users;
create table buy(
id number primary key,
product_id number references product(id),
company_id number references company(id),
count timestamp not null
);
select * from buy;
create table basket(
id number primary key,
product_id number references product(id),
company_id number references company(id),
count timestamp not null
);
select * from basket;
alter table buy add foreign key(user_id) references users(id);
alter table basket add foreign key(user_id) references users(id);
alter table basket drop constraint SYS_C007082; | true |
0a48c894c5f41d75f3f65ee0c2fb4a07f7e4b722 | SQL | ekiddqa/20DecSDET2-IMS-Starter | /src/main/resources/sql-schema.sql | UTF-8 | 991 | 3.828125 | 4 | [
"MIT"
] | permissive | drop schema ims;
CREATE SCHEMA IF NOT EXISTS `ims`;
USE `ims` ;
CREATE TABLE IF NOT EXISTS `ims`.`customers` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(40) NOT NULL,
`surname` VARCHAR(40) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `ims`.`items` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(40) NOT NULL,
`price` DEC(11,2) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `ims`.`orders` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`fk_customer_id` INT(11) NOT NULL,
`value` double DEFAULT 0,
PRIMARY KEY (`id`),
FOREIGN KEY (`fk_customer_id`) REFERENCES `ims`.`customers`(`id`) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS `ims`.`order_item` (
`fk_order_id` INT(11) NOT NULL,
`fk_item_id` INT(11) NOT NULL,
FOREIGN KEY (`fk_order_id`) REFERENCES `ims`.`orders`(`id`) ON DELETE CASCADE,
FOREIGN KEY (`fk_item_id`) REFERENCES `ims`.`items`(`id`) ON DELETE CASCADE
);
| true |
215cabe697b7c192ec1eed94c99809bc0880535c | SQL | vrzhao/CIS-505 | /HW2.sql | UTF-8 | 3,864 | 4.6875 | 5 | [] | no_license | use apps_and_crunchbase;
-- 1. Retrieve all the attributes for app "Twitter"
select * from apps where name like "Twitter";
-- 2. Retrieve the name and price for the apps whose name contains the string "sun" (hint: can begin with "sun", end with "sun", or have "sun" in the middle (e.g. Samsung)
select name, price from apps where name like "%sun%";
-- 3. Retrieve the number of apps whose seller url is not missing
select count(*) from apps where seller_url is not null;
-- 4. Retrieve the primary categories (don't show duplicates)
select distinct Category_primary from apps;
-- 5 Retrieve the min, average, max prices for the primary category "Finance"
select min(price) as MIN, avg(price) as Average, max(price) as MAX from apps where Category_primary like "Finance";
-- 6. Show the distribution of the price of apps. In other words, list all of the prices with the count of the apps at a given price. Please order your results by price in ascending order. (Hint, you should have two columns in your result: price and count. If you are interested in knowing the price structure of apps, you might want to read the first few paragraphs of this article).
select price, count(price) as count from apps group by price order by price ASC;
-- 7. What is the mean price among the paid apps for each category? list in descending order of the mean price.
select Category_primary as Category, AVG(price) as Average from apps where price > 0 group by Category_primary order by Average DESC;
-- 8. Give a top 10 countdown of the most prolific app developers (e.g. list (in decreasing order) the names of the developers that write the most apps and the total number of apps they wrote. (Hint: Two columns, developer name, number of apps, in decreasing order, only the top 10 please)
select Developer_name, count(Developer) as count from apps group by Developer order by count DESC limit 10;
-- 9. Retrieve the id and name for the developers who developed apps in at least 10 primary categories;
select Developer, Developer_name from apps group by Developer having count(distinct Category_primary) >= 10;
-- 10. Are there apps with the same name? Ask about the answer.
select (if(count(n) > 0, 'Yes', 'No')) as 'Are there apps with the same name?', count(n) as 'Number of Names used by at least 2 apps' from (select name, count(name) as n from apps group by name having n > 1) as a;
-- 11. Retrieve the name of the app that has the highest number of ratings (i.e., rating_count) and the number of ratings it received.
select name, rating_count from apps, app_reviews, (select max(rating_count) as count from app_reviews) as maximum where apps.id = app_reviews.id and app_reviews.rating_count = maximum.count;
-- 12. Retrieve the name and primary category for the apps that are game-center enabled and whose primary category is not "Games".
select name, Category_primary from apps where Category_primary <> "Games" and Game_center = 1;
-- 13. In which primary category, the apps have the highest mean average_rating?
select Category_primary as Category, rating as Average from (select Category_primary, AVG(average_rating) as rating from apps, app_reviews where apps.id = app_reviews.id group by Category_primary) as average having rating = max(rating);
-- 14. List the total number of ratings (rating_count) for each primary category? Please list them in descending order of the total number of ratings.
select Category_primary as Category, sum(rating_count) as rating_count from apps, app_reviews where apps.id = app_reviews.id group by Category_primary order by rating_count DESC;
-- 15. List the primary category, number of ratings and average ratings for the app “Google Earth”.
select Category_primary as Primary_Category, rating_count, average_rating from apps, app_reviews where apps.id = app_reviews.id and name like "Google Earth";
| true |
44e7b04d6dd50c1810bc637489c592eb23ceb2fe | SQL | Chem-x/hotel | /app/appartments.sql | UTF-8 | 3,564 | 3.09375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1:3306
-- Время создания: Янв 25 2018 г., 23:24
-- Версия сервера: 5.5.53
-- Версия PHP: 5.5.38
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 */;
--
-- База данных: `hotel`
--
-- --------------------------------------------------------
--
-- Структура таблицы `appartments`
--
CREATE TABLE `appartments` (
`id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`beds` int(11) NOT NULL,
`img` varchar(255) NOT NULL,
`price` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `appartments`
--
INSERT INTO `appartments` (`id`, `title`, `description`, `beds`, `img`, `price`) VALUES
(11, 'Номер на одного', 'Свой пустился точках проектах предупреждал последний маленький там встретил взобравшись до диких рекламных которое свое, семантика вскоре предложения решила раз коварный это, переулка города страну вдали назад великий.', 1, '40476572.jpg', 35),
(12, 'Номер на двоих', 'Свой пустился точках проектах предупреждал последний маленький там встретил взобравшись до диких рекламных которое свое, семантика вскоре предложения решила раз коварный это, переулка города страну вдали назад великий.', 2, '-47952560.jpg', 55),
(13, 'На большую компанию', 'Свой пустился точках проектах предупреждал последний маленький там встретил взобравшись до диких рекламных которое свое, семантика вскоре предложения решила раз коварный это, переулка города страну вдали назад великий.', 3, '660865024.jpg', 100),
(14, 'Особое предложение', 'Свой пустился точках проектах предупреждал последний маленький там встретил взобравшись до диких рекламных которое свое, семантика вскоре предложения решила раз коварный это, переулка города страну вдали назад великий.', 2, '655582228.jpg', 50);
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `appartments`
--
ALTER TABLE `appartments`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `appartments`
--
ALTER TABLE `appartments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
/*!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 */;
| true |
87d58046b922d5513f3a1896e2f7beaf06fa7be4 | SQL | PrzemyslawWrobel/zrozumsql | /zs_m_10_scripts/M10_L2_INTERSECTION_TABLE.sql | UTF-8 | 2,467 | 4.125 | 4 | [
"MIT"
] | permissive | --L2: Przechowywanie Atrybutów Wielowartościowych
/*
Antywzorzec: Kolumna z listą wartości oddzielonych przecinkami
Powody:
* konieczność zmiany struktury
* lenistwo
* konieczność zmiany zapytań
Poznasz go po:
* kolumnie z identyfikatorami oddzielonymi przecinkami lub tablicy
* "Potrzebuje wyciągnąć tylko część identyfikatoró z tej kolumny, jak mogę to zrobić?"
Na Twoje usprawiedliwienie:
* świadoma denormalizacja wynikająca z zysków wydajności
*/
DROP TABLE IF EXISTS products, customers;
CREATE TABLE products (
id SERIAL,
product_name VARCHAR(100),
product_code VARCHAR(10),
product_quantity NUMERIC(10,2),
manufactured_date DATE,
customers_id TEXT,
added_by TEXT DEFAULT 'admin',
created_date TIMESTAMP DEFAULT now()
);
CREATE TABLE customers (
id SERIAL,
customer_name TEXT,
added_by TEXT DEFAULT 'admin',
created_date TIMESTAMP DEFAULT now()
);
INSERT INTO products (product_name, product_code, product_quantity, manufactured_date, customers_id)
VALUES ('Product 1', 'PRD1', 100.25, '20/11/2019', '1,5'),
('Product 1', 'PRD2', 92.25, '1/11/2019', '1,2'),
('Product 2', 'PRD2', 12.25, '1/11/2019', '2'),
('Product 3', 'PRD3', 25.25, '2/11/2019', '3'),
('Product 4', 'PRD4', 68.25, '3/11/2020', '4,5');
INSERT INTO customers (customer_name)
VALUES ('Krzysztof Bury'),
('Onufry Zagłoba'),
('Bohun Tuhajbejowicz'),
('Michał Wołodyjowski'),
('Longinus Podbipięta');
-- PROBLEM
SELECT p.*,
c.customer_name
FROM products p
JOIN customers c ON c.id = ANY(CAST(string_to_array(p.customers_id,',') AS INTEGER[]));
/*
ROZWIAZANIE: Tabela Lącząca - Intersection Table - (wiele - do - wielu)
Opcjonalnie: Dodanie kluczy obcych pomiędzy tabelami.
*/
DROP TABLE IF EXISTS products_customers;
CREATE TABLE products_customers (
id SERIAL,
product_id INTEGER,
customer_id INTEGER
);
INSERT INTO products_customers (product_id, customer_id)
SELECT p.id AS product_id,
c.id AS customer_id
FROM products p
JOIN customers c ON c.id = ANY(CAST(string_to_array(p.customers_id,',') AS INTEGER[]))
ORDER BY p.id, c.id;
ALTER TABLE products DROP COLUMN customers_id;
-- ROZWIAZANIE
SELECT p.*,
c.customer_name
FROM products p
JOIN products_customers pc ON pc.product_id = p.id
JOIN customers c ON c.id = pc.customer_id
ORDER BY p.id, c.id;
-- Przechowuj wartości w osobnej kolumnie i wierszu! | true |
933ed003f709d2b443e847be7ae37b14f7b1467e | SQL | bgoonz/UsefulResourceRepo2.0 | /_MY_ORGS/Web-Dev-Collaborative/blog-research/database/pg-admin/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/delete_multiple.sql | UTF-8 | 350 | 3.109375 | 3 | [
"MIT"
] | permissive | {# We need database name before we execute drop #}
{% if db_ids %}
SELECT db.datname as name FROM pg_database as db WHERE db.oid in {{db_ids}};
{% endif %}
{# Using name from above query we will drop the database #}
{% if dbname_array %}
{% for db in dbname_array %}
DROP DATABASE {{ conn|qtIdent(db.name) }};
{% endfor %}
{% endif %}
| true |
aee1de5092fd33f940275c554f59aac755c50b6a | SQL | xinsec/ckhd | /opengame/.svn/pristine/39/39e5644681b8d9442a3f10797c18595fb74b09ec.svn-base | UTF-8 | 1,559 | 2.828125 | 3 | [] | no_license | --天翼订单请求
CREATE TABLE `tianyi_order` (
`id` varchar(64) COMMENT '主键Id',
`ver` varchar(20) DEFAULT NULL COMMENT '协议版本号',
`requestId` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`orderid` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`channel` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`imsi` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`apName` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`appName` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`chargeName` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`price` varchar(20) DEFAULT NULL COMMENT '请求事务号',
`priceType` varchar(20) DEFAULT NULL COMMENT '计费类型:0-按次计费(默认);1-包月计费,可空',
`payType` varchar(20) DEFAULT NULL COMMENT '付费运营商:1-联通计费; 2-移动计费;3-电信计费',
`sig` varchar(20) DEFAULT NULL COMMENT '签名验证,MD5(orderId+channel+imsi+requestId+key)',
`subOpt` varchar(20) DEFAULT NULL COMMENT '',
`sessionId` varchar(20) DEFAULT NULL COMMENT '移动二次请求sessionId',
`verifyCode` varchar(20) DEFAULT NULL COMMENT '移动二次请求验证码',
`status` int COMMENT '状态,0-一次请求,1-移动二次确认,2-电信的',
`createTime` datetime DEFAULT NULL COMMENT '创建时间',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`remarks` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='和游戏订单接口表'; | true |
3babd832dec3e41f12258447fba89be08970c244 | SQL | youknow933/test | /dawara/src/main/webapp/WEB-INF/doc/dbms/categrp-category-milege/old/categrp.sql | UHC | 4,769 | 4.46875 | 4 | [] | no_license |
0. ̺
DROP TABLE categrp;
1. ̺
CREATE TABLE categrp(
categrpno NUMBER(10) NOT NULL PRIMARY KEY,
nclassification NUMBER(1) DEFAULT 1 NOT NULL,
categrptitle VARCHAR2(50) NOT NULL,
nseqno NUMBER(7) DEFAULT 0 NOT NULL,
nvisible CHAR(1) DEFAULT 'Y' NOT NULL,
rdate DATE NOT NULL,
mem_no NUMBER(6) NULL,
FOREIGN KEY (mem_no) REFERENCES MEMBER (mem_no)
);
COMMENT ON TABLE categrp is 'īװ ';
COMMENT ON COLUMN categrp.categrpno is 'īװ ȣ';
COMMENT ON COLUMN categrp.nclassification is 'īװ з';
COMMENT ON COLUMN categrp.categrptitle is ' ̸';
COMMENT ON COLUMN categrp.nseqno is ' ';
COMMENT ON COLUMN categrp.nvisible is ' ';
COMMENT ON COLUMN categrp.rdate is ' ';
COMMENT ON COLUMN categrp.mem_no is 'ȸ ȣ';
2. (INSERT)
- nclassification: 1-SAMSUNG, 2-LG, 3-APPLE, 4-HP
- nvisible: Y, N
INSERT INTO categrp(categrpno, nclassification, categrptitle, nseqno, nvisible, rdate)
VALUES(1, 1, 'SAMSUNGÿ9', 1, 'Y', sysdate);
3. (DELETE)
DELETE FROM categrp;
4. ȣ ڵ
INSERT INTO categrp(categrpno, nclassification, categrptitle, nseqno, nvisible, rdate, mem_no)
VALUES((SELECT NVL(MAX(categrpno), 0) + 1 as categrpno FROM categrp), 1, 'Zÿ9', 1, 'Y', sysdate, '1');
INSERT INTO categrp(categrpno, nclassification, categrptitle, nseqno, nvisible, rdate)
VALUES((SELECT NVL(MAX(categrpno), 0) + 1 as categrpno FROM categrp), 2, 'Zÿ9', 1, 'Y', sysdate);
INSERT INTO categrp(categrpno, nclassification, categrptitle, nseqno, nvisible, rdate)
VALUES((SELECT NVL(MAX(categrpno), 0) + 1 as categrpno FROM categrp), 3, 'Zÿ9', 1, 'Y', sysdate);
5. (SELECT)
SELECT categrpno, nclassification, categrptitle, nseqno, nvisible, rdate
FROM categrp
ORDER BY categrpno ASC;
6. ȸ
SELECT categrpno, nclassification, categrptitle, nseqno, nvisible, rdate
FROM categrp
WHERE categrpno = 1;
7. (UPDATE)
UPDATE categrp
SET nclassification=1, categrptitle='Zÿ9', nseqno = 1, nvisible='Y'
WHERE categrpno = 1;
8. ȣ (CATEGRPNO DELETE)
DELETE FROM categrp
WHERE categrpno = 1;
9. ˻(%: ų ϳ ̻ )
-- word LIKE '' word = ''
^$
-- word LIKE '%' word = ' '
.*$
-- word LIKE '%' word = '~'
^.*
-- word LIKE '%%' word = ' 湮ؾ~'
.*.*
SELECT categrpno, nclassification, categrptitle, nseqno, nvisible, rdate
FROM categrp=1 AND word LIKE '%Z%'
ORDER BY categrpno ASC;
10. ¡
SELECT categrpno, nclassification, categrptitle, nseqno, nvisible, rdate
FROM(
SELECT categrpno, nclassification, categrptitle, nseqno, nvisible, rdate as r
FROM(
SELECT categrpno, nclassification, categrptitle, nseqno, nvisible, rdate
FROM categrp
WHERE categrp=1
ORDER BY categrpno DESC
)
)
WHERE r >=1 AND r <= 3;
-- ˻
SELECT sellno, ncategoryno, title, content, thumbs, files, sizes, cnt,
replycnt, rdate, word, r
FROM(
SELECT sellno, ncategoryno, title, content, thumbs, files, sizes, cnt,
replycnt, rdate, word, rownum as r
FROM(
SELECT sellno, ncategoryno, title, content, thumbs, files, sizes, cnt,
replycnt, rdate, word
FROM sell
WHERE ncategoryno=1 AND word LIKE '%%'
ORDER BY sellno DESC
)
)
WHERE r >=1 AND r <= 3;
SELLNO NCATEGORYNO TITLE CONTENT THUMBS FILES SIZES CNT REPLYCNT RDATE WORD R
------ ----------- ----- ------- ------------ ----------- ----- --- -------- --------------------- ------------------------ -
3 1 summber.jpg summber.jpg 0 0 0 2018-06-08 16:21:23.0 ,spring,,,,, 1
2 1 spring_m.jpg spring.jpg 0 0 0 2018-06-08 16:21:22.0 ,spring,,,,, 2
| true |
903a0ccf08a29de61178c9e98e286f14dc7542b9 | SQL | openbuild-sheffield/food-hygiene-rating | /templates/Locations.postgres.pre.sql | UTF-8 | 2,428 | 3.953125 | 4 | [
"OGL-UK-3.0",
"MIT"
] | permissive | create extension if not exists "uuid-ossp";
DROP TABLE IF EXISTS app_public.fhr_country CASCADE;
DROP TABLE IF EXISTS app_public.fhr_region CASCADE;
create table app_public.fhr_country (
uuid uuid primary key,
id integer NOT NULL,
name text not null check (char_length(name) < 80),
name_key text check (char_length(name_key) < 80),
created_at timestamp default now(),
updated_at timestamp default now(),
CONSTRAINT unique_fhr_country_id UNIQUE(id)
);
create table app_public.fhr_region (
uuid uuid primary key,
id integer NOT NULL,
name text not null check (char_length(name) < 80),
name_key text check (char_length(name_key) < 80),
code text check (char_length(code) < 80),
country_id integer NOT NULL references app_public.fhr_country(id),
created_at timestamp default now(),
updated_at timestamp default now(),
CONSTRAINT unique_fhr_region_id UNIQUE(id),
CONSTRAINT unique_fhr_region_code UNIQUE(code)
);
comment on table app_public.fhr_country is
'Food Hygiene Rating Scheme Countries.';
comment on column app_public.fhr_country.uuid is
'The primary unique identifier for the food hygiene rating country.';
comment on column app_public.fhr_country.id is
'The unique identifier for the food hygiene rating country as provided by http://api.ratings.food.gov.uk.';
comment on column app_public.fhr_country.name is
'The country name.';
comment on column app_public.fhr_country.name_key is
'The country key.';
comment on column app_public.fhr_country.created_at is
'The time this scheme was created.';
comment on column app_public.fhr_country.updated_at is
'The time this scheme was updated.';
comment on table app_public.fhr_region is
'Food Hygiene Rating Scheme Regions.';
comment on column app_public.fhr_region.uuid is
'The primary unique identifier for the food hygiene rating region.';
comment on column app_public.fhr_region.id is
'The unique identifier for the food hygiene rating region as provided by http://api.ratings.food.gov.uk.';
comment on column app_public.fhr_region.name is
'The region name.';
comment on column app_public.fhr_region.name_key is
'The region name key.';
comment on column app_public.fhr_region.code is
'The region code.';
comment on column app_public.fhr_region.created_at is
'The time this scheme was created.';
comment on column app_public.fhr_region.updated_at is
'The time this scheme was updated.';
| true |
83ea6c4737bc349192babbd02199a891bfa910c4 | SQL | mikelawrencecalleja/bigquery_stackoverflow | /macros/get_query_types_nojinja.sql | UTF-8 | 341 | 3.296875 | 3 | [] | no_license | {% set data_query %}
SELECT 'S' as size, 'red' as color
UNION ALL SELECT 'S' ,'blue'
UNION ALL SELECT 'S', 'red'
UNION ALL SELECT 'M', 'red'
{% endset %}
with data as (
{{ data_query }}
)
SELECT
size,
{{ dbt_utils.PIVOT('color',
get_column_values_from_query(data_query, 'color')) }}
FROM data
GROUP BY size | true |
9189e64569ccea49b5b3db462ead9b3441b880a7 | SQL | gidor/dxfetl | /sql/elabs.1.sql | UTF-8 | 6,389 | 3.125 | 3 | [] | no_license |
drop table punti ;
CREATE TABLE punti (
OBJECTID VARCHAR(20),
X DOUBLE(12,4),
Y DOUBLE(12,4),
Z DOUBLE(12,4)
);
drop table pozzi;
CREATE TABLE pozzi (
OBJECTID VARCHAR(20),
X DOUBLE(12,4),
Y DOUBLE(12,4),
Z DOUBLE(12,4),
RESPTECNI VARCHAR(255),
QUOINFPOZ DOUBLE(12,4),
SPES_SUP INTEGER,
ISTAT_ID VARCHAR(8),
QUOPUN NUMERIC(128,0) DEFAULT 0,
CODE VARCHAR(255),
FORM_CHIU VARCHAR(4),
MAT_CHIU VARCHAR(4),
LARG_CHIU INTEGER,
LUNG_CHIU INTEGER,
FORMA_SUP VARCHAR(4),
MAT_SUP VARCHAR(4),
LARG_SUP INTEGER,
LUNG_SUP INTEGER,
FORMA_INF VARCHAR(4),
MAT_INF VARCHAR(255),
LARG_INF INTEGER,
LUNG_INF INTEGER,
COLPOZ BOOLEAN DEFAULT false,
TRAVASO INTEGER,
COP_CHIU BOOLEAN DEFAULT false,
APP_CHIU BOOLEAN DEFAULT false,
MAT_COLPOZ VARCHAR(2),
SUPPOSA VARCHAR(4),
POS_NODO VARCHAR(255),
POS_SUP VARCHAR(255),
QUOTERR DOUBLE(12,4), DEFAULT 0,
QUOTRAVASO DOUBLE(12,4), DEFAULT 0,
IMAGE VARCHAR(255),
DISEGNI VARCHAR(255),
DATA TIMESTAMP,
NOTE VARCHAR(2),
DEN_PUN VARCHAR(2),
FOTOPOZEST VARCHAR(255),
FOTOPOZINT VARCHAR(255)
);
drop table tubi ;
CREATE table tubi (
OBJECTID VARCHAR(20),
SEQ INTEGER,
X DOUBLE(12,4),
Y DOUBLE(12,4),
X1 DOUBLE(12,4),
Y1 DOUBLE(12,4),
CODE VARCHAR(255),
IDPUNTINI INTEGER DEFAULT 0,
IDPUNTFIN INTEGER DEFAULT 0,
MATLIN VARCHAR(255),
FORMSEZ VARCHAR(255),
ALT_LIN INTEGER DEFAULT 0,
LARGH_LIN INTEGER DEFAULT 0,
QUOINI DOUBLE(12,4), DEFAULT 0,
QUOFIN DOUBLE(12,4), DEFAULT 0,
DISLINI INTEGER DEFAULT 0,
DISFIN INTEGER DEFAULT 0,
TIPFOG VARCHAR(255),
TIPLINIDR VARCHAR(255),
POS_TRATTA VARCHAR(255),
POS_SUP VARCHAR(255),
NOTE VARCHAR(255),
LUNG INTEGER DEFAULT 0,
PENDENZA INTEGER DEFAULT 0,
DEN_TRONCO VARCHAR(255),
ENTRA BOOLEAN DEFAULT 0,
ESCE BOOLEAN DEFAULT 0,
DAPOZZO VARCHAR(255),
VERSOPOZZO VARCHAR(255),
FOTOINT VARCHAR(255),
FOTOINT VARCHAR(255),
FONTUBO DOUBLE(12,4)
) ;
insert into pozzi
(RESPTECNI, OBJECTID, QUOINFPOZ, SPES_SUP, ISTAT_ID, QUOPUN, CODE, FORM_CHIU, MAT_CHIU, LARG_CHIU,
LUNG_CHIU, FORMA_SUP, MAT_SUP, LARG_SUP, LUNG_SUP, FORMA_INF, MAT_INF, LARG_INF, LUNG_INF, COLPOZ,
TRAVASO, COP_CHIU, APP_CHIU, MAT_COLPOZ, SUPPOSA, POS_NODO, POS_SUP, QUOTERR, QUOTRAVASO, IMAGE,
DISEGNI, DATA, NOTE, DEN_PUN, FOTOPOZEST, FOTOPOZINT )
SELECT
RESPTECNI, OBJECTID, QUOINFPOZ, SPES_SUP, ISTAT_ID, QUOPUN, CODE, FORM_CHIU, MAT_CHIU, LARG_CHIU,
LUNG_CHIU, FORMA_SUP, MAT_SUP, LARG_SUP, LUNG_SUP, FORMA_INF, MAT_INF, LARG_INF, LUNG_INF, COLPOZ,
TRAVASO, COP_CHIU, APP_CHIU, MAT_COLPOZ, SUPPOSA, POS_NODO, POS_SUP, QUOTERR, QUOTRAVASO, IMAGE,
DISEGNI, DATA, NOTE, DEN_PUN, FOTOPOZEST, FOTOPOZINT
FROM unionepazzitubislim1;
insert into tubi
(OBJECTID , SEQ ,
CODE, IDPUNTINI, IDPUNTFIN, MATLIN, FORMSEZ, ALT_LIN, LARGH_LIN, QUOINI, QUOFIN, DISLINI, DISFIN,
TIPFOG, TIPLINIDR, POS_TRATTA, POS_SUP, NOTE, LUNG, PENDENZA, DEN_TRONCO, ENTRA, ESCE, DAPOZZO,
VERSOPOZZO, FOTOINT, FONTUBO)
SELECT
OBJECTID , 1,1CODE, 1IDPUNTINI, 1IDPUNTFIN, 1MATLIN, 1FORMSEZ, 1ALT_LIN, 1LARGH_LIN, 1QUOINI, 1QUOFIN, 1DISLINI,
1DISFIN, 1TIPFOG, 1TIPLINIDR, 1POS_TRATTA, 1POS_SUP, 1NOTE, 1LUNG, 1PENDENZA, 1DEN_TRONCO, 1ENTRA,
1ESCE, 1DAPOZZO, 1VERSOPOZZO, 1FOTOINT, 1FONTUBO
FROM unionepazzitubislim1;
insert into tubi
(OBJECTID , SEQ ,CODE, IDPUNTINI, IDPUNTFIN, MATLIN, FORMSEZ, ALT_LIN, LARGH_LIN, QUOINI, QUOFIN, DISLINI, DISFIN,
TIPFOG, TIPLINIDR, POS_TRATTA, POS_SUP, NOTE, LUNG, PENDENZA, DEN_TRONCO, ENTRA, ESCE, DAPOZZO,
VERSOPOZZO, FOTOINT, FONTUBO)
SELECT
OBJECTID , 2,2CODE, 2IDPUNTINI, 2IDPUNTFIN, 2MATLIN, 2FORMSEZ, 2ALT_LIN, 2LARGH_LIN, 2QUOINI, 2QUOFIN, 2DISLINI,
2DISFIN, 2TIPFOG, 2TIPLINIDR, 2POS_TRATTA, 2POS_SUP, 2NOTE, 2LUNG, 2PENDENZA, 2DEN_TRONCO, 2ENTRA,
2ESCE, 2DAPOZZO, 2VERSOPOZZO, 2FOTOINT, 2FONTUBO
FROM unionepazzitubislim1;
insert into tubi
(OBJECTID , SEQ ,CODE, IDPUNTINI, IDPUNTFIN, MATLIN, FORMSEZ, ALT_LIN, LARGH_LIN, QUOINI, QUOFIN, DISLINI, DISFIN,
TIPFOG, TIPLINIDR, POS_TRATTA, POS_SUP, NOTE, LUNG, PENDENZA, DEN_TRONCO, ENTRA, ESCE, DAPOZZO,
VERSOPOZZO, FOTOINT, FONTUBO)
SELECT
OBJECTID , 3,3CODE, 3IDPUNTINI, 3IDPUNTFIN, 3MATLIN, 3FORMSEZ, 3ALT_LIN, 3LARGH_LIN, 3QUOINI, 3QUOFIN, 3DISLINI,
3DISFIN, 3TIPFOG, 3TIPLINIDR, 3POS_TRATTA, 3POS_SUP, 3NOTE, 3LUNG, 3PENDENZA, 3DEN_TRONCO, 3ENTRA,
3ESCE, 3DAPOZZO, 3VERSOPOZZO, 3FOTOINT, 3FONTUBO
FROM unionepazzitubislim1;
insert into tubi
(OBJECTID , SEQ ,CODE, IDPUNTINI, IDPUNTFIN, MATLIN, FORMSEZ, ALT_LIN, LARGH_LIN, QUOINI, QUOFIN, DISLINI, DISFIN,
TIPFOG, TIPLINIDR, POS_TRATTA, POS_SUP, NOTE, LUNG, PENDENZA, DEN_TRONCO, ENTRA, ESCE, DAPOZZO,
VERSOPOZZO, FOTOINT, FONTUBO)
SELECT
OBJECTID , 4,4CODE, 4IDPUNTINI, 4IDPUNTFIN, 4MATLIN, 4FORMSEZ, 4ALT_LIN, 4LARGH_LIN, 4QUOINI, 4QUOFIN, 4DISLINI,
4DISFIN, 4TIPFOG, 4TIPLINIDR, 4POS_TRATTA, 4POS_SUP, 4NOTE, 4LUNG, 4PENDENZA, 4DEN_TRONCO, 4ENTRA,
4ESCE, 4DAPOZZO, 4VERSOPOZZO, 4FOTOINT, 4FONTUBO
FROM unionepazzitubislim1;
insert into tubi
(OBJECTID , SEQ ,CODE, IDPUNTINI, IDPUNTFIN, MATLIN, FORMSEZ, ALT_LIN, LARGH_LIN, QUOINI, QUOFIN, DISLINI, DISFIN,
TIPFOG, TIPLINIDR, POS_TRATTA, POS_SUP, NOTE, LUNG, PENDENZA, DEN_TRONCO, ENTRA, ESCE, DAPOZZO,
VERSOPOZZO, FOTOINT, FONTUBO)
SELECT
OBJECTID , 5,5CODE, 5IDPUNTINI, 5IDPUNTFIN, 5MATLIN, 5FORMSEZ, 5ALT_LIN, 5LARGH_LIN, 5QUOINI, 5QUOFIN, 5DISLINI,
5DISFIN, 5TIPFOG, 5TIPLINIDR, 5POS_TRATTA, 5POS_SUP, 5NOTE, 5LUNG, 5PENDENZA, 5DEN_TRONCO, 5ENTRA,
5ESCE, 5DAPOZZO, 5VERSOPOZZO, 5FOTOINT, 5FONTUBO
FROM unionepazzitubislim1;
insert into tubi
(OBJECTID , SEQ ,CODE, IDPUNTINI, IDPUNTFIN, MATLIN, FORMSEZ, ALT_LIN, LARGH_LIN, QUOINI, QUOFIN, DISLINI, DISFIN,
TIPFOG, TIPLINIDR, POS_TRATTA, POS_SUP, NOTE, LUNG, PENDENZA, DEN_TRONCO, ENTRA, ESCE, DAPOZZO,
VERSOPOZZO, FOTOINT, FONTUBO)
SELECT
OBJECTID , 6,6CODE, 6IDPUNTINI, 6IDPUNTFIN, 6MATLIN, 6FORMSEZ, 6ALT_LIN, 6LARGH_LIN, 6QUOINI, 6QUOFIN, 6DISLINI,
6DISFIN, 6TIPFOG, 6TIPLINIDR, 6POS_TRATTA, 6POS_SUP, 6NOTE, 6LUNG, 6PENDENZA, 6DEN_TRONCO, 6ENTRA,
6ESCE, 6DAPOZZO, 6VERSOPOZZO, 6FOTOINT, 6FONTUBO
FROM unionepazzitubislim1;
| true |
be35284320be42d75cc17709ca72b993893d9ba2 | SQL | nikhil-muskowl/admin-panel | /plugins/faq_module/install/view.sql | UTF-8 | 512 | 3.546875 | 4 | [
"MIT"
] | permissive | -- faq_questions_view
CREATE OR REPLACE ALGORITHM = UNDEFINED
VIEW `faq_questions_view`
AS
SELECT t.*,td.language_id,td.text FROM faq_questions t
LEFT JOIN faq_question_details td ON td.id=t.id;
-- faq_answers_view
CREATE OR REPLACE ALGORITHM = UNDEFINED
VIEW `faq_answers_view`
AS
SELECT t.*,td.language_id,td.text,fqd.text AS question FROM faq_answers t
LEFT JOIN faq_answer_details td ON td.id=t.id
LEFT JOIN faq_question_details fqd ON fqd.id=t.question_id AND fqd.language_id=td.language_id; | true |
a4658af2f3a385bb3bdaf250961a35b08ee0fe71 | SQL | minguu42/tomeit-api | /build/create_tables.sql | UTF-8 | 1,509 | 3.609375 | 4 | [] | no_license | DROP TABLE IF EXISTS pomodoros;
DROP TABLE IF EXISTS tasks;
DROP TABLE IF EXISTS users;
CREATE TABLE IF NOT EXISTS users (
id INT PRIMARY KEY AUTO_INCREMENT,
digest_uid CHAR(64) NOT NULL UNIQUE,
rest_count INT DEFAULT 4 NOT NULL CHECK ( 1 <= rest_count AND rest_count <= 4 ),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
);
CREATE TABLE IF NOT EXISTS tasks (
id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
title VARCHAR(120) NOT NULL,
expected_pomodoro_num INT DEFAULT 0 NOT NULL CHECK (0 <= expected_pomodoro_num AND expected_pomodoro_num <= 6),
due_on TIMESTAMP,
is_completed BOOLEAN DEFAULT FALSE NOT NULL,
completed_on TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE IF NOT EXISTS pomodoros (
id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
task_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (task_id) REFERENCES tasks(id)
); | true |
2769ea9d6707d669adc73c880537fdbe6ffd31e7 | SQL | Aphasia-GitHub/Boco | /db/Oracle/dbTest/procedure/PROC_SP_INDOORS.sql | GB18030 | 8,026 | 2.78125 | 3 | [] | no_license | CREATE OR REPLACE PROCEDURE PROC_SP_INDOORS AS
BEGIN
DECLARE
CURSOR C_JOB IS
SELECT INDOORS.INT_ID,
RC.PROVINCE_NAME,
RC.REGION_NAME,
RC.CITY_NAME,
INDOORS.COUNTY_NAME AS VILLAGE_NAME,
INDOORS.GRID_ID GRID_NUM,
GRID.DEP_NAME OPERATE_DEPARTMENT,
INDOORS.INDDS_CODE INDOORS_NO,
INDOORS.NAME AS INDOORS_NAME,
INDOORS.COVER_DISTR_SYSTEM,
INDOORS.BUILDING_TYPE,
INDOORS.COVER_EARE COVER_AREA,
INDOORS.LOCATION AS ADDRESS,
INDOORS.LONGITUDE,
INDOORS.LATITUDE,
INDOORS.INFO_RESOURCE SOURCE_TYPE,
INDOORS.BUILDING_NUM,
INDOORS.BUILDING_FLOOR,
INDOORS.BUILDING_AREA,
INDOORS.INDOOR_BUILDING_NUM,
INDOORS.INDOOR_BUILDING_FLOOR,
INDOORS.INDOOR_BUILDING_AREA,
INDOORS.OUTDOOR_BUILDING_NUM,
CASE
WHEN CDMA.VENDOR_ID = 7 THEN
CDMA.BSC_NAME
ELSE
GETMSCIDBYREGION(RC.REGION_NAME) || '.' || CDMA.DCSID
END BSCID,
CDMA.BTSID,
CDMA.NAME AS BTS_NAME,
INDOORS.CI,
CELL.CELLID,
CELL.PN,
CELL.LAC,
GETCELLWORKFREQ(GETCARRIERPOWER(283,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID),
GETCARRIERPOWER(201,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID),
GETCARRIERPOWER(242,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID),
GETCARRIERPOWER(160,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID),
GETCARRIERPOWER(37,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID),
GETCARRIERPOWER(78,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID),
GETCARRIERPOWER(119,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID),
GETCARRIERPOWER(1019,
TO_CHAR(CELL.INT_ID),
CELL.VENDOR_ID)) AS WORKFREQ,
INDOORS.VENDOR_NAME,
INDOORS.NEAR_REPEATER_NUM,
INDOORS.FAR_REPEATER_NUM,
INDOORS.INTEGRATOR,
INDOORS.APPLIANCE_PROVIDE_VENDOR,
INDOORS.AMPLIFIER_NBR,
INDOORS.COUPLER_POWER_DIVIDER_NUM,
INDOORS.ATTENUATOR_NUM,
INDOORS.OPEN_TIME ONLINE_DATE,
INDOORS.INDOORS_CLASS,
INDOORS.SYS_STATUS,
INDOORS.MONITOR,
INDOORS.DISTANCE,
INDOORS.FDD_LENGTH FIBERLENGTH,
INDOORS.ANTENNA_FEEDER_AUTHORITY,
INDOORS.COMBINING_MODE,
CASE
WHEN INDOORS.COMBINING_MODE = 'Cר' THEN
''
ELSE
''
END AS COMBINING,
INDOORS.MAINTENANCE_UNIT MAINTAIN_PERSON,
INDOORS.MAINTENANCE_PERSON_PHONE,
INDOORS.CONTACT_OWNER,
INDOORS.CONTACT_OWNER_PHONE,
INDOORS.UPDATE_TIME OPERATIONTIME,
C.DISPLAY_NAME AS OPERATIONUSERNAME,
INDOORS.NOTE REMARK,
INDOORS.REGION_ID,
INDOORS.CITY_ID
FROM C_TCO_PRO_INDOORS INDOORS
LEFT JOIN C_REGION_CITY RC
ON RC.CITY_ID = INDOORS.CITY_ID
LEFT JOIN C_TCO_USER_V2 C
ON INDOORS.OPERATIONUSERID = C.USER_ID
LEFT JOIN CDMAUSER.C_CELL CELL
ON INDOORS.RELATED_CELL = CELL.INT_ID
LEFT JOIN CDMAUSER.C_BTS CDMA
ON CELL.RELATED_BTS = CDMA.INT_ID
LEFT JOIN C_TCO_PRO_BTS BTS
ON CELL.RELATED_BTS = BTS.INT_ID
LEFT JOIN TCO_PRO_GRID GRID
ON INDOORS.GRID_ID = GRID.GRID_NO;
--һαv_cinfo c_emp%ROWTYPE Ϊαc_empеһ
C_ROW C_JOB%ROWTYPE;
BEGIN
FOR C_ROW IN C_JOB LOOP
BEGIN
INSERT INTO HD_C_PRO_INDOORS
(INT_ID,
PROVINCE_NAME,
REGION_NAME,
CITY_NAME,
VILLAGE_NAME,
GRID_NUM,
OPERATE_DEPARTMENT,
INDOORS_NO,
INDOORS_NAME,
COVER_DISTR_SYSTEM,
BUILDING_TYPE,
COVER_AREA,
ADDRESS,
LONGITUDE,
LATITUDE,
SOURCE_TYPE,
BUILDING_NUM,
BUILDING_FLOOR,
BUILDING_AREA,
INDOOR_BUILDING_NUM,
INDOOR_BUILDING_FLOOR,
INDOOR_BUILDING_AREA,
OUTDOOR_BUILDING_NUM,
BSCID,
BTSID,
BTS_NAME,
CI,
CELLID,
PN,
LAC,
WORKFREQ,
VENDOR_NAME,
NEAR_REPEATER_NUM,
FAR_REPEATER_NUM,
INTEGRATOR,
APPLIANCE_PROVIDE_VENDOR,
AMPLIFIER_NBR,
COUPLER_POWER_DIVIDER_NUM,
ATTENUATOR_NUM,
ONLINE_DATE,
INDOORS_CLASS,
SYS_STATUS,
MONITOR,
DISTANCE,
FIBERLENGTH,
ANTENNA_FEEDER_AUTHORITY,
COMBINING_MODE,
COMBINING,
MAINTAIN_PERSON,
MAINTENANCE_PERSON_PHONE,
CONTACT_OWNER,
CONTACT_OWNER_PHONE,
OPERATIONTIME,
OPERATIONUSERNAME,
REMARK,
REGION_ID,
CITY_ID,
HD_TIME)
VALUES
(C_ROW.INT_ID,
C_ROW.PROVINCE_NAME,
C_ROW.REGION_NAME,
C_ROW.CITY_NAME,
C_ROW.VILLAGE_NAME,
C_ROW.GRID_NUM,
C_ROW.OPERATE_DEPARTMENT,
C_ROW.INDOORS_NO,
C_ROW.INDOORS_NAME,
C_ROW.COVER_DISTR_SYSTEM,
C_ROW.BUILDING_TYPE,
C_ROW.COVER_AREA,
C_ROW.ADDRESS,
C_ROW.LONGITUDE,
C_ROW.LATITUDE,
C_ROW.SOURCE_TYPE,
C_ROW.BUILDING_NUM,
C_ROW.BUILDING_FLOOR,
C_ROW.BUILDING_AREA,
C_ROW.INDOOR_BUILDING_NUM,
C_ROW.INDOOR_BUILDING_FLOOR,
C_ROW.INDOOR_BUILDING_AREA,
C_ROW.OUTDOOR_BUILDING_NUM,
C_ROW.BSCID,
C_ROW.BTSID,
C_ROW.BTS_NAME,
C_ROW.CI,
C_ROW.CELLID,
C_ROW.PN,
C_ROW.LAC,
C_ROW.WORKFREQ,
C_ROW.VENDOR_NAME,
C_ROW.NEAR_REPEATER_NUM,
C_ROW.FAR_REPEATER_NUM,
C_ROW.INTEGRATOR,
C_ROW.APPLIANCE_PROVIDE_VENDOR,
C_ROW.AMPLIFIER_NBR,
C_ROW.COUPLER_POWER_DIVIDER_NUM,
C_ROW.ATTENUATOR_NUM,
C_ROW.ONLINE_DATE,
C_ROW.INDOORS_CLASS,
C_ROW.SYS_STATUS,
C_ROW.MONITOR,
C_ROW.DISTANCE,
C_ROW.FIBERLENGTH,
C_ROW.ANTENNA_FEEDER_AUTHORITY,
C_ROW.COMBINING_MODE,
C_ROW.COMBINING,
C_ROW.MAINTAIN_PERSON,
C_ROW.MAINTENANCE_PERSON_PHONE,
C_ROW.CONTACT_OWNER,
C_ROW.CONTACT_OWNER_PHONE,
C_ROW.OPERATIONTIME,
C_ROW.OPERATIONUSERNAME,
C_ROW.REMARK,
C_ROW.REGION_ID,
C_ROW.CITY_ID,
SYSDATE);
COMMIT;
END;
END LOOP;
END;
END PROC_SP_INDOORS;
| true |
de68869b9c4d1bedeef0fb3cc75bb4a4d152516b | SQL | architkansal/MediSurf | /MediSurf-DB/medisurf.sql | UTF-8 | 7,487 | 2.8125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.0.10deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 27, 2017 at 11:03 PM
-- Server version: 5.5.49-0ubuntu0.14.04.1
-- PHP Version: 5.5.9-1ubuntu4.17
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 utf8 */;
--
-- Database: `medisurf`
--
-- --------------------------------------------------------
--
-- Table structure for table `alternatives`
--
CREATE TABLE IF NOT EXISTS `alternatives` (
`original` varchar(200) NOT NULL,
`alternative` varchar(200) NOT NULL,
`latitude` varchar(50) NOT NULL,
`longitude` varchar(50) NOT NULL,
`time_value` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `alternatives`
--
INSERT INTO `alternatives` (`original`, `alternative`, `latitude`, `longitude`, `time_value`) VALUES
('dsoidd', 'discorb', '54.5341', '526.23', '2016-11-06 01:07:28'),
('discorb', 'Glubos', '17.9839378', '79.5330768', '2016-11-06 01:08:13'),
('liofen xl', ' Parafo', '17.9839378', '79.5330768', '2016-11-06 01:13:09'),
('defzar', ' laz', '17.9839378', '79.5330768', '2016-11-06 01:13:09'),
('triben-v', 'Clima Fort', '17.9839378', '79.5330768', '2016-11-06 01:13:09'),
('liofen xl', ' Spinofe', '17.9839378', '79.5330768', '2016-11-06 02:56:17'),
('defzar', ' Defza', '17.9839378', '79.5330768', '2016-11-06 02:56:17'),
('triben-v', ' Camyd', '17.9839378', '79.5330768', '2016-11-06 02:56:17'),
('discorb', ' Glubos', '17.9839378', '79.5330768', '2016-11-06 03:54:28'),
('Spinofen', 'Parafo', '17.9839378', '79.5330768', '2016-11-06 05:45:45'),
('Defnom', 'Defza', '17.9839378', '79.5330768', '2016-11-06 05:45:45'),
('Triben-v', 'Camyd', '17.9839378', '79.5330768', '2016-11-06 05:45:45'),
('Spinofen', ' Parafo', '17.983673', '79.5332525', '2016-11-06 06:20:43'),
('Defnom', ' Defza', '17.983673', '79.5332525', '2016-11-06 06:20:43'),
('Triben-v', ' Triben-', '17.983673', '79.5332525', '2016-11-06 06:20:43'),
('Triben-v', ' Clima Fort', '17.9827868', '79.5346138', '2016-11-07 15:38:16'),
('Spinofen', ' Parafo', '17.9827868', '79.5346138', '2016-11-07 15:38:16'),
('Defnom', ' Defno', '17.9827868', '79.5346138', '2016-11-07 15:38:16'),
('Glubose', ' Glubos', '17.9830754', '79.5349884', '2016-11-12 18:24:27'),
('Clima forte', ' Camyd', '17.9830754', '79.5349884', '2016-11-12 18:24:27'),
('Spinofen', ' Parafo', '17.9830754', '79.5349884', '2016-11-12 18:24:27'),
('Spinofen', ' Parafo', '17.9891308', '79.540012', '2017-01-16 10:51:40'),
('Triben-v', ' Clima Fort', '17.9891308', '79.540012', '2017-01-16 10:51:40'),
('Clima forte', ' Camyd', '17.9891308', '79.540012', '2017-01-16 10:51:40');
-- --------------------------------------------------------
--
-- Table structure for table `medicine`
--
CREATE TABLE IF NOT EXISTS `medicine` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
`generic_salt` varchar(200) NOT NULL,
`brand_name` varchar(200) NOT NULL,
`price` float NOT NULL,
`description` text NOT NULL,
`type` varchar(100) NOT NULL,
`mg_ml` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `medicine`
--
INSERT INTO `medicine` (`id`, `name`, `generic_salt`, `brand_name`, `price`, `description`, `type`, `mg_ml`) VALUES
(1, 'Discorb', 'Acarbose', 'elder pharmaceuticals pvt ltd', 7.5, '\r\nAcarbose prevents the action of certain enzymes in the digestive tract that break down carbohydrates to release glucose, which is subsequently absorbed in the blood. Thus, it controls the rise of blood glucose level after a meal. ', 'tablet', 50),
(2, 'Acarex', 'Acarbose', 'invision medi sciences', 5.5, '\r\nAcarbose prevents the action of certain enzymes in the digestive tract that break down carbohydrates to release glucose, which is subsequently absorbed in the blood. Thus, it controls the rise of blood glucose level after a meal. \r\n', 'tablet', 25),
(3, 'Glubose', 'Acarbose', 'otsira aristo pharmaceuticals pvt ltd', 3.6, '\r\nAcarbose prevents the action of certain enzymes in the digestive tract that break down carbohydrates to release glucose, which is subsequently absorbed in the blood. Thus, it controls the rise of blood glucose level after a meal. \r\n', 'tablet', 25),
(4, 'Liofen XL', 'Baclofen', 'sun pharmaceutical industries ltd', 28, 'This medication is a derivative of gamma-aminobutyric acid (GABA), prescribed for severe chronic spasticity. It also relieves pain and improves muscle movement.\r\n\r\n\r\n\r\n\r\n', 'tablet', 30),
(5, 'Parafon', 'Baclofen', 'johnson & johnson', 5.03, 'This medication is a derivative of gamma-aminobutyric acid (GABA), prescribed for severe chronic spasticity. It also relieves pain and improves muscle movement', 'tablet', 500),
(6, 'Spinofen', 'Baclofen', 'Chemo Biological', 12.2, 'This medication is a derivative of gamma-aminobutyric acid (GABA), prescribed for severe chronic spasticity. It also relieves pain and improves muscle movement', 'tablet', 25),
(7, 'Defnom', 'Deflazacort', 'Acinom healthcare', 8, '\r\nThis medication is a glucocorticoid, prescribed for anti-inflammatory conditions, and used as an immunosuppressant. It is a prodrug.', 'tablet', 6),
(8, 'laza', 'Deflazacort', 'Vilberry healthcare', 7.65, 'This medication is a glucocorticoid, prescribed for anti-inflammatory conditions, and used as an immunosuppressant. It is a prodrug.', 'tablet', 6),
(9, 'Defzar', 'Deflazacort', 'Argos Healthcare pvt ltd', 35, 'This medication is a glucocorticoid, prescribed for anti-inflammatory conditions, and used as an immunosuppressant. It is a prodrug.', 'tablet', 30),
(10, 'Triben-V', 'Clindamycin', 'jenburkt', 113, '\r\nThis medication is an antibiotic, prescribed for certain types of bacterial infections, including infections of the lungs, skin, blood, female reproductive organs and internal organs. It slows or stops the growth of bacteria.', 'tablet', 100),
(11, 'Clima Forte', 'Clindamycin', 'Dewcare', 14.2, '\r\nThis medication is an antibiotic, prescribed for certain types of bacterial infections, including infections of the lungs, skin, blood, female reproductive organs and internal organs. It slows or stops the growth of bacteria.', 'tablet', 100),
(12, 'Camyda', 'Clindamycin', 'Wallace', 15, '\r\nThis medication is an antibiotic, prescribed for certain types of bacterial infections, including infections of the lungs, skin, blood, female reproductive organs and internal organs. It slows or stops the growth of bacteria.', 'tablet', 150);
-- --------------------------------------------------------
--
-- Table structure for table `price`
--
CREATE TABLE IF NOT EXISTS `price` (
`original` int(11) NOT NULL,
`altered` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `price`
--
INSERT INTO `price` (`original`, `altered`) VALUES
(0, 0),
(0, 0),
(0, 0),
(0, 0),
(924, 887),
(924, 887),
(924, 887),
(924, 887),
(924, 887),
(2198, 1351),
(776, 399),
(75, 72),
(457, 247),
(457, 376),
(457, 285),
(69, 13),
(309, 73);
/*!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 */;
| true |
bef08e961acbd5291866ed5d505d81011b5fb454 | SQL | irpanaprialdi/worked | /worked.sql | UTF-8 | 3,934 | 3.1875 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 08 Feb 2021 pada 00.43
-- Versi server: 10.4.6-MariaDB
-- Versi PHP: 7.3.8
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: `worked`
--
-- --------------------------------------------------------
--
-- Struktur dari tabel `biodata`
--
CREATE TABLE `biodata` (
`id_biodata` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`alamat` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `biodata`
--
INSERT INTO `biodata` (`id_biodata`, `id_user`, `alamat`) VALUES
(7, 8, 'Jakarta');
-- --------------------------------------------------------
--
-- Struktur dari tabel `daftar_perusahaan`
--
CREATE TABLE `daftar_perusahaan` (
`id_perusahaan` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`nama_perusahaan` varchar(100) NOT NULL,
`alamat_perusahaan` varchar(255) NOT NULL,
`gaji_perusahaan` double NOT NULL,
`tentang_perusahaan` varchar(255) NOT NULL,
`logo` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `daftar_perusahaan`
--
INSERT INTO `daftar_perusahaan` (`id_perusahaan`, `id_user`, `nama_perusahaan`, `alamat_perusahaan`, `gaji_perusahaan`, `tentang_perusahaan`, `logo`) VALUES
(10, 8, 'Nvidia', 'Jakarta', 1000000, 'Product impian para gamer', 'images/nvidia.png'),
(12, 8, 'Google', 'Jakarta', 900000000, 'Salah satu perusahaan terbaik', 'images/google.jpg'),
(13, 8, 'Microsoft', 'Jakarta', 800000000, 'Product unggulan', 'images/microsoft.png'),
(14, 8, 'Intel', 'Jakarta', 850000000, 'Product kelas atas', 'images/intel.jpg');
-- --------------------------------------------------------
--
-- Struktur dari tabel `user`
--
CREATE TABLE `user` (
`id_user` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data untuk tabel `user`
--
INSERT INTO `user` (`id_user`, `username`, `email`, `password`) VALUES
(8, 'Admin', 'admin@gmail.com', '3d4f2bf07dc1be38b20cd6e46949a1071f9d0e3d');
--
-- Indexes for dumped tables
--
--
-- Indeks untuk tabel `biodata`
--
ALTER TABLE `biodata`
ADD PRIMARY KEY (`id_biodata`),
ADD KEY `id_user` (`id_user`);
--
-- Indeks untuk tabel `daftar_perusahaan`
--
ALTER TABLE `daftar_perusahaan`
ADD PRIMARY KEY (`id_perusahaan`),
ADD KEY `id_user` (`id_user`);
--
-- Indeks untuk tabel `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id_user`);
--
-- AUTO_INCREMENT untuk tabel yang dibuang
--
--
-- AUTO_INCREMENT untuk tabel `biodata`
--
ALTER TABLE `biodata`
MODIFY `id_biodata` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT untuk tabel `daftar_perusahaan`
--
ALTER TABLE `daftar_perusahaan`
MODIFY `id_perusahaan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT untuk tabel `user`
--
ALTER TABLE `user`
MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--
--
-- Ketidakleluasaan untuk tabel `biodata`
--
ALTER TABLE `biodata`
ADD CONSTRAINT `biodata_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`);
--
-- Ketidakleluasaan untuk tabel `daftar_perusahaan`
--
ALTER TABLE `daftar_perusahaan`
ADD CONSTRAINT `daftar_perusahaan_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`);
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 */;
| true |
423c577192c1c524443a07f02c0c2e0c01fc3723 | SQL | hatallika/relational_database_mysql | /coursework/coursework.sql | UTF-8 | 24,161 | 3.25 | 3 | [] | no_license | /* Задача описать модель хранения данных для сети продуктовых магазинов имеющей программу лояльности с бонусной картой.
* Личный кабинет покупателя с историей чеков, бонусов, персональных предложений.
Пользователи: имя, пароль, e-mail, телефон, дата рождения
Анкета с данными пользователя: Город, пол, семейное положение, дети, хобби.
Личный кабинет: Количество бонусов, скидки, история покупок, персональные купоны
(На развитие *подписка на рассылку, * обратная связь, * профили в соц сетях).
Магазин:
Каталог: Категории товаров, Товары
(На развитие *Публикации: Новости и акции компании, скидки на категорию,скидки на товар)
Используемые Функции:
- Сумма чека по его номеру/ Сумма чека по id чека (будет использоваться для начисления бонусов и расчет среднего чека)
Процедура: Вывод списка покупок пользователя в заданный период даты.
Триггер: Записать в логи начисление бонусов в таблицу bonus_history
Представления:
- Вывести список пользователей и сумму чека их последней покупки
- История покупок.
Выборка: вывесту сумму чеков на основе представления "Истории покупок"
**/
DROP DATABASE IF EXISTS retailer_shop;
CREATE DATABASE retailer_shop;
USE retailer_shop;
#Категории товаров в магазине
DROP TABLE IF EXISTS catalogs;
CREATE TABLE catalogs (
id SERIAL PRIMARY KEY,
name VARCHAR(255) COMMENT 'Название Категории товара',
UNIQUE unique_name(name(20))
) COMMENT = 'Категории товаров';
INSERT INTO catalogs (name) VALUES
('Овощи. Фрукты'),
('Молочные продукты'),
('Мясо. Птица'),
('Рыба. Морепродукты'),
('Бакалея'),
('Вода. Соки. Напитки'),
('Колбасы. Сосиски. Мясные деликатесы'),
('Сыры'),
('Замороженные продукты'),
('Хлеб. Выпечка'),
('Чай. Кофе'),
('Сладости')
;
#Товары магазина
DROP TABLE IF EXISTS products;
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(255) COMMENT 'Название товара',
description TEXT COMMENT 'Описание товара',
price DECIMAL (11,2) COMMENT 'Цена товара',
unit_type INT COMMENT 'Единица измерения',
catalog_id BIGINT UNSIGNED,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (catalog_id) REFERENCES catalogs(id)
) COMMENT = 'Список товаров';
INSERT INTO `products` VALUES
(1,'consequuntur','Et eum et sit dignissimos vel. Dicta consequatur aliquid sunt sapiente ut voluptas est odit. Sequi quod eum autem.',0.00,4,1,'2020-07-06 00:24:28','1994-01-10 10:54:41'),
(2,'rerum','Aliquam sapiente vel enim dolorem. Sequi laborum temporibus iure. Consequatur sunt et quia optio deleniti voluptates. Voluptate commodi deserunt harum.',7306807.50,2,2,'1990-09-16 20:43:08','2020-03-27 23:39:25'),
(3,'fugit','Dolores blanditiis natus non est. Sit exercitationem rem sed iure. Voluptatibus animi beatae beatae incidunt rem praesentium nostrum. Et impedit reiciendis consequatur numquam maiores. Eum ut velit voluptas voluptas aut quo.',0.00,4,3,'1972-10-18 14:17:39','1987-09-03 16:34:31'),
(4,'delectus','Et commodi illo atque dolor aperiam consequuntur ullam. Quo assumenda cum reprehenderit commodi unde. Laudantium molestias voluptate placeat cupiditate iure quasi dolor. Illo quia quidem eum dolor.',5288.05,3,4,'1974-03-06 01:07:35','1977-02-28 15:32:18'),
(5,'qui','Id inventore provident aut incidunt. Omnis autem molestias adipisci enim. Adipisci assumenda sed quo est sed sed.',7074707.69,4,5,'2002-10-29 22:27:28','2007-07-23 18:38:08'),
(6,'omnis','Doloribus ducimus omnis consequuntur cumque repellendus rerum impedit. Eos ad quisquam voluptatum reiciendis dolorem.',3.41,2,6,'1970-04-05 19:08:11','1975-03-30 17:25:47'),
(7,'repellendus','Eum nisi voluptatem aut rerum. Et assumenda excepturi et.',2118107.00,1,7,'2012-10-15 10:09:00','1994-10-22 07:25:01'),
(8,'alias','Voluptatum occaecati alias saepe hic ex optio. Sit nulla magnam autem asperiores praesentium totam. Enim voluptatibus aliquid voluptate quia minima doloremque. Qui et vitae voluptas rerum quos optio quia et.',6249.01,2,8,'2018-11-11 01:17:32','2015-02-11 10:33:02'),
(9,'molestiae','Et et natus earum quia odio debitis. Nostrum possimus omnis dolorum dolores et. Eum dolor autem sit nam cumque ducimus.',17821310.44,1,9,'1988-01-31 16:30:29','2019-11-21 07:44:20'),
(10,'architecto','Ut voluptas deserunt dolorum. Deleniti velit fugiat alias vel ex veritatis debitis. Aliquid quidem id deserunt occaecati.',897.28,2,10,'1982-06-01 10:27:00','1972-11-15 02:07:09')
;
# Покупатели состоящие в программе лояльности
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id SERIAL PRIMARY KEY, # BEGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
firstname VARCHAR(200) COMMENT 'Имя покупателя',
lastname VARCHAR(200) COMMENT 'Фамилия покупателя',
email VARCHAR(200) UNIQUE,
password VARCHAR(255),
phone BIGINT UNSIGNED UNIQUE, # +7 (900) 123-45-67 => 79 001 234 567
birthday_at DATE COMMENT 'Дата рождения',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_users_username (firstname, lastname)
) COMMENT 'Покупатели';
INSERT INTO `users` VALUES
(1,'Wilford','Rowe','estella86@example.org','5243bd50e60f8f7996244228075a2bfa00c7df79',89452258497,'2002-05-16','2018-04-25 12:28:20','2013-05-31 12:51:26'),
(2,'Rey','Grant','bartoletti.morris@example.org','826bb0114ac2ff068d223b83eb51f5001a5071be',84943918446,'2019-06-29','2014-03-22 05:13:23','1975-12-07 16:58:08'),
(3,'Kolby','Blick','kayli06@example.com','4e77635fb53289aacb0dc499a18401154e433b95',88673922559,'2000-11-25','2010-09-08 06:15:38','1989-04-17 12:03:11'),
(4,'Maiya','Hoeger','zhegmann@example.com','edf5306562f395ead8d9a7d88466ca552725d453',89841043953,'1990-10-22','1986-11-25 17:33:13','1973-11-02 08:38:19'),
(5,'Christelle','Gislason','hoyt74@example.org','44939384567251075c3548b64cbae1ee2e75f724',82262969305,'1997-08-25','1975-01-05 12:40:06','1995-07-15 16:00:40'),
(6,'Neva','Kohler','goyette.cristobal@example.org','496c6ed34cc1a6f323553a6768bf3698f3fc706f',81724706240,'2001-08-23','1970-08-26 15:20:11','1983-06-08 07:17:00'),
(7,'Francis','Pouros','bonnie73@example.org','4fa5e42947b2eebf951d2a9714a9611bd974ee3c',82299607819,'2005-08-25','1977-01-13 00:30:31','1979-10-26 16:52:05'),
(8,'Timmothy','Moen','claudie.glover@example.com','b3708ccd92683a162d02ec81cf1060157169dd39',85223061065,'1973-07-16','2019-09-26 21:57:26','2001-12-16 05:24:15'),
(9,'Irma','Crooks','kbernhard@example.net','9de13f69668ff4e404f68e3b28f7541506fb6762',87514515323,'2009-09-15','1986-10-05 15:17:52','2008-03-29 12:44:45'),
(10,'Weston','Hackett','marianne06@example.com','dcdb86606c4fb4b5014fa4bcd7a7cec22236a906',89559451052,'1977-06-28','2006-08-23 01:31:58','2017-07-10 13:58:17')
;
# Анкета покупателя questionnaire
DROP TABLE IF EXISTS questionnaire;
CREATE TABLE questionnaire (
user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
gender ENUM ('male','female'),
hometown VARCHAR(250),
family_status BIT,
created_at DATETIME DEFAULT NOW(),
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
#Хобби и дети будут вынесены в отдельные таблицы со связями user_id
FOREIGN KEY (user_id) REFERENCES users(id)
);
INSERT INTO `questionnaire` VALUES
(1,'female','Michelebury',1,'2014-10-27 23:32:31','1983-06-23 12:13:52'),
(2,'female','Wehnerburgh',1,'1995-08-29 03:59:53','2004-08-27 07:04:59'),
(3,'male','West Nigelberg',1,'2011-09-20 04:47:17','1996-11-27 22:24:04'),
(4,'female','Connorton',0,'1975-05-22 08:16:05','2000-07-18 09:34:09'),
(5,'male','South Eleonore',1,'1999-06-13 12:42:44','2019-01-08 07:16:06'),
(6,'female','Skylarfort',1,'1990-02-27 15:11:37','2001-10-15 02:36:25'),
(7,'male','Bobbieton',1,'1993-01-02 10:14:57','2011-01-09 18:48:18'),
(8,'female','Elzafort',1,'1999-06-11 09:52:17','1994-01-18 11:32:11'),
(9,'female','Adeleshire',0,'1996-05-04 16:13:21','2009-02-12 05:43:08'),
(10,'female','Lake Justinatown',1,'1989-03-22 22:23:06','1987-08-04 19:43:34')
;
-- Дети в анкете покупателя. Ребенок созается в момент записи из анкеты родителя. Не учитываем если разные родители записали одного и того же ребенка. Будут как разные.
DROP TABLE IF EXISTS children;
CREATE TABLE children (
id SERIAL PRIMARY KEY,
user_id BIGINT UNSIGNED,
name VARCHAR(255) COMMENT 'Имя ребенка',
birthday_at DATE COMMENT 'Дата рождения ребенка',
gender ENUM ('male','female'),
FOREIGN KEY (user_id) REFERENCES users(id)
);
INSERT INTO `children` VALUES
(1,1,'Rick','2009-05-07','female'),(2,2,'Seth','1982-03-13','female'),
(3,3,'Fiona','2014-10-06','female'),(4,4,'Natalia','1980-01-22','female'),
(5,5,'Ashleigh','1992-06-21','male'),(6,6,'Khalid','1984-05-29','male'),
(7,7,'Andreane','1986-08-08','female'),(8,8,'Yvonne','1972-06-29','male'),
(9,9,'Arturo','1986-04-18','male'),(10,10,'Gertrude','1991-09-12','male')
;
-- справочник интересов/хобби в Анкете покупателя
DROP TABLE IF EXISTS interests;
CREATE TABLE interests (
id SERIAL PRIMARY KEY,
name VARCHAR(255) COMMENT 'Категория интересов'
);
INSERT INTO interests (name) VALUES
('Спорт. Фитнес'), ('Путешествия'), ('Сад. Огород. Дача'),
('Рукоделие'), ('Иностранные языки'), ('Дизайн. Рисование'),
('Компьютерные игры'), ('Чтение'),('Фильмы'),('Музыка');
DROP TABLE IF EXISTS users_interests;
CREATE TABLE users_interests (
user_id BIGINT UNSIGNED NOT NULL,
interest_id BIGINT UNSIGNED NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (interest_id) REFERENCES interests(id)
);
INSERT INTO `users_interests` VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
-- Список купонов на скидку на категорию товаров
DROP TABLE IF EXISTS coupons_catalog;
CREATE TABLE coupons_catalog (
id SERIAL PRIMARY KEY,
catalog_id BIGINT UNSIGNED NOT NULL,
discount_percent DECIMAL(5,2) COMMENT 'процент скидки 0..100',
started_at DATETIME COMMENT 'Начало действия скидки',
finished_at DATETIME COMMENT 'Конец действия скидки',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (catalog_id) REFERENCES catalogs(id)
) COMMENT 'скидки на категории товаров';
INSERT INTO coupons_catalog (catalog_id, discount_percent, started_at, finished_at) VALUES
(1, 30.00, '2021-10-01 00:00:00', '2021-12-31 23:59:59'),
(2, 30.00, '2021-10-01 00:00:00', '2021-12-31 23:59:59'),
(2, 15.00, '2021-10-01 00:00:00', '2021-12-31 23:59:59'),
(3, 25.00, '2021-10-01 00:00:00', '2021-12-31 23:59:59'),
(4, 5.00, '2021-10-01 00:00:00', '2021-12-31 23:59:59')
;
-- Персональные купоны
/*Купоны - скидки на категории товаров предоставляем группе пользователей*/
DROP TABLE IF EXISTS coupons_catalog_users;
CREATE TABLE coupons_catalog_users (
user_id BIGINT UNSIGNED NOT NULL,
coupons_catalog_id BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (user_id, coupons_catalog_id),
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (coupons_catalog_id) REFERENCES coupons_catalog(id)
);
INSERT INTO coupons_catalog_users
(user_id, coupons_catalog_id)
VALUES(1, 1),(1,2),(2,1),(3,1),(4,1),(5,1),(2,4),(6,4);
#Бонусный счет покупателя. Возможно должен быть вычитаемым из истории полкупок и чеков, либо записан из бизнес логики сервиса.
DROP TABLE IF EXISTS bonus_account;
CREATE TABLE bonus_account (
user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
total DECIMAL(10,2),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
INSERT INTO `bonus_account`(user_id, total) VALUES
(1,721.00),(2,124.00),(3,554.00),(4,771.00),(5,533.00),
(6,713.00),(7,820.00),(8,158.00),(9,274.00),(10,537.00);
#Список сформированных чеков
DROP TABLE IF EXISTS receipts;
CREATE TABLE receipts (
id SERIAL PRIMARY KEY,
`number` BIGINT UNSIGNED NOT NULL ,
user_id BIGINT UNSIGNED NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
) COMMENT = 'Чеки покупателей';
INSERT INTO `receipts` VALUES
(1,4,1,'2020-07-24 19:07:33','2020-10-18 06:19:12'),(2,936287374,2,'2015-06-05 08:57:00','1978-04-17 03:40:58'),
(3,0,3,'1997-04-07 05:59:11','1984-07-04 06:44:06'),(4,911446454,4,'2014-02-02 15:41:55','1982-11-13 12:36:48'),
(5,668854,5,'1999-05-07 07:09:47','1995-02-23 08:06:57'),(6,3250142,6,'1980-07-20 21:41:18','1982-01-08 06:57:15'),
(7,41137,7,'1999-03-31 20:08:12','2021-02-14 08:05:20'),(8,78,8,'2006-08-09 10:43:55','2008-01-02 03:44:50'),
(9,183869,9,'2003-03-05 23:53:22','2010-01-13 22:52:02'),(10,5035932,10,'1994-12-07 13:36:51','1972-02-17 00:39:15'),
(11,2488335,1,'2021-07-01 17:45:52','2021-07-06 22:23:24'),(12,3261,2,'1984-09-07 04:45:39','1984-11-06 19:51:18'),
(13,140984,1,'2013-07-07 03:21:48','2013-07-04 04:11:49'),(14,108571,4,'1983-03-17 09:52:27','1996-09-21 00:07:26')
;
# Расшифровка чеков: список товаров в чеках
DROP TABLE IF EXISTS receipts_products;
CREATE TABLE receipts_products (
receipt_id BIGINT UNSIGNED NOT NULL,
product_id BIGINT UNSIGNED NOT NULL,
price_on_sale DECIMAL(10,2) NOT NULL COMMENT 'Стоимость товара на момент продажи' ,
total INT UNSIGNED DEFAULT 1 COMMENT 'Количество товара в чеке',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (receipt_id, product_id),
FOREIGN KEY (receipt_id) REFERENCES receipts(id),
FOREIGN KEY (product_id) REFERENCES products(id)
) COMMENT = 'Состав чека';
INSERT INTO receipts_products
(receipt_id, product_id, price_on_sale, total)
VALUES
(1, 1, '200.00', 2),
(1, 2, '3000.00', 1),
(1, 3, '500.00', 1),
(1, 7, '500.00', 1),
(2, 1, '500.00', 1),
(2, 3, '500.00', 1),
(3, 2, '500.00', 1),
(3, 4, '500.00', 1),
(3, 6, '500.00', 1),
(4, 1, '200.00', 2),
(5, 3, '500.00', 2),
(6, 4, '500.00', 3),
(6, 3, '500.00', 1),
(7, 1, '200.00', 3),
(8, 7, '500.00', 1),
(9, 7, '500.00', 1),
(10, 7, '500.00', 1),
(11, 2, '3000.00',1),
(13, 1, '200.00', 2)
;
#Бонусы: таблица начислений по чеку
/*Храним в отдельной таблице вместе с чеками. По бизнес логике бонусы вычисляются от чека при определенных условиях(процент от суммы чека, покупка определенных позиций в чеке и.т.д.*/
DROP TABLE IF EXISTS receipts_bonuses;
CREATE TABLE receipts_bonuses (
receipt_id BIGINT UNSIGNED NOT NULL,
bonus DECIMAL(10,2),
FOREIGN KEY(receipt_id) REFERENCES receipts(id)
);
# История начисления списания бонусов. Храним движения по счету
/*Справочник событий к начислению бонусов и списанию*/
DROP TABLE IF EXISTS descriptions_operation;
CREATE TABLE descriptions_operation (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) COMMENT 'Причина изменения бонусов'
);
INSERT INTO descriptions_operation
(name)
VALUES('Начисление: по чеку'), ('Списание: по чеку'),
('Начисление: День рождение'), ('Списание: возврат по чеку'), ('Персональная акция')
;
DROP TABLE IF EXISTS bonus_history;
CREATE TABLE bonus_history (
id SERIAL PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
quantity DECIMAL(10,2) COMMENT 'Количество начисленных или списанных бонусов',
operation ENUM ('accrued', 'write-off'),
`date` DATETIME COMMENT 'дата и время операции',
description_operation_id INT UNSIGNED NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (description_operation_id) REFERENCES descriptions_operation(id)
);
INSERT INTO `bonus_history` VALUES
(1,1,174.00,'write-off','1978-11-23 09:23:00',1),(2,2,176.00,'write-off','1990-03-16 15:12:40',2),
(3,3,129.00,'accrued','1974-09-28 23:05:49',3),(4,4,117.00,'accrued','1991-01-30 23:26:45',4),
(5,5,171.00,'write-off','1991-02-18 01:18:32',5),(6,6,192.00,'accrued','1996-09-28 10:01:26',1),
(7,7,167.00,'accrued','1998-10-31 11:45:15',2),(8,8,127.00,'accrued','1970-02-03 10:23:15',3),
(9,9,173.00,'write-off','1978-12-13 07:57:00',4),(10,10,160.00,'accrued','2014-05-05 07:29:12',5),
(11,1,198.00,'accrued','2000-06-29 20:24:07',1),(12,2,180.00,'write-off','2004-08-25 04:25:48',2),
(13,3,197.00,'accrued','2019-07-06 13:21:30',3),(14,4,150.00,'accrued','2000-10-28 23:43:42',4),
(15,5,125.00,'write-off','1976-08-07 22:07:42',5),(16,6,122.00,'write-off','1988-01-06 22:36:14',1),
(17,7,148.00,'accrued','1985-09-30 08:00:15',2),(18,8,135.00,'write-off','1971-03-24 06:43:21',3),
(19,9,165.00,'write-off','1975-01-24 13:56:06',4),(20,10,181.00,'accrued','2018-02-22 08:25:03',5),
(21,1,114.00,'write-off','1974-08-10 03:27:24',1),(22,2,139.00,'write-off','2007-05-27 18:46:07',2),
(23,3,197.00,'accrued','2001-07-29 06:46:45',3),(24,4,128.00,'accrued','1983-12-31 01:10:36',4),
(25,5,164.00,'write-off','2006-08-03 18:27:42',5),(26,6,127.00,'write-off','1973-01-23 08:52:09',1),
(27,7,163.00,'write-off','1996-10-17 09:15:40',2),(28,8,159.00,'write-off','1990-11-02 02:54:05',3),
(29,9,123.00,'write-off','2014-09-05 08:11:50',4),(30,10,100.00,'write-off','1989-06-12 06:01:42',5)
;
/*Создадим триггер записывающий в логи начисление бонусов AFTER INSERT таблицы receipts_bonuses* пользователю*/
DROP TRIGGER IF EXISTS retailer_shop.after_insert_receipts_bonuses_for_user;
USE retailer_shop;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost` TRIGGER `after_insert_receipts_bonuses_for_user` AFTER INSERT ON `receipts_bonuses` FOR EACH ROW BEGIN
DECLARE _user_id BIGINT UNSIGNED;
SELECT user_id INTO _user_id
FROM receipts
WHERE receipts.id = new.receipt_id;
INSERT INTO bonus_history (user_id,quantity, operation,`date`, description_operation_id) VALUES
(_user_id, new.bonus ,'accrued', NOW(), 1);
END $$
DELIMITER ;
/*Функция выводит сумму чека по его номеру.
* Учитываем стоимость товара на момент продажи указанную в чеке (receipts_products), а не текущую стоимость товара в products*/
DROP FUNCTION IF EXISTS retailer_shop.receipt_amount;
DELIMITER $$
$$
CREATE FUNCTION retailer_shop.receipt_amount(num INT)
RETURNS DECIMAL(10,2) READS SQL DATA
BEGIN
DECLARE total DECIMAL(10,2);
SELECT SUM(rp.price_on_sale * rp.total) INTO total
FROM receipts r
JOIN receipts_products rp ON r.id = rp.receipt_id
WHERE r.`number` = num;
RETURN total;
END$$
DELIMITER ;
SELECT receipt_amount(4);
/*Функция считает 3% от суммы чека по его id. Будем использовать ее для начисления бонусов за покупку.
* Учитываем стоимость товара на момент продажи указанную в чеке (receipts_products), а не текущую стоимость товара в products*/
DROP FUNCTION IF EXISTS retailer_shop.receipt_amount_id;
DELIMITER $$
$$
CREATE FUNCTION retailer_shop.receipt_amount_id(_id INT)
RETURNS DECIMAL(10,2) READS SQL DATA
BEGIN
DECLARE total DECIMAL(10,2);
SELECT SUM(rp.price_on_sale * rp.total) INTO total
FROM receipts_products rp
WHERE rp.receipt_id = _id;
RETURN total;
END$$
DELIMITER ;
SELECT receipt_amount_id(2);
/*Процедура shopping_list(id, date1, date2) выводит список покупок пользователя по его id на выбранный период даты */
DROP PROCEDURE IF EXISTS shopping_list;
DELIMITER $$
$$
CREATE PROCEDURE shopping_list(_user_id BIGINT UNSIGNED, start_date DATE, end_date DATE)
BEGIN
SELECT r.`number` , p.name, rp.total, rp.price_on_sale as price,r.created_at
FROM receipts r
JOIN receipts_products rp ON r.id = rp.receipt_id
JOIN products p ON p.id = rp.product_id
WHERE r.user_id = _user_id and DATE(r.created_at) BETWEEN start_date AND end_date;
END $$
DELIMITER ;
# проверка процедуры
call shopping_list(1,'2017-01-01', DATE(NOW()));
/*Используем функцию высчитывающую сумму чека для начисления бонусов 3% от суммы чека. Бонусы могут начислятся системой бизнес-логики
* другими способами*/
/*При записи срабатывает триггер который запишет начисление бонусов в логи таблицы bonus_history*/
INSERT INTO receipts_bonuses VALUES
(1,receipt_amount_id(1)*0.03),
(2,receipt_amount_id(2)*0.03),
(3,receipt_amount_id(3)*0.03),
(11,receipt_amount_id(11)*0.03),
(13,receipt_amount_id(13)*0.03)
;
INSERT INTO receipts_bonuses VALUES
(4, receipt_amount_id(4)*0.03);
/*Представление вывести список пользователей и сумму чека их последней покупки*/
CREATE OR REPLACE VIEW last_receipt_summ
AS SELECT
u.firstname,
u.lastname,
r.`number`,
receipt_amount(r.`number`) as total_summ,
r.created_at
FROM users u
JOIN receipts r ON r.user_id = u.id
WHERE r.created_at = (SELECT MAX(r2.created_at) FROM receipts r2 WHERE r2.user_id = r.user_id );
SELECT * FROM last_receipt_summ;
/*Средний чек покупателя: выбор 5 покупателей с максимальным средним чеком*/
SELECT
u.firstname,
u.lastname,
AVG(receipt_amount_id(r.id)) as AVG_total
FROM users u
JOIN receipts r ON r.user_id = u.id
GROUP BY u.id
ORDER BY AVG_total DESC LIMIT 5;
/*Представление История покупок*/
CREATE OR REPLACE VIEW purchase_history(id, firstname, lastname, `number`, `date`, product, price, total)
AS SELECT
u.id,
u.firstname,
u.lastname,
r.`number`,
r.created_at as `date`,
p.name,
rp.price_on_sale ,
rp.total
FROM users u
JOIN receipts r ON r.user_id = u.id
JOIN receipts_products rp ON rp.receipt_id = r.id
JOIN products p ON p.id = rp.product_id
;
-- Выведем сумму чеков на основе представления истории покупок.
SELECT
`number`,
SUM(price)
FROM purchase_history
GROUP BY id;
| true |
cdd095444687845faa4f195420eed892fe6cc9fe | SQL | cervm/WesternStyle | /src/sql/db_create_tables.sql | UTF-8 | 4,897 | 3.953125 | 4 | [] | no_license | CREATE TABLE categories
(
id INT PRIMARY KEY NOT NULL IDENTITY,
name VARCHAR(50) NOT NULL,
parent_category_id INT
);
CREATE TABLE category_properties
(
id INT PRIMARY KEY NOT NULL IDENTITY,
category_id INT NOT NULL,
property_id INT NOT NULL
);
CREATE TABLE contact_details
(
id INT PRIMARY KEY NOT NULL IDENTITY,
phone VARCHAR(15) NOT NULL,
email VARCHAR(50),
address VARCHAR(100),
postcode VARCHAR(8),
city VARCHAR(50),
country_code VARCHAR(2),
name VARCHAR(50) NOT NULL
);
CREATE UNIQUE INDEX contact_details_email_uindex ON contact_details (email);
CREATE UNIQUE INDEX contact_details_phone_uindex ON contact_details (phone);
CREATE TABLE countries
(
code VARCHAR(2) PRIMARY KEY NOT NULL,
name VARCHAR(100) NOT NULL
);
CREATE UNIQUE INDEX Countries_code_uindex ON countries (code);
CREATE TABLE customer_groups
(
id INT PRIMARY KEY NOT NULL IDENTITY,
name VARCHAR(50) NOT NULL,
discount INT DEFAULT 0 NOT NULL
);
CREATE TABLE customers
(
id INT PRIMARY KEY NOT NULL IDENTITY,
contact_detail_id INT NOT NULL,
customer_group_id INT NOT NULL
);
CREATE TABLE invoices
(
id INT PRIMARY KEY NOT NULL IDENTITY,
payment_date DATETIME2,
amount DECIMAL(8,2) NOT NULL
);
CREATE TABLE order_items
(
id INT PRIMARY KEY NOT NULL IDENTITY,
order_id INT NOT NULL,
variant_id INT NOT NULL,
quantity INT NOT NULL
);
CREATE TABLE orders
(
id INT PRIMARY KEY NOT NULL IDENTITY,
order_date DATETIME2 NOT NULL,
amount DECIMAL(8,2),
delivery_status INT DEFAULT 0 NOT NULL,
invoice_id INT,
customer_id INT NOT NULL,
delivery_date DATETIME2 NOT NULL
);
CREATE TABLE product_categories
(
id INT PRIMARY KEY NOT NULL IDENTITY,
product_id INT NOT NULL,
category_id INT NOT NULL,
is_primary BIT NOT NULL
);
CREATE TABLE products
(
id INT PRIMARY KEY NOT NULL IDENTITY,
name VARCHAR(50) NOT NULL,
cost_price DECIMAL(6,2) DEFAULT 0 NOT NULL,
sales_price DECIMAL(6,2) DEFAULT 0 NOT NULL,
rent_price DECIMAL(6,2) DEFAULT 0 NOT NULL,
country_code VARCHAR(2),
min_stock INT DEFAULT 5 NOT NULL,
description VARCHAR(2000),
supplier_id INT NOT NULL
);
CREATE TABLE properties
(
id INT PRIMARY KEY NOT NULL IDENTITY,
name VARCHAR(50) NOT NULL
);
CREATE TABLE property_values
(
id INT PRIMARY KEY NOT NULL IDENTITY,
property_id INT NOT NULL,
value VARCHAR(100)
);
CREATE TABLE suppliers
(
id INT PRIMARY KEY NOT NULL IDENTITY,
contact_detail_id INT NOT NULL,
co_reg_no INT
);
CREATE TABLE variant_property_values
(
id INT PRIMARY KEY NOT NULL IDENTITY,
property_value_id INT NOT NULL,
variant_id INT NOT NULL
);
CREATE TABLE variants
(
id INT PRIMARY KEY NOT NULL IDENTITY,
product_id INT NOT NULL,
quantity INT NOT NULL
);
ALTER TABLE category_properties ADD CONSTRAINT Category_properties_Categories_id_fk FOREIGN KEY (category_id) REFERENCES categories (id);
ALTER TABLE category_properties ADD CONSTRAINT Category_properties_Properties_id_fk FOREIGN KEY (property_id) REFERENCES properties (id);
ALTER TABLE contact_details ADD CONSTRAINT Contact_details_Countries_code_fk FOREIGN KEY (country_code) REFERENCES countries (code);
ALTER TABLE customers ADD CONSTRAINT Customers_Contact_details_id_fk FOREIGN KEY (contact_detail_id) REFERENCES contact_details (id);
ALTER TABLE customers ADD CONSTRAINT Customers_Customer_groups_id_fk FOREIGN KEY (customer_group_id) REFERENCES customer_groups (id);
ALTER TABLE order_items ADD CONSTRAINT Order_items_Orders_id_fk FOREIGN KEY (order_id) REFERENCES orders (id);
ALTER TABLE orders ADD CONSTRAINT Orders_Invoices_id_fk FOREIGN KEY (invoice_id) REFERENCES invoices (id);
ALTER TABLE orders ADD CONSTRAINT Orders_Customers_id_fk FOREIGN KEY (customer_id) REFERENCES customers (id);
ALTER TABLE product_categories ADD CONSTRAINT Product_categories_Products_id_fk FOREIGN KEY (product_id) REFERENCES products (id);
ALTER TABLE product_categories ADD CONSTRAINT Product_categories_Categories_id_fk FOREIGN KEY (category_id) REFERENCES categories (id);
ALTER TABLE products ADD CONSTRAINT Products_Countries_code_fk FOREIGN KEY (country_code) REFERENCES countries (code);
ALTER TABLE products ADD CONSTRAINT Products_Suppliers_id_fk FOREIGN KEY (supplier_id) REFERENCES suppliers (id);
ALTER TABLE property_values ADD CONSTRAINT Property_values_Properties_id_fk FOREIGN KEY (property_id) REFERENCES properties (id);
ALTER TABLE suppliers ADD CONSTRAINT Suppliers_Contact_details_id_fk FOREIGN KEY (contact_detail_id) REFERENCES contact_details (id);
ALTER TABLE variant_property_values ADD CONSTRAINT Variant_property_values_Property_values_id_fk FOREIGN KEY (property_value_id) REFERENCES property_values (id);
ALTER TABLE variant_property_values ADD CONSTRAINT Variant_property_values_Variants_id_fk FOREIGN KEY (variant_id) REFERENCES variants (id);
ALTER TABLE variants ADD CONSTRAINT Variants_Products_id_fk FOREIGN KEY (product_id) REFERENCES products (id);
| true |
ef7cacac48ea1a4bf85f8647ab640e6810091c81 | SQL | serdarkocerr/DB | /Oracle/H2/h2.sql | ISO-8859-9 | 693 | 3.09375 | 3 | [] | no_license | --SELECT * FROM emp;
--SELECT empno PNO, ename ISIM FROM emp;
--SELECT ename, sal FROM emp;
--SELECT ename ISIM, sal*12 YILLIK_MAAS FROM emp;
--SELECT 3.14*2*2 "EMBERN ALANI" FROM dual;
--SELECT ename "SM", sal "MAA" FROM emp;
--SELECT 'Isim = ' || ename AS BASLIK, sal AS MAAS FROM emp;
--SELECT 'EMBERN ALANI = ' || 3.14*2*2 || ' m2' AS ALAN FROM dual;
--SELECT ename, ' works in department ' literal, deptno FROM emp;
--SELECT ename, comm FROM emp;
--SELECT ename, nvl(comm, 0) FROM emp;
--SELECT ename, sal * 12 + nvl(comm,0) FROM emp;
--SELECT sysdate FROM dual;
--SELECT nvl(ename, '-GIRILMEMIS-') FROM emp_new;
SELECT nvl(ename,'-GIRILMEMIS-') , nvl(hiredate, sysdate) FROM emp_new; | true |
43dc381a747d9e6dcbc507080158beb6e40da584 | SQL | edisonmamian/Desarrollo | /Desarrollo/src/SQL/bd.sql | UTF-8 | 2,043 | 3.6875 | 4 | [] | no_license | DROP SEQUENCE IF EXISTS identificador CASCADE;
DROP TABLE IF EXISTS sedes;
DROP TABLE IF EXISTS usuarios;
DROP TABLE IF EXISTS pqr;
CREATE TABLE sedes (
nombre VARCHAR(40),
ciudad VARCHAR(40),
direccion VARCHAR(40),
telefono VARCHAR(7),
PRIMARY KEY (nombre)
);
CREATE TABLE usuarios (
cedula INTEGER NOT NULL,
usuario VARCHAR(20) NOT NULL,
contrasena VARCHAR(20) NOT NULL,
nombre VARCHAR(30) NOT NULL,
apellidos VARCHAR(40) NOT NULL,
rol VARCHAR (30) NOT NULL,
direccion VARCHAR(50),
telefono VARCHAR(10),
email VARCHAR(30),
PRIMARY KEY (cedula)
);
CREATE SEQUENCE identificador
START 100
increment by 1;
CREATE TABLE pqr (
id_pqr INTEGER DEFAULT nextval('identificador') NOT NULL,
tipo_pqr VARCHAR(25) NOT NULL,
detalle VARCHAR(200) NOT NULL,
nombre VARCHAR(50) NOT NULL,
apellido VARCHAR(100) NOT NULL,
cedula VARCHAR(15) NOT NULL,
direccion VARCHAR(50) NOT NULL,
telefono VARCHAR(10) NOT NULL,
email VARCHAR(50) NOT NULL,
sede VARCHAR(50) NOT NULL,
estado VARCHAR(30) NOT NULL,
respuesta VARCHAR(200),
fecha,
PRIMARY KEY(id_pqr)
);
CREATE SEQUENCE iden
START 1001
increment by 1;
CREATE TABLE envio (
id_envio INTEGER DEFAULT nextval('iden') NOT NULL,
nombre VARCHAR(50) NOT NULL,
cedula VARCHAR(25) NOT NULL,
direccion VARCHAR(100) NOT NULL,
telefono VARCHAR(10) NOT NULL,
nombre2 VARCHAR(50) NOT NULL,
cedula2 VARCHAR(25) NOT NULL,
direccion2 VARCHAR(100) NOT NULL,
telefono2 VARCHAR(10) NOT NULL,
sede VARCHAR(25) NOT NULL,
tipo VARCHAR(25) NOT NULL,
observacion VARCHAR(25) NOT NULL,
peso INTEGER NOT NULL,
declaracion_precio INTEGER NOT NULL,
precio_neto INTEGER NOT NULL,
precio_seguro INTEGER NOT NULL,
precio_impuesto INTEGER NOT NULL,
precio_total INTEGER NOT NULL,
forma_pago VARCHAR(50) NOT NULL,
fecha DATE,
PRIMARY KEY(id_envio)
);
| true |
840d0b5a69d013a65e572c29bc978f95a2a33ca2 | SQL | XccelerateTech/oliverleung | /31-intro-sql/A+B+C.sql | UTF-8 | 1,535 | 4.15625 | 4 | [] | no_license | -- A
CREATE TABLE stock (
id SERIAL primary key,
name VARCHAR(255) not null,
description VARCHAR(255),
quantity INTEGER,
price DECIMAL
);
-- B
DROP TABLE stock;
-- C
CREATE TABLE employee (
employee_id SERIAL primary key,
first_name VARCHAR(255),
last_name VARCHAR(255),
salary INTEGER,
contract_length smallint
);
INSERT INTO employee (first_name,last_name,salary,contract_length) VALUES ('Steven','King',10000,3);
INSERT INTO employee (first_name,last_name,salary,contract_length) VALUES ('Neena','Kochhar',8000,2);
INSERT INTO employee (first_name,last_name,salary,contract_length) VALUES ('David','Austin',12000,2);
INSERT INTO employee (first_name,last_name,salary,contract_length) VALUES ('Nancy','Greenberg',3000,1);
-- Write a query that returns the First and Last Name of every employee earning between 5-11k
SELECT * FROM employee WHERE salary >= 5000 AND salary <= 11000;
-- Which employees are employed for less than 2 years?
SELECT * FROM employee WHERE contract_length < 2;
-- Add two more employees to the table, make up the data.
INSERT INTO employee (first_name,last_name,salary,contract_length) VALUES ('Donald','King',7500,2);
INSERT INTO employee (first_name,last_name,salary,contract_length) VALUES ('Pat','King',9000,1);
-- Nancy Greenberg got a new contract, 2 years, 8000 salary. Update the table.
UPDATE employee SET salary = 8000, contract_length = 2 WHERE employee_id = 4;
-- Sort the table by salary, from high to low. You might want to look here if you are stuck.
SELECT * FROM employee ORDER BY salary DESC; | true |
cb8110e82588bcd1049a8ae11ec24b68bde37eb2 | SQL | aatonkushin/otus-homework-06 | /src/main/resources/schema.sql | UTF-8 | 738 | 3.59375 | 4 | [] | no_license | DROP TABLE IF EXISTS AUTHORS;
CREATE TABLE AUTHORS(ID LONG PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(255) not null);
DROP TABLE IF EXISTS GENRES;
CREATE TABLE GENRES(ID LONG PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(255) not null unique);
DROP TABLE IF EXISTS BOOKS;
CREATE TABLE BOOKS(ID LONG PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(255) not null, AUTHOR_ID LONG, GENRE_ID LONG);
DROP TABLE IF EXISTS BOOK_COMMENTS;
CREATE TABLE BOOK_COMMENTS(ID LONG PRIMARY KEY AUTO_INCREMENT, BOOK_ID LONG, COMMENT_TEXT VARCHAR(4000));
ALTER TABLE BOOKS ADD FOREIGN KEY (AUTHOR_ID) REFERENCES AUTHORS(ID);
ALTER TABLE BOOKS ADD FOREIGN KEY (GENRE_ID) REFERENCES GENRES(ID);
ALTER TABLE BOOK_COMMENTS ADD FOREIGN KEY (BOOK_ID) REFERENCES BOOKS(ID);
| true |
86907e269e377f31453ccb93ea51823816d92db9 | SQL | async-anonymous/qa-db | /postgres.sql | UTF-8 | 2,906 | 3.859375 | 4 | [] | no_license | DROP DATABASE IF EXISTS qa;
CREATE DATABASE qa;
\c qa
CREATE TABLE IF NOT EXISTS questions (
question_id BIGSERIAL,
product_id INTEGER,
question_body VARCHAR(250),
question_date_written TIMESTAMP,
asker_name VARCHAR(50),
asker_email VARCHAR(75),
question_reported BOOLEAN,
question_helpfulness INTEGER,
PRIMARY KEY(question_id)
);
CREATE TABLE IF NOT EXISTS answers (
answer_id BIGSERIAL,
questionId INTEGER,
answer_body VARCHAR(250),
answer_date_written TIMESTAMP,
answerer_name VARCHAR(50),
answerer_email VARCHAR(75),
answer_reported BOOLEAN,
answer_helpful INTEGER,
PRIMARY KEY(answer_id),
FOREIGN KEY(questionId)
REFERENCES questions(question_id)
);
CREATE TABLE IF NOT EXISTS photos (
photos_id BIGSERIAL,
answerId INTEGER,
url VARCHAR(200),
PRIMARY KEY(photos_id),
FOREIGN KEY(answerId)
REFERENCES answers(answer_id)
);
-- jsonb_object_agg(answers.answer_id, answers.answer_body) AS answers
-- (jsonb_build_object('id', answers.answer_id, 'body', answers.answer_body,
-- 'date', answers.answer_date_written, 'answerer_name', answers.answerer_name,
-- 'helpfulness', answers.answer_helpful)
-- CREATE TABLE IF NOT EXISTS questions_format AS
-- SELECT questions.question_id AS question_id,
-- questions.product_id AS product_id,
-- questions.question_body AS question_body,
-- questions.question_date_written AS question_date,
-- questions.asker_name AS asker_name,
-- questions.question_helpful AS question_helpfulness,
-- questions.question_reported AS reported,
-- FROM questions
-- LEFT OUTER JOIN answers ON questions.question_id = answers.questionId
-- GROUP BY questions.question_id;
CREATE TABLE IF NOT EXISTS answers_format AS
SELECT answers.answer_id AS answer_id,
answers.questionid,
answers.answer_reported,
answers.answer_body AS body,
answers.answer_date_written AS date,
answers.answerer_name,
answers.answer_helpful AS helpfulness,
answers.answerer_email,
jsonb_agg(jsonb_build_object('id',photos.photos_id,'url',photos.url)) AS photos FROM answers
LEFT OUTER JOIN photos ON answers.answer_id = photos.answerId
GROUP BY answers.answer_id
ORDER BY answers.answer_helpful DESC;
-- questions:
-- 1dWft84kQu2bsDBHSC5cbphi8gxY-HU4S
-- answers:
-- 1UECWRo5le5opP-VPcEBjenoSIR7Jewn3
-- answers photos:
-- 1PnPZXpECoXVUONELSiixaTX3DzwidXzW
-- wget --no-check-certificate --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1PnPZXpECoXVUONELSiixaTX3DzwidXzW' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1PnPZXpECoXVUONELSiixaTX3DzwidXzW" -O answers_photos.csv && rm -rf /tmp/cookies.txt
-- COPY photos
-- FROM '/home/ubuntu/data/answers_photos.csv'
-- DELIMITER ','
-- CSV HEADER;
| true |
e88d1f511e5d98fd8a0bf989a9770055bb2ac495 | SQL | nbrahman/HackerRank | /06 SQL/03 Aggregration/Weather Observation Station 15_MySQL.sql | UTF-8 | 134 | 3.6875 | 4 | [] | no_license | select round(max(s.long_W), 4)
from station s, (select max(lat_n) lat_n from station where lat_n < 137.2345) t
where s.lat_n = t.lat_n | true |
25d80b5ea2a51232c457c43f46c39300a7dabcb1 | SQL | akshaygodugu/LeetCode_SQL | /ActorsDirectors.sql | UTF-8 | 800 | 3.921875 | 4 | [] | no_license |
CREATE TABLE ActorDirector(
[actor_id] INT,
[director_id] INT,
[timestamp] INT,
)
INSERT INTO ActorDirector
( [actor_id] , [director_id] , [timestamp])
VALUES
( 1 , 1 , 0 ),
( 1 , 1 , 1 ),
( 1 , 1 , 2 ),
( 1 , 2 , 3 ),
( 1 , 2 , 4 ),
( 2 , 1 , 5 ),
( 2 , 1 , 6 )
SELECT actor_id, director_id
FROM ActorDirector
WHERE actor_id = director_id
GROUP BY actor_id, director_id
HAVING COUNT(actor_id) >= 3
-------------- SUB QUERY-----------------
SELECT DISTINCT actor_id, director_id
FROM(
SELECT actor_id, director_id, COUNT(*) OVER (PARTITION BY actor_id, director_id) AS co
FROM actorDirector) AS summary
WHERE summary.co >= 3 | true |
c62229daf9d2b57b365ca9a083f5d43a9834de59 | SQL | SynSub/SynWeb | /sql/SynWeb.sql | UTF-8 | 2,724 | 3.4375 | 3 | [
"MIT"
] | permissive | CREATE TABLE IF NOT EXISTS `coms` (
`nodeid` varchar(12) DEFAULT NULL,
`comtime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`comuser` varchar(500) DEFAULT NULL,
`compost` varchar(6000) DEFAULT NULL,
`comip` varchar(500) DEFAULT NULL,
`comurl` varchar(500) DEFAULT NULL,
`comcredit` int(11) DEFAULT '0',
`comcode` int(11) NOT NULL AUTO_INCREMENT,
`id` int(11) DEFAULT NULL,
UNIQUE KEY `comcode` (`comcode`)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `node` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nodeid` varchar(12) DEFAULT NULL,
`vip` int(11) DEFAULT '0',
`nodecode` varchar(500) DEFAULT NULL,
`nodename` varchar(500) DEFAULT NULL,
`nodedesc` varchar(500) DEFAULT NULL,
`nodeusers` int(11) DEFAULT '0',
`orgtime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`uptime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`nodeip` varchar(500) DEFAULT NULL,
UNIQUE KEY `nodeid` (`nodeid`),
KEY `id` (`id`)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `replies` (
`nodeid` varchar(12) DEFAULT NULL,
`comtime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`comuser` varchar(500) DEFAULT NULL,
`compost` varchar(1000) DEFAULT NULL,
`comip` varchar(500) DEFAULT NULL,
`comcredit` int(11) DEFAULT '0',
`comnum` int(11) DEFAULT NULL,
`comcode` int(11) NOT NULL AUTO_INCREMENT,
UNIQUE KEY `comcode` (`comcode`)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`charname` varchar(50) DEFAULT NULL,
`charid` varchar(100) DEFAULT NULL,
`charemail` varchar(50) DEFAULT NULL,
`charimage` varchar(500) DEFAULT 'default.png',
`bio` varchar(135) DEFAULT NULL,
`twitchurl` varchar(500) DEFAULT NULL,
`yturl` varchar(500) DEFAULT NULL,
`twiturl` varchar(500) DEFAULT NULL,
`gaburl` varchar(500) DEFAULT NULL,
`mindsurl` varchar(500) DEFAULT NULL,
`facebookurl` varchar(500) DEFAULT NULL,
`discordurl` varchar(500) DEFAULT NULL,
`redditurl` varchar(500) DEFAULT NULL,
`periscopeurl` varchar(500) DEFAULT NULL,
`instagramurl` varchar(500) DEFAULT NULL,
`patreonurl` varchar(500) DEFAULT NULL,
`paypalurl` varchar(500) DEFAULT NULL,
`personalurl` varchar(500) DEFAULT NULL,
`following` varchar(5000) DEFAULT 'id = 1',
`chartimer1` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`chartimer2` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`chartimer3` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`chartimer4` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`currency` int(11) DEFAULT '100',
`experience` int(11) DEFAULT '0',
UNIQUE KEY `charname` (`charname`),
KEY `id` (`id`)
) ENGINE=InnoDB; | true |
1da9cce6cc367607c5acfa788f58eb9af1c11efb | SQL | vildapavlicek/Java | /ITStep_course/FirstDb/performance_performence.sql | UTF-8 | 2,689 | 3.203125 | 3 | [] | no_license | -- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: localhost Database: performance
-- ------------------------------------------------------
-- Server version 5.7.21-log
/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!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 */;
--
-- Table structure for table `performence`
--
DROP TABLE IF EXISTS `performence`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `performence` (
`idperformence` int(10) unsigned NOT NULL AUTO_INCREMENT,
`datetime` datetime NOT NULL,
`idkino` int(10) unsigned zerofill NOT NULL,
`idfilm` int(10) unsigned zerofill NOT NULL,
PRIMARY KEY (`idperformence`,`idkino`,`idfilm`),
KEY `idkino_idx` (`idkino`),
KEY `idfilm_idx` (`idfilm`),
CONSTRAINT `idfilm` FOREIGN KEY (`idfilm`) REFERENCES `film` (`idFilm`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `idkino` FOREIGN KEY (`idkino`) REFERENCES `kino` (`idKino`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `performence`
--
LOCK TABLES `performence` WRITE;
/*!40000 ALTER TABLE `performence` DISABLE KEYS */;
INSERT INTO `performence` VALUES (2,'2018-03-14 14:00:00',0000000001,0000000001),(3,'2018-03-14 22:20:00',0000000001,0000000001),(4,'2018-03-14 15:10:00',0000000002,0000000002),(5,'2018-03-14 17:50:00',0000000002,0000000002),(6,'2018-03-14 20:40:00',0000000002,0000000002),(7,'2018-03-14 21:40:00',0000000003,0000000003),(8,'2018-03-14 19:20:00',0000000003,0000000003);
/*!40000 ALTER TABLE `performence` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-03-15 20:17:03
| true |
a86ef02c7cb3296df175e71df1d2cc9ba26eefb0 | SQL | nkoehler/mapper | /BackEnd/mapper/migrations.sql | UTF-8 | 282 | 2.625 | 3 | [
"MIT"
] | permissive | -- would typically check to make sure the table doesn't exist in a real migration file
CREATE TABLE "location_maplocation"
(
"id" serial NOT NULL PRIMARY KEY,
"title" varchar(256) NOT NULL,
"longitude" numeric(21, 9) NOT NULL,
"latitude" numeric(21, 9) NOT NULL
);
| true |
de6432d0e663ac7b64cd6af04a1f33a0ad67a30c | SQL | FerrumRT/School | /school.sql | UTF-8 | 3,689 | 3.359375 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Хост: 127.0.0.1
-- Время создания: Июн 17 2021 г., 10:24
-- Версия сервера: 10.4.14-MariaDB
-- Версия PHP: 7.2.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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 */;
--
-- База данных: `school`
--
-- --------------------------------------------------------
--
-- Структура таблицы `groups`
--
CREATE TABLE `groups` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`teacher` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `groups`
--
INSERT INTO `groups` (`id`, `name`, `teacher`) VALUES
(1, 'Super Group', 3),
(3, 'Timur`s group', 1),
(7, 'Group', 1);
-- --------------------------------------------------------
--
-- Структура таблицы `students`
--
CREATE TABLE `students` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`surname` varchar(255) NOT NULL,
`bdate` date NOT NULL,
`sGroup` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `students`
--
INSERT INTO `students` (`id`, `name`, `surname`, `bdate`, `sGroup`) VALUES
(8, 'Tanir', 'Abduvaliev', '2001-06-01', 3);
-- --------------------------------------------------------
--
-- Структура таблицы `teachers`
--
CREATE TABLE `teachers` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`surname` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`isAdmin` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Дамп данных таблицы `teachers`
--
INSERT INTO `teachers` (`id`, `name`, `surname`, `email`, `password`, `isAdmin`) VALUES
(1, 'Timur', 'Rakhmetulla', 'timka211001@gmail.com', '$2y$12$ajjLgT97JhpeUQ.bUDvkR.53xTU6GOgxSjzk4zJK/5pz08T6eoepa', 0),
(3, 'Admin', 'Adminov', 'admin@admin.com', '$2y$12$ajjLgT97JhpeUQ.bUDvkR.53xTU6GOgxSjzk4zJK/5pz08T6eoepa', 1);
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `groups`
--
ALTER TABLE `groups`
ADD PRIMARY KEY (`id`),
ADD KEY `teacher` (`teacher`);
--
-- Индексы таблицы `students`
--
ALTER TABLE `students`
ADD PRIMARY KEY (`id`);
--
-- Индексы таблицы `teachers`
--
ALTER TABLE `teachers`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `groups`
--
ALTER TABLE `groups`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT для таблицы `students`
--
ALTER TABLE `students`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT для таблицы `teachers`
--
ALTER TABLE `teachers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- Ограничения внешнего ключа сохраненных таблиц
--
--
-- Ограничения внешнего ключа таблицы `groups`
--
ALTER TABLE `groups`
ADD CONSTRAINT `groups_ibfk_1` FOREIGN KEY (`teacher`) REFERENCES `teachers` (`id`);
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 */;
| true |
0b140ba21bd8b5060a301cc7e4fff773ff78ab6a | SQL | somurieengieer/SqlUtility | /searchAllTable.sql | UTF-8 | 1,714 | 4.15625 | 4 | [] | no_license | drop procedure if exists searchValueInAllTables;
delimiter //
create procedure searchValueInAllTables(IN table_schima_name varchar(255), IN keyword varchar(255))
begin
declare v_table varchar(255);
declare v_column varchar(255);
declare done int default 0;
declare cur cursor for
select table_name, column_name from information_schema.columns where TABLE_SCHEMA=table_schima_name;
declare continue handler for sqlstate '02000' set done=1; -- SQLSTATE 値 '02000' で「データなし」状況時にhandleし、done=1を設定する。その後のアクション「継続」をcontinueで指定
set @keyword = keyword;
drop table if exists WORK_DATA;
create temporary table WORK_DATA( -- temporaryを付けると一時テーブルとして作成できる。セッションを抜けると自動でDropされる
table_name varchar(255),
column_name varchar(255),
hit_count int
);
open cur;
repeat
fetch cur into v_table, v_column;
if not done then
set @sql_search=CONCAT('SELECT COUNT(*) INTO @cnt FROM ' , v_table, ' WHERE ', v_column, ' LIKE ?;');
prepare stmt from @sql_search;
execute stmt using @keyword; -- パラメータ値はユーザー変数でのみ提供可能
if (@cnt > 0) then
set @sql_add_result=CONCAT('INSERT INTO WORK_DATA VALUES(?, ?, ?)');
prepare stmt_add_result from @sql_add_result;
SET @v_table = v_table;
SET @v_column = v_column;
execute stmt_add_result using @v_table, @v_column, @cnt;
end if;
end if;
until done end repeat; -- untilの後は終了条件。
close cur;
select * from WORK_DATA;
end
//
delimiter ;
-- 全テーブル検索
call searchValueInAllTables('db_name', '%search_keyword%');
| true |
30b53f3b3d4ea393beb7c8f23f9dc48bc3448258 | SQL | Rojasking700/Week4Day1SQLintro | /homework.sql | UTF-8 | 2,485 | 4.65625 | 5 | [] | no_license | SELECT *
FROM actor;
-- 1. How many actors are there with the last name ‘Wahlberg’?
SELECT count(last_name)
FROM actor
WHERE last_name = 'Wahlberg';
-- 2 actors with the last name 'Wahlberg'
-- 2. How many payments were made between $3.99 and $5.99?
SELECT count(amount)
FROM payment
WHERE amount <= 5.99 and amount >= 3.99;
-- 5607 payments were made
SELECT *
FROM inventory;
--3. What film does the store have the most of? (search in inventory)
SELECT film_id, count(*)
from inventory
GROUP BY film_id
ORDER BY film_id DESC;
-- film_id: 1000 has the highest count of 8
SELECT *
FROM customer;
-- 4. How many customers have the last name ‘William’?
SELECT count(last_name)
FROM customer
WHERE last_name = 'William';
-- there are 0 people with the last name william or maybe i did this wrong?
SELECT *
FROM rental;
--5. What store employee (get the id) sold the most rentals?
SELECT COUNT(staff_id)as num
FROM rental
GROUP BY staff_id
ORDER BY staff_id ASC, num;
-- employee 1 rented out the most films
SELECT *
FROM address;
-- 6. How many different district names are there?
SELECT COUNT(DISTINCT district)
FROM address;
-- there are 378 distinct district names
SELECT *
FROM film_actor;
-- 7. What film has the most actors in it? (use film_actor table and get film_id)
SELECT film_id, COUNT(actor_id) as num
FROM film_actor
GROUP BY film_id
ORDER BY num DESC;
-- the film id with the most actors is 508 with 15 actors
SELECT *
FROM customer;
-- 8. From store_id 1, how many customers have a last name ending with ‘es’? (use customer table)
SELECT store_id, count(last_name)
FROM customer
WHERE last_name LIKE '%es'
GROUP BY store_id
ORDER BY store_id ASC;
-- there are 13 names ending in es in store 1
SELECT *
FROM payment;
-- 9. How many payment amounts (4.99, 5.99, etc.) had a number of rentals above 250 for customers with ids between 380 and 430? (use group by and having > 250)
SELECT amount, COUNT(amount)as cnt
FROM payment
WHERE customer_id >=380 AND customer_id <= 430
GROUP BY amount
HAVING count(amount) > 250
ORDER BY cnt DESC;
-- there are 3 payment amounts above 250 that are 2.99, 4.99 and 0.99
SELECT *
FROM film;
-- 10. Within the film table, how many rating categories are there? And what rating has the most movies total?
SELECT COUNT(DISTINCT rating)
FROM film;
--there are 5 rating categories
SELECT rating, count(rating)as c
FROM film
GROUP BY rating
ORDER BY c DESC;
-- the ratings with the most movies it pg-13
| true |
850fe6a8f1f7d10093767a2d4b2ca2656cab463b | SQL | wahidahaddini/silogterrr | /silogter.sql | UTF-8 | 11,084 | 2.8125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Oct 10, 2018 at 03:04 PM
-- Server version: 10.1.13-MariaDB
-- PHP Version: 5.5.34
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: `silogter`
--
-- --------------------------------------------------------
--
-- Table structure for table `anggaran`
--
CREATE TABLE `anggaran` (
`id_anggaran` int(3) NOT NULL,
`asal_anggaran` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `anggaran`
--
INSERT INTO `anggaran` (`id_anggaran`, `asal_anggaran`) VALUES
(22, 'Prov. Jawa Timur'),
(23, 'aassdsds');
-- --------------------------------------------------------
--
-- Table structure for table `instansi_penerima`
--
CREATE TABLE `instansi_penerima` (
`id_instansi_penerima` int(2) NOT NULL,
`nm_instansi_penerima` varchar(30) NOT NULL,
`alamat_instansi_penerima` varchar(70) NOT NULL,
`cp_instansi_penerima` int(12) UNSIGNED NOT NULL,
`email_instansi_penerima` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `instansi_penerima`
--
INSERT INTO `instansi_penerima` (`id_instansi_penerima`, `nm_instansi_penerima`, `alamat_instansi_penerima`, `cp_instansi_penerima`, `email_instansi_penerima`) VALUES
(1, 'Puskesmas Kec. Lumajang', 'Jl. Semeru No. 3 Lumajang', 334100222, 'ddd@gm.com');
-- --------------------------------------------------------
--
-- Table structure for table `kat_logistik`
--
CREATE TABLE `kat_logistik` (
`id_kat_logistik` int(2) NOT NULL,
`nm_kat_logistik` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `kat_logistik`
--
INSERT INTO `kat_logistik` (`id_kat_logistik`, `nm_kat_logistik`) VALUES
(8, 'bismillah'),
(9, 'zx'),
(10, 'xsdsdsd'),
(11, 'zxzxzxzxzxzxzxzxz'),
(12, 'zxzx'),
(13, 'zxzxzxzxzxzxzxz'),
(14, 'test'),
(15, ' -=[]'),
(16, 'zxzxzx'),
(17, 'zxzxzx'),
(18, 'zxzxzxzxzxzxzxzxzxzx'),
(19, 'zxzxzx'),
(20, 'zxzxzxzxzxsdssdsdsdsd'),
(21, 'u'),
(22, 'zxzxzx'),
(23, 'asasasasasasasasasasa'),
(24, 'zxz'),
(25, 'za'),
(26, 'zasasas');
-- --------------------------------------------------------
--
-- Table structure for table `logistik`
--
CREATE TABLE `logistik` (
`id_logistik` int(11) NOT NULL,
`id_kat_logistik` int(2) NOT NULL,
`nm_logistik` varchar(50) NOT NULL,
`stok` int(11) NOT NULL,
`satuan` varchar(50) NOT NULL,
`harga_satuan` int(20) NOT NULL,
`id_anggaran` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `pegawai`
--
CREATE TABLE `pegawai` (
`id_pegawai` int(11) NOT NULL,
`nip` varchar(30) NOT NULL,
`nama` varchar(30) NOT NULL,
`jabatan` enum('pimpinan','pegawai') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `supplier`
--
CREATE TABLE `supplier` (
`id_supplier` int(2) NOT NULL,
`nm_supplier` varchar(30) NOT NULL,
`cp_supplier` varchar(12) NOT NULL,
`email_supplier` varchar(30) NOT NULL,
`alamat_supplier` varchar(70) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `supplier`
--
INSERT INTO `supplier` (`id_supplier`, `nm_supplier`, `cp_supplier`, `email_supplier`, `alamat_supplier`) VALUES
(1, 'Biofarma', '0334111000', 'email@biofarma.com', 'Jl. Bangka 11 Bandung');
-- --------------------------------------------------------
--
-- Table structure for table `trx_detail_logistik_keluar`
--
CREATE TABLE `trx_detail_logistik_keluar` (
`id_detail_keluar` int(13) NOT NULL,
`no_regist_keluar` int(11) NOT NULL,
`id_logistik` int(11) NOT NULL,
`qty` int(11) NOT NULL,
`subtotal` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `trx_detail_logistik_masuk`
--
CREATE TABLE `trx_detail_logistik_masuk` (
`id_detail_masuk` int(13) NOT NULL,
`no_regist_masuk` int(11) NOT NULL,
`id_logistik` int(11) NOT NULL,
`harga` int(11) NOT NULL,
`qty` int(11) NOT NULL,
`subtotal` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `trx_logistik_keluar`
--
CREATE TABLE `trx_logistik_keluar` (
`no_regist_keluar` int(11) NOT NULL,
`tgl_keluar` date NOT NULL,
`id_pegawai` int(11) NOT NULL,
`id_instansi_penerima` int(2) NOT NULL,
`nm_penerima` varchar(30) NOT NULL,
`nip_penerima` varchar(15) NOT NULL,
`grand_total` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `trx_logistik_masuk`
--
CREATE TABLE `trx_logistik_masuk` (
`no_regist_masuk` int(11) NOT NULL,
`tgl_regist` date NOT NULL,
`id_supplier` int(2) NOT NULL,
`id_pegawai` int(3) NOT NULL,
`grand_total` int(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`id_user` int(11) NOT NULL,
`id_pegawai` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`level` enum('admin','operator') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `anggaran`
--
ALTER TABLE `anggaran`
ADD PRIMARY KEY (`id_anggaran`);
--
-- Indexes for table `instansi_penerima`
--
ALTER TABLE `instansi_penerima`
ADD PRIMARY KEY (`id_instansi_penerima`);
--
-- Indexes for table `kat_logistik`
--
ALTER TABLE `kat_logistik`
ADD PRIMARY KEY (`id_kat_logistik`);
--
-- Indexes for table `logistik`
--
ALTER TABLE `logistik`
ADD PRIMARY KEY (`id_logistik`),
ADD KEY `id_kat_perbekalan` (`id_kat_logistik`,`id_anggaran`),
ADD KEY `id_anggaran` (`id_anggaran`);
--
-- Indexes for table `pegawai`
--
ALTER TABLE `pegawai`
ADD PRIMARY KEY (`id_pegawai`);
--
-- Indexes for table `supplier`
--
ALTER TABLE `supplier`
ADD PRIMARY KEY (`id_supplier`);
--
-- Indexes for table `trx_detail_logistik_keluar`
--
ALTER TABLE `trx_detail_logistik_keluar`
ADD PRIMARY KEY (`id_detail_keluar`),
ADD KEY `id_perbekalan` (`id_logistik`);
--
-- Indexes for table `trx_detail_logistik_masuk`
--
ALTER TABLE `trx_detail_logistik_masuk`
ADD PRIMARY KEY (`id_detail_masuk`),
ADD KEY `no_regist_masuk` (`no_regist_masuk`),
ADD KEY `id_perbekalan` (`id_logistik`);
--
-- Indexes for table `trx_logistik_keluar`
--
ALTER TABLE `trx_logistik_keluar`
ADD PRIMARY KEY (`no_regist_keluar`),
ADD KEY `id_instansi_penerima` (`id_instansi_penerima`),
ADD KEY `id_pegawai` (`id_pegawai`);
--
-- Indexes for table `trx_logistik_masuk`
--
ALTER TABLE `trx_logistik_masuk`
ADD PRIMARY KEY (`no_regist_masuk`),
ADD KEY `id_supplier` (`id_supplier`,`id_pegawai`),
ADD KEY `id_pegawai` (`id_pegawai`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id_user`),
ADD KEY `id_pegawai` (`id_pegawai`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `anggaran`
--
ALTER TABLE `anggaran`
MODIFY `id_anggaran` int(3) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;
--
-- AUTO_INCREMENT for table `instansi_penerima`
--
ALTER TABLE `instansi_penerima`
MODIFY `id_instansi_penerima` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `kat_logistik`
--
ALTER TABLE `kat_logistik`
MODIFY `id_kat_logistik` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27;
--
-- AUTO_INCREMENT for table `logistik`
--
ALTER TABLE `logistik`
MODIFY `id_logistik` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `pegawai`
--
ALTER TABLE `pegawai`
MODIFY `id_pegawai` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `supplier`
--
ALTER TABLE `supplier`
MODIFY `id_supplier` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `trx_detail_logistik_keluar`
--
ALTER TABLE `trx_detail_logistik_keluar`
MODIFY `id_detail_keluar` int(13) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `trx_detail_logistik_masuk`
--
ALTER TABLE `trx_detail_logistik_masuk`
MODIFY `id_detail_masuk` int(13) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `trx_logistik_keluar`
--
ALTER TABLE `trx_logistik_keluar`
MODIFY `no_regist_keluar` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `trx_logistik_masuk`
--
ALTER TABLE `trx_logistik_masuk`
MODIFY `no_regist_masuk` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `logistik`
--
ALTER TABLE `logistik`
ADD CONSTRAINT `logistik_ibfk_1` FOREIGN KEY (`id_kat_logistik`) REFERENCES `kat_logistik` (`id_kat_logistik`) ON UPDATE CASCADE,
ADD CONSTRAINT `logistik_ibfk_2` FOREIGN KEY (`id_anggaran`) REFERENCES `anggaran` (`id_anggaran`) ON UPDATE CASCADE;
--
-- Constraints for table `trx_detail_logistik_keluar`
--
ALTER TABLE `trx_detail_logistik_keluar`
ADD CONSTRAINT `trx_detail_logistik_keluar_ibfk_1` FOREIGN KEY (`id_logistik`) REFERENCES `logistik` (`id_logistik`) ON UPDATE CASCADE;
--
-- Constraints for table `trx_detail_logistik_masuk`
--
ALTER TABLE `trx_detail_logistik_masuk`
ADD CONSTRAINT `trx_detail_logistik_masuk_ibfk_1` FOREIGN KEY (`no_regist_masuk`) REFERENCES `trx_logistik_masuk` (`no_regist_masuk`) ON UPDATE CASCADE,
ADD CONSTRAINT `trx_detail_logistik_masuk_ibfk_2` FOREIGN KEY (`id_logistik`) REFERENCES `logistik` (`id_logistik`) ON UPDATE CASCADE;
--
-- Constraints for table `trx_logistik_keluar`
--
ALTER TABLE `trx_logistik_keluar`
ADD CONSTRAINT `trx_logistik_keluar_ibfk_1` FOREIGN KEY (`id_instansi_penerima`) REFERENCES `instansi_penerima` (`id_instansi_penerima`) ON UPDATE CASCADE,
ADD CONSTRAINT `trx_logistik_keluar_ibfk_2` FOREIGN KEY (`id_pegawai`) REFERENCES `pegawai` (`id_pegawai`) ON UPDATE CASCADE;
--
-- Constraints for table `trx_logistik_masuk`
--
ALTER TABLE `trx_logistik_masuk`
ADD CONSTRAINT `trx_logistik_masuk_ibfk_1` FOREIGN KEY (`id_supplier`) REFERENCES `supplier` (`id_supplier`) ON UPDATE CASCADE,
ADD CONSTRAINT `trx_logistik_masuk_ibfk_2` FOREIGN KEY (`id_pegawai`) REFERENCES `pegawai` (`id_pegawai`) ON UPDATE CASCADE;
--
-- Constraints for table `user`
--
ALTER TABLE `user`
ADD CONSTRAINT `user_ibfk_1` FOREIGN KEY (`id_pegawai`) REFERENCES `pegawai` (`id_pegawai`) ON UPDATE 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 */;
| true |
4f634df53769363c66f75b93f395a8a4d7033628 | SQL | nikhileshxiii/flask-postgres-db | /db_script.sql | UTF-8 | 9,332 | 3.5 | 4 | [] | no_license | CREATE TABLE zztemp_store
(
store_id serial NOT NULL,
address text,
CONSTRAINT zztemp_store_pkey PRIMARY KEY (store_id)
)
WITH (
OIDS=FALSE
);
--ALTER TABLE zztemp_store
--OWNER TO flask_user;
insert into zztemp_store values (1, '1000 NE Sam Walton Ln, Lee''s Summit, MO 64086');
insert into zztemp_store values (2, '10300 E Highway 350, Raytown, MO 64138');
insert into zztemp_store values (3, '2015 W Foxwood Dr, Raymore, MO 64083');
insert into zztemp_store values (4, '4000 S Bolger Rd, Independence, MO 64055');
insert into zztemp_store values (5, '11701 Metcalf Ave, Overland Park, KS 66210');
CREATE TABLE zztemp_paytype
(
paytype numeric(1,0) NOT NULL,
description character varying,
CONSTRAINT zztemp_paytype_pkey PRIMARY KEY (paytype),
CONSTRAINT zztemp_paytype_check CHECK (paytype = 0::numeric OR paytype = 1::numeric)
)
WITH (
OIDS=FALSE
);
ALTER TABLE zztemp_paytype
--OWNER TO flask_user;
insert into zztemp_paytype values (0, 'Part Time Pay');
insert into zztemp_paytype values (1, 'Full Time Pay');
CREATE TABLE zztemp_items
(
item_id serial NOT NULL,
brand character varying,
description character varying,
price numeric(10,2) NOT NULL,
shapeofproduct character varying,
sizeofproduct character varying,
upc numeric(9,0) NOT NULL,
weight numeric,
item_group character varying,
CONSTRAINT zztemp_items_pkey PRIMARY KEY (item_id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE zztemp_items
--OWNER TO flask_user;
insert into zztemp_items (brand, description, item_group, price, shapeofproduct, sizeofproduct, upc, weight)
values ('Google', 'Pixel', 'cell phone', 649.00, 'Bar', '143.8 x 69.5 x 8.5 mm', 949239308, 143);
insert into zztemp_items (brand, description, item_group, price, shapeofproduct, sizeofproduct, upc, weight)
values ('Apple', 'iPhone 5S', 'cell phone', 258.00, 'Bar', '123.8 x 58.6 x 7.6 mm', 949229308, 112);
insert into zztemp_items (brand, description, item_group, price, shapeofproduct, sizeofproduct, upc, weight)
values ('Apple', 'iPhone 7 Plus', 'cell phone', 769.00, 'Bar', '158.2 x 77.9 x 7.3 mm', 949223308, 188);
insert into zztemp_items (brand, description, item_group, price, shapeofproduct, sizeofproduct, upc, weight)
values ('ZTE', 'Axon 7', 'cell phone', 349.98, 'Bar', '151.7 x 75 x 7.9 mm', 949739308, 175);
CREATE TABLE zztemp_inventory
(
store_id integer NOT NULL,
item_id integer NOT NULL,
quantity_of_items_available numeric,
CONSTRAINT zztemp_inventory_pkey PRIMARY KEY (store_id, item_id),
CONSTRAINT zztemp_inventory_item_id_fkey FOREIGN KEY (item_id)
REFERENCES zztemp_items (item_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT zztemp_inventory_store_id_fkey FOREIGN KEY (store_id)
REFERENCES zztemp_store (store_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE zztemp_inventory
--OWNER TO flask_user;
insert into zztemp_inventory values (1, 1, 10);
insert into zztemp_inventory values (2, 1, 10);
insert into zztemp_inventory values (3, 1, 10);
insert into zztemp_inventory values (4, 1, 10);
insert into zztemp_inventory values (5, 1, 10);
insert into zztemp_inventory values (1, 2, 10);
insert into zztemp_inventory values (2, 2, 10);
insert into zztemp_inventory values (3, 2, 10);
insert into zztemp_inventory values (4, 2, 10);
insert into zztemp_inventory values (5, 2, 10);
insert into zztemp_inventory values (1, 3, 10);
insert into zztemp_inventory values (2, 3, 10);
insert into zztemp_inventory values (3, 3, 10);
insert into zztemp_inventory values (4, 3, 10);
insert into zztemp_inventory values (5, 3, 10);
insert into zztemp_inventory values (1, 4, 10);
insert into zztemp_inventory values (2, 4, 10);
insert into zztemp_inventory values (3, 4, 10);
insert into zztemp_inventory values (4, 4, 10);
insert into zztemp_inventory values (5, 4, 10);
CREATE TABLE zztemp_employees
(
emp_id character varying NOT NULL,
emp_name character varying NOT NULL,
ssn numeric(9,0) NOT NULL,
phone numeric(10,0),
store_id integer,
dateofemploy date,
address text,
paytype numeric(1,0) NOT NULL,
pay numeric(10,2),
quitdate date,
manager_id numeric,
passwd character varying,
CONSTRAINT zztemp_employees_pkey PRIMARY KEY (emp_id),
CONSTRAINT zztemp_employees_paytype_fkey FOREIGN KEY (paytype)
REFERENCES zztemp_paytype (paytype) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT zztemp_employees_store_id_fkey FOREIGN KEY (store_id)
REFERENCES zztemp_store (store_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT zztemp_employees_ssn_key UNIQUE (ssn)
)
WITH (
OIDS=FALSE
);
ALTER TABLE zztemp_employees
--OWNER TO flask_user;
insert into zztemp_employees (emp_id, emp_name, ssn, phone, store_id, dateofemploy, address, paytype, pay, quitdate, manager_id, passwd)
values ('emp1', 'Alison', 920382683, 8163540203, 1, '09-09-2010', '711-2880 Nulla St., Missouri 64081', 0, 2400, '09-20-2016', 'emp2', 'password');
insert into zztemp_employees (emp_id, emp_name, ssn, phone, store_id, dateofemploy, address, paytype, pay, passwd)
values ('emp2', 'Andrea', 920332683, 8155956203, 1, '09-09-2005', 'P.O. Box 283 8562 Fusce Rd., Missouri 64081', 1, 12400, 'password');
insert into zztemp_employees (emp_id, emp_name, ssn, phone, store_id, dateofemploy, address, paytype, pay, quitdate, manager_id, passwd)
values ('emp3', 'Benjamin', 928782683, 8163945203, 2, '09-09-2010', '606-3727 Ullamcorper. Street, Missouri 64081', 0, 240, '09-20-2016', 'emp2', 'password');
insert into zztemp_employees (emp_id, emp_name, ssn, phone, store_id, dateofemploy, address, paytype, pay, quitdate, manager_id, passwd)
values ('emp4', 'Brian', 920385683, 8163940287, 3, '09-09-2010', 'Ap #867-859 Sit Rd., Missouri 64081', 0, 240, '09-20-2016', 'emp2', 'password');
insert into zztemp_employees (emp_id, emp_name, ssn, phone, store_id, dateofemploy, address, paytype, pay, quitdate, manager_id, passwd)
values ('emp5', 'Christian', 920982683, 8169940203, 4, '09-09-2010', '7292 Dictum Av., Missouri 64081', 0, 240, '09-20-2016', 'emp2', 'password');
insert into zztemp_employees (emp_id, emp_name, ssn, phone, store_id, dateofemploy, address, paytype, pay, quitdate, manager_id, passwd)
values ('emp6', 'David', 920382634, 8163945603, 5, '09-09-2010', 'Ap #651-8679 Sodales Av., Missouri 64081', 1, 10000, '09-20-2016', 'emp2', 'password');
update zztemp_employees set quitdate = null where 1=1;
CREATE TABLE zztemp_customers
(
cust_id character varying NOT NULL,
cust_name character varying NOT NULL,
phone numeric(10,0),
datelasttrans date,
datecreated date NOT NULL,
passwd character varying,
CONSTRAINT zztemp_customers_pkey PRIMARY KEY (cust_id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE zztemp_customers
--OWNER TO flask_user;
insert into zztemp_customers (cust_id, cust_name, phone, datecreated, passwd)
values ('cust1', 'Chloe', 8169304566, '08-21-2010', 'password');
insert into zztemp_customers (cust_id, cust_name, phone, datecreated, passwd)
values ('cust2', 'Brian', 8169308736, '04-21-2008', 'password');
insert into zztemp_customers (cust_id, cust_name, phone, datecreated, passwd)
values ('cust3', 'Ball', 8169304536, '03-25-2007', 'password');
insert into zztemp_customers (cust_id, cust_name, phone, datecreated, passwd)
values ('cust4', 'Brown', 8169338836, '04-26-2004', 'password');
insert into zztemp_customers (cust_id, cust_name, phone, datecreated, passwd)
values ('cust5', 'Anne', 8169308736, now(), 'password');
create sequence zztemp_checkout_checkout_id_seq;
CREATE TABLE zztemp_checkout
(
checkout_id numeric NOT NULL DEFAULT nextval('zztemp_checkout_checkout_id_seq'::regclass),
cust_id character varying NOT NULL,
dateofcheckout date NOT NULL,
store_id integer,
subtotal numeric(10,2) NOT NULL,
emp_id character varying NOT NULL,
CONSTRAINT zztemp_checkout_pkey PRIMARY KEY (checkout_id),
CONSTRAINT zztemp_checkout_emp_id_fkey FOREIGN KEY (emp_id)
REFERENCES zztemp_employees (emp_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT zztemp_checkout_store_id_fkey FOREIGN KEY (store_id)
REFERENCES zztemp_store (store_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE zztemp_checkout
--OWNER TO flask_user;
alter sequence zztemp_checkout_checkout_id_seq restart;
create sequence zztemp_checkout_item_details_sl_no_seq;
CREATE TABLE zztemp_checkout_item_details
(
checkout_id numeric NOT NULL,
quantity numeric NOT NULL,
item_id integer NOT NULL,
sl_no integer NOT NULL DEFAULT nextval('zztemp_checkout_item_details_sl_no_seq'::regclass),
CONSTRAINT zztemp_checkout_item_details_pkey PRIMARY KEY (sl_no),
CONSTRAINT zztemp_checkoutaction_checkout_id_fkey FOREIGN KEY (checkout_id)
REFERENCES zztemp_checkout (checkout_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT zztemp_checkoutaction_item_id_fkey FOREIGN KEY (item_id)
REFERENCES zztemp_items (item_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE zztemp_checkout_item_details
--OWNER TO flask_user;
alter sequence zztemp_checkout_item_details_sl_no_seq restart;
| true |
d1bba297c72fb2f0e25585f3d3d898b937bf1b71 | SQL | storydrivendatasets-pre-2022-archive/congress-legislators-simplified | /src/dba/trim/bootstrap.sql | UTF-8 | 777 | 3.03125 | 3 | [
"MIT"
] | permissive | .bail on
.echo on
-- drop/create new tables
.open ./data/processed/congress-legislators-simplified.trim.sqlite
.read ./src/dba/trim/schema.sql
-- import the data
.changes on
/* we'll just import from existing vanilla data instead of
importing from raw
*/
ATTACH DATABASE
'./data/processed/congress-legislators-simplified.vanilla.sqlite'
AS vanilla;
INSERT INTO
legislator
SELECT
bioguide_id
, type
, last_name
, first_name
, state
, party
, district
, senate_class
, birthday
, gender
, url
, govtrack_id
, thomas_id
, fec_ids
, lis_id
, icpsr_id
, wikipedia_id
FROM
vanilla.legislator
ORDER BY
vanilla.legislator.bioguide_id;
-- index the data
.read ./src/dba/trim/indexes.sql
| true |
71ae71704477aca5ae8c6cb67b588fb168e8a6ad | SQL | PorscheNote/CarInfoService | /src/main/resources/car.sql | UTF-8 | 737 | 2.90625 | 3 | [] | no_license | -- CREATE DATABASE --
CREATE SCHEMA `CarInfoService` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
-- CREATE TABLE --
CREATE TABLE IF NOT EXISTS `car` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`manufacturer` varchar(100) NOT NULL,
`year` int(11) NOT NULL,
`model` varchar(100) NOT NULL,
`displacement` int(11) NOT NULL,
`power` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- CREATE SAMPLE DATA --
INSERT INTO `car` (`manufacturer`, `year`, `model`, `displacement`, `power`) VALUES
('Porsche', 2013, '911 GT3 RS', 3996, 500),
('Lamborghini', 2012, 'Aventador', 6498, 700),
('Ferrari', 2012, '458 Italia', 4497, 565),
('Nissan', 2012, 'GT-R', 3799, 530),
('BMW', 2014, 'M3', 2979, 431);
| true |
85d141212046166cce52d92fa91d1fe164d26fc5 | SQL | bruno-alves7/TRYBE-sd-07-project-mysql-one-for-all | /desafio9.sql | UTF-8 | 321 | 3.65625 | 4 | [] | no_license | USE SpotifyClone;
DELIMITER $$
CREATE PROCEDURE albuns_do_artista(IN nome VARCHAR(45))
BEGIN
SELECT artistas.artista AS artista,
albuns.album AS album
FROM SpotifyClone.artistas
INNER JOIN SpotifyClone.albuns
ON artistas.artista_id = albuns.artista_id
WHERE nome = artistas.artista
ORDER BY album asc;
END $$
DELIMITER ;
| true |
dea7da6ae4bfdb2e83614c49826bf40da34addef | SQL | ravishankarmalviya/mitesh | /1282_ravishankar/db/mydb(1).sql | UTF-8 | 3,051 | 3.28125 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Mar 30, 2019 at 08:12 AM
-- Server version: 5.7.21
-- PHP Version: 7.2.4
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: `mydb`
--
-- --------------------------------------------------------
--
-- Table structure for table `employee`
--
DROP TABLE IF EXISTS `employee`;
CREATE TABLE IF NOT EXISTS `employee` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `employee`
--
INSERT INTO `employee` (`id`, `name`) VALUES
(1, 'Manan Modi'),
(2, 'Ravishankar Malviya'),
(3, 'Piyush Parmar'),
(4, 'Kalpesh Bajaj');
-- --------------------------------------------------------
--
-- Table structure for table `empmanagment`
--
DROP TABLE IF EXISTS `empmanagment`;
CREATE TABLE IF NOT EXISTS `empmanagment` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`orgname` varchar(255) NOT NULL,
`dateoftraining` varchar(255) NOT NULL,
`placeoftraning` varchar(255) NOT NULL,
`purposeoftraining` text NOT NULL,
`employee` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `empmanagment`
--
INSERT INTO `empmanagment` (`id`, `orgname`, `dateoftraining`, `placeoftraning`, `purposeoftraining`, `employee`) VALUES
(3, '3', '2019-03-22', 'ravi ravi new tral', 'ravi', '3');
-- --------------------------------------------------------
--
-- Table structure for table `organization`
--
DROP TABLE IF EXISTS `organization`;
CREATE TABLE IF NOT EXISTS `organization` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `organization`
--
INSERT INTO `organization` (`id`, `name`) VALUES
(1, 'AEGEE'),
(2, 'AIESEC'),
(3, 'BBYO'),
(4, 'British Columbia Youth Parliament'),
(5, 'Canadian Cadet Organizations'),
(6, 'CISV International');
-- --------------------------------------------------------
--
-- Table structure for table `policies`
--
DROP TABLE IF EXISTS `policies`;
CREATE TABLE IF NOT EXISTS `policies` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`number` varchar(20) DEFAULT NULL,
`amount` float DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `policies`
--
INSERT INTO `policies` (`id`, `number`, `amount`) VALUES
(22, '456', 234);
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 */;
| true |
254624c3324e3d489cdda02cebb4d04b56d963b2 | SQL | UmJaeJeong/DataBase | /MYSQL/실습-3.sql | UTF-8 | 366 | 3.125 | 3 | [] | no_license | #보안상의 문제로 인하여 일부 데이터만 실제 테이블에서 필요한 열을 복사해서
#view를 만들어준다. 하여, view는 일종의 가상테이블이라고 생각하면 된다.
create view uv_memberTBL
as
select memberName, memberAddress
from member TBL;
#실제 테이블과 같은 조회결과를 지닌다.
select *
from uv_membertbl; | true |
393a2958e687022e9a5de58fec7a52b388d54b2c | SQL | kovacsroland/Beer-Rating-Application | /database/beerodalom.sql | UTF-8 | 36,189 | 3.015625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Gép: 127.0.0.1
-- Létrehozás ideje: 2019. Ápr 09. 08:34
-- Kiszolgáló verziója: 10.1.37-MariaDB
-- PHP verzió: 7.2.12
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 */;
--
-- Adatbázis: `beerodalom`
--
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `beers`
--
CREATE TABLE `beers` (
`beer_ID` int(11) NOT NULL,
`brewery_ID` int(11) NOT NULL,
`glass_ID` int(11) NOT NULL,
`category_ID` int(11) NOT NULL,
`beer_name` varchar(100) NOT NULL,
`taste` varchar(50) NOT NULL,
`color` varchar(50) NOT NULL,
`foam` varchar(50) NOT NULL,
`smell` varchar(50) NOT NULL,
`ABV` float NOT NULL,
`IBU` int(3) NOT NULL,
`EBC` int(3) NOT NULL,
`capacity` float NOT NULL,
`serving_temp` varchar(15) NOT NULL,
`overall_taste_point` int(11) NOT NULL,
`overall_color_point` int(11) NOT NULL,
`overall_foam_point` int(11) NOT NULL,
`overall_smell_point` int(11) NOT NULL,
`overall_rating_point` int(11) NOT NULL,
`rating_count` int(11) NOT NULL,
`all_like` int(11) NOT NULL,
`all_unlike` int(11) NOT NULL,
`image` varchar(100) NOT NULL,
`add_tmp` date NOT NULL,
`making_tmp` date NOT NULL,
`description` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `beers`
--
INSERT INTO `beers` (`beer_ID`, `brewery_ID`, `glass_ID`, `category_ID`, `beer_name`, `taste`, `color`, `foam`, `smell`, `ABV`, `IBU`, `EBC`, `capacity`, `serving_temp`, `overall_taste_point`, `overall_color_point`, `overall_foam_point`, `overall_smell_point`, `overall_rating_point`, `rating_count`, `all_like`, `all_unlike`, `image`, `add_tmp`, `making_tmp`, `description`) VALUES
(1, 1, 6, 203, 'Hathárom', 'édeskés, keserű kávés és kekszes', 'Fekete', 'enyhén habzó ', ' kakaópor és a cikória kávé', 4.9, 25, 74, 0.5, '10-13 °C', 79, 69, 61, 47, 9, 1, 0, 1, 'Hathárom.png', '2019-02-27', '2019-02-22', 'A Wembley Stadionban lejátszott legendás futballmérkőzés ihlette Hathárom arra vállalkozik, hogy ne csak fociban, de sörben is odacsapjon az angoloknak. Ezzel a könnyű, kellemesen pörkölt ízeket hozó, halványbarna, kekszesen-malátás angol porterrel Hidegkuti, Puskás, Bozsik és az Aranycsapat előtt tisztelgünk, akik legyőzték a hazai pályán 90 éve veretlen Angliát.'),
(2, 1, 11, 192, 'Esthajnal \'18', 'csokis, kávés, szilvás enyhén füstös', 'Fekete', 'kevés, sötét', 'füstölt szilva', 10.5, 62, 350, 0.33, '14-16 °C', 65, 67, 86, 81, 8, 1, 0, 1, 'Esthajnal \'18.png', '2019-02-27', '2018-12-01', 'Limitált kiadású, évente megújuló Esthajnal söreink nem csupán ünnepi meglepetések, de télnyitó desszertsörök is egyben. Az Esthajnal-sorozat hatodik darabjában, az Esthajnal ’18-ban a békési aszaltszilva füstössége találkozik a pörkölt árpa és maláta kávés-karamellás ízkarakterével, amelyet egy krémes, bársonyosan lágy russian imprerial stout foglal keretbe. Az Esthajnal \'18-at sörfőzőmesterünk úgy alkotta meg, hogy az ünnepek alatt mindig legyen jó ok egy meghitt, karácsonyi sörözéshez.'),
(3, 1, 11, 192, 'Rettegett Iván', 'csokis, pörköltmagvas ', 'Fekete', 'sötét és tartós', 'sűrű, pörköltes', 9, 60, 270, 0.33, '12-14 °C', 0, 0, 0, 0, 0, 0, 0, 0, 'Rettegett Iván.png', '2019-02-27', '2019-02-01', 'Ez a sörtípus több évszázados kísérletezés, tudás és játékosság eredménye, melyet a 18. századi brit sörfőzők az orosz cári udvar részére készítettek. Ehhez a gazdagon fűszerezett, kirobbanóan zamatos már-már átláthatatlanul fekete sörhöz négyféle malátát adtunk, amik tökéletes harmóniát alkotnak a füstös, a csokoládés és a krémesen karamellás ízkarakterekkel.'),
(4, 1, 3, 226, 'Ogre', ' Lágy, kevés keserűség, édes maláta', 'Borostyánsárga', 'nem tartós', 'Pilzeni, komlós', 5.6, 33, 13, 0.5, '7-12 °C', 0, 0, 0, 0, 0, 0, 0, 0, 'Ogre.png', '2019-02-27', '2005-01-01', 'A Szent András Sörfőzde egyik zászlóshajójának számító Ogre markánsan komlózott pilzeni sörélményt garantál, amelyhez határozott alkoholtartalom és izgalmas aroma párosul. Így született meg a tradicionális, cseh ivósör jellegű mestermunka. Nevét az ötletindítóról, Marosvári „Ogre” Lászlóról, az ország egyik leghíresebb sörszakértőjéről kapta, aki azóta márkasörözőnk, az Ogre bácsi Söröző szakértő vezetője is egyben.');
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `beers_ratings`
--
CREATE TABLE `beers_ratings` (
`beer_rating_ID` int(11) NOT NULL,
`profile_ID` int(11) NOT NULL,
`beer_ID` int(11) NOT NULL,
`taste_point` int(3) NOT NULL,
`color_point` int(3) NOT NULL,
`foam_point` int(3) NOT NULL,
`smell_point` int(3) NOT NULL,
`overall_point` int(2) NOT NULL,
`like_unlike` int(1) NOT NULL,
`rating_tmp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`image` varchar(100) NOT NULL,
`opinion` varchar(350) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `beers_ratings`
--
INSERT INTO `beers_ratings` (`beer_rating_ID`, `profile_ID`, `beer_ID`, `taste_point`, `color_point`, `foam_point`, `smell_point`, `overall_point`, `like_unlike`, `rating_tmp`, `image`, `opinion`) VALUES
(1, 2, 1, 79, 69, 61, 47, 9, 0, '2019-04-08 23:35:56', '2 Navigation tile 484x967 jpg.jpg', 'sdfdsggsfdgsdfgfdsgdfgdsfgsdfgddfgsf'),
(2, 2, 2, 65, 67, 86, 81, 8, 0, '2019-04-08 23:37:00', '4k6-1920x1080.jpg', 'cvbncvbncvbnbvncvbnbvnvcbncvbncbvncvb');
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `breweries`
--
CREATE TABLE `breweries` (
`brewery_ID` int(11) NOT NULL,
`country_ID` int(11) NOT NULL,
`brewery_name` varchar(100) NOT NULL,
`place` varchar(100) NOT NULL,
`image` varchar(100) NOT NULL,
`website` varchar(80) NOT NULL,
`facebook_link` varchar(80) NOT NULL,
`instagram_name` varchar(60) NOT NULL,
`twitter_name` varchar(60) NOT NULL,
`introduced_date` date NOT NULL,
`adding_tmp` date NOT NULL,
`beers_count` int(4) NOT NULL,
`rating_overall` int(11) NOT NULL,
`rating_count` int(11) NOT NULL,
`all_like` int(11) NOT NULL,
`all_unlike` int(11) NOT NULL,
`description` varchar(750) NOT NULL,
`active` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `breweries`
--
INSERT INTO `breweries` (`brewery_ID`, `country_ID`, `brewery_name`, `place`, `image`, `website`, `facebook_link`, `instagram_name`, `twitter_name`, `introduced_date`, `adding_tmp`, `beers_count`, `rating_overall`, `rating_count`, `all_like`, `all_unlike`, `description`, `active`) VALUES
(1, 97, 'Békésszentandrási Szent András Sörfőzde', 'Békésszentandrás, Szent András u. 11, 5561', 'SzentAndrasSorfozde.png', 'https://szentandrassorfozde.hu/', 'SzentAndrasSorfozde', 'szentandrassorfozde', '', '1993-01-01', '2019-02-26', 24, 0, 0, 0, 0, 'A Szent András Sörfőzde több mint 20 éve gyárt kiemelkedő minőségű magyar kézműves sörkülönlegességeket. 2011-ben az év sörfőzdéjének választott békésszentandrási kisüzem nem titkolt célja, hogy a sörivást valódi gasztronómiai eseménnyé nemesítse. A főzde meglehetősen erős karakteres komlós, illetve gyümölcsös söreinek utánozhatatlansága a hamisítatlan, lágy Szent András ízvilágban és a békésszentandrási víz meghatározó jellegében rejlik. A főzde széles sörkínálatában a valódi gyümölccsel készült söröktől kezdve az erőteljes, közel 10 %-os fekete sörökig minden megtalálható.', 1),
(2, 97, 'MONYO Brewing Co.', 'Budapest, Maglódi út 47., 1106', 'MONYO Brewing Co..png', 'http://monyobrewing.com/', 'MonyoBrewingCo', 'monyobrewing', '', '2014-01-01', '2019-02-26', 52, 10, 1, 0, 1, 'A MONYO Brewing Co. sörfőzdéjét 2014-ben alapította Pein Ádám, Németh Antal és Elek Zoltán alapította. Egyike annak a négy kisüzemi hazai sörfőzdének, amelyek összefogásából létrejött 2016 nyarán a Főzdepark az egykori Királyi sörfőzde ipari parkjában. 2015-ben a főzde elnyerte az \"Év sörfőzdéje\" díjat. 2016-ban az Alltech Commonwealth versenyén a hazai sörfőzdék 27 kategóriában indultak, ebből 16 érmet sikerült szerezniük összesen, a MONYO ebből 7 érmet szerzett.', 1),
(3, 97, 'Mad Scientist', 'Budapest, Maglódi út 47, 1106', 'Mad Scientist.png', 'http://madscientist.hu/', 'madscientistbeer', 'madscientistbeer', '', '2016-01-01', '2019-02-26', 62, 10, 1, 0, 1, 'A Mad Scientist budapesti kisüzemi sörfőzdét 2016-ban alapította a mesterhármas, Tarján Csaba, Szilágyi Tamás és Závodszky Gergő. 2016 áprilisában lepték meg először a közönséget söreikkel. Ekkor négy nedűd dobtak piacra, azóta pedig már számtalan főzetet dobtak piacra. A bezsebelt díjak egyenesen arányosan nőnek a megjelent sörök számával.', 1),
(4, 66, 'Põhjala Brewery', 'Peetri 5 10415 Tallinn', 'Põhjala Brewery.png', 'https://pohjalabeer.com/', 'pohjalabeer', 'pohjalabeer', 'pohjalabeer', '2011-12-01', '2019-02-26', 80, 8, 0, 0, 0, 'Põhjala was founded in Tallinn, Estonia at the end of 2011 by four Estonian beer enthusiasts and home brewers. Soon thereafter the company was joined by a Scottish head brewer, Chris Pilkington, with a few years of Brewdog experience under his belt. The first Põhjala beer, Öö Imperial Baltic Porter, was released in the beginning of 2013 and for most of that year, our beers were contract-brewed in other breweries’ production facilities while we prepared to open our own.', 1),
(5, 155, 'Heineken', 'Tweede Weteringplantsoen 21 1017 ZD Amsterdam,', 'Heineken.png', 'https://www.heineken.com', 'heineken', 'heineken', 'heineken', '1863-12-16', '2019-02-26', 32, 0, 0, 0, 0, 'Heineken N.V. is a Dutch brewing company, founded in 1864 by Gerard Adriaan Heineken in Amsterdam. As of 2017, Heineken owns over 165 breweries in more than 70 countries. It produces 250 international, regional, local and speciality beers and ciders and employs approximately 73,000 people. With an annual beer production of 188.3 million hectoliters in 2015, and global revenues of EUR 20,511 billions in 2015, Heineken N.V. is the number one brewer in Europe and one of the largest brewers by volume in the world.', 1),
(6, 56, 'Carlsberg Group', '100 Ny Carlsberg Vej 1799 Copenhagen V Denmark', 'Carlsberg Group.png', 'https://www.carlsberg.com/', 'Carlsberg', 'carlsberg', 'carlsberggroup', '1847-01-01', '2019-02-26', 304, 0, 0, 0, 0, 'Carlsberg A/S is a global brewer. Founded in 1847 by J. C. Jacobsen, the company\'s headquarters is located in Copenhagen, Denmark. Since Jacobsen\'s death in 1887, the majority owner of the company has been the Carlsberg Foundation. The company\'s flagship brand is Carlsberg (named after Jacobsen\'s son Carl). It also brews Tuborg, Kronenbourg, Somersby cider, Russia\'s best-selling beer Baltika, Belgian Grimbergen abbey beers, and more than 500 local beers.', 1);
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `brewery_ratings`
--
CREATE TABLE `brewery_ratings` (
`brewery_rating_ID` int(11) NOT NULL,
`profile_ID` int(11) NOT NULL,
`brewery_ID` int(11) NOT NULL,
`image` varchar(100) NOT NULL,
`rating` int(2) NOT NULL,
`like_unlike` int(1) NOT NULL,
`rating_tmp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`opinion` varchar(350) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `brewery_ratings`
--
INSERT INTO `brewery_ratings` (`brewery_rating_ID`, `profile_ID`, `brewery_ID`, `image`, `rating`, `like_unlike`, `rating_tmp`, `opinion`) VALUES
(1, 2, 2, '4k6-1920x1080.jpg', 10, 0, '2019-04-08 23:41:16', 'fdsfsfdsfsdfdsfdsfdsfsdfsdf'),
(2, 2, 3, '4k6-1920x1080.jpg', 10, 0, '2019-04-08 23:42:12', 'fdsfdsfsdfdsf');
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `categories`
--
CREATE TABLE `categories` (
`category_ID` int(11) NOT NULL,
`category_name` varchar(60) NOT NULL,
`parent` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `categories`
--
INSERT INTO `categories` (`category_ID`, `category_name`, `parent`) VALUES
(1, 'Ale', 0),
(2, 'Lager', 0),
(3, 'Spontán', 0),
(4, 'Hibrid', 0),
(5, 'Alkoholmentes', 0),
(6, 'Gluténmentes', 0),
(7, 'Egyéb', 0),
(8, 'Adambier', 1),
(9, 'American Pale Wheat Ale', 1),
(10, 'American Wild Ale', 1),
(11, 'Australian Sparkling Ale', 1),
(12, 'Barley Wine', 1),
(13, 'Belgian Ale', 1),
(14, 'Bière de Champagne / Bière Brut', 1),
(15, 'Bière de Garde', 1),
(16, 'Bière de Mars', 1),
(17, 'Black & Tan', 1),
(18, 'Blonde Ale', 1),
(19, 'Brown Ale', 1),
(20, 'Burton Ale', 1),
(21, 'Cream Ale', 1),
(22, 'Dampfbier', 1),
(23, 'Dark Ale', 1),
(24, 'Dark Ale', 1),
(25, 'English Bitter', 1),
(26, 'English Mild Ale', 1),
(27, 'Extra Special / Strong Bitter', 1),
(28, 'Golden Ale', 1),
(29, 'Grisette', 1),
(30, 'Gruit / Ancient Herbed Ale', 1),
(31, 'Grätzer / Grodziskie', 1),
(32, 'Italian Grape Ale', 1),
(33, 'Kölsch', 1),
(34, 'Lichtenhainer', 1),
(35, 'Mild', 1),
(36, 'Mumme', 1),
(37, 'Old Ale', 1),
(38, 'Pale Ale', 1),
(39, 'Patersbier', 1),
(40, 'Red Ale', 1),
(41, 'Roggenbier', 1),
(42, 'Rye Beer', 1),
(43, 'Rye Wine', 1),
(44, 'Sahti', 1),
(45, 'Saison / Farmhouse Ale', 1),
(46, 'Scotch Ale / Wee Heavy', 1),
(47, 'Scottish Export Ale', 1),
(48, 'Sour Ale', 1),
(49, 'Strong Ale', 1),
(50, 'Table Beer', 1),
(51, 'Traditional Ale', 1),
(52, 'Wheat beer', 1),
(53, 'Winter Ale', 1),
(54, 'Winter Warmer', 1),
(55, 'Witbier', 1),
(56, 'Amber Lager', 2),
(57, 'American Amber / Red Lager', 2),
(58, 'American Light Lager', 2),
(59, 'Bock', 2),
(60, 'Dark Lager', 2),
(61, 'Dunkel Lager', 2),
(62, 'Euro Dark Lager', 2),
(63, 'Euro Lager', 2),
(64, 'Euro Strong Lager', 2),
(65, 'Festbier', 2),
(66, 'Happoshu', 2),
(67, 'Hard Seltzer', 2),
(68, 'IPL (India Pale Lager)', 2),
(69, 'Japanese Rice Lager', 2),
(70, 'Kellerbier / Zwickelbier', 2),
(71, 'Munich Dunkel Lager', 2),
(72, 'Märzen', 2),
(73, 'North American Adjunct Lager', 2),
(74, 'Pale Lager', 2),
(75, 'Rauchbier', 2),
(76, 'Red Lager', 2),
(77, 'Schwarzbier', 2),
(78, 'Vienna Lager', 2),
(79, 'Winter Lager', 2),
(80, 'Zoigl', 2),
(81, 'Lambic', 3),
(82, 'California Common', 4),
(83, 'Kentucky Common', 4),
(84, 'Smoked Beer', 4),
(85, 'Steam Beer', 4),
(86, 'Cider', 7),
(87, 'Fruit Beer', 7),
(88, 'Ginger Beer', 7),
(89, 'Honey Beer', 7),
(90, 'Kombucha', 7),
(91, 'Kvass', 7),
(92, 'Malt Beer', 7),
(93, 'Malt Liquor ', 7),
(94, 'Pumpkin / Yam Beer', 7),
(95, 'Root Beer', 7),
(96, 'Shandy / Radler', 7),
(97, 'Specialty Grain', 7),
(98, 'Spiced / Herbed Beer', 7),
(99, 'American Barley Wine', 12),
(100, 'English Barley Wine', 12),
(101, 'Other Barley Wine', 12),
(102, 'Abbey', 13),
(103, 'Amber', 13),
(104, 'Belgian Strong Dark Ale', 13),
(105, 'Belgian Strong Golden Ale', 13),
(106, 'Blond', 13),
(107, 'Dubbel', 13),
(108, 'Flemish red', 13),
(109, 'Quadrupel', 13),
(110, 'Trappist', 13),
(111, 'Tripel', 13),
(112, ' English Brown Ale', 19),
(113, 'American Brown Ale', 19),
(114, 'Belgian Brown Ale', 19),
(115, 'Imperial / Double Brown Ale', 19),
(116, 'Other Brown Ale', 19),
(117, 'Porter', 23),
(118, 'Stout', 23),
(119, 'Altbier', 38),
(120, 'American Pale Ale', 38),
(121, 'American Pale Wheat Ale', 38),
(122, 'Australian Pale Ale', 38),
(123, 'Belgian Pale Ale', 38),
(124, 'English Bitter', 38),
(125, 'English Pale Ale', 38),
(126, 'IPA', 38),
(127, 'International Pale Ale', 38),
(128, 'New England Pale Ale', 38),
(129, 'New Zealand Pale Ale', 38),
(130, 'Saison', 38),
(131, 'Scotch Ale', 38),
(132, 'Berliner Weisse', 52),
(133, 'Dunkel Wheat beer', 52),
(134, 'Dunkelweizen', 52),
(135, 'Hefeweizen', 52),
(136, 'Hefeweizen Light / Leicht', 52),
(137, 'Kristallweizen', 52),
(138, 'Other Wheat Beer', 52),
(139, 'Weizenbock', 52),
(140, 'White beer', 52),
(141, 'American Strong Ale', 49),
(142, 'English Strong Ale', 49),
(143, 'Other Strong Ale', 49),
(144, 'American Amber / Red Red Ale', 40),
(145, 'Flemish Red Ale', 40),
(146, 'Imperial / Double Red Ale', 40),
(147, 'Irish Red Ale', 40),
(148, 'Other Red Ale', 40),
(149, 'Sour Ale', 48),
(150, 'Sour Berliner Weisse', 48),
(151, 'Sour Farmhouse IPA', 48),
(152, 'Sour Flanders Oud Bruin', 48),
(153, 'Sour Flanders Red Ale', 48),
(154, 'Sour Fruited', 48),
(155, 'Sour Gose', 48),
(156, 'Doppelbock', 59),
(157, 'Eisbock', 59),
(158, 'Maibock / Heller (Helles) / Lentebock', 59),
(159, 'Single / Traditional', 59),
(160, 'Weizenbock', 59),
(161, 'Dortmunder / Export', 74),
(162, 'Dry Lager', 74),
(163, 'Helles', 74),
(164, 'Pilsner', 74),
(165, 'Spetial', 74),
(166, 'Faro', 81),
(167, 'Framboise', 81),
(168, 'Fruit Lambic', 81),
(169, 'Gueuze', 81),
(170, 'Kriek', 81),
(171, 'Traditional Lambic', 81),
(172, 'Dry Cider', 86),
(173, 'Herbed / Spiced / Hopped Cider', 86),
(174, 'Ice / Applewine Cider', 86),
(175, 'Other Cider', 86),
(176, 'Other Fruit Cider', 86),
(177, 'Perry Cider', 86),
(178, 'Sweet Cider', 86),
(179, 'Mead Beer', 7),
(180, 'American Imperial / Double Stout', 118),
(181, 'American Stout', 118),
(182, 'Chocolate Stout', 118),
(183, 'Coffee Stout', 118),
(184, 'Dry Stout', 118),
(185, 'English Stout', 118),
(186, 'Foreign / Export Stout', 118),
(187, 'Imperial / Double Stout', 118),
(188, 'Imperial Stout', 118),
(189, 'Milk Stout', 118),
(190, 'Oatmeal Stout', 118),
(191, 'Oyster Stout', 118),
(192, 'Russian Imperial Stout', 118),
(193, 'Imperial / Double White Stout', 118),
(194, 'Imperial Milk / Sweet Stout', 118),
(195, 'Imperial Oatmeal Stout', 118),
(196, 'Irish Dry Stout', 118),
(197, 'Milk / Sweet Stout', 118),
(198, 'Other Stout', 118),
(199, 'White Stout', 118),
(200, 'American Porter', 117),
(201, 'Baltic Porter', 117),
(202, 'Coffee Porter', 117),
(203, 'English Porter', 117),
(204, 'Imperial / Double Porter', 117),
(205, 'Other Porter', 117),
(206, 'American IPA', 126),
(207, 'Belgian IPA', 126),
(208, 'Black / Cascadian Dark Ale IPA', 126),
(209, 'Brown IPA', 126),
(210, 'Brut IPA', 126),
(211, 'English IPA', 126),
(212, 'Imperial / Double Black IPA', 126),
(213, 'Imperial / Double IPA', 126),
(214, 'Imperial / Double New England IPA', 126),
(215, 'International IPA', 126),
(216, 'Milkshake IPA', 126),
(217, 'New England IPA', 126),
(218, 'Red IPA', 126),
(219, 'Rye IPA', 126),
(220, 'Session / India Session Ale IPA', 126),
(221, 'Triple IPA', 126),
(222, 'White IPA', 126),
(223, 'Czech Pilsner', 164),
(224, 'German Pilsner', 164),
(225, 'Imperial / Double Pilsner', 164),
(226, 'Other Pilsner', 164),
(227, 'Braggot', 179),
(228, 'Cyser', 179),
(229, 'Melomel', 179),
(230, 'Metheglin', 179),
(231, 'Other', 179),
(232, 'Pyment', 179);
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `confirm`
--
CREATE TABLE `confirm` (
`confirm_ID` int(11) NOT NULL,
`profile_ID` int(11) NOT NULL,
`confirm_key` varchar(40) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `confirm`
--
INSERT INTO `confirm` (`confirm_ID`, `profile_ID`, `confirm_key`) VALUES
(1, 2, 'df2cd7104536553afde9f7d66133d578eccb4606');
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `countries`
--
CREATE TABLE `countries` (
`country_ID` int(11) NOT NULL,
`country_code` varchar(2) NOT NULL,
`country_name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `countries`
--
INSERT INTO `countries` (`country_ID`, `country_code`, `country_name`) VALUES
(1, 'AF', 'Afghanistan'),
(2, 'AL', 'Albania'),
(3, 'DZ', 'Algeria'),
(4, 'DS', 'American Samoa'),
(5, 'AD', 'Andorra'),
(6, 'AO', 'Angola'),
(7, 'AI', 'Anguilla'),
(8, 'AQ', 'Antarctica'),
(9, 'AG', 'Antigua and Barbuda'),
(10, 'AR', 'Argentina'),
(11, 'AM', 'Armenia'),
(12, 'AW', 'Aruba'),
(13, 'AU', 'Australia'),
(14, 'AT', 'Austria'),
(15, 'AZ', 'Azerbaijan'),
(16, 'BS', 'Bahamas'),
(17, 'BH', 'Bahrain'),
(18, 'BD', 'Bangladesh'),
(19, 'BB', 'Barbados'),
(20, 'BY', 'Belarus'),
(21, 'BE', 'Belgium'),
(22, 'BZ', 'Belize'),
(23, 'BJ', 'Benin'),
(24, 'BM', 'Bermuda'),
(25, 'BT', 'Bhutan'),
(26, 'BO', 'Bolivia'),
(27, 'BA', 'Bosnia and Herzegovina'),
(28, 'BW', 'Botswana'),
(29, 'BV', 'Bouvet Island'),
(30, 'BR', 'Brazil'),
(31, 'IO', 'British Indian Ocean Territory'),
(32, 'BN', 'Brunei Darussalam'),
(33, 'BG', 'Bulgaria'),
(34, 'BF', 'Burkina Faso'),
(35, 'BI', 'Burundi'),
(36, 'KH', 'Cambodia'),
(37, 'CM', 'Cameroon'),
(38, 'CA', 'Canada'),
(39, 'CV', 'Cape Verde'),
(40, 'KY', 'Cayman Islands'),
(41, 'CF', 'Central African Republic'),
(42, 'TD', 'Chad'),
(43, 'CL', 'Chile'),
(44, 'CN', 'China'),
(45, 'CX', 'Christmas Island'),
(46, 'CC', 'Cocos (Keeling) Islands'),
(47, 'CO', 'Colombia'),
(48, 'KM', 'Comoros'),
(49, 'CG', 'Congo'),
(50, 'CK', 'Cook Islands'),
(51, 'CR', 'Costa Rica'),
(52, 'HR', 'Croatia (Hrvatska)'),
(53, 'CU', 'Cuba'),
(54, 'CY', 'Cyprus'),
(55, 'CZ', 'Czech Republic'),
(56, 'DK', 'Denmark'),
(57, 'DJ', 'Djibouti'),
(58, 'DM', 'Dominica'),
(59, 'DO', 'Dominican Republic'),
(60, 'TP', 'East Timor'),
(61, 'EC', 'Ecuador'),
(62, 'EG', 'Egypt'),
(63, 'SV', 'El Salvador'),
(64, 'GQ', 'Equatorial Guinea'),
(65, 'ER', 'Eritrea'),
(66, 'EE', 'Estonia'),
(67, 'ET', 'Ethiopia'),
(68, 'FK', 'Falkland Islands (Malvinas)'),
(69, 'FO', 'Faroe Islands'),
(70, 'FJ', 'Fiji'),
(71, 'FI', 'Finland'),
(72, 'FR', 'France'),
(73, 'FX', 'France, Metropolitan'),
(74, 'GF', 'French Guiana'),
(75, 'PF', 'French Polynesia'),
(76, 'TF', 'French Southern Territories'),
(77, 'GA', 'Gabon'),
(78, 'GM', 'Gambia'),
(79, 'GE', 'Georgia'),
(80, 'DE', 'Germany'),
(81, 'GH', 'Ghana'),
(82, 'GI', 'Gibraltar'),
(83, 'GK', 'Guernsey'),
(84, 'GR', 'Greece'),
(85, 'GL', 'Greenland'),
(86, 'GD', 'Grenada'),
(87, 'GP', 'Guadeloupe'),
(88, 'GU', 'Guam'),
(89, 'GT', 'Guatemala'),
(90, 'GN', 'Guinea'),
(91, 'GW', 'Guinea-Bissau'),
(92, 'GY', 'Guyana'),
(93, 'HT', 'Haiti'),
(94, 'HM', 'Heard and Mc Donald Islands'),
(95, 'HN', 'Honduras'),
(96, 'HK', 'Hong Kong'),
(97, 'HU', 'Hungary'),
(98, 'IS', 'Iceland'),
(99, 'IN', 'India'),
(100, 'IM', 'Isle of Man'),
(101, 'ID', 'Indonesia'),
(102, 'IR', 'Iran (Islamic Republic of)'),
(103, 'IQ', 'Iraq'),
(104, 'IE', 'Ireland'),
(105, 'IL', 'Israel'),
(106, 'IT', 'Italy'),
(107, 'CI', 'Ivory Coast'),
(108, 'JE', 'Jersey'),
(109, 'JM', 'Jamaica'),
(110, 'JP', 'Japan'),
(111, 'JO', 'Jordan'),
(112, 'KZ', 'Kazakhstan'),
(113, 'KE', 'Kenya'),
(114, 'KI', 'Kiribati'),
(115, 'KP', 'Korea, Democratic People\'s Republic of'),
(116, 'KR', 'Korea, Republic of'),
(117, 'XK', 'Kosovo'),
(118, 'KW', 'Kuwait'),
(119, 'KG', 'Kyrgyzstan'),
(120, 'LA', 'Lao People\'s Democratic Republic'),
(121, 'LV', 'Latvia'),
(122, 'LB', 'Lebanon'),
(123, 'LS', 'Lesotho'),
(124, 'LR', 'Liberia'),
(125, 'LY', 'Libyan Arab Jamahiriya'),
(126, 'LI', 'Liechtenstein'),
(127, 'LT', 'Lithuania'),
(128, 'LU', 'Luxembourg'),
(129, 'MO', 'Macau'),
(130, 'MK', 'Macedonia'),
(131, 'MG', 'Madagascar'),
(132, 'MW', 'Malawi'),
(133, 'MY', 'Malaysia'),
(134, 'MV', 'Maldives'),
(135, 'ML', 'Mali'),
(136, 'MT', 'Malta'),
(137, 'MH', 'Marshall Islands'),
(138, 'MQ', 'Martinique'),
(139, 'MR', 'Mauritania'),
(140, 'MU', 'Mauritius'),
(141, 'TY', 'Mayotte'),
(142, 'MX', 'Mexico'),
(143, 'FM', 'Micronesia, Federated States of'),
(144, 'MD', 'Moldova, Republic of'),
(145, 'MC', 'Monaco'),
(146, 'MN', 'Mongolia'),
(147, 'ME', 'Montenegro'),
(148, 'MS', 'Montserrat'),
(149, 'MA', 'Morocco'),
(150, 'MZ', 'Mozambique'),
(151, 'MM', 'Myanmar'),
(152, 'NA', 'Namibia'),
(153, 'NR', 'Nauru'),
(154, 'NP', 'Nepal'),
(155, 'NL', 'Netherlands'),
(156, 'AN', 'Netherlands Antilles'),
(157, 'NC', 'New Caledonia'),
(158, 'NZ', 'New Zealand'),
(159, 'NI', 'Nicaragua'),
(160, 'NE', 'Niger'),
(161, 'NG', 'Nigeria'),
(162, 'NU', 'Niue'),
(163, 'NF', 'Norfolk Island'),
(164, 'MP', 'Northern Mariana Islands'),
(165, 'NO', 'Norway'),
(166, 'OM', 'Oman'),
(167, 'PK', 'Pakistan'),
(168, 'PW', 'Palau'),
(169, 'PS', 'Palestine'),
(170, 'PA', 'Panama'),
(171, 'PG', 'Papua New Guinea'),
(172, 'PY', 'Paraguay'),
(173, 'PE', 'Peru'),
(174, 'PH', 'Philippines'),
(175, 'PN', 'Pitcairn'),
(176, 'PL', 'Poland'),
(177, 'PT', 'Portugal'),
(178, 'PR', 'Puerto Rico'),
(179, 'QA', 'Qatar'),
(180, 'RE', 'Reunion'),
(181, 'RO', 'Romania'),
(182, 'RU', 'Russian Federation'),
(183, 'RW', 'Rwanda'),
(184, 'KN', 'Saint Kitts and Nevis'),
(185, 'LC', 'Saint Lucia'),
(186, 'VC', 'Saint Vincent and the Grenadines'),
(187, 'WS', 'Samoa'),
(188, 'SM', 'San Marino'),
(189, 'ST', 'Sao Tome and Principe'),
(190, 'SA', 'Saudi Arabia'),
(191, 'SN', 'Senegal'),
(192, 'RS', 'Serbia'),
(193, 'SC', 'Seychelles'),
(194, 'SL', 'Sierra Leone'),
(195, 'SG', 'Singapore'),
(196, 'SK', 'Slovakia'),
(197, 'SI', 'Slovenia'),
(198, 'SB', 'Solomon Islands'),
(199, 'SO', 'Somalia'),
(200, 'ZA', 'South Africa'),
(201, 'GS', 'South Georgia South Sandwich Islands'),
(202, 'SS', 'South Sudan'),
(203, 'ES', 'Spain'),
(204, 'LK', 'Sri Lanka'),
(205, 'SH', 'St. Helena'),
(206, 'PM', 'St. Pierre and Miquelon'),
(207, 'SD', 'Sudan'),
(208, 'SR', 'Suriname'),
(209, 'SJ', 'Svalbard and Jan Mayen Islands'),
(210, 'SZ', 'Swaziland'),
(211, 'SE', 'Sweden'),
(212, 'CH', 'Switzerland'),
(213, 'SY', 'Syrian Arab Republic'),
(214, 'TW', 'Taiwan'),
(215, 'TJ', 'Tajikistan'),
(216, 'TZ', 'Tanzania, United Republic of'),
(217, 'TH', 'Thailand'),
(218, 'TG', 'Togo'),
(219, 'TK', 'Tokelau'),
(220, 'TO', 'Tonga'),
(221, 'TT', 'Trinidad and Tobago'),
(222, 'TN', 'Tunisia'),
(223, 'TR', 'Turkey'),
(224, 'TM', 'Turkmenistan'),
(225, 'TC', 'Turks and Caicos Islands'),
(226, 'TV', 'Tuvalu'),
(227, 'UG', 'Uganda'),
(228, 'UA', 'Ukraine'),
(229, 'AE', 'United Arab Emirates'),
(230, 'GB', 'United Kingdom'),
(231, 'US', 'United States'),
(232, 'UM', 'United States minor outlying islands'),
(233, 'UY', 'Uruguay'),
(234, 'UZ', 'Uzbekistan'),
(235, 'VU', 'Vanuatu'),
(236, 'VA', 'Vatican City State'),
(237, 'VE', 'Venezuela'),
(238, 'VN', 'Vietnam'),
(239, 'VG', 'Virgin Islands (British)'),
(240, 'VI', 'Virgin Islands (U.S.)'),
(241, 'WF', 'Wallis and Futuna Islands'),
(242, 'EH', 'Western Sahara'),
(243, 'YE', 'Yemen'),
(244, 'ZR', 'Zaire'),
(245, 'ZM', 'Zambia'),
(246, 'ZW', 'Zimbabwe');
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `friends`
--
CREATE TABLE `friends` (
`friend_ID` int(11) NOT NULL,
`initiator_ID` int(11) NOT NULL,
`acceptor_ID` int(11) NOT NULL,
`active` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `glasses`
--
CREATE TABLE `glasses` (
`glass_ID` int(11) NOT NULL,
`glass_type` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `glasses`
--
INSERT INTO `glasses` (`glass_ID`, `glass_type`) VALUES
(1, 'Weizenbier'),
(2, 'Pilsner'),
(3, 'Footed Pilsner'),
(4, 'Tulip Pint'),
(5, 'Conical Pint'),
(6, 'Nonic Pint'),
(7, 'Willi Becher'),
(8, 'Stange'),
(9, 'Flute'),
(10, 'Pokal'),
(11, 'Snifter'),
(12, 'Goblet'),
(13, 'Chalice'),
(14, 'Oversized Wine'),
(15, 'Tulip'),
(16, 'Thistle'),
(17, 'Tumbler'),
(18, 'Hopside Down'),
(19, 'Yard'),
(20, 'Boot'),
(21, 'Stein'),
(22, 'Dimpled Mug'),
(23, 'Tankard'),
(24, 'Oktoberfest Mug');
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `persons`
--
CREATE TABLE `persons` (
`person_ID` int(11) NOT NULL,
`country_ID` int(11) NOT NULL,
`birth_date` date NOT NULL,
`first_name` varchar(40) NOT NULL,
`last_name` varchar(40) NOT NULL,
`email` varchar(100) NOT NULL,
`check_question` varchar(60) NOT NULL,
`check_answer` varchar(60) NOT NULL,
`sex` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `persons`
--
INSERT INTO `persons` (`person_ID`, `country_ID`, `birth_date`, `first_name`, `last_name`, `email`, `check_question`, `check_answer`, `sex`) VALUES
(1, 97, '0000-00-00', '', '', '', '', '', 0),
(2, 97, '1994-07-12', 'Roland', 'Kovács ', 'latinkukacprof@hotmail.com', 'Mi a kedvenc könyved?', 'Hogyan elégítsünk ki egy nőt 24 óra alatt', 1);
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `private_message`
--
CREATE TABLE `private_message` (
`msg_ID` int(11) NOT NULL,
`sender_ID` int(11) NOT NULL,
`consignee_ID` int(11) NOT NULL,
`message` varchar(350) NOT NULL,
`send_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`seen` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `private_message`
--
INSERT INTO `private_message` (`msg_ID`, `sender_ID`, `consignee_ID`, `message`, `send_timestamp`, `seen`) VALUES
(1, 1, 2, 'Isten hozott a To Beer Or Not To Beer sör és sörfőzde értékelő oldalán.', '2019-04-08 21:36:07', 1);
-- --------------------------------------------------------
--
-- Tábla szerkezet ehhez a táblához `profiles`
--
CREATE TABLE `profiles` (
`profile_ID` int(11) NOT NULL,
`person_ID` int(11) NOT NULL,
`username` varchar(20) NOT NULL,
`password` varchar(40) NOT NULL,
`profile_pic` varchar(100) NOT NULL,
`join_tmp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_enter` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`coin` int(11) NOT NULL,
`rating_count` int(11) NOT NULL,
`active` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- A tábla adatainak kiíratása `profiles`
--
INSERT INTO `profiles` (`profile_ID`, `person_ID`, `username`, `password`, `profile_pic`, `join_tmp`, `last_enter`, `coin`, `rating_count`, `active`) VALUES
(1, 1, 'Rendszer', '', '', '2019-04-08 21:24:29', '2019-04-08 21:24:29', 0, 0, 0),
(2, 2, 'latinkukacprof', 'b6fc4ab7f014b293fadfbbd07d460ad76ae8de2d', '', '2019-04-08 21:36:04', '2019-04-09 06:13:35', 20, 4, 1);
--
-- Indexek a kiírt táblákhoz
--
--
-- A tábla indexei `beers`
--
ALTER TABLE `beers`
ADD PRIMARY KEY (`beer_ID`),
ADD KEY `brewery_ID` (`brewery_ID`),
ADD KEY `glass_ID` (`glass_ID`),
ADD KEY `category_ID` (`category_ID`);
--
-- A tábla indexei `beers_ratings`
--
ALTER TABLE `beers_ratings`
ADD PRIMARY KEY (`beer_rating_ID`),
ADD KEY `profile_ID` (`profile_ID`),
ADD KEY `beer_ID` (`beer_ID`);
--
-- A tábla indexei `breweries`
--
ALTER TABLE `breweries`
ADD PRIMARY KEY (`brewery_ID`),
ADD KEY `country_ID` (`country_ID`);
--
-- A tábla indexei `brewery_ratings`
--
ALTER TABLE `brewery_ratings`
ADD PRIMARY KEY (`brewery_rating_ID`),
ADD KEY `profile_ID` (`profile_ID`),
ADD KEY `brewery_ID` (`brewery_ID`);
--
-- A tábla indexei `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`category_ID`);
--
-- A tábla indexei `confirm`
--
ALTER TABLE `confirm`
ADD PRIMARY KEY (`confirm_ID`),
ADD KEY `profile_ID` (`profile_ID`);
--
-- A tábla indexei `countries`
--
ALTER TABLE `countries`
ADD PRIMARY KEY (`country_ID`);
--
-- A tábla indexei `friends`
--
ALTER TABLE `friends`
ADD PRIMARY KEY (`friend_ID`),
ADD KEY `initiator_ID` (`initiator_ID`),
ADD KEY `acceptor_ID` (`acceptor_ID`);
--
-- A tábla indexei `glasses`
--
ALTER TABLE `glasses`
ADD PRIMARY KEY (`glass_ID`);
--
-- A tábla indexei `persons`
--
ALTER TABLE `persons`
ADD PRIMARY KEY (`person_ID`),
ADD KEY `country_ID` (`country_ID`);
--
-- A tábla indexei `private_message`
--
ALTER TABLE `private_message`
ADD PRIMARY KEY (`msg_ID`),
ADD KEY `sender_ID` (`sender_ID`),
ADD KEY `consignee_ID` (`consignee_ID`);
--
-- A tábla indexei `profiles`
--
ALTER TABLE `profiles`
ADD PRIMARY KEY (`profile_ID`),
ADD KEY `person_ID` (`person_ID`);
--
-- A kiírt táblák AUTO_INCREMENT értéke
--
--
-- AUTO_INCREMENT a táblához `beers`
--
ALTER TABLE `beers`
MODIFY `beer_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT a táblához `beers_ratings`
--
ALTER TABLE `beers_ratings`
MODIFY `beer_rating_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT a táblához `breweries`
--
ALTER TABLE `breweries`
MODIFY `brewery_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT a táblához `brewery_ratings`
--
ALTER TABLE `brewery_ratings`
MODIFY `brewery_rating_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT a táblához `categories`
--
ALTER TABLE `categories`
MODIFY `category_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=233;
--
-- AUTO_INCREMENT a táblához `confirm`
--
ALTER TABLE `confirm`
MODIFY `confirm_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT a táblához `countries`
--
ALTER TABLE `countries`
MODIFY `country_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=247;
--
-- AUTO_INCREMENT a táblához `friends`
--
ALTER TABLE `friends`
MODIFY `friend_ID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT a táblához `glasses`
--
ALTER TABLE `glasses`
MODIFY `glass_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT a táblához `persons`
--
ALTER TABLE `persons`
MODIFY `person_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT a táblához `private_message`
--
ALTER TABLE `private_message`
MODIFY `msg_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT a táblához `profiles`
--
ALTER TABLE `profiles`
MODIFY `profile_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Megkötések a kiírt táblákhoz
--
--
-- Megkötések a táblához `beers`
--
ALTER TABLE `beers`
ADD CONSTRAINT `beers_ibfk_1` FOREIGN KEY (`brewery_ID`) REFERENCES `breweries` (`brewery_ID`),
ADD CONSTRAINT `beers_ibfk_2` FOREIGN KEY (`glass_ID`) REFERENCES `glasses` (`glass_ID`),
ADD CONSTRAINT `beers_ibfk_3` FOREIGN KEY (`category_ID`) REFERENCES `categories` (`category_ID`);
--
-- Megkötések a táblához `beers_ratings`
--
ALTER TABLE `beers_ratings`
ADD CONSTRAINT `beers_ratings_ibfk_1` FOREIGN KEY (`profile_ID`) REFERENCES `profiles` (`profile_ID`),
ADD CONSTRAINT `beers_ratings_ibfk_2` FOREIGN KEY (`beer_ID`) REFERENCES `beers` (`beer_ID`);
--
-- Megkötések a táblához `breweries`
--
ALTER TABLE `breweries`
ADD CONSTRAINT `breweries_ibfk_1` FOREIGN KEY (`country_ID`) REFERENCES `countries` (`country_ID`);
--
-- Megkötések a táblához `brewery_ratings`
--
ALTER TABLE `brewery_ratings`
ADD CONSTRAINT `brewery_ratings_ibfk_1` FOREIGN KEY (`profile_ID`) REFERENCES `profiles` (`profile_ID`),
ADD CONSTRAINT `brewery_ratings_ibfk_2` FOREIGN KEY (`brewery_ID`) REFERENCES `breweries` (`brewery_ID`);
--
-- Megkötések a táblához `confirm`
--
ALTER TABLE `confirm`
ADD CONSTRAINT `confirm_ibfk_1` FOREIGN KEY (`profile_ID`) REFERENCES `profiles` (`profile_ID`);
--
-- Megkötések a táblához `friends`
--
ALTER TABLE `friends`
ADD CONSTRAINT `friends_ibfk_1` FOREIGN KEY (`initiator_ID`) REFERENCES `profiles` (`profile_ID`),
ADD CONSTRAINT `friends_ibfk_2` FOREIGN KEY (`acceptor_ID`) REFERENCES `profiles` (`profile_ID`);
--
-- Megkötések a táblához `persons`
--
ALTER TABLE `persons`
ADD CONSTRAINT `persons_ibfk_1` FOREIGN KEY (`country_ID`) REFERENCES `countries` (`country_ID`);
--
-- Megkötések a táblához `private_message`
--
ALTER TABLE `private_message`
ADD CONSTRAINT `private_message_ibfk_1` FOREIGN KEY (`sender_ID`) REFERENCES `profiles` (`profile_ID`),
ADD CONSTRAINT `private_message_ibfk_2` FOREIGN KEY (`consignee_ID`) REFERENCES `profiles` (`profile_ID`);
--
-- Megkötések a táblához `profiles`
--
ALTER TABLE `profiles`
ADD CONSTRAINT `profiles_ibfk_1` FOREIGN KEY (`person_ID`) REFERENCES `persons` (`person_ID`);
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 */;
| true |
1b791ca5950620b7a7af5b0e300442b1d82be7f5 | SQL | laminr/cjrp | /Database/cjrp.sql | UTF-8 | 5,490 | 3.9375 | 4 | [] | no_license | 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';
CREATE SCHEMA IF NOT EXISTS `cjrp` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `cjrp` ;
-- -----------------------------------------------------
-- Table `cjrp`.`label`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cjrp`.`label` (
`label_id` INT NOT NULL AUTO_INCREMENT,
`type` VARCHAR(45) NULL COMMENT 'island, city, company_hotel, company_car, car_make, car_type, rating_delay',
`value` VARCHAR(45) NULL,
PRIMARY KEY (`label_id`),
UNIQUE INDEX `label_id_UNIQUE` (`label_id` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `cjrp`.`company`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cjrp`.`company` (
`company_id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NULL,
`island_label_id` INT NOT NULL,
`city_label_id` INT NOT NULL,
`type_label_id` INT NOT NULL COMMENT 'hotel or car',
`rating` DOUBLE(2,1) NULL,
`description` LONGTEXT NULL,
PRIMARY KEY (`company_id`, `island_label_id`, `city_label_id`, `type_label_id`),
INDEX `fk_company_label_idx` (`island_label_id` ASC),
INDEX `fk_company_label1_idx` (`city_label_id` ASC),
INDEX `fk_company_label2_idx` (`type_label_id` ASC),
UNIQUE INDEX `company_id_UNIQUE` (`company_id` ASC),
CONSTRAINT `fk_company_label`
FOREIGN KEY (`island_label_id`)
REFERENCES `cjrp`.`label` (`label_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_company_label1`
FOREIGN KEY (`city_label_id`)
REFERENCES `cjrp`.`label` (`label_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_company_label2`
FOREIGN KEY (`type_label_id`)
REFERENCES `cjrp`.`label` (`label_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `cjrp`.`car`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cjrp`.`car` (
`car_id` INT NOT NULL AUTO_INCREMENT,
`make_label_id` INT NOT NULL,
`model` VARCHAR(45) NULL,
`type_label_id` INT NOT NULL,
`capacity` INT NULL,
PRIMARY KEY (`car_id`, `make_label_id`, `type_label_id`),
INDEX `fk_car_label1_idx` (`make_label_id` ASC),
INDEX `fk_car_label2_idx` (`type_label_id` ASC),
UNIQUE INDEX `car_id_UNIQUE` (`car_id` ASC),
CONSTRAINT `fk_car_label1`
FOREIGN KEY (`make_label_id`)
REFERENCES `cjrp`.`label` (`label_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_car_label2`
FOREIGN KEY (`type_label_id`)
REFERENCES `cjrp`.`label` (`label_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = ' ';
-- -----------------------------------------------------
-- Table `cjrp`.`carRating`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cjrp`.`carRating` (
`rating_id` INT NOT NULL AUTO_INCREMENT,
`company_id` INT NOT NULL,
`car_id` INT NOT NULL,
`perDay` DOUBLE(6,2) NOT NULL,
`perWeekRatio` DOUBLE(5,4) NOT NULL,
`fee` DOUBLE(6,2) NOT NULL,
PRIMARY KEY (`rating_id`, `company_id`, `car_id`),
INDEX `fk_rating_company1_idx` (`company_id` ASC),
UNIQUE INDEX `rating_id_UNIQUE` (`rating_id` ASC),
INDEX `fk_rating_car1_idx` (`car_id` ASC),
CONSTRAINT `fk_rating_company1`
FOREIGN KEY (`company_id`)
REFERENCES `cjrp`.`company` (`company_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_rating_car1`
FOREIGN KEY (`car_id`)
REFERENCES `cjrp`.`car` (`car_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `cjrp`.`room`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cjrp`.`room` (
`room_id` INT NOT NULL,
`type_label_id` INT NOT NULL,
`capacity` INT NOT NULL DEFAULT 1,
PRIMARY KEY (`room_id`, `type_label_id`),
UNIQUE INDEX `room_id_UNIQUE` (`room_id` ASC),
INDEX `fk_room_label1_idx` (`type_label_id` ASC),
CONSTRAINT `fk_room_label1`
FOREIGN KEY (`type_label_id`)
REFERENCES `cjrp`.`label` (`label_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `cjrp`.`hotelRating`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `cjrp`.`hotelRating` (
`rating_id` INT NOT NULL AUTO_INCREMENT,
`company_id` INT NOT NULL,
`perDay` DOUBLE(6,2) NOT NULL,
`perWeekRatio` DOUBLE(5,4) NOT NULL,
`fee` DOUBLE(6,2) NOT NULL,
`type_label_id` INT NOT NULL,
PRIMARY KEY (`rating_id`, `company_id`, `type_label_id`),
INDEX `fk_rating_company1_idx` (`company_id` ASC),
UNIQUE INDEX `rating_id_UNIQUE` (`rating_id` ASC),
INDEX `fk_hotelRating_room1_idx` (`type_label_id` ASC),
CONSTRAINT `fk_rating_company10`
FOREIGN KEY (`company_id`)
REFERENCES `cjrp`.`company` (`company_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_hotelRating_room1`
FOREIGN KEY (`type_label_id`)
REFERENCES `cjrp`.`room` (`type_label_id`)
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;
| true |
87faa028abea73fa4f8d6d3d7bdac9a12e9b336a | SQL | magdalena70/MSSQL-DB-Basics | /SQL-Language-Basics/Sample_Exam/Section_03-Querying-Problem1-EmloyeesSalary.sql | UTF-8 | 126 | 2.90625 | 3 | [] | no_license | SELECT e.EmployeeID, e.HireDate, e.Salary, e.BranchID
FROM Employees AS e
WHERE e.Salary > 2000 AND e.HireDate > '2009-06-15' | true |
ba64fbf0e99bac704febca853246a9b52a1db82b | SQL | prasetiyo28/majelis | /db/majelis.sql | UTF-8 | 6,997 | 3.203125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | -- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jul 17, 2019 at 07:34 AM
-- Server version: 10.3.15-MariaDB
-- 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: `majelis`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE `admin` (
`id_admin` int(11) NOT NULL,
`nama` varchar(120) NOT NULL,
`email` varchar(150) NOT NULL,
`password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id_admin`, `nama`, `email`, `password`) VALUES
(1, 'Fatkhul Falah', 'fatkhulfalah@gmail.com', '2b620bdf79fc91e5f062c2d6e897dd3c'),
(2, 'admin', 'admin@majelis.com', '21232f297a57a5a743894a0e4a801fc3');
-- --------------------------------------------------------
--
-- Table structure for table `kategori`
--
CREATE TABLE `kategori` (
`id_kategori` int(2) NOT NULL,
`kategori` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `kategori`
--
INSERT INTO `kategori` (`id_kategori`, `kategori`) VALUES
(1, 'Nadhatul Ulama'),
(2, 'Muhammadiyah');
-- --------------------------------------------------------
--
-- Table structure for table `kegiatan`
--
CREATE TABLE `kegiatan` (
`id` int(11) NOT NULL,
`id_majelis` int(11) NOT NULL,
`nama_kegiatan` varchar(255) NOT NULL,
`tempat` varchar(255) NOT NULL,
`tanggal` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `kegiatan`
--
INSERT INTO `kegiatan` (`id`, `id_majelis`, `nama_kegiatan`, `tempat`, `tanggal`) VALUES
(1, 1, 'Pengajian', 'Masjid Al ikhlas no 20', '2019-07-31'),
(2, 1, 'Pengajian Rutin', 'Masjid Al Ikhlas Debong', '2019-07-15');
-- --------------------------------------------------------
--
-- Table structure for table `majelis`
--
CREATE TABLE `majelis` (
`id_majelis` int(1) NOT NULL,
`nama_majelis` varchar(150) NOT NULL,
`ketua` varchar(150) NOT NULL,
`alamat` varchar(255) NOT NULL,
`kontak` varchar(13) NOT NULL,
`id_kategori` int(1) NOT NULL,
`logo` varchar(255) NOT NULL,
`verif` int(1) NOT NULL DEFAULT 0,
`longitude` double NOT NULL DEFAULT 0,
`latitude` double NOT NULL DEFAULT 0,
`infaq` int(11) NOT NULL DEFAULT 0,
`block` int(11) NOT NULL DEFAULT 0,
`deleted` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `majelis`
--
INSERT INTO `majelis` (`id_majelis`, `nama_majelis`, `ketua`, `alamat`, `kontak`, `id_kategori`, `logo`, `verif`, `longitude`, `latitude`, `infaq`, `block`, `deleted`) VALUES
(1, 'JQH AL Mizans', 'Aldin Tri Mulyo', 'Kalinyamat Wetan', '082898989898', 1, '', 1, 0, 0, 2000000, 0, 0),
(2, 'Arauddhotul Mahmoedah', 'Ahmad Syekh ', 'Jalan Teuku Umar No.30 Tegal', '0828382839128', 2, 'majelis_1558085386.png', 0, 0, 0, 0, 0, 0),
(3, 'Majelis Al Ikhlas', 'Falah', 'Jatibarang', '08543281777', 1, 'majelis_1558410730.png', 0, 0, 0, 0, 0, 0),
(4, 'JQH Al Amin', 'Mulyono', 'Jalan Merpati no 30 Dukuhturi', '0872372187172', 2, 'majelis_1563097503.png', 0, 109.1248786455078, -6.903887937730955, 0, 0, 0);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id_user` int(11) NOT NULL,
`nama` varchar(150) NOT NULL,
`alamat` varchar(150) DEFAULT NULL,
`email` varchar(100) NOT NULL,
`jenis_kelamin` varchar(9) DEFAULT NULL,
`password` varchar(255) NOT NULL,
`id_majelis` int(11) NOT NULL DEFAULT 0,
`deleted` tinyint(1) NOT NULL DEFAULT 0,
`verif` tinyint(1) NOT NULL DEFAULT 0,
`blocked` tinyint(1) NOT NULL DEFAULT 0,
`level` tinyint(4) NOT NULL DEFAULT 0,
`token` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id_user`, `nama`, `alamat`, `email`, `jenis_kelamin`, `password`, `id_majelis`, `deleted`, `verif`, `blocked`, `level`, `token`) VALUES
(1, 'Aldin Tri Mulyo', 'Kalinyamat Kulon Gang 12 , Kota Tegal', 'aldin@gmail.com', 'Laki-Laki', '7a59124c390c24bd6f76035deea98c83', 1, 0, 1, 0, 0, ''),
(2, 'Bayu Adi Prasetiyo', NULL, 'bayu@gmail.com', 'Laki-Laki', '6ad14ba9986e3615423dfca256d04e3f', 0, 0, 1, 0, 0, ''),
(3, 'Aldin', NULL, 'aldin@gmail.com', 'Laki-Laki', 'dda51d3feaa9d758f9c556312266923a', 0, 0, 0, 0, 0, ''),
(4, 'Adi', NULL, 'adi@gmail.com', 'Laki-Laki', '6ad14ba9986e3615423dfca256d04e3f', 0, 0, 1, 0, 0, ''),
(5, 'Chloe', NULL, 'chloe@gmail.com', 'Perempuan', '6ad14ba9986e3615423dfca256d04e3f', 0, 0, 1, 0, 0, ''),
(6, 'Kim', NULL, 'kim@gmail.com', 'Laki-Laki', '25d55ad283aa400af464c76d713c07ad', 0, 0, 1, 0, 0, 'da340038be2e5077646e1c946ca0a4e95726b0b7c3316173450c0d51fb9f691f448cefd2f4b37968');
-- --------------------------------------------------------
--
-- Table structure for table `users_majelis`
--
CREATE TABLE `users_majelis` (
`id_users` int(11) NOT NULL,
`id_majelis` int(11) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users_majelis`
--
INSERT INTO `users_majelis` (`id_users`, `id_majelis`, `email`, `password`) VALUES
(1, 1, 'majelis1@gmail.com', '25d55ad283aa400af464c76d713c07ad'),
(2, 1, 'amin@gmail.com', '9276af0022e0cb0073a9ca05a18e0521');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id_admin`);
--
-- Indexes for table `kategori`
--
ALTER TABLE `kategori`
ADD PRIMARY KEY (`id_kategori`);
--
-- Indexes for table `kegiatan`
--
ALTER TABLE `kegiatan`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `majelis`
--
ALTER TABLE `majelis`
ADD PRIMARY KEY (`id_majelis`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id_user`);
--
-- Indexes for table `users_majelis`
--
ALTER TABLE `users_majelis`
ADD PRIMARY KEY (`id_users`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id_admin` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `kategori`
--
ALTER TABLE `kategori`
MODIFY `id_kategori` int(2) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `kegiatan`
--
ALTER TABLE `kegiatan`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `majelis`
--
ALTER TABLE `majelis`
MODIFY `id_majelis` int(1) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `users_majelis`
--
ALTER TABLE `users_majelis`
MODIFY `id_users` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
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 */;
| true |
23343ee488461c589471072b4a769eb0bb34041c | SQL | salvadorcea2/PlataformaInteraccionesAlmacen | /sql/repseg.sql | UTF-8 | 59,936 | 3.03125 | 3 | [] | no_license | CREATE EXTENSION hstore;
CREATE TABLE campo (
id integer NOT NULL,
plantilla_campo_id integer NOT NULL,
receptor_id integer NOT NULL,
habilitado boolean DEFAULT true
);
ALTER TABLE campo OWNER TO repo_adm;
--
-- TOC entry 217 (class 1259 OID 186957)
-- Name: campo_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE campo_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE campo_id_seq OWNER TO repo_adm;
--
-- TOC entry 2868 (class 0 OID 0)
-- Dependencies: 217
-- Name: campo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE campo_id_seq OWNED BY campo.id;
--
-- TOC entry 189 (class 1259 OID 186706)
-- Name: canal; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE canal (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE canal OWNER TO repo_adm;
--
-- TOC entry 188 (class 1259 OID 186704)
-- Name: canal_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE canal_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE canal_id_seq OWNER TO repo_adm;
--
-- TOC entry 2869 (class 0 OID 0)
-- Dependencies: 188
-- Name: canal_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE canal_id_seq OWNED BY canal.id;
--
-- TOC entry 193 (class 1259 OID 186734)
-- Name: canal_transmision; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE canal_transmision (
id integer NOT NULL,
propiedades character varying(80)[],
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE canal_transmision OWNER TO repo_adm;
--
-- TOC entry 192 (class 1259 OID 186732)
-- Name: canal_transmision_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE canal_transmision_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE canal_transmision_id_seq OWNER TO repo_adm;
--
-- TOC entry 2870 (class 0 OID 0)
-- Dependencies: 192
-- Name: canal_transmision_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE canal_transmision_id_seq OWNED BY canal_transmision.id;
--
-- TOC entry 210 (class 1259 OID 186888)
-- Name: extractor; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE extractor (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE extractor OWNER TO repo_adm;
--
-- TOC entry 209 (class 1259 OID 186886)
-- Name: extractor_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE extractor_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE extractor_id_seq OWNER TO repo_adm;
--
-- TOC entry 2871 (class 0 OID 0)
-- Dependencies: 209
-- Name: extractor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE extractor_id_seq OWNED BY extractor.id;
--
-- TOC entry 195 (class 1259 OID 186748)
-- Name: formato; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE formato (
id integer NOT NULL,
propiedades character varying(80)[],
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE formato OWNER TO repo_adm;
--
-- TOC entry 194 (class 1259 OID 186746)
-- Name: formato_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE formato_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE formato_id_seq OWNER TO repo_adm;
--
-- TOC entry 2872 (class 0 OID 0)
-- Dependencies: 194
-- Name: formato_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE formato_id_seq OWNED BY formato.id;
--
-- TOC entry 201 (class 1259 OID 186789)
-- Name: institucion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE institucion (
id integer NOT NULL,
subsecretaria_id integer,
nombre character varying(120) NOT NULL,
habilitado boolean DEFAULT true
);
ALTER TABLE institucion OWNER TO repo_adm;
--
-- TOC entry 200 (class 1259 OID 186787)
-- Name: institucion_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE institucion_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE institucion_id_seq OWNER TO repo_adm;
--
-- TOC entry 2873 (class 0 OID 0)
-- Dependencies: 200
-- Name: institucion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE institucion_id_seq OWNED BY institucion.id;
--
-- TOC entry 230 (class 1259 OID 187072)
-- Name: interaccion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE interaccion (
id integer NOT NULL,
recepcion_id integer NOT NULL,
periodicidad_id integer NOT NULL,
fecha_interaccion timestamp with time zone,
fecha_creacion timestamp with time zone DEFAULT now(),
tipo_interaccion_id integer NOT NULL,
canal_id integer NOT NULL,
tramite_id integer NOT NULL,
localidad_id integer NOT NULL,
hmac256 bytea
);
ALTER TABLE interaccion OWNER TO repo_adm;
--
-- TOC entry 229 (class 1259 OID 187070)
-- Name: interaccion_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE interaccion_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE interaccion_id_seq OWNER TO repo_adm;
--
-- TOC entry 2874 (class 0 OID 0)
-- Dependencies: 229
-- Name: interaccion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE interaccion_id_seq OWNED BY interaccion.id;
--
-- TOC entry 228 (class 1259 OID 187050)
-- Name: intermedio; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE intermedio (
id integer NOT NULL,
recepcion_id integer NOT NULL,
tramite_id integer NOT NULL,
fecha_creacion timestamp with time zone DEFAULT now(),
data jsonb,
hmac256 bytea
);
ALTER TABLE intermedio OWNER TO repo_adm;
--
-- TOC entry 227 (class 1259 OID 187048)
-- Name: intermedio_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE intermedio_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE intermedio_id_seq OWNER TO repo_adm;
--
-- TOC entry 2875 (class 0 OID 0)
-- Dependencies: 227
-- Name: intermedio_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE intermedio_id_seq OWNED BY intermedio.id;
--
-- TOC entry 185 (class 1259 OID 186687)
-- Name: localidad; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE localidad (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
codigo_ine_comuna integer,
codigo_ine_provinica integer,
codigo_ine_region integer,
codigo_pais character varying(3) NOT NULL,
tipo character varying(2) NOT NULL,
habilitado boolean DEFAULT true
);
ALTER TABLE localidad OWNER TO repo_adm;
--
-- TOC entry 184 (class 1259 OID 186685)
-- Name: localidad_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE localidad_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE localidad_id_seq OWNER TO repo_adm;
--
-- TOC entry 2876 (class 0 OID 0)
-- Dependencies: 184
-- Name: localidad_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE localidad_id_seq OWNED BY localidad.id;
--
-- TOC entry 197 (class 1259 OID 186762)
-- Name: ministerio; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE ministerio (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
habilitado boolean DEFAULT true
);
ALTER TABLE ministerio OWNER TO repo_adm;
--
-- TOC entry 196 (class 1259 OID 186760)
-- Name: ministerio_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE ministerio_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE ministerio_id_seq OWNER TO repo_adm;
--
-- TOC entry 2877 (class 0 OID 0)
-- Dependencies: 196
-- Name: ministerio_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE ministerio_id_seq OWNED BY ministerio.id;
--
-- TOC entry 235 (class 1259 OID 187145)
-- Name: notificacion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE notificacion (
id integer NOT NULL,
usuario_id integer NOT NULL,
receptor_id integer NOT NULL,
fecha_creacion timestamp with time zone,
texto text,
despachada boolean DEFAULT false
);
ALTER TABLE notificacion OWNER TO repo_adm;
--
-- TOC entry 234 (class 1259 OID 187143)
-- Name: notificacion_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE notificacion_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE notificacion_id_seq OWNER TO repo_adm;
--
-- TOC entry 2878 (class 0 OID 0)
-- Dependencies: 234
-- Name: notificacion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE notificacion_id_seq OWNED BY notificacion.id;
--
-- TOC entry 191 (class 1259 OID 186720)
-- Name: periodicidad; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE periodicidad (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE periodicidad OWNER TO repo_adm;
--
-- TOC entry 190 (class 1259 OID 186718)
-- Name: periodicidad_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE periodicidad_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE periodicidad_id_seq OWNER TO repo_adm;
--
-- TOC entry 2879 (class 0 OID 0)
-- Dependencies: 190
-- Name: periodicidad_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE periodicidad_id_seq OWNED BY periodicidad.id;
--
-- TOC entry 187 (class 1259 OID 186698)
-- Name: persona; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE persona (
id integer NOT NULL,
rut integer NOT NULL,
dv character varying(1) NOT NULL,
nombre character varying(120) NOT NULL,
primer_apellido character varying(120) NOT NULL,
segundo_apellido character varying(120),
fecha_nacimiento date,
vulnerable boolean
);
ALTER TABLE persona OWNER TO repo_adm;
--
-- TOC entry 186 (class 1259 OID 186696)
-- Name: persona_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE persona_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE persona_id_seq OWNER TO repo_adm;
--
-- TOC entry 2880 (class 0 OID 0)
-- Dependencies: 186
-- Name: persona_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE persona_id_seq OWNED BY persona.id;
--
-- TOC entry 216 (class 1259 OID 186930)
-- Name: plantilla_campo; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE plantilla_campo (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
nombre_campo character varying(120),
descripcion text,
extractor_id integer,
transformador_id integer,
validador_id integer,
propiedades hstore,
habilitado boolean DEFAULT true
);
ALTER TABLE plantilla_campo OWNER TO repo_adm;
--
-- TOC entry 215 (class 1259 OID 186928)
-- Name: plantilla_campo_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE plantilla_campo_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE plantilla_campo_id_seq OWNER TO repo_adm;
--
-- TOC entry 2881 (class 0 OID 0)
-- Dependencies: 215
-- Name: plantilla_campo_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE plantilla_campo_id_seq OWNED BY plantilla_campo.id;
--
-- TOC entry 205 (class 1259 OID 186824)
-- Name: plantilla_recepcion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE plantilla_recepcion (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true,
plantilla text
);
ALTER TABLE plantilla_recepcion OWNER TO repo_adm;
--
-- TOC entry 204 (class 1259 OID 186822)
-- Name: plantilla_recepcion_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE plantilla_recepcion_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE plantilla_recepcion_id_seq OWNER TO repo_adm;
--
-- TOC entry 2882 (class 0 OID 0)
-- Dependencies: 204
-- Name: plantilla_recepcion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE plantilla_recepcion_id_seq OWNED BY plantilla_recepcion.id;
--
-- TOC entry 220 (class 1259 OID 186978)
-- Name: recepcion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE recepcion (
id integer NOT NULL,
receptor_id integer NOT NULL,
fecha_creacion timestamp with time zone DEFAULT now(),
estado character varying(40) NOT NULL,
archivo character varying(2000) NOT NULL,
hmac256 bytea,
propiedades hstore
);
ALTER TABLE recepcion OWNER TO repo_adm;
--
-- TOC entry 224 (class 1259 OID 187009)
-- Name: recepcion_bitacora; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE recepcion_bitacora (
id integer NOT NULL,
recepcion_id integer NOT NULL,
fecha_creacion timestamp with time zone DEFAULT now(),
nivel character varying(80),
log text,
etapa character varying(80)
);
ALTER TABLE recepcion_bitacora OWNER TO repo_adm;
--
-- TOC entry 223 (class 1259 OID 187007)
-- Name: recepcion_bitacora_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE recepcion_bitacora_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE recepcion_bitacora_id_seq OWNER TO repo_adm;
--
-- TOC entry 2883 (class 0 OID 0)
-- Dependencies: 223
-- Name: recepcion_bitacora_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE recepcion_bitacora_id_seq OWNED BY recepcion_bitacora.id;
--
-- TOC entry 222 (class 1259 OID 186995)
-- Name: recepcion_estados; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE recepcion_estados (
id integer NOT NULL,
recepcion_id integer NOT NULL,
fecha_creacion timestamp with time zone DEFAULT now(),
estado character varying(40)
);
ALTER TABLE recepcion_estados OWNER TO repo_adm;
--
-- TOC entry 221 (class 1259 OID 186993)
-- Name: recepcion_estados_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE recepcion_estados_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE recepcion_estados_id_seq OWNER TO repo_adm;
--
-- TOC entry 2884 (class 0 OID 0)
-- Dependencies: 221
-- Name: recepcion_estados_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE recepcion_estados_id_seq OWNED BY recepcion_estados.id;
--
-- TOC entry 219 (class 1259 OID 186976)
-- Name: recepcion_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE recepcion_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE recepcion_id_seq OWNER TO repo_adm;
--
-- TOC entry 2885 (class 0 OID 0)
-- Dependencies: 219
-- Name: recepcion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE recepcion_id_seq OWNED BY recepcion.id;
--
-- TOC entry 207 (class 1259 OID 186838)
-- Name: receptor; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE receptor (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
canal_transmision_id integer NOT NULL,
formato_id integer NOT NULL,
plantilla_recepcion_id integer NOT NULL,
periodicidad_id integer NOT NULL,
notificacion_diaria boolean DEFAULT false,
propiedades hstore,
habilitado boolean DEFAULT true
);
ALTER TABLE receptor OWNER TO repo_adm;
--
-- TOC entry 206 (class 1259 OID 186836)
-- Name: receptor_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE receptor_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE receptor_id_seq OWNER TO repo_adm;
--
-- TOC entry 2886 (class 0 OID 0)
-- Dependencies: 206
-- Name: receptor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE receptor_id_seq OWNED BY receptor.id;
--
-- TOC entry 199 (class 1259 OID 186773)
-- Name: subsecretaria; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE subsecretaria (
id integer NOT NULL,
ministerio_id integer,
nombre character varying(120) NOT NULL,
habilitado boolean DEFAULT true
);
ALTER TABLE subsecretaria OWNER TO repo_adm;
--
-- TOC entry 198 (class 1259 OID 186771)
-- Name: subsecretaria_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE subsecretaria_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE subsecretaria_id_seq OWNER TO repo_adm;
--
-- TOC entry 2887 (class 0 OID 0)
-- Dependencies: 198
-- Name: subsecretaria_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE subsecretaria_id_seq OWNED BY subsecretaria.id;
--
-- TOC entry 183 (class 1259 OID 186673)
-- Name: tipo_interaccion; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE tipo_interaccion (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE tipo_interaccion OWNER TO repo_adm;
--
-- TOC entry 182 (class 1259 OID 186671)
-- Name: tipo_interaccion_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE tipo_interaccion_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE tipo_interaccion_id_seq OWNER TO repo_adm;
--
-- TOC entry 2888 (class 0 OID 0)
-- Dependencies: 182
-- Name: tipo_interaccion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE tipo_interaccion_id_seq OWNED BY tipo_interaccion.id;
--
-- TOC entry 203 (class 1259 OID 186805)
-- Name: tipo_tramite; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE tipo_tramite (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
institucion_id integer NOT NULL,
codigo_pmg character varying(80),
habilitado boolean DEFAULT true
);
ALTER TABLE tipo_tramite OWNER TO repo_adm;
--
-- TOC entry 202 (class 1259 OID 186803)
-- Name: tipo_tramite_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE tipo_tramite_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE tipo_tramite_id_seq OWNER TO repo_adm;
--
-- TOC entry 2889 (class 0 OID 0)
-- Dependencies: 202
-- Name: tipo_tramite_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE tipo_tramite_id_seq OWNED BY tipo_tramite.id;
--
-- TOC entry 208 (class 1259 OID 186871)
-- Name: tipo_tramite_receptor; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE tipo_tramite_receptor (
tipo_tramite_id integer NOT NULL,
receptor_id integer NOT NULL
);
ALTER TABLE tipo_tramite_receptor OWNER TO repo_adm;
--
-- TOC entry 226 (class 1259 OID 187026)
-- Name: tramite; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE tramite (
id integer NOT NULL,
recepcion_id integer NOT NULL,
tipo_tramite_id integer NOT NULL,
persona_id integer NOT NULL,
fecha_creacion timestamp with time zone DEFAULT now(),
fecha_tramite timestamp without time zone
);
ALTER TABLE tramite OWNER TO repo_adm;
--
-- TOC entry 225 (class 1259 OID 187024)
-- Name: tramite_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE tramite_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE tramite_id_seq OWNER TO repo_adm;
--
-- TOC entry 2890 (class 0 OID 0)
-- Dependencies: 225
-- Name: tramite_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE tramite_id_seq OWNED BY tramite.id;
--
-- TOC entry 212 (class 1259 OID 186902)
-- Name: transformador; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE transformador (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE transformador OWNER TO repo_adm;
--
-- TOC entry 211 (class 1259 OID 186900)
-- Name: transformador_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE transformador_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE transformador_id_seq OWNER TO repo_adm;
--
-- TOC entry 2891 (class 0 OID 0)
-- Dependencies: 211
-- Name: transformador_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE transformador_id_seq OWNED BY transformador.id;
--
-- TOC entry 232 (class 1259 OID 187119)
-- Name: usuario; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE usuario (
id integer NOT NULL,
usuario character varying(120) NOT NULL,
email character varying(120) NOT NULL,
habilitado boolean DEFAULT true,
telefono character varying(12)
);
ALTER TABLE usuario OWNER TO repo_adm;
--
-- TOC entry 231 (class 1259 OID 187117)
-- Name: usuario_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE usuario_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE usuario_id_seq OWNER TO repo_adm;
--
-- TOC entry 2892 (class 0 OID 0)
-- Dependencies: 231
-- Name: usuario_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE usuario_id_seq OWNED BY usuario.id;
--
-- TOC entry 233 (class 1259 OID 187128)
-- Name: usuario_receptor; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE usuario_receptor (
usuario_id integer NOT NULL,
receptor_id integer NOT NULL
);
ALTER TABLE usuario_receptor OWNER TO repo_adm;
--
-- TOC entry 214 (class 1259 OID 186916)
-- Name: validador; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE validador (
id integer NOT NULL,
nombre character varying(120) NOT NULL,
descripcion text,
habilitado boolean DEFAULT true
);
ALTER TABLE validador OWNER TO repo_adm;
--
-- TOC entry 213 (class 1259 OID 186914)
-- Name: validador_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE validador_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE validador_id_seq OWNER TO repo_adm;
--
-- TOC entry 2893 (class 0 OID 0)
-- Dependencies: 213
-- Name: validador_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE validador_id_seq OWNED BY validador.id;
--
-- TOC entry 2553 (class 2604 OID 186962)
-- Name: campo id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY campo ALTER COLUMN id SET DEFAULT nextval('campo_id_seq'::regclass);
--
-- TOC entry 2524 (class 2604 OID 186709)
-- Name: canal id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY canal ALTER COLUMN id SET DEFAULT nextval('canal_id_seq'::regclass);
--
-- TOC entry 2528 (class 2604 OID 186737)
-- Name: canal_transmision id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY canal_transmision ALTER COLUMN id SET DEFAULT nextval('canal_transmision_id_seq'::regclass);
--
-- TOC entry 2545 (class 2604 OID 186891)
-- Name: extractor id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY extractor ALTER COLUMN id SET DEFAULT nextval('extractor_id_seq'::regclass);
--
-- TOC entry 2530 (class 2604 OID 186751)
-- Name: formato id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY formato ALTER COLUMN id SET DEFAULT nextval('formato_id_seq'::regclass);
--
-- TOC entry 2536 (class 2604 OID 186792)
-- Name: institucion id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY institucion ALTER COLUMN id SET DEFAULT nextval('institucion_id_seq'::regclass);
--
-- TOC entry 2565 (class 2604 OID 187075)
-- Name: interaccion id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion ALTER COLUMN id SET DEFAULT nextval('interaccion_id_seq'::regclass);
--
-- TOC entry 2563 (class 2604 OID 187053)
-- Name: intermedio id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY intermedio ALTER COLUMN id SET DEFAULT nextval('intermedio_id_seq'::regclass);
--
-- TOC entry 2521 (class 2604 OID 186690)
-- Name: localidad id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY localidad ALTER COLUMN id SET DEFAULT nextval('localidad_id_seq'::regclass);
--
-- TOC entry 2532 (class 2604 OID 186765)
-- Name: ministerio id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY ministerio ALTER COLUMN id SET DEFAULT nextval('ministerio_id_seq'::regclass);
--
-- TOC entry 2569 (class 2604 OID 187148)
-- Name: notificacion id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY notificacion ALTER COLUMN id SET DEFAULT nextval('notificacion_id_seq'::regclass);
--
-- TOC entry 2526 (class 2604 OID 186723)
-- Name: periodicidad id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY periodicidad ALTER COLUMN id SET DEFAULT nextval('periodicidad_id_seq'::regclass);
--
-- TOC entry 2523 (class 2604 OID 186701)
-- Name: persona id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY persona ALTER COLUMN id SET DEFAULT nextval('persona_id_seq'::regclass);
--
-- TOC entry 2551 (class 2604 OID 186933)
-- Name: plantilla_campo id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_campo ALTER COLUMN id SET DEFAULT nextval('plantilla_campo_id_seq'::regclass);
--
-- TOC entry 2540 (class 2604 OID 186827)
-- Name: plantilla_recepcion id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_recepcion ALTER COLUMN id SET DEFAULT nextval('plantilla_recepcion_id_seq'::regclass);
--
-- TOC entry 2555 (class 2604 OID 186981)
-- Name: recepcion id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion ALTER COLUMN id SET DEFAULT nextval('recepcion_id_seq'::regclass);
--
-- TOC entry 2559 (class 2604 OID 187012)
-- Name: recepcion_bitacora id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion_bitacora ALTER COLUMN id SET DEFAULT nextval('recepcion_bitacora_id_seq'::regclass);
--
-- TOC entry 2557 (class 2604 OID 186998)
-- Name: recepcion_estados id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion_estados ALTER COLUMN id SET DEFAULT nextval('recepcion_estados_id_seq'::regclass);
--
-- TOC entry 2542 (class 2604 OID 186841)
-- Name: receptor id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY receptor ALTER COLUMN id SET DEFAULT nextval('receptor_id_seq'::regclass);
--
-- TOC entry 2534 (class 2604 OID 186776)
-- Name: subsecretaria id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY subsecretaria ALTER COLUMN id SET DEFAULT nextval('subsecretaria_id_seq'::regclass);
--
-- TOC entry 2519 (class 2604 OID 186676)
-- Name: tipo_interaccion id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_interaccion ALTER COLUMN id SET DEFAULT nextval('tipo_interaccion_id_seq'::regclass);
--
-- TOC entry 2538 (class 2604 OID 186808)
-- Name: tipo_tramite id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_tramite ALTER COLUMN id SET DEFAULT nextval('tipo_tramite_id_seq'::regclass);
--
-- TOC entry 2562 (class 2604 OID 187029)
-- Name: tramite id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tramite ALTER COLUMN id SET DEFAULT nextval('tramite_id_seq'::regclass);
--
-- TOC entry 2547 (class 2604 OID 186905)
-- Name: transformador id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY transformador ALTER COLUMN id SET DEFAULT nextval('transformador_id_seq'::regclass);
--
-- TOC entry 2567 (class 2604 OID 187122)
-- Name: usuario id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usuario ALTER COLUMN id SET DEFAULT nextval('usuario_id_seq'::regclass);
--
-- TOC entry 2549 (class 2604 OID 186919)
-- Name: validador id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY validador ALTER COLUMN id SET DEFAULT nextval('validador_id_seq'::regclass);
--
-- TOC entry 2841 (class 0 OID 186959)
-- Dependencies: 218
-- Data for Name: campo; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2894 (class 0 OID 0)
-- Dependencies: 217
-- Name: campo_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('campo_id_seq', 1, false);
--
-- TOC entry 2812 (class 0 OID 186706)
-- Dependencies: 189
-- Data for Name: canal; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO canal VALUES (1, 'WEB', 'WEB', true);
--
-- TOC entry 2895 (class 0 OID 0)
-- Dependencies: 188
-- Name: canal_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('canal_id_seq', 1, true);
--
-- TOC entry 2816 (class 0 OID 186734)
-- Dependencies: 193
-- Data for Name: canal_transmision; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO canal_transmision VALUES (1, NULL, 'SFTP', 'SFTP', true);
--
-- TOC entry 2896 (class 0 OID 0)
-- Dependencies: 192
-- Name: canal_transmision_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('canal_transmision_id_seq', 1, true);
--
-- TOC entry 2833 (class 0 OID 186888)
-- Dependencies: 210
-- Data for Name: extractor; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2897 (class 0 OID 0)
-- Dependencies: 209
-- Name: extractor_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('extractor_id_seq', 1, false);
--
-- TOC entry 2818 (class 0 OID 186748)
-- Dependencies: 195
-- Data for Name: formato; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO formato VALUES (1, NULL, 'LOG', 'LOG', true);
--
-- TOC entry 2898 (class 0 OID 0)
-- Dependencies: 194
-- Name: formato_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('formato_id_seq', 1, true);
--
-- TOC entry 2824 (class 0 OID 186789)
-- Dependencies: 201
-- Data for Name: institucion; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO institucion VALUES (1, 1, 'INSTITUCION', true);
--
-- TOC entry 2899 (class 0 OID 0)
-- Dependencies: 200
-- Name: institucion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('institucion_id_seq', 1, true);
--
-- TOC entry 2900 (class 0 OID 0)
-- Dependencies: 229
-- Name: interaccion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('interaccion_id_seq', 63898, true);
--
-- TOC entry 2851 (class 0 OID 187050)
-- Dependencies: 228
-- Data for Name: intermedio; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2901 (class 0 OID 0)
-- Dependencies: 227
-- Name: intermedio_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('intermedio_id_seq', 1, false);
--
-- TOC entry 2808 (class 0 OID 186687)
-- Dependencies: 185
-- Data for Name: localidad; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO localidad VALUES (1, 'SIN LOCALIDAD', NULL, NULL, NULL, 'CL', 'SL', true);
--
-- TOC entry 2902 (class 0 OID 0)
-- Dependencies: 184
-- Name: localidad_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('localidad_id_seq', 3, true);
--
-- TOC entry 2820 (class 0 OID 186762)
-- Dependencies: 197
-- Data for Name: ministerio; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO ministerio VALUES (1, 'MINISTERIO', true);
--
-- TOC entry 2903 (class 0 OID 0)
-- Dependencies: 196
-- Name: ministerio_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('ministerio_id_seq', 1, true);
--
-- TOC entry 2858 (class 0 OID 187145)
-- Dependencies: 235
-- Data for Name: notificacion; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2904 (class 0 OID 0)
-- Dependencies: 234
-- Name: notificacion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('notificacion_id_seq', 1, false);
--
-- TOC entry 2814 (class 0 OID 186720)
-- Dependencies: 191
-- Data for Name: periodicidad; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO periodicidad VALUES (1, 'TIMESTAMP', 'TIMESTAMP', true);
INSERT INTO periodicidad VALUES (2, 'DIARIA', 'DIARIA', true);
INSERT INTO periodicidad VALUES (3, 'SEMANAL', 'SEMANAL', true);
INSERT INTO periodicidad VALUES (4, 'MENSUAL', 'MENSUAL', true);
INSERT INTO periodicidad VALUES (5, 'ANUAL', 'ANUAL', true);
--
-- TOC entry 2905 (class 0 OID 0)
-- Dependencies: 190
-- Name: periodicidad_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('periodicidad_id_seq', 5, true);
--
-- TOC entry 2810 (class 0 OID 186698)
-- Dependencies: 187
-- Data for Name: persona; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO persona VALUES (1, 1, '9', 'NO INFORMADO', 'NO INFORMADO', NULL, NULL, NULL);
--
-- TOC entry 2906 (class 0 OID 0)
-- Dependencies: 186
-- Name: persona_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('persona_id_seq', 3, true);
--
-- TOC entry 2839 (class 0 OID 186930)
-- Dependencies: 216
-- Data for Name: plantilla_campo; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2907 (class 0 OID 0)
-- Dependencies: 215
-- Name: plantilla_campo_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('plantilla_campo_id_seq', 1, false);
--
-- TOC entry 2828 (class 0 OID 186824)
-- Dependencies: 205
-- Data for Name: plantilla_recepcion; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO plantilla_recepcion VALUES (1, 'PLANTILLA_RECEPCION', 'PLANTILLA_RECEPCION', true, 'PLANTILLA_RECEPCION');
--
-- TOC entry 2908 (class 0 OID 0)
-- Dependencies: 204
-- Name: plantilla_recepcion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('plantilla_recepcion_id_seq', 1, true);
--
-- TOC entry 2847 (class 0 OID 187009)
-- Dependencies: 224
-- Data for Name: recepcion_bitacora; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2909 (class 0 OID 0)
-- Dependencies: 223
-- Name: recepcion_bitacora_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('recepcion_bitacora_id_seq', 1, false);
--
-- TOC entry 2845 (class 0 OID 186995)
-- Dependencies: 222
-- Data for Name: recepcion_estados; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2910 (class 0 OID 0)
-- Dependencies: 221
-- Name: recepcion_estados_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('recepcion_estados_id_seq', 1, false);
--
-- TOC entry 2911 (class 0 OID 0)
-- Dependencies: 219
-- Name: recepcion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('recepcion_id_seq', 54, true);
--
-- TOC entry 2830 (class 0 OID 186838)
-- Dependencies: 207
-- Data for Name: receptor; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO receptor VALUES (1, 'RECEPTOR', NULL, 1, 1, 1, 2, false, NULL, true);
--
-- TOC entry 2912 (class 0 OID 0)
-- Dependencies: 206
-- Name: receptor_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('receptor_id_seq', 1, true);
--
-- TOC entry 2822 (class 0 OID 186773)
-- Dependencies: 199
-- Data for Name: subsecretaria; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO subsecretaria VALUES (1, 1, 'SUBSECRETARIA', true);
--
-- TOC entry 2913 (class 0 OID 0)
-- Dependencies: 198
-- Name: subsecretaria_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('subsecretaria_id_seq', 1, true);
--
-- TOC entry 2806 (class 0 OID 186673)
-- Dependencies: 183
-- Data for Name: tipo_interaccion; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO tipo_interaccion VALUES (1, 'INICIO', 'INICIO', true);
INSERT INTO tipo_interaccion VALUES (2, 'FIN', 'FIN', true);
--
-- TOC entry 2914 (class 0 OID 0)
-- Dependencies: 182
-- Name: tipo_interaccion_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('tipo_interaccion_id_seq', 2, true);
--
-- TOC entry 2826 (class 0 OID 186805)
-- Dependencies: 203
-- Data for Name: tipo_tramite; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO tipo_tramite VALUES (1, 'CARTAS', 'CARTAS', 1, '1', true);
INSERT INTO tipo_tramite VALUES (2, 'CERTIFICADOS', 'CERTIFICADOS', 1, '1', true);
INSERT INTO tipo_tramite VALUES (3, 'CONSTANCIA', 'CONSTANCIA', 1, '1', true);
INSERT INTO tipo_tramite VALUES (4, 'PARITARIO', 'PARITARIO', 1, '1', true);
INSERT INTO tipo_tramite VALUES (5, 'PARITARIOFAENA', 'PARITARIOFAENA', 1, '1', true);
INSERT INTO tipo_tramite VALUES (6, 'CENTRALIZACION', 'CENTRALIZACION', 1, '1', true);
INSERT INTO tipo_tramite VALUES (7, 'MULTAS', 'MULTAS', 1, '1', true);
INSERT INTO tipo_tramite VALUES (8, 'INTERMEDIARIOAGRICOLA', 'INTERMEDIARIOAGRICOLA', 1, '1', true);
INSERT INTO tipo_tramite VALUES (9, 'CONTRATOMENOR', 'CONTRATOMENOR', 1, '1', true);
INSERT INTO tipo_tramite VALUES (10, 'TRABCASAPARTICULAR', 'TRABCASAPARTICULAR', 1, '1', true);
--
-- TOC entry 2915 (class 0 OID 0)
-- Dependencies: 202
-- Name: tipo_tramite_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('tipo_tramite_id_seq', 10, true);
--
-- TOC entry 2831 (class 0 OID 186871)
-- Dependencies: 208
-- Data for Name: tipo_tramite_receptor; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2916 (class 0 OID 0)
-- Dependencies: 225
-- Name: tramite_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('tramite_id_seq', 63900, true);
--
-- TOC entry 2835 (class 0 OID 186902)
-- Dependencies: 212
-- Data for Name: transformador; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2917 (class 0 OID 0)
-- Dependencies: 211
-- Name: transformador_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('transformador_id_seq', 1, false);
--
-- TOC entry 2855 (class 0 OID 187119)
-- Dependencies: 232
-- Data for Name: usuario; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2918 (class 0 OID 0)
-- Dependencies: 231
-- Name: usuario_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('usuario_id_seq', 1, false);
--
-- TOC entry 2856 (class 0 OID 187128)
-- Dependencies: 233
-- Data for Name: usuario_receptor; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2837 (class 0 OID 186916)
-- Dependencies: 214
-- Data for Name: validador; Type: TABLE DATA; Schema: public; Owner: postgres
--
--
-- TOC entry 2919 (class 0 OID 0)
-- Dependencies: 213
-- Name: validador_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('validador_id_seq', 1, false);
--
-- TOC entry 2640 (class 2606 OID 186965)
-- Name: campo pk_campo; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY campo
ADD CONSTRAINT pk_campo PRIMARY KEY (id);
--
-- TOC entry 2582 (class 2606 OID 186715)
-- Name: canal pk_canal; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY canal
ADD CONSTRAINT pk_canal PRIMARY KEY (id);
--
-- TOC entry 2590 (class 2606 OID 186743)
-- Name: canal_transmision pk_canal_transmision; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY canal_transmision
ADD CONSTRAINT pk_canal_transmision PRIMARY KEY (id);
--
-- TOC entry 2624 (class 2606 OID 186897)
-- Name: extractor pk_extractor; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY extractor
ADD CONSTRAINT pk_extractor PRIMARY KEY (id);
--
-- TOC entry 2594 (class 2606 OID 186757)
-- Name: formato pk_formato; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY formato
ADD CONSTRAINT pk_formato PRIMARY KEY (id);
--
-- TOC entry 2606 (class 2606 OID 186795)
-- Name: institucion pk_institucion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY institucion
ADD CONSTRAINT pk_institucion PRIMARY KEY (id);
--
-- TOC entry 2652 (class 2606 OID 187081)
-- Name: interaccion pk_interaccion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion
ADD CONSTRAINT pk_interaccion PRIMARY KEY (id);
--
-- TOC entry 2650 (class 2606 OID 187059)
-- Name: intermedio pk_intermedio; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY intermedio
ADD CONSTRAINT pk_intermedio PRIMARY KEY (id);
--
-- TOC entry 2576 (class 2606 OID 186693)
-- Name: localidad pk_localidad; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY localidad
ADD CONSTRAINT pk_localidad PRIMARY KEY (id);
--
-- TOC entry 2598 (class 2606 OID 186768)
-- Name: ministerio pk_ministerio; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY ministerio
ADD CONSTRAINT pk_ministerio PRIMARY KEY (id);
--
-- TOC entry 2660 (class 2606 OID 187154)
-- Name: notificacion pk_notificacion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY notificacion
ADD CONSTRAINT pk_notificacion PRIMARY KEY (id);
--
-- TOC entry 2586 (class 2606 OID 186729)
-- Name: periodicidad pk_periodicidad; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY periodicidad
ADD CONSTRAINT pk_periodicidad PRIMARY KEY (id);
--
-- TOC entry 2580 (class 2606 OID 186703)
-- Name: persona pk_persona; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY persona
ADD CONSTRAINT pk_persona PRIMARY KEY (id);
--
-- TOC entry 2636 (class 2606 OID 186939)
-- Name: plantilla_campo pk_plantilla_campo; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_campo
ADD CONSTRAINT pk_plantilla_campo PRIMARY KEY (id);
--
-- TOC entry 2614 (class 2606 OID 186833)
-- Name: plantilla_recepcion pk_plantilla_recepcion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_recepcion
ADD CONSTRAINT pk_plantilla_recepcion PRIMARY KEY (id);
--
-- TOC entry 2642 (class 2606 OID 186987)
-- Name: recepcion pk_recepcion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion
ADD CONSTRAINT pk_recepcion PRIMARY KEY (id);
--
-- TOC entry 2646 (class 2606 OID 187018)
-- Name: recepcion_bitacora pk_recepcion_bitacora; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion_bitacora
ADD CONSTRAINT pk_recepcion_bitacora PRIMARY KEY (id);
--
-- TOC entry 2644 (class 2606 OID 187001)
-- Name: recepcion_estados pk_recepcion_estados; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion_estados
ADD CONSTRAINT pk_recepcion_estados PRIMARY KEY (id);
--
-- TOC entry 2618 (class 2606 OID 186848)
-- Name: receptor pk_receptor; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY receptor
ADD CONSTRAINT pk_receptor PRIMARY KEY (id);
--
-- TOC entry 2602 (class 2606 OID 186779)
-- Name: subsecretaria pk_subsecretaria; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY subsecretaria
ADD CONSTRAINT pk_subsecretaria PRIMARY KEY (id);
--
-- TOC entry 2572 (class 2606 OID 186682)
-- Name: tipo_interaccion pk_tipo_interaccion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_interaccion
ADD CONSTRAINT pk_tipo_interaccion PRIMARY KEY (id);
--
-- TOC entry 2610 (class 2606 OID 186814)
-- Name: tipo_tramite pk_tipo_tramite; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_tramite
ADD CONSTRAINT pk_tipo_tramite PRIMARY KEY (id);
--
-- TOC entry 2648 (class 2606 OID 187032)
-- Name: tramite pk_tramite; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tramite
ADD CONSTRAINT pk_tramite PRIMARY KEY (id);
--
-- TOC entry 2622 (class 2606 OID 186875)
-- Name: tipo_tramite_receptor pk_tramite_receptor; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_tramite_receptor
ADD CONSTRAINT pk_tramite_receptor PRIMARY KEY (receptor_id, tipo_tramite_id);
--
-- TOC entry 2628 (class 2606 OID 186911)
-- Name: transformador pk_transformador; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY transformador
ADD CONSTRAINT pk_transformador PRIMARY KEY (id);
--
-- TOC entry 2654 (class 2606 OID 187125)
-- Name: usuario pk_usuario; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usuario
ADD CONSTRAINT pk_usuario PRIMARY KEY (id);
--
-- TOC entry 2658 (class 2606 OID 187132)
-- Name: usuario_receptor pk_usuarios_receptor; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usuario_receptor
ADD CONSTRAINT pk_usuarios_receptor PRIMARY KEY (receptor_id, usuario_id);
--
-- TOC entry 2632 (class 2606 OID 186925)
-- Name: validador pk_validador; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY validador
ADD CONSTRAINT pk_validador PRIMARY KEY (id);
--
-- TOC entry 2584 (class 2606 OID 186717)
-- Name: canal uq_canal_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY canal
ADD CONSTRAINT uq_canal_nombre UNIQUE (nombre);
--
-- TOC entry 2592 (class 2606 OID 186745)
-- Name: canal_transmision uq_canal_transmision_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY canal_transmision
ADD CONSTRAINT uq_canal_transmision_nombre UNIQUE (nombre);
--
-- TOC entry 2626 (class 2606 OID 186899)
-- Name: extractor uq_extractor; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY extractor
ADD CONSTRAINT uq_extractor UNIQUE (nombre);
--
-- TOC entry 2596 (class 2606 OID 186759)
-- Name: formato uq_formato_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY formato
ADD CONSTRAINT uq_formato_nombre UNIQUE (nombre);
--
-- TOC entry 2608 (class 2606 OID 186797)
-- Name: institucion uq_institucion_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY institucion
ADD CONSTRAINT uq_institucion_nombre UNIQUE (nombre);
--
-- TOC entry 2578 (class 2606 OID 186695)
-- Name: localidad uq_localidad_interaccion_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY localidad
ADD CONSTRAINT uq_localidad_interaccion_nombre UNIQUE (nombre);
--
-- TOC entry 2600 (class 2606 OID 186770)
-- Name: ministerio uq_ministerio_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY ministerio
ADD CONSTRAINT uq_ministerio_nombre UNIQUE (nombre);
--
-- TOC entry 2588 (class 2606 OID 186731)
-- Name: periodicidad uq_periodicidad_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY periodicidad
ADD CONSTRAINT uq_periodicidad_nombre UNIQUE (nombre);
--
-- TOC entry 2638 (class 2606 OID 186941)
-- Name: plantilla_campo uq_plantilla_campo; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_campo
ADD CONSTRAINT uq_plantilla_campo UNIQUE (nombre);
--
-- TOC entry 2616 (class 2606 OID 186835)
-- Name: plantilla_recepcion uq_plantilla_recepcion; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_recepcion
ADD CONSTRAINT uq_plantilla_recepcion UNIQUE (nombre);
--
-- TOC entry 2620 (class 2606 OID 186850)
-- Name: receptor uq_receptor_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY receptor
ADD CONSTRAINT uq_receptor_nombre UNIQUE (nombre);
--
-- TOC entry 2604 (class 2606 OID 186781)
-- Name: subsecretaria uq_subsecretaria_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY subsecretaria
ADD CONSTRAINT uq_subsecretaria_nombre UNIQUE (nombre);
--
-- TOC entry 2574 (class 2606 OID 186684)
-- Name: tipo_interaccion uq_tipo_interaccion_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_interaccion
ADD CONSTRAINT uq_tipo_interaccion_nombre UNIQUE (nombre);
--
-- TOC entry 2612 (class 2606 OID 186816)
-- Name: tipo_tramite uq_tramite_nombre; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_tramite
ADD CONSTRAINT uq_tramite_nombre UNIQUE (nombre);
--
-- TOC entry 2630 (class 2606 OID 186913)
-- Name: transformador uq_transformador; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY transformador
ADD CONSTRAINT uq_transformador UNIQUE (nombre);
--
-- TOC entry 2656 (class 2606 OID 187127)
-- Name: usuario uq_usuario_usuario; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usuario
ADD CONSTRAINT uq_usuario_usuario UNIQUE (usuario);
--
-- TOC entry 2634 (class 2606 OID 186927)
-- Name: validador uq_validador; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY validador
ADD CONSTRAINT uq_validador UNIQUE (nombre);
--
-- TOC entry 2673 (class 2606 OID 186966)
-- Name: campo fk_campo_plantilla; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY campo
ADD CONSTRAINT fk_campo_plantilla FOREIGN KEY (plantilla_campo_id) REFERENCES plantilla_campo(id);
--
-- TOC entry 2674 (class 2606 OID 186971)
-- Name: campo fk_campo_receptor; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY campo
ADD CONSTRAINT fk_campo_receptor FOREIGN KEY (receptor_id) REFERENCES receptor(id);
--
-- TOC entry 2675 (class 2606 OID 186988)
-- Name: recepcion fk_campo_receptor; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion
ADD CONSTRAINT fk_campo_receptor FOREIGN KEY (receptor_id) REFERENCES receptor(id);
--
-- TOC entry 2662 (class 2606 OID 186798)
-- Name: institucion fk_institucion_subsecretaria; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY institucion
ADD CONSTRAINT fk_institucion_subsecretaria FOREIGN KEY (subsecretaria_id) REFERENCES subsecretaria(id);
--
-- TOC entry 2684 (class 2606 OID 187087)
-- Name: interaccion fk_interaccion_canal; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion
ADD CONSTRAINT fk_interaccion_canal FOREIGN KEY (canal_id) REFERENCES canal(id);
--
-- TOC entry 2688 (class 2606 OID 187112)
-- Name: interaccion fk_interaccion_localidad; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion
ADD CONSTRAINT fk_interaccion_localidad FOREIGN KEY (localidad_id) REFERENCES localidad(id);
--
-- TOC entry 2687 (class 2606 OID 187102)
-- Name: interaccion fk_interaccion_periodicidad; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion
ADD CONSTRAINT fk_interaccion_periodicidad FOREIGN KEY (periodicidad_id) REFERENCES periodicidad(id);
--
-- TOC entry 2686 (class 2606 OID 187097)
-- Name: interaccion fk_interaccion_recepcion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion
ADD CONSTRAINT fk_interaccion_recepcion FOREIGN KEY (recepcion_id) REFERENCES recepcion(id);
--
-- TOC entry 2683 (class 2606 OID 187082)
-- Name: interaccion fk_interaccion_tipo_interaccion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion
ADD CONSTRAINT fk_interaccion_tipo_interaccion FOREIGN KEY (tipo_interaccion_id) REFERENCES tipo_interaccion(id);
--
-- TOC entry 2685 (class 2606 OID 187092)
-- Name: interaccion fk_interaccion_tramite; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY interaccion
ADD CONSTRAINT fk_interaccion_tramite FOREIGN KEY (tramite_id) REFERENCES tramite(id);
--
-- TOC entry 2681 (class 2606 OID 187060)
-- Name: intermedio fk_intermedio_recepcion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY intermedio
ADD CONSTRAINT fk_intermedio_recepcion FOREIGN KEY (recepcion_id) REFERENCES recepcion(id);
--
-- TOC entry 2682 (class 2606 OID 187065)
-- Name: intermedio fk_intermedio_tramite; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY intermedio
ADD CONSTRAINT fk_intermedio_tramite FOREIGN KEY (tramite_id) REFERENCES tramite(id);
--
-- TOC entry 2670 (class 2606 OID 186942)
-- Name: plantilla_campo fk_plantilla_campo_extractor; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_campo
ADD CONSTRAINT fk_plantilla_campo_extractor FOREIGN KEY (extractor_id) REFERENCES extractor(id);
--
-- TOC entry 2671 (class 2606 OID 186947)
-- Name: plantilla_campo fk_plantilla_campo_transformador; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_campo
ADD CONSTRAINT fk_plantilla_campo_transformador FOREIGN KEY (transformador_id) REFERENCES transformador(id);
--
-- TOC entry 2672 (class 2606 OID 186952)
-- Name: plantilla_campo fk_plantilla_campo_validador; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY plantilla_campo
ADD CONSTRAINT fk_plantilla_campo_validador FOREIGN KEY (validador_id) REFERENCES validador(id);
--
-- TOC entry 2677 (class 2606 OID 187019)
-- Name: recepcion_bitacora fk_recepcion_bitacora_recepcion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion_bitacora
ADD CONSTRAINT fk_recepcion_bitacora_recepcion FOREIGN KEY (recepcion_id) REFERENCES recepcion(id);
--
-- TOC entry 2676 (class 2606 OID 187002)
-- Name: recepcion_estados fk_recepcion_estados_recepcion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY recepcion_estados
ADD CONSTRAINT fk_recepcion_estados_recepcion FOREIGN KEY (recepcion_id) REFERENCES recepcion(id);
--
-- TOC entry 2665 (class 2606 OID 186856)
-- Name: receptor fk_receptor_canal_transmision; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY receptor
ADD CONSTRAINT fk_receptor_canal_transmision FOREIGN KEY (canal_transmision_id) REFERENCES canal_transmision(id);
--
-- TOC entry 2666 (class 2606 OID 186861)
-- Name: receptor fk_receptor_formato; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY receptor
ADD CONSTRAINT fk_receptor_formato FOREIGN KEY (formato_id) REFERENCES formato(id);
--
-- TOC entry 2667 (class 2606 OID 186866)
-- Name: receptor fk_receptor_periodicidad; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY receptor
ADD CONSTRAINT fk_receptor_periodicidad FOREIGN KEY (periodicidad_id) REFERENCES periodicidad(id);
--
-- TOC entry 2664 (class 2606 OID 186851)
-- Name: receptor fk_receptor_plantilla_recepcion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY receptor
ADD CONSTRAINT fk_receptor_plantilla_recepcion FOREIGN KEY (plantilla_recepcion_id) REFERENCES plantilla_recepcion(id);
--
-- TOC entry 2661 (class 2606 OID 186782)
-- Name: subsecretaria fk_subsecretaria_ministerio; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY subsecretaria
ADD CONSTRAINT fk_subsecretaria_ministerio FOREIGN KEY (ministerio_id) REFERENCES ministerio(id);
--
-- TOC entry 2663 (class 2606 OID 186817)
-- Name: tipo_tramite fk_tramite_institucion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_tramite
ADD CONSTRAINT fk_tramite_institucion FOREIGN KEY (institucion_id) REFERENCES institucion(id);
--
-- TOC entry 2679 (class 2606 OID 187043)
-- Name: tramite fk_tramite_persona; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tramite
ADD CONSTRAINT fk_tramite_persona FOREIGN KEY (persona_id) REFERENCES persona(id);
--
-- TOC entry 2678 (class 2606 OID 187033)
-- Name: tramite fk_tramite_recepcion; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tramite
ADD CONSTRAINT fk_tramite_recepcion FOREIGN KEY (recepcion_id) REFERENCES recepcion(id);
--
-- TOC entry 2669 (class 2606 OID 186881)
-- Name: tipo_tramite_receptor fk_tramite_receptor_receptor; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_tramite_receptor
ADD CONSTRAINT fk_tramite_receptor_receptor FOREIGN KEY (receptor_id) REFERENCES receptor(id);
--
-- TOC entry 2668 (class 2606 OID 186876)
-- Name: tipo_tramite_receptor fk_tramite_receptor_tipo_tramite; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tipo_tramite_receptor
ADD CONSTRAINT fk_tramite_receptor_tipo_tramite FOREIGN KEY (tipo_tramite_id) REFERENCES tipo_tramite(id);
--
-- TOC entry 2680 (class 2606 OID 192044)
-- Name: tramite fk_tramite_tipo_tramite; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY tramite
ADD CONSTRAINT fk_tramite_tipo_tramite FOREIGN KEY (tipo_tramite_id) REFERENCES tipo_tramite(id);
--
-- TOC entry 2690 (class 2606 OID 187138)
-- Name: usuario_receptor fk_usuario_receptor_receptor; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usuario_receptor
ADD CONSTRAINT fk_usuario_receptor_receptor FOREIGN KEY (receptor_id) REFERENCES receptor(id);
--
-- TOC entry 2689 (class 2606 OID 187133)
-- Name: usuario_receptor fk_usuario_receptor_usuario; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY usuario_receptor
ADD CONSTRAINT fk_usuario_receptor_usuario FOREIGN KEY (usuario_id) REFERENCES usuario(id);
create table mantenedor (
tabla varchar(120),
singular varchar(120),
plural varchar(120),
constraint pk_mantenedor primary key (tabla)
);
insert into mantenedor (tabla, singular, plural) values ('canal','Canal de interacción','Canales de interacción');
insert into mantenedor (tabla, singular, plural) values ('canal_transmision','Canal de transmisión','Canales de transmision');
insert into mantenedor (tabla, singular, plural) values ('extractor','Extractor','Extractores');
insert into mantenedor (tabla, singular, plural) values ('formato','Formato','Formatos');
insert into mantenedor (tabla, singular, plural) values ('periodicidad','Periodicidad','Periodicidades');
insert into mantenedor (tabla, singular, plural) values ('tipo_interaccion','Tipo de interacción','Tipos de interacción');
insert into mantenedor (tabla, singular, plural) values ('transformador','Transformador','Transformadores');
insert into mantenedor (tabla, singular, plural) values ('validador','Validador','Validadores');
| true |
346030da309ba28ebbea5e1084c823fb0818bbf7 | SQL | Arcangellmar/team_quality_assurance | /database/database.sql | UTF-8 | 975 | 3.21875 | 3 | [] | no_license | USE `heroku_f8f49523a25a3a5`;
CREATE TABLE states(
id INT NOT NULL primary KEY AUTO_INCREMENT,
state VARCHAR(255)
);
INSERT INTO states (id,state)
VALUES
(1,'check'),
(2,'uncheck');
-- imposible null by form validation
CREATE TABLE pcso_applicants(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
full_name VARCHAR(255),
company_name VARCHAR(255),
phone_number INT,
email VARCHAR(255),
id_states INT,
registred_at TIMESTAMP NOT NULL DEFAULT current_timestamp,
FOREIGN KEY (id_states) REFERENCES states(id)
);
CREATE TABLE pcso_admin(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(255),
password VARCHAR(255),
ip_computer VARCHAR(255),
comunicate_at TIMESTAMP NOT NULL DEFAULT current_timestamp ,
registred_at TIMESTAMP NOT NULL DEFAULT current_timestamp
-- reated_at_time TIME() NOT NULL DEFAULT DATE_FORMAT(NOW( ),"%H:%i:%S") ,
-- created_at_day DATE NOT NULL DEFAULT CURDATE()
); | true |
14feccdfda1b97ec7960c15f1b700ecbc52f88b1 | SQL | gurpreet19/ec198392_wht | /Database/configuration/03_02_headless_tool/Delta_WST/TargetPackageDefinitions/ECBP_VCF_BODY.sql | UTF-8 | 41,718 | 3 | 3 | [] | no_license | CREATE OR REPLACE PACKAGE BODY EcBp_VCF IS
/****************************************************************
** Package : EcBp_VCF, body part
**
** Calcuates various API gravity and volume corection factors (VCF)
** based on the Manual of Petroleum Measurement Standards Chapter 11
** May 2004 addition
** Includes API Table 6 adjustments based on the official API documentation
**
** Date Whom Change description:
** ---------- -------- --------------------------------------
** 07.11.2012 rajarsar ECPD-20359: Modified the function of calcAPIGravityObs, calcAPIGravityCorr and calcDensityCorr.
** Added the new functions of calcDensityCorr_SI, calcVCFobsDensity_SI and calcVCFstdDensity_SI.
** 22.03.2013 kumarsur ECPD-23650: Added calcDiluentConcentration(), calcShrinkageFactor() and calcAPIBlendShrinkage().
*****************************************************************/
---------------------------------------------------------------------------------------------------
-- Function : calcAPIGravityObs
-- Description : Calculates what the observed API gravity would have been given the
-- corrected API gravity and the sample temperature.
-- NOTE this is the inverse of the normal calculation and is used in cases where
-- the original lab work is done at a temperature different than the sample temperature
-- INPUT Corrected API gravity at 60 degrees and original sample temperature
---------------------------------------------------------------------------------------------------
FUNCTION calcAPIGravityObs(
p_API_Gravity NUMBER,
p_Temp_Obs NUMBER,
p_decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_Ctl NUMBER;
ln_delta_Temp NUMBER;
ln_density_60 NUMBER;
ln_density_obs NUMBER;
ln_A NUMBER;
ln_RHO_Star NUMBER;
ln_result NUMBER;
BEGIN
-- Calculate density at 60 degrees from corrected API gravity
ln_density_60 := EcBp_VCF.getDensityFromAPI(p_API_gravity);
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 / (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(p_temp_obs);
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + 0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979)));
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_density_obs := ln_density_60 * ln_Ctl;
-- Calculate API gravity at observed temperature from density at observed temperature
ln_result := round(EcBp_VCF.getAPIFromDensity(ln_density_obs),p_decimals);
RETURN ln_result;
END calcAPIGravityObs;
---------------------------------------------------------------------------------------------------
-- Function : calcAPIGravityCorr
-- Description : Calculates what the CORRECTED API gravity given the
-- observed tempature and observed gravity
-- This is normally done as a set of iterations until a certain delta is achieved
-- In this case it is hard coded for max 10 iterations
-- This provides good results for the normal range of operations
--
---------------------------------------------------------------------------------------------------
FUNCTION calcAPIGravityCorr(
p_API_Gravity_obs NUMBER,
p_Temp_Obs NUMBER,
p_decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_Ctl NUMBER;
ln_density_60 NUMBER;
ln_density_obs NUMBER;
ln_density_delta NUMBER;
ln_result NUMBER;
ln_A NUMBER;
ln_RHO_Star NUMBER;
ln_Delta_Temp NUMBER;
ln_E_factor NUMBER;
ln_Dt_factor NUMBER;
ln_delta_density_60 NUMBER;
ln_counter NUMBER;
BEGIN
-- Calculate density at observed condition from observed API gravity p_API_gravity_obs;--
ln_density_obs := EcBp_VCF.getDensityFromAPI(p_API_gravity_obs);
-- Use the observed density as the first guess for the corrected density
ln_density_60 := ln_density_obs;
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(p_temp_obs);
-- Loop through iterations until convergence is reached
FOR ln_counter IN 1..10 LOOP
-- Calculate the A factor
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
IF ln_Ctl = 0 THEN
RAISE_APPLICATION_ERROR(-20000,'The combination of the Temperature and API Gravity is not valid.');
ELSE
-- Calculate API gravity at observed temperature from density at observed temperature
ln_density_Delta := (ln_density_obs / ln_Ctl) - ln_density_60;
END IF;
-- Exit when convergence is reached
EXIT WHEN abs(ln_density_Delta) < 0.0000001;
-- Estimate the amount of change in the density needed to get a good answer
ln_E_factor := (ln_density_obs/ln_Ctl) - ln_density_60; --ln_density_Delta/ln_Ctl;
ln_Dt_factor := 2 * ln_alpha_60 * (p_temp_obs - 60) *(1 + 1.6 * ln_alpha_60* (p_temp_obs - 60));
ln_delta_density_60 := ln_E_factor / (1+ln_Dt_factor);
-- Adjust the guessed density based on the above delta
ln_density_60 := ln_density_60 + ln_delta_density_60;
END LOOP;
-- Convert back to API units ln_density_60;--
ln_result := round(EcBp_VCF.getAPIfromDensity(ln_density_60),p_decimals);
RETURN ln_result;
END calcAPIGravityCorr;
---------------------------------------------------------------------------------------------------
-- Function : calcDensityCorr
-- Description : Calculates what the CORRECTED density given the
-- observed tempature and observed density
-- This is normally done as a set of iterations until a certain delta is achieved
-- In this case it is hard coded for max 10 iterations
-- This provides good results for the normal range of operations
--
---------------------------------------------------------------------------------------------------
FUNCTION calcDensityCorr(
p_Density_obs NUMBER,
p_Temp_Obs NUMBER,
p_decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_Ctl NUMBER;
ln_density_60 NUMBER;
ln_density_delta NUMBER;
ln_result NUMBER;
ln_A NUMBER;
ln_RHO_Star NUMBER;
ln_Delta_Temp NUMBER;
ln_E_factor NUMBER;
ln_Dt_factor NUMBER;
ln_delta_density_60 NUMBER;
ln_counter NUMBER;
BEGIN
-- Use the observed density as the first guess for the corrected density
ln_density_60 := p_Density_obs;
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(p_temp_obs);
-- Loop through iterations until convergence is reached
FOR ln_counter IN 1..10 LOOP
-- Calculate the A factor
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
IF ln_Ctl = 0 THEN
RAISE_APPLICATION_ERROR(-20000,'The combination of the Temperature and Observed Density is not valid.');
ELSE
-- Calculate API gravity at observed temperature from density at observed temperature
ln_density_Delta := (p_Density_obs / ln_Ctl) - ln_density_60;
END IF;
-- Exit when convergence is reached
EXIT WHEN abs(ln_density_Delta) < 0.0000001;
-- Estimate the amount of change in the density needed to get a good answer
ln_E_factor := (p_Density_obs/ln_Ctl) - ln_density_60; --ln_density_Delta/ln_Ctl;
ln_Dt_factor := 2 * ln_alpha_60 * (p_temp_obs - 60) *(1 + 1.6 * ln_alpha_60* (p_temp_obs - 60));
ln_delta_density_60 := ln_E_factor / (1+ln_Dt_factor);
-- Adjust the guessed density based on the above delta
ln_density_60 := ln_density_60 + ln_delta_density_60;
END LOOP;
-- Convert back to API units ln_density_60;--
ln_result := round(ln_density_60,p_decimals);
RETURN ln_result;
END calcDensityCorr;
---------------------------------------------------------------------------------------------------
-- Function : calcDensityCorrObs_SI
-- Description : Calculates what the CORRECTED density given the
-- observed tempature and observed density in SI Units
-- This is normally done as a set of iterations until a certain delta is achieved
-- In this case it is hard coded for max 10 iterations
-- This provides good results for the normal range of operations
--
-- API Chapter 11.1 section 11.1.7.2
--
---------------------------------------------------------------------------------------------------
FUNCTION calcDensityCorr_SI(
p_Density_obs NUMBER,
p_Temp_Obs NUMBER,
p_Temp_Base NUMBER DEFAULT 15,
p_decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_Ctl NUMBER;
ln_Ctl_60 NUMBER;
ln_density_60 NUMBER;
ln_density_delta NUMBER;
ln_result NUMBER;
ln_A NUMBER;
ln_RHO_Star NUMBER;
ln_Temp_Base_F NUMBER;
ln_Temp_obs_F NUMBER;
ln_Delta_Temp NUMBER;
ln_E_factor NUMBER;
ln_Dt_factor NUMBER;
ln_delta_density_60 NUMBER;
ln_counter NUMBER;
BEGIN
-- Use the observed density as the first guess for the corrected density
ln_density_60 := p_Density_obs;
-- Convert base temperature to F
ln_temp_base_f := (p_temp_base *9/5)+32;
ln_temp_obs_f := (p_temp_obs *9/5)+32;
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(ln_temp_obs_f);
-- Loop through iterations until convergence is reached
FOR ln_counter IN 1..10 LOOP
-- Calculate the A factor
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl_60 := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
IF ln_Ctl_60 = 0 THEN
RAISE_APPLICATION_ERROR(-20000,'The combination of the Temperature and Observed Density is not valid.');
ELSE
-- Calculate API gravity at observed temperature from density at observed temperature
ln_density_Delta := (p_Density_obs / ln_Ctl_60) - ln_density_60;
END IF;
-- Exit when convergence is reached
EXIT WHEN abs(ln_density_Delta) < 0.0000001;
-- Estimate the amount of change in the density needed to get a good answer
ln_E_factor := (p_Density_obs/ln_Ctl_60) - ln_density_60; --ln_density_Delta/ln_Ctl;
ln_Dt_factor := 2 * ln_alpha_60 * (p_temp_obs - 60) *(1 + 1.6 * ln_alpha_60* (p_temp_obs - 60));
ln_delta_density_60 := ln_E_factor / (1+ln_Dt_factor);
-- Adjust the guessed density based on the above delta
ln_density_60 := ln_density_60 + ln_delta_density_60;
END LOOP;
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(ln_temp_base_f);
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
-- Convert back to API units ln_density_60
ln_result := round((ln_density_60 * ln_ctl),p_decimals);
RETURN ln_result;
END calcDensityCorr_SI;
---------------------------------------------------------------------------------------------------
-- Function : calcVCFobsAPI
-- Description : Calculates the VCF for an observed API gravity given the
-- observed tempature
---------------------------------------------------------------------------------------------------
FUNCTION calcVCFobsAPI(
p_API_Gravity_obs NUMBER,
p_Temp_Obs NUMBER,
p_decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_Ctl NUMBER;
ln_density_60 NUMBER;
ln_density_obs NUMBER;
ln_density_delta NUMBER;
ln_result NUMBER;
ln_A NUMBER;
ln_RHO_Star NUMBER;
ln_Delta_Temp NUMBER;
ln_E_factor NUMBER;
ln_Dt_factor NUMBER;
ln_delta_density_60 NUMBER;
ln_counter NUMBER;
BEGIN
-- Calculate density at observed condition from observed API gravity
ln_density_obs := EcBp_VCF.getDensityFromAPI(p_API_gravity_obs);
-- Use the observed density as the first guess for the corrected density
ln_density_60 := ln_density_obs;
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(p_temp_obs);
-- Loop through iterations until convergence is reached
FOR ln_counter IN 1..10 LOOP
-- Calculate the A factor
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
IF ln_Ctl = 0 THEN
RAISE_APPLICATION_ERROR(-20000,'The combination of the Temperature and Observed API is not valid.');
ELSE
-- Calculate API gravity at observed temperature from density at observed temperature
ln_density_Delta := (ln_density_obs / ln_Ctl) - ln_density_60;
END IF;
-- Exit when convergence is reached
EXIT WHEN abs(ln_density_Delta) < 0.0000001;
-- Estimate the amount of change in the density needed to get a good answer
ln_E_factor := (ln_density_obs/ln_Ctl) - ln_density_60; --ln_density_Delta/ln_Ctl;
ln_Dt_factor := 2 * ln_alpha_60 * (p_temp_obs - 60) *(1 + 1.6 * ln_alpha_60* (p_temp_obs - 60));
ln_delta_density_60 := ln_E_factor / (1+ln_Dt_factor);
-- Adjust the guessed density based on the above delta
ln_density_60 := ln_density_60 + ln_delta_density_60;
END LOOP;
ln_result := round(ln_Ctl,p_decimals);
RETURN ln_result;
END calcVCFobsAPI;
---------------------------------------------------------------------------------------------------
-- Function : calcVCFobsDensity_SI
-- Description : Calculates what the VCF is CORRECTED density given the
-- observed tempature and observed density in SI Units
-- This is normally done as a set of iterations until a certain delta is achieved
-- In this case it is hard coded for max 10 iterations
-- This provides good results for the normal range of operations
--
-- API Chapter 11.1 section 11.1.7.2
--
---------------------------------------------------------------------------------------------------
FUNCTION calcVCFobsDensity_SI(
p_Density_obs NUMBER,
p_Temp_Obs NUMBER,
p_Temp_Base NUMBER DEFAULT 15,
p_decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_Ctl NUMBER;
ln_Ctl_60 NUMBER;
ln_density_60 NUMBER;
ln_density_delta NUMBER;
ln_result NUMBER;
ln_A NUMBER;
ln_RHO_Star NUMBER;
ln_Temp_Base_F NUMBER;
ln_Temp_obs_F NUMBER;
ln_Delta_Temp NUMBER;
ln_E_factor NUMBER;
ln_Dt_factor NUMBER;
ln_delta_density_60 NUMBER;
ln_counter NUMBER;
BEGIN
-- Use the observed density as the first guess for the corrected density
ln_density_60 := p_Density_obs;
-- Convert base temperature to F
ln_temp_base_f := (p_temp_base *9/5)+32;
ln_temp_obs_f := (p_temp_obs *9/5)+32;
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(ln_temp_obs_f);
-- Loop through iterations until convergence is reached
FOR ln_counter IN 1..10 LOOP
-- Calculate the A factor
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl_60 := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
IF ln_Ctl_60 = 0 THEN
RAISE_APPLICATION_ERROR(-20000,'The combination of the Temperature and Observed Density is not valid.');
ELSE
-- Calculate API gravity at observed temperature from density at observed temperature
ln_density_Delta := (p_Density_obs / ln_Ctl_60) - ln_density_60;
END IF;
-- Exit when convergence is reached
EXIT WHEN abs(ln_density_Delta) < 0.0000001;
-- Estimate the amount of change in the density needed to get a good answer
ln_E_factor := (p_Density_obs/ln_Ctl_60) - ln_density_60; --ln_density_Delta/ln_Ctl;
ln_Dt_factor := 2 * ln_alpha_60 * (p_temp_obs - 60) *(1 + 1.6 * ln_alpha_60* (p_temp_obs - 60));
ln_delta_density_60 := ln_E_factor / (1+ln_Dt_factor);
-- Adjust the guessed density based on the above delta
ln_density_60 := ln_density_60 + ln_delta_density_60;
END LOOP;
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(ln_temp_base_f);
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
-- CTL at SI conditions
ln_result := round((ln_ctl_60 / ln_ctl),p_decimals);
RETURN ln_result;
END calcVCFobsDensity_SI;
---------------------------------------------------------------------------------------------------
-- Function : calcVCFstdAPI
-- Description : Calculates the VCF for a starndard API gravity given the
-- observed tempature
--
---------------------------------------------------------------------------------------------------
FUNCTION calcVCFstdAPI(
p_API_Gravity_std NUMBER,
p_Temp_Obs NUMBER,
p_Decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_A NUMBER;
ln_Rho_star NUMBER;
ln_Ctl NUMBER;
ln_delta_Temp NUMBER;
ln_density_std NUMBER;
ln_result NUMBER;
BEGIN
-- Convert API gravity to density
ln_density_std := EcBp_VCF.getDensityFromAPI(p_API_gravity_std);
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_std**2);
ln_RHO_Star := ln_density_std * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(p_temp_obs);
-- Temperature VCF factor
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
ln_result := round(ln_ctl,p_Decimals);
RETURN ln_result;
END calcVCFstdAPI;
---------------------------------------------------------------------------------------------------
-- Function : calcVCFstdDensity
-- Description : Calculates the VCF for a starndard density given the
-- observed tempature
--
---------------------------------------------------------------------------------------------------
FUNCTION calcVCFstdDensity(
p_Density_std NUMBER,
p_Temp_Obs NUMBER,
p_Decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_A NUMBER;
ln_Rho_star NUMBER;
ln_Ctl NUMBER;
ln_delta_Temp NUMBER;
ln_result NUMBER;
BEGIN
ln_A := 0.0137498 * 341.0957 / (2 * p_Density_std**2);
ln_RHO_Star := p_Density_std * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(p_temp_obs);
-- Temperature VCF factor
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
ln_result := round(ln_ctl,p_Decimals);
RETURN ln_result;
END calcVCFstdDensity;
---------------------------------------------------------------------------------------------------
-- Function : calcVCFstdDensity_SI
-- Description : Calculates what the VCF is at CORRECTED density given the
-- observed tempature and standard density at the SI Temperature bass
-- This is normally done as a set of iterations until a certain delta is achieved
-- In this case it is hard coded for max 10 iterations
-- This provides good results for the normal range of operations
--
-- APH Chapter 11 section 11.1.7.1
--
---------------------------------------------------------------------------------------------------
FUNCTION calcVCFstdDensity_SI(
p_Density_Std NUMBER,
p_Temp_Obs NUMBER,
p_Temp_Base NUMBER DEFAULT 15,
p_decimals NUMBER DEFAULT 5)
RETURN NUMBER
IS
ln_Alpha_60 NUMBER;
ln_Ctl NUMBER;
ln_Ctl_60 NUMBER;
ln_density_60 NUMBER;
ln_density_delta NUMBER;
ln_result NUMBER;
ln_A NUMBER;
ln_RHO_Star NUMBER;
ln_Temp_Base_F NUMBER;
ln_Temp_obs_F NUMBER;
ln_Delta_Temp NUMBER;
ln_E_factor NUMBER;
ln_Dt_factor NUMBER;
ln_delta_density_60 NUMBER;
ln_counter NUMBER;
BEGIN
-- Use the observed density as the first guess for the corrected density
ln_density_60 := p_Density_Std;
-- Convert base temperature to F
ln_temp_base_f := (p_temp_base *9/5)+32;
ln_temp_obs_f := (p_temp_obs *9/5)+32;
-- Convert the temperature to ITPS-68 basis
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(ln_temp_base_f);
-- Loop through iterations until convergence is reached
FOR ln_counter IN 1..10 LOOP
-- Calculate the A factor
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl_60 := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
IF ln_Ctl_60 = 0 THEN
RAISE_APPLICATION_ERROR(-20000,'The combination of the Temperature and Observed Density is not valid.');
ELSE
-- Calculate API gravity at observed temperature from density at observed temperature
ln_density_Delta := (p_Density_Std / ln_Ctl_60) - ln_density_60;
END IF;
-- Exit when convergence is reached
EXIT WHEN abs(ln_density_Delta) < 0.0000001;
-- Estimate the amount of change in the density needed to get a good answer
ln_E_factor := (p_Density_Std/ln_Ctl_60) - ln_density_60; --ln_density_Delta/ln_Ctl;
ln_Dt_factor := 2 * ln_alpha_60 * (p_temp_obs - 60) *(1 + 1.6 * ln_alpha_60* (p_temp_obs - 60));
ln_delta_density_60 := ln_E_factor / (1+ln_Dt_factor);
-- Adjust the guessed density based on the above delta
ln_density_60 := ln_density_60 + ln_delta_density_60;
END LOOP;
ln_Delta_temp := EcBp_VCF.calcDeltaTempIPTS68(ln_temp_obs_f);
ln_A := 0.0137498 * 341.0957 / (2 * ln_density_60**2);
ln_RHO_Star := ln_density_60 * (1+ ((exp(ln_A*(1+0.8*ln_A)) - 1)/(1+ln_a*(1+1.6*ln_a)*2)));
ln_Alpha_60 := 341.0957 / (ln_RHO_Star**2);
-- Density at temperature the sample was taken at (tank or stream temperature)
ln_Ctl := exp(-1*ln_Alpha_60*ln_Delta_temp*(1 + (0.8*ln_Alpha_60*(ln_Delta_temp + 0.01374979))));
ln_ctl := ln_ctl / ln_ctl_60;
-- CTL at SI conditions
ln_result := round(ln_ctl,p_decimals);
RETURN ln_result;
END calcVCFstdDensity_SI;
---------------------------------------------------------------------------------------------------
-- Function : calcDeltaTempIPTS68
-- Description : Calculates the delta temperatur for API calculations based on
-- the IPTS-68 standard.
-- Input temp must be in F
---------------------------------------------------------------------------------------------------
FUNCTION calcDeltaTempIPTS68(
p_Temp_Obs NUMBER)
RETURN NUMBER
IS
ln_Temp_IPTS_68 NUMBER;
ln_temp_obs_C NUMBER;
ln_Temp_obs_scaled NUMBER;
ln_Temp_IPTS_delta NUMBER;
ln_delta_Temp NUMBER;
BEGIN
-- Convert to C
-- ln_temp_obs_C := (p_temp_obs-32)/1.8;
ln_temp_obs_C := Ecdp_Unit.convertValue(p_temp_obs,'F','C');
-- Convert to scaled value
ln_Temp_obs_scaled := ln_temp_obs_C/630;
ln_Temp_IPTS_delta :=((-0.148759+
(-0.267408+
(1.080760+
(1.269056+
(-4.089591+
(-1.871251+
(7.438081+
(-3.536296*ln_Temp_obs_scaled)
)*ln_Temp_obs_scaled
)*ln_Temp_obs_scaled
)*ln_Temp_obs_scaled
)*ln_Temp_obs_scaled
)*ln_Temp_obs_scaled
)*ln_Temp_obs_scaled
)*ln_Temp_obs_scaled
);
--Convert back to F
-- ln_Temp_IPTS_68 := ((ln_Temp_obs_C - ln_Temp_IPTS_delta) * 1.8) + 32;
ln_Temp_IPTS_68 := Ecdp_Unit.convertValue((ln_Temp_obs_C - ln_Temp_IPTS_delta),'C','F');
ln_Delta_temp := ln_Temp_IPTS_68 - 60.0068749;
RETURN ln_Delta_temp;
END calcDeltaTempIPTS68;
--<EC-DOC>
---------------------------------------------------------------------------------------------------
-- Function : getAPIFromDensity --
-- Description : returns API gravity from Density --
-- API Gravity is so called oil field unit, temp is 60F. Density returned is also at 60F --
-- Preconditions : --
-- Postconditions : --
-- --
-- Using tables : --
-- --
-- Using functions: --
-- --
-- Configuration --
-- required : --
-- --
-- Behaviour : --
-- --
---------------------------------------------------------------------------------------------------
FUNCTION getAPIFromDensity(p_density NUMBER)
RETURN NUMBER IS
BEGIN
-- The formula can be calculated this way:
-- API Gravity = (141.5 / Specific gravity) - 131.5
-- API Gravity = (141.5 / (Density of crude/Density of Water)) - 131.5
-- API Gravity = (141.5 * Density of water / Density of crude) - 131.5
RETURN (141.5 * ecdp_unit.convertValue(ecdp_system.getWaterDensity(ecdp_unit.convertValue(60,'F','C')),ecdp_unit.GetUnitFromLogical('WATER_DENS'),'KGPERSM3')/ p_density) - 131.5;
END getAPIfromDensity;
--<EC-DOC>
---------------------------------------------------------------------------------------------------
-- Function : getDensityFromAPI
-- Description : returns Density from API gravity
-- Preconditions : --
-- Postconditions : --
-- --
-- Using tables : --
-- --
-- Using functions: --
-- --
-- Configuration --
-- required : --
-- --
-- Behaviour : --
-- --
---------------------------------------------------------------------------------------------------
FUNCTION getDensityFromAPI(p_API NUMBER)
RETURN NUMBER IS
BEGIN
RETURN (141.5 * ecdp_unit.convertValue(ecdp_system.getWaterDensity(ecdp_unit.convertValue(60,'F','C')),ecdp_unit.GetUnitFromLogical('WATER_DENS'),'KGPERSM3')/(131.5 + p_API));
END getDensityFromAPI;
--<EC-DOC>
---------------------------------------------------------------------------------------------------
-- Function : calcDiluentConcentration
-- Description : returns Diluent concentration from API 12.3 standards
-- Preconditions : --
-- Postconditions : --
-- --
-- Using tables : --
-- --
-- Using functions: --
-- --
-- Configuration --
-- required : --
-- --
-- Behaviour : --
-- --
---------------------------------------------------------------------------------------------------
FUNCTION calcDiluentConcentration(p_object_id stream.object_id%TYPE,
p_daytime DATE)
RETURN NUMBER IS
ln_diluent_vol NUMBER;
ln_diluent_cut NUMBER;
lv_class VARCHAR2(32);
BEGIN
lv_class := ecdp_objects.GetObjClassName(p_object_id);
IF lv_class = 'STREAM' THEN
ln_diluent_cut := ec_strm_day_stream.diluent_cut(p_object_id, p_daytime);
ELSE
ln_diluent_cut := ec_tank_measurement.diluent_cut(p_object_id, 'DAY_CLOSING', p_daytime);
END IF;
IF ln_diluent_cut IS NOT NULL THEN
RETURN ln_diluent_cut;
ELSE
ln_diluent_vol := calcAPIBlendShrinkage(p_object_id, p_daytime, 'DILUENT_VOLUME');
IF ln_diluent_vol > -1 THEN
RETURN (ln_diluent_vol/(ln_diluent_vol+1));
ELSE
RETURN NULL;
END IF;
END IF;
END calcDiluentConcentration;
--<EC-DOC>
---------------------------------------------------------------------------------------------------
-- Function : calcShrinkageFactor
-- Description : returns blend shrinkage factor from API 12.3 standards.
-- Preconditions : --
-- Postconditions : --
-- --
-- Using tables : --
-- --
-- Using functions: --
-- --
-- Configuration --
-- required : --
-- --
-- Behaviour : --
-- --
---------------------------------------------------------------------------------------------------
FUNCTION calcShrinkageFactor(p_object_id stream.object_id%TYPE,
p_daytime DATE)
RETURN NUMBER IS
ln_diluent_vol NUMBER;
ln_diluent_cut NUMBER;
ln_blend_vol NUMBER;
ln_diluent_dens NUMBER;
ln_bitumen_dens NUMBER;
lv_class VARCHAR2(32);
lv_unit_type VARCHAR2(32);
BEGIN
SELECT unit INTO lv_unit_type
FROM ctrl_uom_setup WHERE measurement_type='STD_OIL_VOL' AND db_unit_ind='Y';
lv_class := ecdp_objects.GetObjClassName(p_object_id);
IF lv_class = 'STREAM' THEN
ln_diluent_cut := ec_strm_day_stream.diluent_cut(p_object_id, p_daytime);
ln_diluent_dens := Ecbp_Stream_Fluid.findStdDens(ec_strm_version.ref_diluent_stream_id(p_object_id,p_daytime,'<='),p_daytime);
ln_bitumen_dens := Ecbp_Stream_Fluid.findStdDens(ec_strm_version.ref_bitumen_stream_id(p_object_id,p_daytime,'<='),p_daytime);
ELSE
ln_diluent_cut := ec_tank_measurement.diluent_cut(p_object_id, 'DAY_CLOSING', p_daytime);
ln_diluent_dens := Ecbp_Tank.findDiluentDens(p_object_id, 'DAY_CLOSING', p_daytime);
ln_bitumen_dens := Ecbp_Tank.findBitumenDens(p_object_id, 'DAY_CLOSING', p_daytime);
END IF;
IF ln_diluent_cut IS NOT NULL THEN
ln_diluent_vol := ln_diluent_cut/(1-ln_diluent_cut);
IF lv_unit_type='SM3' THEN
ln_blend_vol := (1+ln_diluent_vol)*
(100-(2.69*10000*ln_diluent_cut*100*power((100-ln_diluent_cut*100),0.819)*POWER(((1/ln_diluent_dens)-(1/ln_bitumen_dens)),2.28)))/100;
ELSE
ln_blend_vol := (1+ln_diluent_vol)*
(100-(4.86/power(10,8)*ln_diluent_cut*100*power((100-ln_diluent_cut*100),0.819)*POWER((ln_diluent_dens-ln_bitumen_dens),2.28)))/100;
END IF;
ELSE
ln_diluent_vol := calcAPIBlendShrinkage(p_object_id, p_daytime, 'DILUENT_VOLUME');
ln_blend_vol := calcAPIBlendShrinkage(p_object_id, p_daytime, 'BLEND_VOLUME');
END IF;
IF ln_diluent_vol > -1 THEN
RETURN (ln_blend_vol/(ln_diluent_vol+1));
ELSE
RETURN NULL;
END IF;
END calcShrinkageFactor;
--<EC-DOC>
---------------------------------------------------------------------------------------------------
-- Function : calcAPIBlendShrinkage
-- Description : returns Diluent Volume OR Blend Volume dependng on p_return_char value
-- Calculates volume of Diluent and Blend starting with 1m3 unshrunk.
-- Preconditions : --
-- Postconditions : --
-- --
-- Using tables : --
-- --
-- Using functions: --
-- --
-- Configuration --
-- required : --
-- --
-- Behaviour : --
-- --
---------------------------------------------------------------------------------------------------
FUNCTION calcAPIBlendShrinkage(p_object_id stream.object_id%TYPE,
p_daytime DATE,
p_return_char VARCHAR2)
RETURN NUMBER IS
ln_iteration_count NUMBER :=0;
ln_diluent_vol NUMBER :=0;
ln_delta_diluent_vol NUMBER;
ln_delta_diluent_mass NUMBER;
ln_delta_concentration NUMBER;
ln_delta_shrink_factor NUMBER;
ln_delta_shrink_vol NUMBER;
ln_shrinkage_vol NUMBER :=0;
ln_current_blend_vol NUMBER :=1;
ln_current_blend_mass NUMBER;
ln_current_blend_dens NUMBER;
ln_diluent_dens NUMBER;
ln_target_blend_dens NUMBER;
ln_new_blend_mass NUMBER;
ln_new_blend_vol NUMBER;
ln_new_blend_ideal_vol NUMBER;
lv_class VARCHAR2(32);
lv_unit_type VARCHAR2(32);
BEGIN
SELECT unit INTO lv_unit_type
FROM ctrl_uom_setup WHERE measurement_type='STD_OIL_VOL' AND db_unit_ind='Y';
lv_class := ecdp_objects.GetObjClassName(p_object_id);
IF lv_class = 'STREAM' THEN
ln_target_blend_dens := Ecbp_Stream_Fluid.findStdDens(p_object_id, p_daytime);
ln_diluent_dens := Ecbp_Stream_Fluid.findStdDens(ec_strm_version.ref_diluent_stream_id(p_object_id,p_daytime,'<='),p_daytime);
ln_current_blend_dens := Ecbp_Stream_Fluid.findStdDens(ec_strm_version.ref_bitumen_stream_id(p_object_id,p_daytime,'<='),p_daytime);
ELSIF lv_class = 'TANK' THEN
ln_target_blend_dens := Ecbp_Tank.findStdDens(p_object_id, 'DAY_CLOSING', p_daytime);
ln_diluent_dens := Ecbp_Tank.findDiluentDens(p_object_id, 'DAY_CLOSING', p_daytime);
ln_current_blend_dens := Ecbp_Tank.findBitumenDens(p_object_id, 'DAY_CLOSING', p_daytime);
ELSE
NULL;
END IF;
IF ln_target_blend_dens>0 AND ln_diluent_dens>0 AND ln_current_blend_dens>0 THEN
WHILE (ln_iteration_count <= 20 OR abs(ln_target_blend_dens-ln_current_blend_dens) > 0.000001) LOOP
ln_current_blend_mass := ln_current_blend_vol * ln_current_blend_dens;
ln_delta_diluent_vol := ln_current_blend_vol * ((ln_current_blend_dens-ln_target_blend_dens)/(ln_target_blend_dens-ln_diluent_dens));
ln_diluent_vol := ln_diluent_vol + ln_delta_diluent_vol;
ln_delta_diluent_mass := ln_delta_diluent_vol * ln_diluent_dens;
ln_new_blend_mass := ln_current_blend_mass + ln_delta_diluent_mass;
ln_new_blend_ideal_vol := ln_delta_diluent_vol + ln_current_blend_vol;
ln_delta_concentration := (ln_delta_diluent_vol/ln_new_blend_ideal_vol)*100;
IF lv_unit_type='SM3' THEN
ln_delta_shrink_factor := 26900 *
ln_delta_concentration *
POWER((100-ln_delta_concentration),0.819) *
POWER(((1/ln_diluent_dens)-(1/ln_current_blend_dens)),2.28);
ELSE
ln_delta_shrink_factor := 4.86/power(10,8)*
ln_delta_concentration *
POWER((100-ln_delta_concentration),0.819) *
POWER((ln_diluent_dens-ln_current_blend_dens),2.28);
END IF;
ln_delta_shrink_vol := (ln_delta_shrink_factor/100) * ln_new_blend_ideal_vol;
ln_shrinkage_vol := ln_shrinkage_vol + ln_delta_shrink_vol;
ln_new_blend_vol := ln_new_blend_ideal_vol - ln_delta_shrink_vol;
ln_current_blend_vol := ln_new_blend_vol;
ln_current_blend_dens := (ln_new_blend_mass/ln_new_blend_vol);
ln_iteration_count := ln_iteration_count + 1;
END LOOP;
IF p_return_char='BLEND_VOLUME' THEN
RETURN ln_current_blend_vol;
ELSIF p_return_char = 'DILUENT_VOLUME' THEN
RETURN ln_diluent_vol;
ELSE
RETURN NULL;
END IF;
ELSE
RETURN NULL;
END IF;
END calcAPIBlendShrinkage;
END EcBp_VCF; | true |
717201a4564bb8badcea124b31f38196ff9cfefa | SQL | FELLSAT/Procedimientos | /Procedimientos/Parte 1/H3i_SP_ACTUALIZA_PERFIL.sql | UTF-8 | 1,924 | 3.25 | 3 | [] | no_license | CREATE OR REPLACE PROCEDURE H3i_SP_ACTUALIZA_PERFIL
-- =============================================
-- Author: FELIPE SATIZABAL
-- =============================================
(
v_CD_CODI_PERF IN VARCHAR2,
v_NO_NOMB_PERF IN VARCHAR2,
v_TX_SERV_PERF IN VARCHAR2,
v_TX_ELEM_PERF IN VARCHAR2,
v_NU_ESTADO_PERF IN NUMBER,
v_ENTIDAD IN NUMBER,
v_NIVEL IN NUMBER
)
AS
v_temp NUMBER(1, 0) := 0;
BEGIN
BEGIN
SELECT 1 INTO v_temp
FROM DUAL
WHERE ( SELECT COUNT(CD_CODI_PERF)
FROM PERFILES
WHERE CD_CODI_PERF = v_CD_CODI_PERF ) = 0;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
IF v_temp = 1 THEN
--NUEVO PERFIL
BEGIN
INSERT INTO PERFILES
( CD_CODI_PERF, NO_NOMB_PERF, TX_SERV_PERF, TX_ELEM_PERF, NU_ESTADO_PERF, NU_AUTO_ENTI_PERF, NU_NIVEL_SEG )
VALUES ( v_CD_CODI_PERF, v_NO_NOMB_PERF, v_TX_SERV_PERF, v_TX_ELEM_PERF, v_NU_ESTADO_PERF, v_ENTIDAD, v_NIVEL );
--CREANDO LOS PERMISOS DE SEGURIDAD (POR DEFECTO NO TIENE NINGUN PERMISO)
INSERT INTO PERMISOS
( SELECT DISTINCT v_CD_CODI_PERF ,
CD_CODI_OPCI ,
'N' ,
'N' ,
'N' ,
'N' ,
'N' ,
'N'
FROM OPCIONES );
END;
ELSE
BEGIN
UPDATE PERFILES
SET NO_NOMB_PERF = v_NO_NOMB_PERF,
TX_SERV_PERF = v_TX_SERV_PERF,
TX_ELEM_PERF = v_TX_ELEM_PERF,
NU_ESTADO_PERF = v_NU_ESTADO_PERF,
NU_AUTO_ENTI_PERF = v_ENTIDAD,
NU_NIVEL_SEG = v_NIVEL
WHERE CD_CODI_PERF = v_CD_CODI_PERF;
END;
END IF;
EXCEPTION
WHEN OTHERS
THEN RAISE_APPLICATION_ERROR(SQLCODE,SQLERRM);
END; | true |
5a184c57f7bfef96bbeee7894331607d67fe1c63 | SQL | marciocrodrigues/ApiDapper | /ApiDapper.Infra/Scripts/Procedure/spGetCustomerOrdersCount.sql | UTF-8 | 387 | 4.0625 | 4 | [] | no_license | CREATE PROCEDURE spGetCustomerOrdersCount
@Document Char(11)
AS
SELECT c.[Id],
CONCAT(c.[FirstName], ' ', c.[LastName]) AS [Name],
c.[Document],
COUNT(O.Id) AS [Orders]
FROM
[Customer] c INNER JOIN [Order] o ON o.[CustomerId] = c.[Id]
WHERE
c.[Document] = @Document
GROUP BY
c.[Id],
c.[FirstName],
c.[LastName],
c.[Document] | true |
ab257bb673230db148f838c7e53d96c273f62e59 | SQL | dwfs-bue-pal-2/shelp | /scriptBD/shelp.sql | UTF-8 | 6,078 | 3.109375 | 3 | [] | no_license | SET NAMES `utf8`;
DROP DATABASE IF EXISTS `shelp`;
CREATE DATABASE `shelp`;
USE `shelp`;
DROP TABLE IF EXISTS `shops`;
CREATE TABLE `shops`
(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`image` varchar(500),
`address` varchar(500) NOT NULL,
`lat` FLOAT(10,6) NOT NULL DEFAULT 0,
`lon` FLOAT(10,6) NOT NULL DEFAULT 0,
`phone` int(30),
`type` varchar(30),
`description` varchar(700),
`hours` varchar(50),
`active` TINYINT(1) DEFAULT 1,
PRIMARY KEY(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
LOCK TABLES `shops` WRITE;
INSERT INTO `shops`
VALUES
(1, 'Chori', 11111111111111112, 'Thames 1653, CABA.',-34.587678, -58.430562, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(2, 'Osaka', 11111111111111112, 'Soler 5608, CABA.',-34.580588, -58.432815, 1139669857, 'Restaurant', 'b , es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(3, 'Koh Lanta', 11111111111111112, 'Gorriti 4647, CABA.',-34.591637, -58.427352, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(4, 'La choza de Gascon', 11111111111111112, 'Gascon 1701, CABA.',-34.589760, -58.422216, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(5, 'Cooperativa Ale Ale', 11111111111111112, 'José A. Cabrera 4270, CABA.',-34.594836, -58.425406, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(6, 'Sarkis', 11111111111111112, 'Thames 1101, CABA.',-34.591219, -58.436129, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(7, 'Cantina Don Chicho En Palermo', 11111111111111112, 'Honduras 5710, CABA.',-34.583051, -58.437633, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(8, 'El Peron Peron', 11111111111111112, 'Angel Justiniano Carranza 2225, CABA.',-34.578447, -58.433532, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(9, 'Crizia Restaurante', 11111111111111112, 'Gorriti 5143, CABA.',-34.588211, -58.432533, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1),
(10, '1810 Cocina Regional', 11111111111111112, 'Julian Alvarez 1998, CABA.',-34.589168, -58.419248, 1148650030, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1);
UNLOCK TABLES;
USE `shelp`;
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`
(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(70) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
LOCK TABLES `users` WRITE;
INSERT INTO `users`
VALUES
(1,'A.J. Cook'),
(2,'Aaron Eckhart'),
(3,'Aaron Murphy'),
(4,'Aaron Stanford'),
(5,'Abdolgani Yousefrazi'),
(6,'Abel Ayala'),
(7,'Abigail Breslin');
UNLOCK TABLES;
USE `shelp`;
DROP TABLE IF EXISTS `reviews`;
CREATE TABLE `reviews` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) unsigned NOT NULL,
`shop_id` int(11) unsigned NOT NULL,
`score` int(11) NOT NULL,
`comment` varchar(240),
`date` DATETIME DEFAULT CURRENT_TIMESTAMP,
`active` TINYINT (1) DEFAULT 1,
PRIMARY KEY(`id`),
KEY `reviews_user` (`user_id`),
CONSTRAINT `reviews_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
KEY `reviews_shops` (`shop_id`),
CONSTRAINT `shops_user` FOREIGN KEY (`shop_id`) REFERENCES `shops` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
LOCK TABLES `reviews` WRITE;
INSERT INTO `reviews`
VALUES
(1,1,1,3,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(2,2,4,5,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(3,2,2,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(4,4,3,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(5,1,7,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(6,5,7,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(7,7,8,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(8,6,1,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(9,6,5,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(10,6,6,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(11,6,9,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(12,1,1,3,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(13,2,1,5,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(14,2,2,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(15,4,1,4,'Lorem Impsum review review Lorem Impsum review review Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(16,1,7,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(17,5,1,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1),
(18,6,10,4,'Lorem Impsum review review', CURRENT_TIMESTAMP, 1);
UNLOCK TABLES;
INSERT INTO shops VALUES (13, 'Chori', 11111111111111112, 'Thames 1653, CABA.',-34.587678, -58.430562, 1139669857, 'Restaurant', 'Chori, es un pequeño lugar de Palermo que homenajea al sándwich emblema de la tradición parrillera argentina, el choripán.', 'Martes a Domingo. 12:30 a 00:30', 1); | true |
d154102ae6050aaccd4f17bf8ddea8e7c7e1c708 | SQL | MCZbase/DDL | /TABLE/CTMEDIA_RELATIONSHIP.sql | UTF-8 | 289 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive |
CREATE TABLE "CTMEDIA_RELATIONSHIP"
( "MEDIA_RELATIONSHIP" VARCHAR2(40 CHAR) NOT NULL ENABLE,
"DESCRIPTION" VARCHAR2(4000),
"LABEL" VARCHAR2(255),
"AUTO_TABLE" VARCHAR2(40),
CONSTRAINT "PK_CTMEDIA_RELATIONSHIP" PRIMARY KEY ("MEDIA_RELATIONSHIP")
USING INDEX ENABLE
) | true |
836dd90339c8e0bf7eada16fe842cbad2f3355a2 | SQL | Dinohunter582/Music-Player | /slotify.sql | UTF-8 | 7,622 | 3.015625 | 3 | [] | no_license | -- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Aug 19, 2021 at 08:10 PM
-- Server version: 10.4.20-MariaDB
-- PHP Version: 7.4.21
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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: `slotify`
--
-- --------------------------------------------------------
--
-- Table structure for table `albums`
--
CREATE TABLE `albums` (
`id` int(11) NOT NULL,
`title` varchar(250) NOT NULL,
`artist` int(11) NOT NULL,
`genre` int(11) NOT NULL,
`artworkPath` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `albums`
--
INSERT INTO `albums` (`id`, `title`, `artist`, `genre`, `artworkPath`) VALUES
(1, 'Music is the Weapon', 3, 6, 'assets/images/artwork/Major_lazer.jpeg'),
(2, 'good girl gone bad', 5, 1, 'assets/images/artwork/Rhiana.jpeg'),
(3, 'Full frequency', 4, 2, 'assets/images/artwork/Sean_Paul.jpeg'),
(4, 'SHAKIRA', 2, 1, 'assets/images/artwork/Shakira.jpeg'),
(5, 'Afrowave 3', 1, 3, 'assets/images/artwork/Afro_B.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `artists`
--
CREATE TABLE `artists` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `artists`
--
INSERT INTO `artists` (`id`, `name`) VALUES
(1, 'Afro B'),
(2, 'Shakira'),
(3, 'Major lazer'),
(4, 'Sean Paul'),
(5, 'Rhiana');
-- --------------------------------------------------------
--
-- Table structure for table `genres`
--
CREATE TABLE `genres` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `genres`
--
INSERT INTO `genres` (`id`, `name`) VALUES
(1, 'Pop'),
(2, 'R & B'),
(3, 'Hip-hop'),
(4, 'Rap'),
(5, 'Classical'),
(6, 'Techno'),
(7, 'Jazz'),
(8, 'Country'),
(9, 'electro-dance-music');
-- --------------------------------------------------------
--
-- Table structure for table `playlists`
--
CREATE TABLE `playlists` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`owner` varchar(50) NOT NULL,
`dateCreated` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `playlists`
--
INSERT INTO `playlists` (`id`, `name`, `owner`, `dateCreated`) VALUES
(2, 'My playlist 2', 'mark52', '2021-08-12 00:00:00'),
(3, 'Jam List', 'mark52', '2021-08-12 00:00:00');
-- --------------------------------------------------------
--
-- Table structure for table `playlistSongs`
--
CREATE TABLE `playlistSongs` (
`id` int(11) NOT NULL,
`songId` int(11) NOT NULL,
`playlistId` int(11) NOT NULL,
`playlistOrder` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `playlistSongs`
--
INSERT INTO `playlistSongs` (`id`, `songId`, `playlistId`, `playlistOrder`) VALUES
(3, 6, 2, 1),
(7, 3, 3, 1),
(8, 2, 3, 2),
(9, 9, 3, 3),
(10, 11, 2, 2);
-- --------------------------------------------------------
--
-- Table structure for table `Songs`
--
CREATE TABLE `Songs` (
`id` int(11) NOT NULL,
`title` varchar(250) NOT NULL,
`artist` int(11) NOT NULL,
`album` int(11) NOT NULL,
`genre` int(11) NOT NULL,
`duration` varchar(8) NOT NULL,
`path` varchar(500) NOT NULL,
`albumOrder` int(11) NOT NULL,
`plays` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `Songs`
--
INSERT INTO `Songs` (`id`, `title`, `artist`, `album`, `genre`, `duration`, `path`, `albumOrder`, `plays`) VALUES
(1, 'happiness', 3, 1, 6, '4:22', 'assets/music/bensound-happiness.mp3', 1, 23),
(2, 'jazzy frenchy', 5, 2, 1, '1:45', 'assets/music/bensound-jazzyfrenchy.mp3', 1, 18),
(3, 'little idea', 2, 4, 1, '2:49', 'assets/music/bensound-littleidea.mp3', 1, 23),
(4, 'funky element', 1, 5, 3, '3:09', 'assets/music/bensound-funkyelement.mp3', 1, 14),
(5, 'energy', 4, 3, 2, '3:00', 'assets/music/bensound-energy.mp3', 1, 21),
(6, 'extreme Action', 3, 1, 6, '4:00', 'assets/music/bensound-extremeaction.mp3', 2, 23),
(7, 'Dubstep', 4, 3, 2, '4:00', 'assets/music/bensound-dubstep.mp3', 2, 15),
(8, 'novermber', 1, 5, 3, '3:00', 'assets/music/bensound-november.mp3', 2, 17),
(9, 'pop dance', 5, 2, 1, '3:09', 'assets/music/bensound-popdance.mp3', 2, 17),
(10, 'tomorrow', 3, 1, 6, '2:40', 'assets/music/bensound-tomorrow.mp3', 3, 21),
(11, 'Condo', 1, 5, 3, '2:47', 'assets/music/Afro-B-Condo.mp3', 2, 39),
(15, 'fine wine and henassy', 1, 5, 3, '3:12', 'assets/music/Fine-Wine-&-Hennessy.mp3', 4, 1),
(16, 'C\'est Cuit', 3, 1, 6, '2:37', 'assets/music/Cest-Cuit.mp3', 4, 1),
(17, 'Oh My Gawd', 3, 1, 6, '2:59', 'assets/music/Oh-My-Gawd.mp3', 5, 1);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`username` varchar(25) NOT NULL,
`firstName` varchar(50) NOT NULL,
`lastName` varchar(50) NOT NULL,
`email` varchar(200) NOT NULL,
`password` varchar(32) NOT NULL,
`signUpDate` datetime NOT NULL,
`profilePic` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `username`, `firstName`, `lastName`, `email`, `password`, `signUpDate`, `profilePic`) VALUES
(1, 'mark6', 'Mark', 'Mark', 'Mark@help.com', 'a43b5a84c6702f34a628a19d979a6111', '2021-07-28 00:00:00', 'assets/images/profile-pics/head_emerald.png'),
(2, 'mark52', 'Mark', 'Leung', 'mark@mark.com', '5f4dcc3b5aa765d61d8327deb882cf99', '2021-07-29 00:00:00', 'assets/images/profile-pics/head_emerald.png');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `albums`
--
ALTER TABLE `albums`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `artists`
--
ALTER TABLE `artists`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `genres`
--
ALTER TABLE `genres`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `playlists`
--
ALTER TABLE `playlists`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `playlistSongs`
--
ALTER TABLE `playlistSongs`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `Songs`
--
ALTER TABLE `Songs`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `albums`
--
ALTER TABLE `albums`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `artists`
--
ALTER TABLE `artists`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `genres`
--
ALTER TABLE `genres`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `playlists`
--
ALTER TABLE `playlists`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `playlistSongs`
--
ALTER TABLE `playlistSongs`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `Songs`
--
ALTER TABLE `Songs`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
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 */;
| true |
988a0c8feb2c0474ab6701d38676fc001044536e | SQL | juliannevela/07_build-lab | /sql/setup.sql | UTF-8 | 469 | 3.21875 | 3 | [] | no_license | DROP TABLE IF EXISTS jokes;
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
user_email TEXT NOT NULL
);
CREATE TABLE jokes (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
joke_id INT NOT NULL,
setup TEXT NOT NULL,
punchline TEXT NOT NULL,
joke_type TEXT NOT NULL,
linked_user INT REFERENCES users(id) ON DELETE SET NULL
);
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.