text
stringlengths
6
9.38M
drop table users; CREATE table users( id integer primary key, username varchar(20), password varchar(40), salt varchar(40) ); drop table books; CREATE table books( id integer primary key, title varchar(30), publisher varchar(20), genre varchar(30), description varchar(300) );
-- **************************************************** -- ** REQUIRES -- ** - FHIR/Language -- ** - NHSDD/Religion -- ** - NHSDD/Speciality -- ** - NHSDD/Inpatient -- ** - NHSDD/Ethnicity -- **************************************************** -- Ensure core code scheme exists INSERT IGNORE INTO concept (document, id, name, description) VALUES (1, 'CM_DiscoveryCode', 'Discovery code', 'Discovery (core) coding scheme '); -- Get scheme id SELECT @scm := dbid FROM concept WHERE id = 'CM_DiscoveryCode'; -- Code scheme prefix entries INSERT IGNORE INTO concept (document, id, scheme, code, name, description) VALUES -- GENERAL/GLOBAL -- (1, 'CM_Org_LNWH', @scm, 'CM_Org_LNWH', 'London North West Hospitals', 'London North West Hospitals'), (1, 'CM_Sys_Silverlink', @scm, 'CM_Sys_Silverlink', 'Silverlink', 'Silverlink system'), (1, 'LNWHSilverlink', @scm, 'LNWHSilverlink', 'LNWH Silverlink Local Codes', 'London North West Hospitals Sliverlink local code scheme'); INSERT IGNORE INTO concept_property_data (`dbid`, `group`, `property`, `value`) SELECT c.dbid, 0 AS `group`, p.dbid AS `property`, 'LNWH_SL_' AS `value` FROM concept c JOIN concept p ON p.id = 'code_prefix' WHERE c.id = 'LNWHSilverlink'; -- ******************** Gender ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'gender', '/LNWH/SLVRLNK/GNDR'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/LNWH/SLVRLNK/GNDR', 'DM_gender'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/LNWH/SLVRLNK/GNDR', 'F', 'LNWHSilverlink', 'FHIR_AG_female'), ('/LNWH/SLVRLNK/GNDR', 'M', 'LNWHSilverlink', 'FHIR_AG_male'), ('/LNWH/SLVRLNK/GNDR', 'U', 'LNWHSilverlink', 'FHIR_AG_unknown'), ('/LNWH/SLVRLNK/GNDR', 'I', 'LNWHSilverlink', 'FHIR_AG_other'); -- ******************** Religion ******************** -- Concepts SELECT @scm := dbid FROM concept WHERE id = 'LNWHSilverlink'; INSERT IGNORE INTO concept (document, id, scheme, code, name, description) VALUES -- New 26/05/2022 - DDSEUS-101 (1, 'LNWH_SL_Rlgn_Pen', @scm, 'LNWH_SL_Rlgn_Pen', 'Pentecostal', 'Pentecostal'), (1, 'LNWH_SL_Rlgn_CofG', @scm, 'LNWH_SL_Rlgn_CofG', 'Church of God', 'Church of God'), (1, 'LNWH_SL_Rlgn_CofC', @scm, 'LNWH_SL_Rlgn_CofC', 'Church of Christ', 'Church of Christ'), (1, 'LNWH_SL_Rlgn_OF', @scm, 'LNWH_SL_Rlgn_OF', 'Other Free Church', 'Other Free Church'), -- Added 6 Jul 2022 @ request of Michael Taylor - DDSEUS-101 -- (1, 'LNWH_SL_Rlgn_CHAP', @scm, 'LNWH_SL_Rlgn_CHAP', 'Chapel', 'Chapel'), (1, 'LNWH_SL_Rlgn_EPIS', @scm, 'LNWH_SL_Rlgn_EPIS', 'Episcopal', 'Episcopal'), (1, 'LNWH_SL_Rlgn_MAPU', @scm, 'LNWH_SL_Rlgn_MAPU', 'Mapuche', 'Mapuche'), (1, 'LNWH_SL_Rlgn_MOON', @scm, 'LNWH_SL_Rlgn_MOON', 'Moonies', 'Moonies'), (1, 'LNWH_SL_Rlgn_NAPC', @scm, 'LNWH_SL_Rlgn_NAPC', 'New Apostolic Church', 'New Apostolic Church'), (1, 'LNWH_SL_Rlgn_NDEN', @scm, 'LNWH_SL_Rlgn_NDEN', 'Non Denominational', 'Non Denominational'), (1, 'LNWH_SL_Rlgn_OCR', @scm, 'LNWH_SL_Rlgn_OCR', 'Order of the Cross', 'Order of the Cross'), (1, 'LNWH_SL_Rlgn_PO', @scm, 'LNWH_SL_Rlgn_PO', 'Polish Orthodox', 'Polish Orthodox'), (1, 'LNWH_SL_Rlgn_SHI', @scm, 'LNWH_SL_Rlgn_SHI', 'Shilo', 'Shilo'), (1, 'LNWH_SL_Rlgn_WES', @scm, 'LNWH_SL_Rlgn_WES', 'Wesleyan', 'Wesleyan'), (1, 'LNWH_SL_Rlgn_WI', @scm, 'LNWH_SL_Rlgn_WI', 'Welsh Independent', 'Welsh Independent'), (1, 'LNWH_SL_Rlgn_WWI', @scm, 'LNWH_SL_Rlgn_WWI', 'White Witch', 'White Witch'), (1, 'LNWH_SL_Rlgn_ZION', @scm, 'LNWH_SL_Rlgn_ZION', 'Zionist', 'Zionist'); -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'religion', '/LNWH/SLVRLNK/RLGN'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/LNWH/SLVRLNK/RLGN', 'DM_religion'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/LNWH/SLVRLNK/RLGN', 'BAHA', 'LNWHSilverlink', 'CM_ReligionA1'), ('/LNWH/SLVRLNK/RLGN', 'BUD', 'LNWHSilverlink', 'CM_ReligionB1'), ('/LNWH/SLVRLNK/RLGN', 'CHRI', 'LNWHSilverlink', 'CM_ReligionC1'), ('/LNWH/SLVRLNK/RLGN', 'ANG', 'LNWHSilverlink', 'CM_ReligionC4'), ('/LNWH/SLVRLNK/RLGN', 'AC', 'LNWHSilverlink', 'CM_ReligionC6'), ('/LNWH/SLVRLNK/RLGN', 'BAP', 'LNWHSilverlink', 'CM_ReligionC8'), ('/LNWH/SLVRLNK/RLGN', 'CH', 'LNWHSilverlink', 'CM_ReligionC16'), ('/LNWH/SLVRLNK/RLGN', 'CHSC', 'LNWHSilverlink', 'CM_ReligionC19'), ('/LNWH/SLVRLNK/RLGN', 'C/W', 'LNWHSilverlink', 'CM_ReligionC21'), ('/LNWH/SLVRLNK/RLGN', 'C/E', 'LNWHSilverlink', 'CM_ReligionC22'), ('/LNWH/SLVRLNK/RLGN', 'C/I', 'LNWHSilverlink', 'CM_ReligionC24'), ('/LNWH/SLVRLNK/RLGN', 'C/S', 'LNWHSilverlink', 'CM_ReligionC25'), ('/LNWH/SLVRLNK/RLGN', 'CONG', 'LNWHSilverlink', 'CM_ReligionC26'), ('/LNWH/SLVRLNK/RLGN', 'COPO', 'LNWHSilverlink', 'CM_ReligionC27'), ('/LNWH/SLVRLNK/RLGN', 'EVAN', 'LNWHSilverlink', 'CM_ReligionC32'), ('/LNWH/SLVRLNK/RLGN', 'ORTH', 'LNWHSilverlink', 'CM_ReligionC41'), ('/LNWH/SLVRLNK/RLGN', 'JWIT', 'LNWHSilverlink', 'CM_ReligionC44'), ('/LNWH/SLVRLNK/RLGN', 'LUTH', 'LNWHSilverlink', 'CM_ReligionC46'), ('/LNWH/SLVRLNK/RLGN', 'METH', 'LNWHSilverlink', 'CM_ReligionC49'), ('/LNWH/SLVRLNK/RLGN', 'MOR', 'LNWHSilverlink', 'CM_ReligionC50'), ('/LNWH/SLVRLNK/RLGN', 'MORM', 'LNWHSilverlink', 'CM_ReligionC51'), ('/LNWH/SLVRLNK/RLGN', 'NT', 'LNWHSilverlink', 'CM_ReligionC53'), ('/LNWH/SLVRLNK/RLGN', 'N/C', 'LNWHSilverlink', 'CM_ReligionC54'), ('/LNWH/SLVRLNK/RLGN', 'PRES', 'LNWHSilverlink', 'CM_ReligionC59'), ('/LNWH/SLVRLNK/RLGN', 'PROT', 'LNWHSilverlink', 'CM_ReligionC60'), ('/LNWH/SLVRLNK/RLGN', 'PB', 'LNWHSilverlink', 'CM_ReligionC61'), ('/LNWH/SLVRLNK/RLGN', 'QUAK', 'LNWHSilverlink', 'CM_ReligionC62'), ('/LNWH/SLVRLNK/RLGN', 'RAST', 'LNWHSilverlink', 'CM_ReligionC63'), ('/LNWH/SLVRLNK/RLGN', 'R/C', 'LNWHSilverlink', 'CM_ReligionC67'), ('/LNWH/SLVRLNK/RLGN', 'R/O', 'LNWHSilverlink', 'CM_ReligionC68'), ('/LNWH/SLVRLNK/RLGN', 'RUS', 'LNWHSilverlink', 'CM_ReligionC69'), ('/LNWH/SLVRLNK/RLGN', 'SALV', 'LNWHSilverlink', 'CM_ReligionC70'), ('/LNWH/SLVRLNK/RLGN', 'S/O', 'LNWHSilverlink', 'CM_ReligionC72'), ('/LNWH/SLVRLNK/RLGN', 'SDA', 'LNWHSilverlink', 'CM_ReligionC73'), ('/LNWH/SLVRLNK/RLGN', 'UN', 'LNWHSilverlink', 'CM_ReligionC78'), ('/LNWH/SLVRLNK/RLGN', 'URC', 'LNWHSilverlink', 'CM_ReligionC79'), ('/LNWH/SLVRLNK/RLGN', 'HIN', 'LNWHSilverlink', 'CM_ReligionD1'), ('/LNWH/SLVRLNK/RLGN', 'JAIN', 'LNWHSilverlink', 'CM_ReligionE1'), ('/LNWH/SLVRLNK/RLGN', 'JEW', 'LNWHSilverlink', 'CM_ReligionF1'), ('/LNWH/SLVRLNK/RLGN', 'MUS', 'LNWHSilverlink', 'CM_ReligionG1'), ('/LNWH/SLVRLNK/RLGN', 'PAGA', 'LNWHSilverlink', 'CM_ReligionH1'), ('/LNWH/SLVRLNK/RLGN', 'DRUI', 'LNWHSilverlink', 'CM_ReligionH4'), ('/LNWH/SLVRLNK/RLGN', 'WIC', 'LNWHSilverlink', 'CM_ReligionH9'), ('/LNWH/SLVRLNK/RLGN', 'SIKH', 'LNWHSilverlink', 'CM_ReligionI1'), ('/LNWH/SLVRLNK/RLGN', 'ZORO', 'LNWHSilverlink', 'CM_ReligionJ1'), ('/LNWH/SLVRLNK/RLGN', 'AGN', 'LNWHSilverlink', 'CM_ReligionK1'), ('/LNWH/SLVRLNK/RLGN', 'HMST', 'LNWHSilverlink', 'CM_ReligionK11'), ('/LNWH/SLVRLNK/RLGN', 'OTH', 'LNWHSilverlink', 'CM_ReligionK20'), ('/LNWH/SLVRLNK/RLGN', 'SPIR', 'LNWHSilverlink', 'CM_ReligionK27'), -- ('/LNWH/SLVRLNK/RLGN', 'UN', 'LNWHSilverlink', 'CM_ReligionK30'), -- Removed in 6 Jul update ('/LNWH/SLVRLNK/RLGN', 'ATH', 'LNWHSilverlink', 'CM_ReligionL1'), ('/LNWH/SLVRLNK/RLGN', 'UNK', 'LNWHSilverlink', 'CM_ReligionN1'), -- Added 26 May 2022 @ request of Michael Taylor - DDSEUS-101 -- ('/LNWH/SLVRLNK/RLGN', 'NK', 'LNWHSilverlink', 'CM_ReligionN1'), ('/LNWH/SLVRLNK/RLGN', 'PEN', 'LNWHSilverlink', 'LNWH_SL_Rlgn_Pen'), ('/LNWH/SLVRLNK/RLGN', 'NONE', 'LNWHSilverlink', 'CM_ReligionL1'), ('/LNWH/SLVRLNK/RLGN', 'C/G', 'LNWHSilverlink', 'LNWH_SL_Rlgn_CofG'), ('/LNWH/SLVRLNK/RLGN', 'COFC', 'LNWHSilverlink', 'LNWH_SL_Rlgn_CofC'), ('/LNWH/SLVRLNK/RLGN', 'OF', 'LNWHSilverlink', 'LNWH_SL_Rlgn_OF'), -- Added 6 Jul 2022 @ request of Michael Taylor - DDSEUS-101 -- ('/LNWH/SLVRLNK/RLGN', 'ISLM', 'LNWHSilverlink', 'CM_ReligionG1'), ('/LNWH/SLVRLNK/RLGN', 'UN', 'LNWHSilverlink', 'CM_ReligionC78'), ('/LNWH/SLVRLNK/RLGN', 'CHAP', 'LNWHSilverlink', 'LNWH_SL_Rlgn_CHAP'), ('/LNWH/SLVRLNK/RLGN', 'EPIS', 'LNWHSilverlink', 'LNWH_SL_Rlgn_EPIS'), ('/LNWH/SLVRLNK/RLGN', 'MAPU', 'LNWHSilverlink', 'LNWH_SL_Rlgn_MAPU'), ('/LNWH/SLVRLNK/RLGN', 'MOON', 'LNWHSilverlink', 'LNWH_SL_Rlgn_MOON'), ('/LNWH/SLVRLNK/RLGN', 'NAPC', 'LNWHSilverlink', 'LNWH_SL_Rlgn_NAPC'), ('/LNWH/SLVRLNK/RLGN', 'NDEN', 'LNWHSilverlink', 'LNWH_SL_Rlgn_NDEN'), ('/LNWH/SLVRLNK/RLGN', 'O-CR', 'LNWHSilverlink', 'LNWH_SL_Rlgn_OCR'), ('/LNWH/SLVRLNK/RLGN', 'P/O', 'LNWHSilverlink', 'LNWH_SL_Rlgn_PO'), ('/LNWH/SLVRLNK/RLGN', 'SHI', 'LNWHSilverlink', 'LNWH_SL_Rlgn_SHI'), ('/LNWH/SLVRLNK/RLGN', 'WES', 'LNWHSilverlink', 'LNWH_SL_Rlgn_WES'), ('/LNWH/SLVRLNK/RLGN', 'WI', 'LNWHSilverlink', 'LNWH_SL_Rlgn_WI'), ('/LNWH/SLVRLNK/RLGN', 'W-WI', 'LNWHSilverlink', 'LNWH_SL_Rlgn_WWI'), ('/LNWH/SLVRLNK/RLGN', 'ZION', 'LNWHSilverlink', 'LNWH_SL_Rlgn_ZION'); -- ******************** Ethnicity ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'ethnicity', '/CDS/PTNT/ETHNC_CTGRY'); -- ******************** Admission Method ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'admission_method_code', '/CDS/INPTNT/ADMSSN_MTHD'); -- ******************** Admission Source ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'admission_source_code', '/CDS/INPTNT/ADMSSN_SRC'); -- ******************** Discharge Method ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'discharge_method', '/CDS/INPTNT/DSCHRG_MTHD'); -- ******************** Discharge Destination ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'discharge_destination_code', '/CDS/INPTNT/DSCHRG_DSTNTN'); -- ******************** Treatment Function ******************** -- ************ MISSING SPECIALITIES **************** -- Concepts SELECT @scm := dbid FROM concept WHERE id = 'CM_DiscoveryCode'; INSERT IGNORE INTO concept (document, id, scheme, code, name, description) VALUES (1, 'CM_TrtmntFnc821', @scm, 'CM_TrtmntFnc821', 'Blood Transfusion', 'Blood Transfusion'), (1, 'CM_TrtmntFnc833', @scm, 'CM_TrtmntFnc833', 'Medical Microbiology', 'Medical Microbiology'); -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'treatment_function_code', '/LNWH/SLVRLNK/TRTMNT_FNCTN'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DM_treatmentFunctionAdmit'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/LNWH/SLVRLNK/TRTMNT_FNCTN', '180', 'LNWHSilverlink', 'CM_TrtmntFnc180'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'A/E', 'LNWHSilverlink', 'CM_TrtmntFnc180'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'A/THERAPY', 'LNWHSilverlink', 'CM_TrtmntFnc660'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ACUMED', 'LNWHSilverlink', 'CM_TrtmntFnc326'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ADULTCF', 'LNWHSilverlink', 'CM_TrtmntFnc343'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ADULTOT', 'LNWHSilverlink', 'CM_TrtmntFnc651'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ADULTPT', 'LNWHSilverlink', 'CM_TrtmntFnc650'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ADULTSLT', 'LNWHSilverlink', 'CM_TrtmntFnc652'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ALLERGY', 'LNWHSilverlink', 'CM_TrtmntFnc317'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ANAES', 'LNWHSilverlink', 'CM_TrtmntFnc190'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ASM', 'LNWHSilverlink', 'CM_TrtmntFnc200'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'AUDIO', 'LNWHSilverlink', 'CM_TrtmntFnc310'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'BCS', 'LNWHSilverlink', 'CM_TrtmntFnc301'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'BCSP', 'LNWHSilverlink', 'CM_TrtmntFnc301'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'BLOODTRAN', 'LNWHSilverlink', 'CM_TrtmntFnc821'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'BONDIS', 'LNWHSilverlink', 'CM_TrtmntFnc110'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'BREAST', 'LNWHSilverlink', 'CM_TrtmntFnc103'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'BSS', 'LNWHSilverlink', 'CM_TrtmntFnc301'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'C/APSYCH', 'LNWHSilverlink', 'CM_TrtmntFnc711'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'C/SERVICES', 'LNWHSilverlink', 'CM_TrtmntFnc658'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CARD/REHAB', 'LNWHSilverlink', 'CM_TrtmntFnc327'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CARDIO', 'LNWHSilverlink', 'CM_TrtmntFnc320'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CARDSURG', 'LNWHSilverlink', 'CM_TrtmntFnc170'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CCN', 'LNWHSilverlink', 'CM_TrtmntFnc290'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CHEMPATH', 'LNWHSilverlink', 'CM_TrtmntFnc822'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CHIROPODY', 'LNWHSilverlink', 'CM_TrtmntFnc653'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CLINGEN', 'LNWHSilverlink', 'CM_TrtmntFnc311'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CLINHAEM', 'LNWHSilverlink', 'CM_TrtmntFnc303'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CLINIMMU', 'LNWHSilverlink', 'CM_TrtmntFnc316'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CLINONCO', 'LNWHSilverlink', 'CM_TrtmntFnc800'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CLINPHAR', 'LNWHSilverlink', 'CM_TrtmntFnc305'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CLINPHYS', 'LNWHSilverlink', 'CM_TrtmntFnc304'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'CLINPSYC', 'LNWHSilverlink', 'CM_TrtmntFnc656'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'COL', 'LNWHSilverlink', 'CM_TrtmntFnc502'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'COM', 'LNWHSilverlink', 'CM_TrtmntFnc560'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'COMMED', 'LNWHSilverlink', 'CM_TrtmntFnc300'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'COMMEND', 'LNWHSilverlink', 'CM_TrtmntFnc900'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'COMSERV', 'LNWHSilverlink', 'CM_TrtmntFnc900'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DENMED', 'LNWHSilverlink', 'CM_TrtmntFnc450'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DENORTH', 'LNWHSilverlink', 'CM_TrtmntFnc143'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DENTAL', 'LNWHSilverlink', 'CM_TrtmntFnc140'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DERM', 'LNWHSilverlink', 'CM_TrtmntFnc330'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DIAB', 'LNWHSilverlink', 'CM_TrtmntFnc307'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DIAB/ES', 'LNWHSilverlink', 'CM_TrtmntFnc920'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DIAGNOSI', 'LNWHSilverlink', 'CM_TrtmntFnc812'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DIET', 'LNWHSilverlink', 'CM_TrtmntFnc654'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DIETETICS', 'LNWHSilverlink', 'CM_TrtmntFnc654'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'DRAMA', 'LNWHSilverlink', 'CM_TrtmntFnc659'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EDUCATE', 'LNWHSilverlink', 'CM_TrtmntFnc290'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT01', 'LNWHSilverlink', 'CM_TrtmntFnc180'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT02', 'LNWHSilverlink', 'CM_TrtmntFnc190'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT03', 'LNWHSilverlink', 'CM_TrtmntFnc310'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT04', 'LNWHSilverlink', 'CM_TrtmntFnc320'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT05', 'LNWHSilverlink', 'CM_TrtmntFnc330'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT06', 'LNWHSilverlink', 'CM_TrtmntFnc302'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT07', 'LNWHSilverlink', 'CM_TrtmntFnc120'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT08', 'LNWHSilverlink', 'CM_TrtmntFnc301'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT09', 'LNWHSilverlink', 'CM_TrtmntFnc300'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT10', 'LNWHSilverlink', 'CM_TrtmntFnc100'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT11', 'LNWHSilverlink', 'CM_TrtmntFnc360'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT12', 'LNWHSilverlink', 'CM_TrtmntFnc430'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT13', 'LNWHSilverlink', 'CM_TrtmntFnc502'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT15', 'LNWHSilverlink', 'CM_TrtmntFnc361'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT16', 'LNWHSilverlink', 'CM_TrtmntFnc400'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT18', 'LNWHSilverlink', 'CM_TrtmntFnc901'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT20', 'LNWHSilverlink', 'CM_TrtmntFnc140'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT22', 'LNWHSilverlink', 'CM_TrtmntFnc110'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT23', 'LNWHSilverlink', 'CM_TrtmntFnc259'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT24', 'LNWHSilverlink', 'CM_TrtmntFnc410'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT25', 'LNWHSilverlink', 'CM_TrtmntFnc800'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT26', 'LNWHSilverlink', 'CM_TrtmntFnc410'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT27', 'LNWHSilverlink', 'CM_TrtmntFnc340'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT28', 'LNWHSilverlink', 'CM_TrtmntFnc101'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT29', 'LNWHSilverlink', 'CM_TrtmntFnc350'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT30', 'LNWHSilverlink', 'CM_TrtmntFnc315'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT31', 'LNWHSilverlink', 'CM_TrtmntFnc321'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT34', 'LNWHSilverlink', 'CM_TrtmntFnc257'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT36', 'LNWHSilverlink', 'CM_TrtmntFnc822'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT37', 'LNWHSilverlink', 'CM_TrtmntFnc307'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT38', 'LNWHSilverlink', 'CM_TrtmntFnc722'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT40', 'LNWHSilverlink', 'CM_TrtmntFnc501'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT41', 'LNWHSilverlink', 'CM_TrtmntFnc653'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT43', 'LNWHSilverlink', 'CM_TrtmntFnc100'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT44', 'LNWHSilverlink', 'CM_TrtmntFnc653'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT47', 'LNWHSilverlink', 'CM_TrtmntFnc303'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT49', 'LNWHSilverlink', 'CM_TrtmntFnc191'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT50', 'LNWHSilverlink', 'CM_TrtmntFnc503'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT51', 'LNWHSilverlink', 'CM_TrtmntFnc370'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT52', 'LNWHSilverlink', 'CM_TrtmntFnc370'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT53', 'LNWHSilverlink', 'CM_TrtmntFnc324'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT66', 'LNWHSilverlink', 'CM_TrtmntFnc192'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT86', 'LNWHSilverlink', 'CM_TrtmntFnc103'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT88', 'LNWHSilverlink', 'CM_TrtmntFnc950'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT89', 'LNWHSilverlink', 'CM_TrtmntFnc950'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT90', 'LNWHSilverlink', 'CM_TrtmntFnc657'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT92', 'LNWHSilverlink', 'CM_TrtmntFnc502'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT94', 'LNWHSilverlink', 'CM_TrtmntFnc650'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT95', 'LNWHSilverlink', 'CM_TrtmntFnc320'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EHT97', 'LNWHSilverlink', 'CM_TrtmntFnc654'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EIMOS', 'LNWHSilverlink', 'CM_TrtmntFnc140'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ENDO', 'LNWHSilverlink', 'CM_TrtmntFnc302'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ENT', 'LNWHSilverlink', 'CM_TrtmntFnc120'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'EYES', 'LNWHSilverlink', 'CM_TrtmntFnc130'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'FORENS/P', 'LNWHSilverlink', 'CM_TrtmntFnc712'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'G/COLOPR', 'LNWHSilverlink', 'CM_TrtmntFnc301'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GASTRO', 'LNWHSilverlink', 'CM_TrtmntFnc301'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GENMD-HASU', 'LNWHSilverlink', 'CM_TrtmntFnc328'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GENMD-SU', 'LNWHSilverlink', 'CM_TrtmntFnc328'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GENMED', 'LNWHSilverlink', 'CM_TrtmntFnc300'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GENPATH', 'LNWHSilverlink', 'CM_TrtmntFnc820'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GENPRAC', 'LNWHSilverlink', 'CM_TrtmntFnc300'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GENSURG', 'LNWHSilverlink', 'CM_TrtmntFnc100'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GERIMED', 'LNWHSilverlink', 'CM_TrtmntFnc430'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GERIM-OPAL', 'LNWHSilverlink', 'CM_TrtmntFnc430'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GPPHYSIO', 'LNWHSilverlink', 'CM_TrtmntFnc650'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GUM', 'LNWHSilverlink', 'CM_TrtmntFnc360'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'GYNAE', 'LNWHSilverlink', 'CM_TrtmntFnc502'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'HAEM', 'LNWHSilverlink', 'CM_TrtmntFnc303'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'HEALTHYB', 'LNWHSilverlink', 'CM_TrtmntFnc424'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'HISTOPAT', 'LNWHSilverlink', 'CM_TrtmntFnc824'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'IMC', 'LNWHSilverlink', 'CM_TrtmntFnc318'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'IMMUN', 'LNWHSilverlink', 'CM_TrtmntFnc316'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'IMMUPATH', 'LNWHSilverlink', 'CM_TrtmntFnc316'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'IMOS', 'LNWHSilverlink', 'CM_TrtmntFnc140'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'INF/MED', 'LNWHSilverlink', 'CM_TrtmntFnc301'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'INF/SURG', 'LNWHSilverlink', 'CM_TrtmntFnc104'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'INFDIS', 'LNWHSilverlink', 'CM_TrtmntFnc350'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'IRADIO', 'LNWHSilverlink', 'CM_TrtmntFnc811'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ITUMED', 'LNWHSilverlink', 'CM_TrtmntFnc192'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'M/THERAPY', 'LNWHSilverlink', 'CM_TrtmntFnc661'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'MEDONC', 'LNWHSilverlink', 'CM_TrtmntFnc370'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'MEDOPHTH', 'LNWHSilverlink', 'CM_TrtmntFnc460'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'MEDVIRO', 'LNWHSilverlink', 'CM_TrtmntFnc834'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'MENTHAND', 'LNWHSilverlink', 'CM_TrtmntFnc700'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'MENTILL', 'LNWHSilverlink', 'CM_TrtmntFnc710'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'MIC', 'LNWHSilverlink', 'CM_TrtmntFnc833'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'MIDWIFE', 'LNWHSilverlink', 'CM_TrtmntFnc560'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'NELENT', 'LNWHSilverlink', 'CM_TrtmntFnc120'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'NEONAT', 'LNWHSilverlink', 'CM_TrtmntFnc422'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'NEPHRO', 'LNWHSilverlink', 'CM_TrtmntFnc361'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'NEURO', 'LNWHSilverlink', 'CM_TrtmntFnc400'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'NEUROSUR', 'LNWHSilverlink', 'CM_TrtmntFnc150'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'NPY', 'LNWHSilverlink', 'CM_TrtmntFnc401'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'NUCLEAR', 'LNWHSilverlink', 'CM_TrtmntFnc371'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'OBS', 'LNWHSilverlink', 'CM_TrtmntFnc501'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'OBS PN', 'LNWHSilverlink', 'CM_TrtmntFnc501'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'OBSAN', 'LNWHSilverlink', 'CM_TrtmntFnc501'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'OBSCS', 'LNWHSilverlink', 'CM_TrtmntFnc501'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'OCCU/MED', 'LNWHSilverlink', 'CM_TrtmntFnc901'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'OMFS', 'LNWHSilverlink', 'CM_TrtmntFnc145'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'OPTO', 'LNWHSilverlink', 'CM_TrtmntFnc662'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'ORTHOTIC', 'LNWHSilverlink', 'CM_TrtmntFnc658'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAED', 'LNWHSilverlink', 'CM_TrtmntFnc420'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAED/COMM', 'LNWHSilverlink', 'CM_TrtmntFnc290'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDCARD', 'LNWHSilverlink', 'CM_TrtmntFnc321'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDCF', 'LNWHSilverlink', 'CM_TrtmntFnc264'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDCLINIA', 'LNWHSilverlink', 'CM_TrtmntFnc255'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDDENT', 'LNWHSilverlink', 'CM_TrtmntFnc142'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDDERM', 'LNWHSilverlink', 'CM_TrtmntFnc257'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDDM', 'LNWHSilverlink', 'CM_TrtmntFnc263'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDENDO', 'LNWHSilverlink', 'CM_TrtmntFnc252'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDGASTRO', 'LNWHSilverlink', 'CM_TrtmntFnc213'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDINFD', 'LNWHSilverlink', 'CM_TrtmntFnc256'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDMEDONC', 'LNWHSilverlink', 'CM_TrtmntFnc260'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDNEPHRO', 'LNWHSilverlink', 'CM_TrtmntFnc259'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDNEUR', 'LNWHSilverlink', 'CM_TrtmntFnc421'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDNEUROD', 'LNWHSilverlink', 'CM_TrtmntFnc291'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDOT', 'LNWHSilverlink', 'CM_TrtmntFnc651'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDPT', 'LNWHSilverlink', 'CM_TrtmntFnc650'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDRESM', 'LNWHSilverlink', 'CM_TrtmntFnc258'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDRHEUM', 'LNWHSilverlink', 'CM_TrtmntFnc262'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDS', 'LNWHSilverlink', 'CM_TrtmntFnc420'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDSLT', 'LNWHSilverlink', 'CM_TrtmntFnc652'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAEDSURG', 'LNWHSilverlink', 'CM_TrtmntFnc171'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PAINMAN', 'LNWHSilverlink', 'CM_TrtmntFnc191'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PALL/MED', 'LNWHSilverlink', 'CM_TrtmntFnc315'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PHTSIO', 'LNWHSilverlink', 'CM_TrtmntFnc650'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PHYSIORR', 'LNWHSilverlink', 'CM_TrtmntFnc650'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PLASURG', 'LNWHSilverlink', 'CM_TrtmntFnc160'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PODIATRY', 'LNWHSilverlink', 'CM_TrtmntFnc653'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'POSTCOVID', 'LNWHSilverlink', 'CM_TrtmntFnc348'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PPR', 'LNWHSilverlink', 'CM_TrtmntFnc342'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PROS', 'LNWHSilverlink', 'CM_TrtmntFnc657'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PSYCHO', 'LNWHSilverlink', 'CM_TrtmntFnc713'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PSYCHO/T', 'LNWHSilverlink', 'CM_TrtmntFnc713'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'PSYGERI', 'LNWHSilverlink', 'CM_TrtmntFnc715'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'RADIO', 'LNWHSilverlink', 'CM_TrtmntFnc812'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'REHAB', 'LNWHSilverlink', 'CM_TrtmntFnc314'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'RESDENT', 'LNWHSilverlink', 'CM_TrtmntFnc141'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'RESPHYS', 'LNWHSilverlink', 'CM_TrtmntFnc341'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'RHEUM', 'LNWHSilverlink', 'CM_TrtmntFnc410'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'RHEUM/RE', 'LNWHSilverlink', 'CM_TrtmntFnc410'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'RHEUMRES', 'LNWHSilverlink', 'CM_TrtmntFnc410'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'RHEUMRR', 'LNWHSilverlink', 'CM_TrtmntFnc410'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'S/COLOPR', 'LNWHSilverlink', 'CM_TrtmntFnc104'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'SP/CARE', 'LNWHSilverlink', 'CM_TrtmntFnc422'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'SPEECH', 'LNWHSilverlink', 'CM_TrtmntFnc652'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'SPORT/EM', 'LNWHSilverlink', 'CM_TrtmntFnc325'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'STOMA', 'LNWHSilverlink', 'CM_TrtmntFnc104'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'STROKE/MED', 'LNWHSilverlink', 'CM_TrtmntFnc328'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'THORMED', 'LNWHSilverlink', 'CM_TrtmntFnc340'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'TIA', 'LNWHSilverlink', 'CM_TrtmntFnc329'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'TR/ORTHO', 'LNWHSilverlink', 'CM_TrtmntFnc110'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'TRANSURG', 'LNWHSilverlink', 'CM_TrtmntFnc102'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'TROP/MED', 'LNWHSilverlink', 'CM_TrtmntFnc352'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'UROLOGY', 'LNWHSilverlink', 'CM_TrtmntFnc101'), ('/LNWH/SLVRLNK/TRTMNT_FNCTN', 'VASSURG', 'LNWHSilverlink', 'CM_TrtmntFnc107'); -- ******************** Language ******************** -- Concepts SELECT @scm := dbid FROM concept WHERE id = 'LNWHSilverlink'; INSERT IGNORE INTO concept (document, id, scheme, code, name, description) VALUES (1, 'LNWH_SL_Lng_OTH', @scm, 'LNWH_SL_Lng_OTH', 'Other', 'Other'), -- New 12/05/2022 - ADTS-149 (1, 'LNWH_SL_Lng_UNK', @scm, 'LNWH_SL_Lng_UNK', 'Unknown', 'Unknown'), -- New 12/05/2022 - ADTS-149 (1, 'LNWH_SL_Lng_ROMA', @scm, 'LNWH_SL_Lng_ROMA', 'Roma', 'Roma'), -- New 12/05/2022 - ADTS-149 (1, 'LNWH_SL_Lng_DEA', @scm, 'LNWH_SL_Lng_DEA', 'Dea', 'Dea'), -- New 12/05/2022 - ADTS-149 (1, 'LNWH_SL_Lng_DARI', @scm, 'LNWH_SL_Lng_DARI', 'Dari', 'Dari'); -- New 12/05/2022 - ADTS-149 -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'language', '/LNWH/SLVRLNK/LNGG'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/LNWH/SLVRLNK/LNGG', 'DM_language'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/LNWH/SLVRLNK/LNGG', 'ARA', 'LNWHSilverlink', 'FHIR_LANG_ar'), ('/LNWH/SLVRLNK/LNGG', 'BENG', 'LNWHSilverlink', 'FHIR_LANG_bn'), ('/LNWH/SLVRLNK/LNGG', 'GER', 'LNWHSilverlink', 'FHIR_LANG_de'), ('/LNWH/SLVRLNK/LNGG', 'GRE', 'LNWHSilverlink', 'FHIR_LANG_el'), ('/LNWH/SLVRLNK/LNGG', 'ENG', 'LNWHSilverlink', 'FHIR_LANG_en'), ('/LNWH/SLVRLNK/LNGG', 'SPA', 'LNWHSilverlink', 'FHIR_LANG_es'), ('/LNWH/SLVRLNK/LNGG', 'FRE', 'LNWHSilverlink', 'FHIR_LANG_fr'), ('/LNWH/SLVRLNK/LNGG', 'GUJ', 'LNWHSilverlink', 'FHIR_LANG_gu'), ('/LNWH/SLVRLNK/LNGG', 'HEB', 'LNWHSilverlink', 'FHIR_LANG_he'), ('/LNWH/SLVRLNK/LNGG', 'HIN', 'LNWHSilverlink', 'FHIR_LANG_hi'), ('/LNWH/SLVRLNK/LNGG', 'ITI', 'LNWHSilverlink', 'FHIR_LANG_it'), ('/LNWH/SLVRLNK/LNGG', 'JAP', 'LNWHSilverlink', 'FHIR_LANG_ja'), ('/LNWH/SLVRLNK/LNGG', 'KOR', 'LNWHSilverlink', 'FHIR_LANG_ko'), ('/LNWH/SLVRLNK/LNGG', 'DUT', 'LNWHSilverlink', 'FHIR_LANG_nl'), ('/LNWH/SLVRLNK/LNGG', 'PUN', 'LNWHSilverlink', 'FHIR_LANG_pa'), ('/LNWH/SLVRLNK/LNGG', 'POL', 'LNWHSilverlink', 'FHIR_LANG_pl'), ('/LNWH/SLVRLNK/LNGG', 'PASH', 'LNWHSilverlink', 'FHIR_LANG_ps'), ('/LNWH/SLVRLNK/LNGG', 'POR', 'LNWHSilverlink', 'FHIR_LANG_pt'), ('/LNWH/SLVRLNK/LNGG', 'RUSS', 'LNWHSilverlink', 'FHIR_LANG_ru'), ('/LNWH/SLVRLNK/LNGG', 'SING', 'LNWHSilverlink', 'FHIR_LANG_si'), ('/LNWH/SLVRLNK/LNGG', 'SOM', 'LNWHSilverlink', 'FHIR_LANG_so'), ('/LNWH/SLVRLNK/LNGG', 'ALB', 'LNWHSilverlink', 'FHIR_LANG_sq'), ('/LNWH/SLVRLNK/LNGG', 'SWAH', 'LNWHSilverlink', 'FHIR_LANG_sw'), ('/LNWH/SLVRLNK/LNGG', 'TAM', 'LNWHSilverlink', 'FHIR_LANG_ta'), ('/LNWH/SLVRLNK/LNGG', 'TURK', 'LNWHSilverlink', 'FHIR_LANG_tr'), ('/LNWH/SLVRLNK/LNGG', 'URD', 'LNWHSilverlink', 'FHIR_LANG_ur'), ('/LNWH/SLVRLNK/LNGG', 'VIE', 'LNWHSilverlink', 'FHIR_LANG_vi'), ('/LNWH/SLVRLNK/LNGG', 'DBSL', 'LNWHSilverlink', 'FHIR_LANG_q4'), ('/LNWH/SLVRLNK/LNGG', 'NEPA', 'LNWHSilverlink', 'FHIR_LANG_ne'), -- New 12/05/2022 - ADTS-149 ('/LNWH/SLVRLNK/LNGG', 'FARS', 'LNWHSilverlink', 'FHIR_LANG_fa'), -- New 12/05/2022 - ADTS-149 -- Local ('/LNWH/SLVRLNK/LNGG', 'OTH', 'LNWHSilverlink', 'LNWH_SL_Lng_OTH'), -- New 12/05/2022 - ADTS-149 ('/LNWH/SLVRLNK/LNGG', 'UNK', 'LNWHSilverlink', 'LNWH_SL_Lng_UNK'), -- New 12/05/2022 - ADTS-149 ('/LNWH/SLVRLNK/LNGG', 'ROMA', 'LNWHSilverlink', 'LNWH_SL_Lng_ROMA'), -- New 12/05/2022 - ADTS-149 ('/LNWH/SLVRLNK/LNGG', 'DEA', 'LNWHSilverlink', 'LNWH_SL_Lng_DEA'), -- New 12/05/2022 - ADTS-149 ('/LNWH/SLVRLNK/LNGG', 'DARI', 'LNWHSilverlink', 'LNWH_SL_Lng_DARI'); -- New 12/05/2022 - ADTS-149 -- ******************** Encounter ******************** -- Concepts SELECT @scm := dbid FROM concept WHERE id = 'LNWHSilverlink'; INSERT IGNORE INTO concept (document, id, scheme, code, name, description) VALUES (1, 'LNWH_SL_Enc_DayCase', @scm, 'LNWH_SL_Enc_DayCase', 'Day case', 'Day case'), (1, 'LNWH_SL_Enc_Inpatient', @scm, 'LNWH_SL_Enc_Inpatient', 'Inpatient', 'Inpatient'), (1, 'LNWH_SL_Enc_Maternity', @scm, 'LNWH_SL_Enc_Maternity', 'Maternity', 'Maternity'), (1, 'LNWH_SL_Enc_Newborn', @scm, 'LNWH_SL_Enc_Newborn', 'Newborn', 'Newborn'), (1, 'LNWH_SL_Enc_RegRDayAdm', @scm, 'LNWH_SL_Enc_RegRDayAdm', 'Regular day admission', 'Regular day admission'), (1, 'LNWH_SL_Enc_RegNghtAdm', @scm, 'LNWH_SL_Enc_RegNghtAdm', 'Regular night admission', 'Regular night admission'), (1, 'LNWH_SL_Enc_DirectRef', @scm, 'LNWH_SL_Enc_DirectRef', 'Direct referral', 'Direct referral'), (1, 'LNWH_SL_Enc_Emergency', @scm, 'LNWH_SL_Enc_Emergency', 'Emergency department', 'Emergency department'), (1, 'LNWH_SL_Enc_Outpatient', @scm, 'LNWH_SL_Enc_Outpatient', 'Outpatient', 'Outpatient'), (1, 'LNWH_SL_Enc_DCWL', @scm, 'LNWH_SL_Enc_DCWL', 'Day case waiting list', 'Day case waiting list'), (1, 'LNWH_SL_Enc_PreReg', @scm, 'LNWH_SL_Enc_PreReg', 'Preregistration', 'Preregistration'), (1, 'LNWH_SL_Enc_IPWL', @scm, 'LNWH_SL_Enc_IPWL', 'Inpatient waiting list', 'Inpatient waiting list'), (1, 'LNWH_SL_Enc_PreAdmit', @scm, 'LNWH_SL_Enc_PreAdmit', 'Outpatient registration', 'Outpatient registration'), (1, 'LNWH_SL_Enc_OPReferral', @scm, 'LNWH_SL_Enc_OPReferral', 'Outpatient referral', 'Outpatient referral'); -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_LNWH', 'CM_Sys_Silverlink', null, null, 'encounter_type', '/LNWH/SLVRLNK/ENCNTR_TYP'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/LNWH/SLVRLNK/ENCNTR_TYP', 'DM_admissionPatientClassification'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/LNWH/SLVRLNK/ENCNTR_TYP', 'DAYCASE', 'LNWHSilverlink', 'LNWH_SL_Enc_DayCase'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'INPATIENT', 'LNWHSilverlink', 'LNWH_SL_Enc_Inpatient'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'MATERNITY', 'LNWHSilverlink', 'LNWH_SL_Enc_Maternity'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'NEWBORN', 'LNWHSilverlink', 'LNWH_SL_Enc_Newborn'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'REGRDAYADM', 'LNWHSilverlink', 'LNWH_SL_Enc_RegRDayAdm'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'REGNGHTADM', 'LNWHSilverlink', 'LNWH_SL_Enc_RegNghtAdm'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'DIRECTREF', 'LNWHSilverlink', 'LNWH_SL_Enc_DirectRef'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'EMERGENCY', 'LNWHSilverlink', 'LNWH_SL_Enc_Emergency'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'OUTPATIENT', 'LNWHSilverlink', 'LNWH_SL_Enc_Outpatient'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'DCWL', 'LNWHSilverlink', 'LNWH_SL_Enc_DCWL'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'PREREG', 'LNWHSilverlink', 'LNWH_SL_Enc_PreReg'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'IPWL', 'LNWHSilverlink', 'LNWH_SL_Enc_IPWL'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'PREADMIT', 'LNWHSilverlink', 'LNWH_SL_Enc_PreAdmit'), ('/LNWH/SLVRLNK/ENCNTR_TYP', 'OPREFERRAL', 'LNWHSilverlink', 'LNWH_SL_Enc_OPReferral');
add jar /user/cloudland/apps/event-collect/client/brickhouse-0.7.1-SNAPSHOT.jar; CREATE TEMPORARY FUNCTION collect AS 'brickhouse.udf.collect.CollectUDAF'; CREATE TEMPORARY FUNCTION map_filter_keys_pattern AS 'brickhouse.udf.collect.MapFilterKeyPatternUDF'; set hbase.mapred.outputtable="device_day_metric_new"; --explain insert into table scloud_phone.device_day_metric ( key, music_download, wallpaper_download,wallpaper_set, eui_apps_special_detail, eui_apps_all_event, device_other_apps_crash_count, device_other_apps_install,device_other_apps_upgrade,device_other_apps_uninstall, device_other_apps_active_time, device_other_apps_active_count,device_other_apps_basic ) select named_struct('month', substr('20151124', 1, 6), 'day_imei', concat_ws('', '20151124', imei)) as key, event_map['euiapp_Music_download'], event_map['euiapp_Wallpaper_download'], event_map['euiapp_Wallpaper_set'], map('', cast('-1' as bigint)), map_filter_keys_pattern(event_map, 'euiapp', true) euiapp_event, map_filter_keys_pattern(event_map, '_install', false) as all_app_install, map_filter_keys_pattern(event_map, '_upgrade', false) as all_app_upgrade, map_filter_keys_pattern(event_map, '_uninstall', false) as all_app_uninstall, map('', cast('-1' as bigint)), map('', cast('-1' as bigint)), map('', cast('-1' as bigint)), map('', cast('-1' as bigint)) from (select imei, collect(full_name, count_value) as event_map from (select case when length(imei) = 1 then props["imei"] else imei end as imei, concat_ws('_', nvl(props["packageName"], 'euiapp'), app_name, event_id) as full_name, count(imei) as count_value from dwd.dwd_flow_sdk_phone_event_day where dt = '20151124' and imei is not null --and length(imei) = 15 --and imei = '868256026946797' --and imei = '866479021496608' and app_name is not null and event_id is not null group by imei,event_id,app_name,props["packageName"],props["imei"] ) group_table where full_name not in ('euiapp_PMS_APP_install', 'euiapp_PMS_APP_uninstall', 'euiapp_PMS_APP_upgrade') group by imei ) category_table
SELECT --消込履歴詳細.入金結果フラグ N.TRANSFER_RESULT_FLG, --消込履歴詳細.消込失敗フラグ N.NEGATION_FAIL_FLG, --消込履歴詳細.ワーニングフラグ N.WARN_FLG, --契約情報.売主_取引先コード CI.AGENCY_CUST_CODE, --契約情報.売主_取引先名 CI.AGENCY_NAME, --契約情報.顧客_取引先コード CI.CUSTOMER_CODE, --契約情報.顧客_取引先名 CI.CUSTOMER_NAME, --契約情報.顧客_引落口座番号 CI.CUSTOMER_ACCOUNT_NO, --A.回収通貨 R.CURRENCY_ID AS CURRENCY_ID, --消込履歴詳細.契約番号 N.CONTRACT_NO, --消込履歴詳細.回数 N.COUPON, --R.回収予定日 R.WITHDRAW_SCHEDULE_DATE, --R.回収予定額 R.WITHDRAW_SCHEDULE_AMOUNT, --消込履歴詳細.回収実績日 N.WITHDRAW_RESULT_DATE, --消込履歴詳細.回収実績額 N.TRANSFER_AMOUNT, --消込履歴詳細.回収事由 N.WITHDRAW_CASUS, --消込履歴詳細.回収事由対応するコード名称 C.CODE_NAME AS WITHDRAW_CASUS_NAME, --A.実回収方法 C1.CODE_NAME AS REAL_WITHDRAW_METHOD, --銀行支店名 AC.BANK_BRANCH_NAME, --消込履歴詳細.消込結果理由 N.TRANSFER_NEGATION_FAIL_REASON, --回収事由用回収予定日 R.WITHDRAW_SCHEDULE_DATE AS WITHDRAW_CAUSU_DATE FROM --消込履歴詳細 NEGATION_HISTORY_DETAIL_INFO N INNER JOIN VIEW_REQUST_INFO R ON --請求情報VIEW.契約番号 = 消込履歴詳細.契約番 R.CONTRACT_NO = N.CONTRACT_NO --請求情報VIEW.回数 = 消込履歴詳細.回数 AND ( ( R.COUPON IS NOT NULL AND R.COUPON = N.COUPON ) OR( R.COUPON IS NULL AND N.COUPON IS NULL ) ) --請求回収情報.回数連番 = 消込履歴詳細.回数連番 AND ( ( R.COUPON_SEQ IS NOT NULL AND R.COUPON_SEQ = N.COUPON_SEQ ) OR( R.COUPON_SEQ IS NULL AND N.COUPON_SEQ IS NULL ) ) AND --消込履歴詳細.ファイルID = パラメタ.消込履歴ID N.FILE_ID = /*negationHistoryId*/'' AND --消込履歴詳細.回収事由 = 請求情報VIEW.回収事由 N.WITHDRAW_CASUS = R.WITHDRAW_CASUS LEFT JOIN --契約情報 CONTRACT_INFO CI ON --契約情報.契約番号 = 消込履歴詳細.契約番号 CI.CONTRACT_NO = N.CONTRACT_NO LEFT JOIN --口座マスタ ACCOUNT_INFO AC ON --口座情報マスタ.口座番号 = 請求回収情報.予定回収口座番号 AC.ACCOUNT_NO = R.REAL_WITHDRAW_ACCOUNT_NO AND --口座情報マスタ.取引先コード = 契約情報.拠点コード AC.CUSTOMER_CODE = CI.CHARGE_AGENCY LEFT JOIN --コードマスタ CODE_MASTER C ON C.CODE_TYPE = CAST(/*codeMstKbn*/'' AS CHAR(3)) AND N.WITHDRAW_CASUS = C.CODE_ID AND C.COUNTRY_ID = /*countryId*/ LEFT JOIN --コードマスタ CODE_MASTER C1 ON C1.CODE_TYPE = CAST(/*codeRealMethod*/'' AS CHAR(3)) AND C1.CODE_ID = R.REAL_WITHDRAW_METHOD AND C1.COUNTRY_ID = /*countryId*/ ORDER BY --消込履歴詳細.入金結果フラグ N.TRANSFER_RESULT_FLG ASC, --消込履歴詳細.消込失敗フラグ N.NEGATION_FAIL_FLG ASC, --消込履歴詳細.ワーニングフラグ N.WARN_FLG ASC, --契約情報.売主_取引先コード CI.AGENCY_CUST_CODE ASC, --契約情報.顧客_取引先コード CI.CUSTOMER_CODE ASC, --消込履歴詳細.契約番号 N.CONTRACT_NO ASC, --消込履歴詳細.回収事由 N.WITHDRAW_CASUS DESC, --消込履歴詳細.回数 N.COUPON ASC
--// add FacebookPost fields: name,caption -- Migration SQL that makes the change goes here. alter table FacebookPost add name varchar(255) not null, add caption varchar(1024) not null; --//@UNDO -- SQL to undo the change goes here. alter table FacebookPost drop name, drop caption;
#sql("getFavoriteGroupTypeByName") select * from favorite_group_type where favoriteGroupName = #para(favoriteGroupName) #end #sql("getFavoriteGroupTypeById") select * from favorite_group_type where favoriteGroupId = #para(favoriteGroupId) #end #sql("getFavoriteGroup") select * from favorite_group where userId = #para(userId) and favoriteGroupId = #para(favoriteGroupId) #end #sql("getFavoriteGroupByGroupName") select * from favorite_group where userId = #para(userId) and favoriteGroupId = ( select favoriteGroupId from favorite_group_type where favoriteGroupName = #para(favoriteGroupName) ) #end #sql("getMinRankWeightFromFavoriteGroup") select min(rankWeight) from favorite_group where userId = ? #end #sql("getFavoriteGroupName") select distinct favorite_group_type.favoriteGroupName, favorite_group_type.favoriteGroupId, favorite_group.rankWeight from favorite_group_type, favorite_group where favorite_group_type.favoriteGroupId = favorite_group.favoriteGroupId and favorite_group.userId = #para(userId) order by favorite_group.rankWeight desc ; #end #sql("countAllFavoriteStock") select count(*) from favorite_stock where userId = ? ; #end #sql("countSpecialFavoriteStock") select count(*) from favorite_stock where userId = ? and specialAttention = true; #end #sql("countFavoriteStock") select count(*) from favorite_stock where userId = ? and favoriteGroupId = ?; #end #sql("deleteFavoriteGroupByGroupId") delete from favorite_group where userId = ? and favoriteGroupId = ? #end #sql("deleteFavoriteGroupByGroupName") delete from favorite_group where userId = ? and favoriteGroupId = ( select favoriteGroupId from favorite_group_type where favoriteGroupName = ?; #end #sql("getFavoriteStocks") select stockTableId, rankWeight, specialAttention from favorite_stock where userId = #para(userId) and favoriteGroupId = #para(favoriteGroupId) order by rankWeight desc; #end #sql("getAllFavoriteStocks") select stockTableId, rankWeight, specialAttention from favorite_stock where userId = #para(userId) order by rankWeight desc; #end #sql("getSpecialFavoriteStocks") select stockTableId, rankWeight, specialAttention from favorite_stock where userId = #para(userId) and specialAttention <> 0 order by rankWeight desc; #end #sql("getExistentFavoriteStock") select * from favorite_stock where userId = #para(userId) and stockTableId = #para(stockTableId); #end #sql("getExistentFavoriteStockFromFavoriteGroup") select * from favorite_stock where userId = #para(userId) and favoriteGroupId = #para(favoriteGroupId) and stockTableId = #para(stockTableId); #end #sql("getMinRankWeightFromFavoriteStock") select min(rankWeight) from favorite_stock where userId = ? #end #sql("getMaxRankWeightFromFavoriteStock") select max(rankWeight) from favorite_stock where userId = ? #end #sql("deleteFavoriteStock") delete from favorite_stock where userId = ? and favoriteGroupId = ? and stockTableId = ?; #end #sql("deleteFavoriteStockFromAllGroup") delete from favorite_stock where userId = ? and stockTableId = ?; #end #sql("setSpecialFavoriteStock") update favorite_stock set specialAttention = #para(specialAttention) where userId = #para(userId) and stockTableId = #para(stockTableId) #end #sql("setFavoriteStockTop") update favorite_stock set rankWeight = #para(rankWeight) where userId = #para(userId) and stockTableId = #para(stockTableId) #end #sql("getFavoriteStockMaxRankWeight") select max(rankWeight) from favorite_stock where userId = (select userId from user where phone = ? or email = ? or userId = ? ) #end
DROP TABLE V_VIK_TLINE_WORK_ORDER; CREATE TABLE V_VIK_TLINE_WORK_ORDER ( USER_ID NUMBER(10) , USER_NAME VARCHAR2( CHAR) , USER_FULL_NAME VARCHAR2( CHAR) , REASON_ID NUMBER(10) , REASON_NAME VARCHAR2( CHAR) , CONSTRAINT PK_V_VIK_TLINE_WORK_ORDER PRIMARY KEY () using index tablespace indexsml )tablespace datasml; --No sequence specified for this table comment on table V_VIK_TLINE_WORK_ORDER is ''; comment on column V_VIK_TLINE_WORK_ORDER.USER_ID is ''; comment on column V_VIK_TLINE_WORK_ORDER.USER_NAME is ''; comment on column V_VIK_TLINE_WORK_ORDER.USER_FULL_NAME is ''; comment on column V_VIK_TLINE_WORK_ORDER.REASON_ID is ''; comment on column V_VIK_TLINE_WORK_ORDER.REASON_NAME is '';
ALTER TABLE `categories` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT, MODIFY `addontype_id` int(10) unsigned NOT NULL, MODIFY `application_id` int(10) unsigned DEFAULT NULL, MODIFY `weight` int(11) NOT NULL, MODIFY `created` datetime(6) NOT NULL, MODIFY `modified` datetime(6) NOT NULL, MODIFY `count` int(11) NOT NULL, MODIFY `slug` varchar(50) NOT NULL, MODIFY `misc` tinyint(1) NOT NULL;
-- MySQL dump 10.13 Distrib 5.5.59, for debian-linux-gnu (x86_64) -- -- Host: localhost Database: paper -- ------------------------------------------------------ -- Server version 5.5.59-0ubuntu0.14.04.1 /*!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 `category` -- DROP TABLE IF EXISTS `category`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `category` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `parent_id` BIGINT NOT NULL, `category` varchar(256) NOT NULL, `catrgory_name` varchar(256) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `category` -- LOCK TABLES `category` WRITE; /*!40000 ALTER TABLE `category` DISABLE KEYS */; /*!40000 ALTER TABLE `category` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `code` -- DROP TABLE IF EXISTS `code`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `code` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `paper_id` BIGINT NOT NULL, `user_id` BIGINT NOT NULL, `author` varchar(256) DEFAULT NULL, `path` varchar(45) NOT NULL, `comments` text NOT NULL, `flag` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `fk_code_1_idx` (`paper_id`), KEY `fk_code_2_idx` (`user_id`), CONSTRAINT `fk_code_1` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_code_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `code` -- LOCK TABLES `code` WRITE; /*!40000 ALTER TABLE `code` DISABLE KEYS */; /*!40000 ALTER TABLE `code` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `comments` -- DROP TABLE IF EXISTS `comments`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `comments` ( `id` BIGINT NOT NULL, `paper_id` BIGINT NOT NULL, `user_id` BIGINT NOT NULL, `comments` text NOT NULL, `time` date NOT NULL, `flag` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `fk_comments_1_idx` (`paper_id`), KEY `fk_comments_2_idx` (`user_id`), CONSTRAINT `fk_comments_1` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_comments_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `comments` -- LOCK TABLES `comments` WRITE; /*!40000 ALTER TABLE `comments` DISABLE KEYS */; /*!40000 ALTER TABLE `comments` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `history` -- DROP TABLE IF EXISTS `history`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `history` ( `id` BIGINT NOT NULL, `paper_id` BIGINT DEFAULT NULL, `user_id` BIGINT NOT NULL, `operation` varchar(256) DEFAULT NULL, `time` date DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_history_1_idx` (`paper_id`), KEY `fk_history_2_idx` (`user_id`), CONSTRAINT `fk_history_1` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_history_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `history` -- LOCK TABLES `history` WRITE; /*!40000 ALTER TABLE `history` DISABLE KEYS */; /*!40000 ALTER TABLE `history` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `paper` -- DROP TABLE IF EXISTS `paper`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `paper` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `title` varchar(256) NOT NULL, `summary` text NOT NULL, `path` varchar(256) NOT NULL, `filename` varchar(256) NOT NULL, `tag` varchar(256) NOT NULL, `author` varchar(45) NOT NULL, `download_time` int(11) NOT NULL DEFAULT '0', `category_id` BIGINT NOT NULL, `user_id` BIGINT NOT NULL, `year` date NOT NULL, `create_time` date NOT NULL, `delete_user_id` BIGINT NOT NULL, `delete_time` date NOT NULL, `rank` int(11) NOT NULL DEFAULT '3', `flag` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `fk_paper_1_idx` (`user_id`), KEY `fk_paper_2_idx` (`category_id`), KEY `fk_paper_3_idx` (`delete_user_id`), CONSTRAINT `fk_paper_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_paper_2` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_paper_3` FOREIGN KEY (`delete_user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `paper` -- LOCK TABLES `paper` WRITE; /*!40000 ALTER TABLE `paper` DISABLE KEYS */; /*!40000 ALTER TABLE `paper` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `rank` -- DROP TABLE IF EXISTS `rank`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `rank` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `paper_id` BIGINT NOT NULL, `user_id` BIGINT NOT NULL, `rank` int(11) NOT NULL, `time` date NOT NULL, PRIMARY KEY (`id`), KEY `fk_rank_1_idx` (`paper_id`), KEY `fk_rank_2_idx` (`user_id`), CONSTRAINT `fk_rank_1` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_rank_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `rank` -- LOCK TABLES `rank` WRITE; /*!40000 ALTER TABLE `rank` DISABLE KEYS */; /*!40000 ALTER TABLE `rank` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `subscribe` -- DROP TABLE IF EXISTS `subscribe`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `subscribe` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `paper_id` BIGINT NOT NULL, `user_id` BIGINT NOT NULL, PRIMARY KEY (`id`), KEY `fk_subscribe_1_idx` (`paper_id`), KEY `fk_subscribe_2_idx` (`user_id`), CONSTRAINT `fk_subscribe_1` FOREIGN KEY (`paper_id`) REFERENCES `paper` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_subscribe_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `subscribe` -- LOCK TABLES `subscribe` WRITE; /*!40000 ALTER TABLE `subscribe` DISABLE KEYS */; /*!40000 ALTER TABLE `subscribe` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `user` -- DROP TABLE IF EXISTS `user`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `user` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `username` varchar(45) NOT NULL, `email` varchar(256) NOT NULL, `remarks` text NOT NULL, `role` int(11) DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `user` -- LOCK TABLES `user` WRITE; /*!40000 ALTER TABLE `user` DISABLE KEYS */; /*!40000 ALTER TABLE `user` 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-26 12:19:27
-- MySQL dump 10.13 Distrib 5.7.24, for osx10.14 (x86_64) -- -- Host: localhost Database: hackerrank_15_days -- ------------------------------------------------------ -- Server version 5.7.24 /*!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 `hackers` -- DROP TABLE IF EXISTS `hackers`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `hackers` ( `hacker_id` int(11) NOT NULL, `name` varchar(33) COLLATE utf8_swedish_ci NOT NULL, PRIMARY KEY (`hacker_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `hackers` -- LOCK TABLES `hackers` WRITE; /*!40000 ALTER TABLE `hackers` DISABLE KEYS */; INSERT INTO `hackers` VALUES (15758,'rose'),(20703,'angela'),(38289,'patrick'),(39396,'frank'),(44065,'lisa'),(53473,'kimberly'),(62529,'bonnie'),(79722,'michael'); /*!40000 ALTER TABLE `hackers` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `submissions` -- DROP TABLE IF EXISTS `submissions`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `submissions` ( `submission_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `submission_id` int(11) NOT NULL, `hacker_id` int(11) NOT NULL, `score` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `submissions` -- LOCK TABLES `submissions` WRITE; /*!40000 ALTER TABLE `submissions` DISABLE KEYS */; INSERT INTO `submissions` VALUES ('2016-03-01 08:00:00',8494,20703,0),('2016-03-01 08:00:00',22403,53473,15),('2016-03-01 08:00:00',23965,79722,60),('2016-03-01 08:00:00',30173,36396,70),('2016-03-02 08:00:00',34928,20703,0),('2016-03-02 08:00:00',38740,15758,60),('2016-03-02 08:00:00',42769,79722,25),('2016-03-02 08:00:00',44364,79722,60),('2016-03-03 08:00:00',45440,20703,0),('2016-03-03 08:00:00',49050,36396,70),('2016-03-03 08:00:00',50273,79722,5),('2016-03-04 08:00:00',50344,20703,0),('2016-03-04 08:00:00',51360,44065,90),('2016-03-04 08:00:00',54404,53473,65),('2016-03-04 08:00:00',61533,79722,45),('2016-03-05 08:00:00',72852,20703,0),('2016-03-05 08:00:00',74546,38289,0),('2016-03-05 08:00:00',76487,62529,0),('2016-03-05 08:00:00',82439,36396,10),('2016-03-05 08:00:00',90006,36396,40),('2016-03-06 08:00:00',90404,20703,0); /*!40000 ALTER TABLE `submissions` 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 2019-04-05 9:15:01
PARAMETERS [@AñoID] Text ( 4 ), [@MesID] Text (2); SELECT C.NombreCompleto, D.SituacionLaboralNombre, E.Fecha, (A.RemuneracionVacacional+A.Bonificaciones+A.OtrosInafecto+A.OtrosConceptos+A.Indemnizacion-A.Retencion-A.Prestamo-A.Adelanto-A.RetencionAlimento-A.SistemaPensionarioValor-A.AporteAgrario-A.AporteEssalud) AS Neto, F.SeguroNombre, (H.Fecha-G.Fecha) AS Dias FROM ((((((TB_Vacaciones AS A LEFT JOIN TB_Fecha AS B ON A.FechaEmisionID = B.FechaID) LEFT JOIN TB_Trabajador AS C ON A.TrabajadorID = C.TrabajadorID) LEFT JOIN TB_SituacionLaboral AS D ON A.SituacionLaboralID = D.SituacionLaboralID) LEFT JOIN TB_Fecha AS E ON A.FechaEmisionID = E.FechaID) LEFT JOIN TB_Seguro AS F ON A.SistemaPensionarioID = F.SeguroID) LEFT JOIN TB_Fecha AS G ON A.DescansoInicioID = G.FechaID) LEFT JOIN TB_Fecha AS H ON A.DescansoFinID = H.FechaID WHERE (B.AñoID=[@AñoID] OR [@AñoID] is NULL) AND (B.MesID=[@MesID] OR [@MesID] IS NULL);
INSERT INTO materia(id, nombre) VALUES (1, 'Derecho Administrativo'), (2, 'Derecho Constitucional'), (3, 'Derecho Comercial'), (4, 'Derecho Corporativo'), (5, 'Propiedad Intelectual'), (6, 'Derecho de Autor'), (7, 'Derecho Civil'), (8, 'Derecho Laboral'), (9, 'Derecho Migratorio'), (10, 'Condominios'), (11, 'Derecho Sucesoral'), (12, 'Asociaciones Sin Fines de Lucro'), (13, 'Derecho Ambiental'), (14, 'Derecho Inmobiliario'), (15, 'Otras Materias'), (16, 'Descarga de Documentos Modelo'), (17, 'Representación Legal'), (18, 'Consultoría'), (19, 'Diligencias Legales'), (20, 'Elaboración y Redacción'), (21, 'Representación Legal Vial y con Aseguradoras') ;
CREATE PROCEDURE query_employee (p_id IN employees.employee_id%TYPE, p_name OUT employees.last_name%TYPE, p_salary OUT employees.salary%TYPE, p_comm OUT employees.commission_pct%TYPE) AUTHID CURRENT_USER IS BEGIN SELECT last_name, salary, commission_pct INTO p_name, p_salary, p_comm FROM employees WHERE employee_id=p_id; END query_employee; /
SELECT facid, name, round("Total Minutes" / 60::decimal,2) FROM (SELECT facid, name, sum(minutes) AS "Total Minutes" FROM (SELECT f.facid, name, slots, slots * 30 AS "minutes" FROM cd.bookings AS b JOIN cd.facilities AS f ON b.facid = f.facid) as s GROUP BY facid, name ORDER BY facid) as s2
create table award_report_terms_bk as select * from award_report_terms where award_number = '000000-00000'; select count(*) from award_report_terms_bk; select a.award_number,t.award_number from award_report_terms t, award a where a.award_id = t.award_id and t.award_number = '000000-00000'; update award_report_terms art set award_number = (select award_number from award where art.award_id = award.award_id) where art.award_number = '000000-00000'; select a.award_number,t.award_number from award_report_terms t, award a where a.award_id = t.award_id and a.award_number != t.award_number;
/* Finds the actors a given actor has played together in the most shows. * Tags: * actor_id: The actor ID */ SELECT name AS similar_actor_name, actor_id AS similar_actor_id, COUNT(1) AS similar_actor_count FROM played_in INNER JOIN actors ON actors.id = played_in.actor_id WHERE show_id IN ( SELECT show_id FROM played_in WHERE actor_id = :actor_id ) AND actor_id <> :actor_id GROUP BY actor_id HAVING similar_actor_count > 1 ORDER BY similar_actor_count DESC LIMIT 10
--NOTHING TO DO HERE
-- 取消されたWHT情報を取得 SELECT T.* FROM ( SELECT A.WHT_FLG,A.WHT_RATE, -- 2016/10/17 PDC対応 add start SUM(A.TRANSFER_AMOUNT) OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS) AS TRANSFER_AMOUNT, SUM(A.PRINCIPAL_RESULT_AMOUNT) OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS) AS PRINCIPAL_RESULT_AMOUNT, SUM(A.VAT_PRINCIPAL_RESULT_AMOUNT) OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS) AS VAT_PRINCIPAL_RESULT_AMOUNT, SUM(A.INTEREST_RESULT_AMOUNT) OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS) AS INTEREST_RESULT_AMOUNT, SUM(A.VAT_INTEREST_RESULT_AMOUNT) OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS) AS VAT_INTEREST_RESULT_AMOUNT, -- 2016/10/17 PDC対応 add end SUM(A.WHT_AMOUNT) OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS) AS WHT_AMOUNT, -- 2016/08/25 手動入金消込画面 源泉税追加対応 add start SUM(ISNULL(A.NET_WITHDRAW_RESULT_AMOUNT,0)) OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS) AS NET_WITHDRAW_RESULT_AMOUNT, -- 2016/08/25 手動入金消込画面 源泉税追加対応 add end ROW_NUMBER() OVER(PARTITION BY A.CONTRACT_NO,A.WITHDRAW_CASUS ORDER BY A.MODIFY_DATE DESC) AS ROWNUM FROM NEGATION_HISTORY_DETAIL_INFO AS A -- 消込履歴詳細 WHERE -- AND 契約番号 = 引数.契約番号 A.CONTRACT_NO = /*contractNo*/'' -- AND 回収種別 = 引数.回収種別 AND A.WITHDRAW_CASUS = /*withdrawCasus*/'' -- 取消フラグ=未取消 AND A.RESULT_FLG_CANCLE_FLG = /*dto.yesNoFlgNo*/'' -- AND 消込失敗フラグ = '0'  AND A.NEGATION_FAIL_FLG = /*dto.negationFailFlgOff*/'' -- AND 入金結果フラグ = 「1:成功」 AND A.TRANSFER_RESULT_FLG = CAST(/*dto.receiptResultFlgSucc*/'1' AS CHAR(1)) AND ISNULL(A.COUPON,-1) = ISNULL(/*coupon*/,-1) AND ISNULL(A.COUPON_SEQ,0) = ISNULL(/*couponSeq*/,0) AND ISNULL(A.SUPPLIES_NO,/*dto.strSuppliesNo*/'0000000000') =ISNULL(/*suppliesNo*/,/*dto.strSuppliesNo*/'0000000000') --1:入金 AND A.NEGATION_FLG=/*dto.negationFlgReceive*/'1' ) T WHERE ROWNUM = 1
#------------------------------------------------------------ # Script MySQL. #------------------------------------------------------------ #------------------------------------------------------------ # Table: UTILISATEUR #------------------------------------------------------------ CREATE TABLE UTILISATEUR( id_uti Int NOT NULL AUTO_INCREMENT, mdp Varchar (255) , nom Varchar (255) , prenom Varchar (255) , adresse Varchar (50) , cp Int(5) , tel Int(10) , mail Varchar (100) , statut BOOLEAN , mot_cle Varchar (25) , valide BOOLEAN , PRIMARY KEY (id_uti ) )ENGINE=InnoDB; #------------------------------------------------------------ # Table: ATTENTE #------------------------------------------------------------ CREATE TABLE ATTENTE( num_attente Int AUTO_INCREMENT, id_uti Int , date_debut Date , date_fin Date , PRIMARY KEY (num_attente) )ENGINE=InnoDB; #------------------------------------------------------------ # Table: RESERVER #------------------------------------------------------------ CREATE TABLE RESERVER( id_uti Int, id_place Int, date_debut Date, date_fin Date, PRIMARY KEY (id_uti, id_place) )ENGINE=InnoDB; # Variables, pour stocker le nb de place dans le parking CREATE TABLE VARIABLES( id_var INT NOT NULL AUTO_INCREMENT, nom_var varchar(255), valeur varchar(255), PRIMARY KEY (id_var) )ENGINE=InnoDB;
SELECT A.CNTRCTCD AS CONTRACT_NO, --合同编号 A.AGENCYNM AS AGENCY_NAME, --(代理商)公司名称 A.CUSTNM AS CUSTOMER_NAME, --申请人名 A.MACHINENM AS SUPPLIES_NAME, --物件名称 A.CNTRCTAMT AS WITHDRAW_SUM_TOTAL, --租赁合同总额 A.RENTPERIOD AS CONTRACT_PERIOD, --租赁期限 A.APPLYDATE AS APPLY_DATE, --申请日期 A.APPLYSN AS APPLY_SN, --申請流水号 A.APPLYCNT AS APPLY_CNT --申請回数 FROM View_Apply A WHERE NOT EXISTS ( SELECT 1 FROM (SELECT CONTRACT_NO, CANCAL_STATE FROM APPLY_INFO) AS APPLY_TB WHERE APPLY_TB.CONTRACT_NO = ( A.CNTRCTCD) COLLATE Chinese_PRC_CI_AS AND APPLY_TB.CANCAL_STATE = CAST(/*cancalState*/ AS CHAR(1)) )
-- BY: MAZEN AMRIA (PART 1) CREATE TABLE IF NOT EXISTS employee ( emp_id VARCHAR(50), -- username emp_password VARCHAR(200) NOT NULL, -- encrypted password emp_name VARCHAR(50) NOT NULL, -- real name emp_role VARCHAR(50) DEFAULT 'Unauthorized', -- [Manager|Vending Manager|Cashier|Guest|Unauthorized] emp_registration_date DATE NOT NULL, emp_status VARCHAR(50) DEFAULT 'Employed', -- [Employed|Retired|Fired] PRIMARY KEY (emp_id), CONSTRAINT CHECK (emp_role IN ('Manager', 'Vending Manager', 'Cashier', 'Guest', 'Unauthorized')), CONSTRAINT CHECK (emp_status IN ('Employed', 'Retired', 'Fired')) ); CREATE TABLE IF NOT EXISTS vendor ( vendor_id VARCHAR(50), -- vendor's email secret_key VARCHAR(128) NOT NULL UNIQUE, vendor_name VARCHAR(50), -- vendor's name vendor_location VARCHAR(50), -- vendor's country PRIMARY KEY (vendor_id) ); -- BY: AHMAD KHATIB (PART 1) CREATE TABLE IF NOT EXISTS customer ( customer_id VARCHAR(50), customer_name VARCHAR(50), date_of_birth DATE, PRIMARY KEY (customer_id) ); CREATE TABLE IF NOT EXISTS invoice_discount( discount_id INTEGER AUTO_INCREMENT, discount_percentage INTEGER NOT NULL, total_price DECIMAL(10,2), min_date DATE, max_date DATE, discount_status VARCHAR(50) DEFAULT 'فعال', PRIMARY KEY (discount_id) ); CREATE TABLE IF NOT EXISTS invoice ( invoice_id INTEGER AUTO_INCREMENT, total_price DECIMAL(10,2), invoice_time DATETIME, customer_id VARCHAR(50), cashier_id VARCHAR(50), discount_id INTEGER, PRIMARY KEY (invoice_id), FOREIGN KEY (customer_id) REFERENCES customer(customer_id), FOREIGN KEY (cashier_id) REFERENCES employee(emp_id), FOREIGN KEY (discount_id) REFERENCES invoice_discount(discount_id) ); -- BY: SARA SHAABNA CREATE TABLE IF NOT EXISTS category ( category_id VARCHAR(50), category_name VARCHAR(50), PRIMARY KEY (category_id) ); CREATE TABLE IF NOT EXISTS item ( item_id VARCHAR(200), item_name VARCHAR(50), selling_price DOUBLE, remaining_quantity INTEGER, category_id VARCHAR(50), PRIMARY KEY (item_id), FOREIGN KEY (category_id) REFERENCES category(category_id) ); CREATE TABLE IF NOT EXISTS invoice_includes_item ( quantity INTEGER NOT NULL, price_per_unit DOUBLE NOT NULL, item_id VARCHAR(200) NOT NULL, invoice_id INTEGER NOT NULL, discount_id INTEGER, PRIMARY KEY (item_id, invoice_id), FOREIGN KEY (item_id) REFERENCES item(item_id), FOREIGN KEY (invoice_id) REFERENCES invoice(invoice_id) ); -- BY: AHMAD KHATIB (PART 2) CREATE TABLE IF NOT EXISTS item_discount( discount_id INTEGER AUTO_INCREMENT, discount_percentage INTEGER NOT NULL, item_id VARCHAR(200), minimum_quantity INTEGER, min_date DATE, max_date DATE, discount_status VARCHAR(50) DEFAULT 'فعال', PRIMARY KEY (discount_id), FOREIGN KEY (item_id) REFERENCES item(item_id) ); ALTER TABLE invoice_includes_item ADD FOREIGN KEY (discount_id) REFERENCES item_discount(discount_id); -- BY: MAZEN AMRIA (PART 2) CREATE TABLE IF NOT EXISTS vending_process ( process_id INTEGER AUTO_INCREMENT, vending_date DATE NOT NULL, -- the date on which the item vended vendor_id VARCHAR(50), vending_manager_id VARCHAR(50), -- the id of the employee who managed this process FOREIGN KEY (vendor_id) REFERENCES vendor(vendor_id), FOREIGN KEY (vending_manager_id) REFERENCES employee(emp_id), PRIMARY KEY (process_id) ); CREATE TABLE IF NOT EXISTS vending_process_items ( process_id INTEGER, item_id VARCHAR(200), quantity INTEGER NOT NULL, vending_price REAL NOT NULL, production_date DATE NOT NULL, expiry_date DATE NOT NULL, FOREIGN KEY (process_id) REFERENCES vending_process(process_id), FOREIGN KEY (item_id) REFERENCES item(item_id), PRIMARY KEY (process_id, item_id) ); CREATE TABLE IF NOT EXISTS vending_request ( request_id INTEGER AUTO_INCREMENT, before_date DATE NOT NULL, -- the requested items should be vended before date request_time DATETIME NOT NULL, manager_id VARCHAR(50), -- the id of the manager who requested this item status VARCHAR(50) DEFAULT 'requested', -- the status of the request [requested|assigned|resolved] FOREIGN KEY (manager_id) REFERENCES employee(emp_id), PRIMARY KEY (request_id), CONSTRAINT CHECK (status IN ('requested', 'assigned', 'resolved')) ); CREATE TABLE IF NOT EXISTS tender ( request_id INTEGER, vending_manager_id VARCHAR(50), creation_time DATETIME NOT NULL, deadline DATETIME NOT NULL, secret_key VARCHAR(128) NOT NULL UNIQUE, status VARCHAR(50) DEFAULT 'open', -- the status of the tender [open|closed|resolved] FOREIGN KEY (vending_manager_id) REFERENCES employee(emp_id), FOREIGN KEY (request_id) REFERENCES vending_request(request_id), PRIMARY KEY (request_id), CONSTRAINT CHECK (status IN ('open', 'closed', 'resolved')) ); CREATE TABLE IF NOT EXISTS vending_request_items ( request_id INTEGER, item_id VARCHAR(200), quantity INTEGER NOT NULL, FOREIGN KEY (request_id) REFERENCES vending_request(request_id), FOREIGN KEY (item_id) REFERENCES item(item_id), PRIMARY KEY (request_id, item_id) ); CREATE TABLE IF NOT EXISTS offer ( offer_id INTEGER AUTO_INCREMENT, request_id INTEGER, vendor_id VARCHAR(50), vending_date DATE NOT NULL, submission_time DATETIME NOT NULL, FOREIGN KEY (vendor_id) REFERENCES vendor(vendor_id), FOREIGN KEY (request_id) REFERENCES vending_request(request_id), PRIMARY KEY (offer_id) ); CREATE TABLE IF NOT EXISTS offer_items ( offer_id INTEGER, item_id VARCHAR(200), vending_price REAL NOT NULL, production_date DATE NOT NULL, expiry_date DATE NOT NULL, FOREIGN KEY (offer_id) REFERENCES offer(offer_id), FOREIGN KEY (item_id) REFERENCES item(item_id), PRIMARY KEY (offer_id, item_id) );
CREATE TABLE affice ( afficeid int NOT NULL , title varchar (40) NOT NULL , time datetime NOT NULL , employeeid int NOT NULL , content text , PRIMARY KEY (afficeid) ); CREATE TABLE bumf ( bumfid int NOT NULL , sendter int NOT NULL , accepter int NOT NULL , title varchar (40) NOT NULL , time datetime NOT NULL , content text NOT NULL , affix varchar (40) NOT NULL , examine bit NOT NULL , sign bit NOT NULL , PRIMARY KEY (bumfid) ) ; CREATE TABLE department ( departmentid int NOT NULL , name varchar (20) NOT NULL , explain1 varchar (255) NOT NULL, PRIMARY KEY (departmentid) ) ; CREATE TABLE emexcellence ( excellenceid int NOT NULL , employeeid int NOT NULL , time datetime NOT NULL , levelid int NOT NULL , departmentid int NOT NULL , PRIMARY KEY (excellenceid) ) ; CREATE TABLE eminfo ( employeeid int NOT NULL , name varchar (20) NOT NULL , sex bit NOT NULL , birthday datetime NOT NULL , learn varchar (10) NOT NULL , post varchar (10) NOT NULL , departmentid int NOT NULL , jobid int NOT NULL , tel varchar (20) NOT NULL , addr varchar (100) NOT NULL , stateid int NOT NULL , limit1 bit NOT NULL , PRIMARY KEY (employeeid) ); CREATE TABLE emstate ( stateid int NOT NULL , name varchar (10) NOT NULL , explain1 text NULL , PRIMARY KEY (stateid) ) ; CREATE TABLE info ( infoid int NOT NULL , title varchar (40) NOT NULL , time datetime NOT NULL , sendter int NOT NULL , accepter int NOT NULL , content text NOT NULL , new bit NULL , PRIMARY KEY (infoid) ) ; CREATE TABLE job ( jobid int NOT NULL , name varchar (20) NOT NULL , explain1 text NULL , PRIMARY KEY (jobid) ) ; CREATE TABLE password ( employeeid int NOT NULL , password varchar (20) NOT NULL , time datetime NOT NULL , PRIMARY KEY (employeeid) ) ; CREATE TABLE sign ( signid int NOT NULL , time datetime NOT NULL , employeeid int NOT NULL , late bit NOT NULL , quit bit NOT NULL , leave1 bit NOT NULL , work bit NOT NULL , signstateid int NOT NULL , PRIMARY KEY (signid) ) ; CREATE TABLE signstate ( signstateid int NOT NULL , describestate varchar (20) NOT NULL , time datetime NOT NULL, PRIMARY KEY (signstateid) ) ;
CREATE TABLE [ERP].[AplicacionAnticipoCobrarDetalle] ( [ID] INT IDENTITY (1, 1) NOT NULL, [IdAplicacionAnticipoCobrar] INT NULL, [IdCuentaCobrar] INT NULL, [IdTipoComprobante] INT NULL, [IdMoneda] INT NULL, [Documento] VARCHAR (20) NULL, [Serie] VARCHAR (4) NULL, [Total] DECIMAL (14, 5) NULL, [TotalAplicado] DECIMAL (14, 5) NULL, [Fecha] DATETIME NULL, [IdDebeHaber] INT NULL, CONSTRAINT [PK__Aplicaci__3214EC27E569A864] PRIMARY KEY CLUSTERED ([ID] ASC), CONSTRAINT [FK__Aplicacio__IdApl__71C891C7] FOREIGN KEY ([IdAplicacionAnticipoCobrar]) REFERENCES [ERP].[AplicacionAnticipoCobrar] ([ID]), CONSTRAINT [FK__Aplicacio__IdCue__72BCB600] FOREIGN KEY ([IdCuentaCobrar]) REFERENCES [ERP].[CuentaCobrar] ([ID]), CONSTRAINT [FK__Aplicacio__IdMon__74A4FE72] FOREIGN KEY ([IdMoneda]) REFERENCES [Maestro].[Moneda] ([ID]), CONSTRAINT [FK__Aplicacio__IdTip__73B0DA39] FOREIGN KEY ([IdTipoComprobante]) REFERENCES [PLE].[T10TipoComprobante] ([ID]) );
drop database if exists sagimara; 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 `sagimara` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; USE `sagimara` ; -- ----------------------------------------------------- -- Table `sagimara`.`USER` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`USER` ( `user_phone` VARCHAR(20) NOT NULL, `user_verification` VARCHAR(20) NULL, `user_status` TINYINT NULL, `user_area` VARCHAR(45) NULL, PRIMARY KEY (`user_phone`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`LOCATION` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`LOCATION` ( `location_num` INT NOT NULL AUTO_INCREMENT, `USER_user_phone` VARCHAR(20) NULL, `location_time` DATETIME NULL, `location_coordinate` VARCHAR(45) NULL, INDEX `fk_LOCATION_USER1_idx` (`USER_user_phone` ASC), PRIMARY KEY (`location_num`), CONSTRAINT `fk_LOCATION_USER1` FOREIGN KEY (`USER_user_phone`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`VIDEO` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`VIDEO` ( `USER_user_phone` VARCHAR(20) NOT NULL, `video_link` VARCHAR(100) NULL, `video_date` DATETIME NULL, UNIQUE INDEX `videolink_UNIQUE` (`video_link` ASC), INDEX `fk_VIDEO_USER1_idx` (`USER_user_phone` ASC), PRIMARY KEY (`USER_user_phone`), CONSTRAINT `fk_VIDEO_USER1` FOREIGN KEY (`USER_user_phone`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`INQUIRY` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`INQUIRY` ( `inquiry_num` INT NOT NULL AUTO_INCREMENT, `USER_user_phone` VARCHAR(20) NOT NULL, `inquiry_time` DATE NULL, INDEX `fk_INQUIRY_USER1_idx` (`USER_user_phone` ASC), PRIMARY KEY (`inquiry_num`), CONSTRAINT `fk_INQUIRY_USER1` FOREIGN KEY (`USER_user_phone`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = MyISAM; -- ----------------------------------------------------- -- Table `sagimara`.`TRADE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`TRADE` ( `trade_id` INT NOT NULL, `USER_seller` VARCHAR(20) NOT NULL, `USER_buyer` VARCHAR(20) NOT NULL, `trade_category` VARCHAR(45) NOT NULL, `trade_status` TINYINT NULL, `trade_link` VARCHAR(45) NULL, `trade_detail` TEXT NULL, `trade_date` DATETIME NULL, PRIMARY KEY (`trade_id`), INDEX `fk_TRADE_USER1_idx` (`USER_seller` ASC), INDEX `fk_TRADE_USER2_idx` (`USER_buyer` ASC), UNIQUE INDEX `trade_category_UNIQUE` (`trade_category` ASC), CONSTRAINT `fk_TRADE_USER1` FOREIGN KEY (`USER_seller`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_TRADE_USER2` FOREIGN KEY (`USER_buyer`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`CATEGORY` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`CATEGORY` ( `category_id` VARCHAR(45) NOT NULL, `category_name` VARCHAR(45) NULL, PRIMARY KEY (`category_id`), CONSTRAINT `fk_CATEGORY_TRADE1` FOREIGN KEY (`category_id`) REFERENCES `sagimara`.`TRADE` (`trade_category`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`WATCH` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`WATCH` ( `watch_from` VARCHAR(20) NOT NULL, `watch_to` VARCHAR(20) NOT NULL, `watch_time` DATETIME NOT NULL, PRIMARY KEY (`watch_to`, `watch_from`), INDEX `fk_WATCH_from_to_idx` (`watch_from` ASC), CONSTRAINT `fk_WATCH_from` FOREIGN KEY (`watch_from`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_WATCH_to` FOREIGN KEY (`watch_to`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`NOTIFICATION` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`NOTIFICATION` ( `notifty_from` VARCHAR(20) NOT NULL, `notify_to` VARCHAR(20) NOT NULL, `notify_time` DATETIME NULL, `notify_detail` TEXT NULL, PRIMARY KEY (`notify_to`, `notifty_from`), INDEX `fk_NOTI_from_idx` (`notifty_from` ASC), CONSTRAINT `fk_NOTI_from` FOREIGN KEY (`notifty_from`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_NOTI_to` FOREIGN KEY (`notify_to`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`VERIFICATION` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`VERIFICATION` ( `USER_user_phone` VARCHAR(20) NOT NULL, `verification_time` DATETIME NULL, INDEX `fk_VERIFICATION_USER1_idx` (`USER_user_phone` ASC), PRIMARY KEY (`USER_user_phone`), CONSTRAINT `fk_VERIFICATION_USER1` FOREIGN KEY (`USER_user_phone`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `sagimara`.`REQUEST` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`REQUEST` ( `request_from` VARCHAR(20) NOT NULL, `request_to` VARCHAR(20) NOT NULL, `request_date` DATETIME NOT NULL, PRIMARY KEY (`request_to`, `request_from`), INDEX `fk_REQUEST_USER1_idx` (`request_from` ASC), INDEX `fk_REQUEST_USER2_idx` (`request_to` ASC), CONSTRAINT `fk_REQUEST_USER1` FOREIGN KEY (`request_from`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_REQUEST_USER2` FOREIGN KEY (`request_to`) REFERENCES `sagimara`.`USER` (`user_phone`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB ; -- ----------------------------------------------------- -- Table `sagimara`.`ADMIN` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `sagimara`.`ADMIN` ( `admin_id` VARCHAR(12) NOT NULL, `admin_password` VARCHAR(32) NULL, `admin_name` VARCHAR(45) NULL, `admin_email` VARCHAR(45) NULL, `admin_status` TINYINT NULL, PRIMARY KEY (`admin_id`)) ENGINE = InnoDB ; -- ----------------------------------------------------- -- View `sagimara`.`view1` -- ----------------------------------------------------- DROP TABLE IF EXISTS `sagimara`.`view1`; USE `sagimara`; CREATE VIEW `USER_PROFILE` AS SELECT u.user_phone AS 'phone_number', u.user_status AS 'status', u.user_verification AS 'verification', u.user_area AS 'location', count(w.watch_to) AS 'watch' , count(n.notify_to) AS 'notify' from USER AS u left JOIN WATCH AS w ON (u.user_phone = w.watch_to) left JOIN NOTIFICATION AS n ON (u.user_phone = n.notify_to) group by u.user_phone ; -- ----------------------------------------------------- -- View `sagimara`.`view2` -- ----------------------------------------------------- DROP TABLE IF EXISTS `sagimara`.`view2`; USE `sagimara`; CREATE VIEW `USER_INQUIRY` AS SELECT USER_user_phone AS 'phone_number', count(if(inquiry_time=(CURRENT_DATE()-INTERVAL 6 DAY),inquiry_time,null)) AS '6day ago', count(if(inquiry_time=(CURRENT_DATE()-INTERVAL 5 DAY),inquiry_time,null)) AS '5day ago', count(if(inquiry_time=(CURRENT_DATE()-INTERVAL 4 DAY),inquiry_time,null)) AS '4day ago', count(if(inquiry_time=(CURRENT_DATE()-INTERVAL 3 DAY),inquiry_time,null)) AS '3day ago', count(if(inquiry_time=(CURRENT_DATE()-INTERVAL 2 DAY),inquiry_time,null)) AS '2day ago', count(if(inquiry_time=(CURRENT_DATE()-INTERVAL 1 DAY),inquiry_time,null)) AS '1day ago', count(if(inquiry_time=(CURRENT_DATE()),inquiry_time,null)) AS 'today' FROM INQUIRY group by USER_user_phone ; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
SELECT dbo.products.pname, dbo.categorys.cname from products,categorys where CHARINDEX(categorys.cname, products.cname) > 0; SELECT dbo.products.pname, null from products where products.cname is null;
ALTER TABLE `History` DROP COLUMN `unitNumber`, DROP COLUMN `liftFlag`, DROP COLUMN `stopped`, DROP COLUMN `startflag`, DROP COLUMN `endflag`, DROP COLUMN `locationtype`, DROP COLUMN `collectionstatus`, DROP COLUMN `collectionstatusparsed`, DROP COLUMN `distanceBetweenPoints`, DROP COLUMN `timeBetweenPoints`, DROP COLUMN `collectionZoneEnd`; ALTER TABLE `History` ADD COLUMN `stopId` SMALLINT(3) UNSIGNED DEFAULT NULL AFTER `dateTime`, ADD COLUMN `plotType` ENUM('plot', 'atpickup', 'pickup', 'atstop', 'stopcompleted', 'atdelivery', 'delivered' ) NOT NULL DEFAULT 'plot' AFTER `stopId`, ADD COLUMN `jobNumber` INT(10) UNSIGNED DEFAULT NULL AFTER `plotType`; ALTER TABLE `History` CHANGE COLUMN `datecreated` `timeStamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; DROP FUNCTION IF EXISTS CheckStartRecord; ALTER TABLE `Fix` ADD COLUMN `stopId` SMALLINT(3) UNSIGNED DEFAULT NULL AFTER `speed`, ADD COLUMN `plotType` ENUM('plot', 'atpickup', 'pickup', 'atstop', 'stopcompleted', 'atdelivery', 'delivered' ) NOT NULL DEFAULT 'plot' AFTER `stopId`, ADD COLUMN `jobNumber` INT(10) UNSIGNED DEFAULT NULL AFTER `plotType`;
--DEPARTMENTS TABLE CREATE TABLE DEPARTMENTS ( DEPARTMENT_ID VARCHAR2 (10) NOT NULL, DEPARTMENT_NAME VARCHAR2 (20) NOT NULL, CONSTRAINT DEPARTMENT_PK PRIMARY KEY (DEPARTMENT_ID) ); --EMPLOYEES TABLE CREATE TABLE EMPLOYEES ( EMPLOYEE_ID VARCHAR2 (10) NOT NULL, FIRST_NAME VARCHAR2 (20) NOT NULL, LAST_NAME VARCHAR2 (20) NOT NULL, DATE_OF_BIRTH DATE NOT NULL, HIRE_DATE DATE NOT NULL, DESIGNATION VARCHAR2 (20) NOT NULL, EMAIL_ID VARCHAR2 (30) NOT NULL, PHONE_NUMBER NUMERIC (10) NOT NULL, GENDER VARCHAR2 (20) NOT NULL, ADDRESS VARCHAR2 (50) NOT NULL, CONSTRAINT EMPLOYEES_PK PRIMARY KEY (EMPLOYEE_ID) ); --EMPLOYEE FINANCIALS TABLE CREATE TABLE EMPLOYEE_FINANCIALS ( AADHAAR_NUMBER VARCHAR2 (12) NOT NULL, EMPLOYEE_ID VARCHAR2 (10) NOT NULL, BANK_ACCOUNT_NUMBER VARCHAR2 (20) NOT NULL, BANK_NAME VARCHAR2 (30) NOT NULL, CONSTRAINT EMPLOYEE_FINANCIALS_PK PRIMARY KEY (AADHAAR_NUMBER), CONSTRAINT EMPLOYEE_FINANCIALS_FK FOREIGN KEY (EMPLOYEE_ID) REFERENCES EMPLOYEES (EMPLOYEE_ID) ); --DESIGNATION TABLE CREATE TABLE DESIGNATION ( DESIGNATION_ID VARCHAR2 (10) NOT NULL, DEPARTMENT_ID VARCHAR2 (10) NOT NULL, DESIGNATION VARCHAR2 (20) NOT NULL, BASIC_SALARY NUMERIC (10, 2) NOT NULL, AGP NUMERIC (10, 2) NOT NULL, --ACADEMIC GRADE PAY DA NUMERIC (10, 2) NOT NULL, --DEARNESS ALLOWANCE HRA NUMERIC (10, 2) NOT NULL, --HOUSE RENT ALLOWANCE OTHER_ALLOWANCES NUMERIC (10, 2) NOT NULL, EPF NUMERIC (10, 2) NOT NULL, --EMPLOYEES' PROVIDENT FUND NPS NUMERIC (10, 2) NOT NULL, --NATIONAL PENSION SYSTEM ESI NUMERIC (10, 2) NOT NULL, --EMPLOYEES' STATE INSURANCE TDS NUMERIC (10, 2) NOT NULL, --TAX DEDUCTED AT SOURCE CONSTRAINT DESIGNATION_PK PRIMARY KEY (DESIGNATION_ID), CONSTRAINT DESIGNATION_FK FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENTS (DEPARTMENT_ID) ); --SALARY DETAILS TABLE CREATE TABLE SALARY_DETAILS ( EMPLOYEE_ID VARCHAR2(10) NOT NULL, MONTH VARCHAR2(10), YEAR NUMBER(10), GROSS_SALARY NUMERIC (10, 2) NOT NULL, NET_SALARY NUMERIC (10,2) NOT NULL, CONSTRAINT PAYROLL_DETAILS_FK FOREIGN KEY (EMPLOYEE_ID) REFERENCES EMPLOYEES (EMPLOYEE_ID) ); --LEAVES TABLE CREATE TABLE LEAVES ( EMPLOYEE_ID VARCHAR2 (10) NOT NULL, CASUAL_LEAVES NUMERIC(3) DEFAULT (12), MEDICAL_LEAVES NUMERIC (3) DEFAULT (12), MATERNITY_LEAVES NUMERIC (3) DEFAULT (90), BIRTHDAY_LEAVE NUMERIC (1) DEFAULT (1), EARNED_LEAVES NUMERIC (3) DEFAULT (30), LEAVES_WITHOUT_PAY NUMERIC (3) NOT NULL, CONSTRAINT LEAVES_FK FOREIGN KEY (EMPLOYEE_ID) REFERENCES EMPLOYEES (EMPLOYEE_ID) ); --ATTENDANCE TABLE CREATE TABLE ATTENDANCE ( EMPLOYEE_ID VARCHAR2 (10), MONTH VARCHAR2 (10) NOT NULL, TOTAL_DAYS NUMERIC (2), WORKING_DAYS NUMERIC (2), DAYS_ATTENTED NUMERIC (2), CONSTRAINT ATTENDANCE_FK FOREIGN KEY (EMPLOYEE_ID) REFERENCES EMPLOYEES (EMPLOYEE_ID) );
CREATE TABLE items ( id serial UNIQUE, name TEXT not null ); CREATE TABLE stocks ( id serial UNIQUE, item_id integer not null REFERENCES items(id), price integer, sold boolean default false not null );
/* Formatted on 21/07/2014 18:43:04 (QP5 v5.227.12220.39754) */ CREATE OR REPLACE FORCE VIEW MCRE_OWN.V_MCRES_APP_SP_LEGALI_ALB_CNV ( ID_LEGALE, DTA_INIZIO_ALBO, DTA_INIZIO_CONVENZ, DTA_FINE_ALBO, DTA_FINE_CONVENZ, VAL_NOTE_ALBO_CONV, PROG_MOV ) AS SELECT cod_id_legale AS id_legale, dta_inizio_albo, dta_inizio_convenz, dta_fine_albo, dta_fine_convenz, val_note_albo_conv, 0 prog_mov FROM t_mcres_app_legali_esterni a WHERE dta_fine_albo IS NOT NULL OR dta_inizio_albo IS NOT NULL OR dta_fine_convenz IS NOT NULL OR dta_inizio_convenz IS NOT NULL UNION ALL SELECT ID_LEGALE, DTA_INIZIO_ALBO, DTA_INIZIO_CONVENZ, DTA_FINE_ALBO, DTA_FINE_CONVENZ, VAL_NOTE_ALBO_CONV, prog_mov FROM T_MCRES_APP_LEGALI_ALB_CNV_MOV b ORDER BY id_legale, prog_mov;
CREATE TABLE [ERP].[TransformacionServicioDetalle] ( [ID] BIGINT IDENTITY (1, 1) NOT NULL, [IdTransformacion] INT NULL, [IdTransformacionServicio] INT NULL, [Cantidad] DECIMAL (18, 5) NULL, [PrecioUnitario] DECIMAL (18, 5) NULL, [Total] DECIMAL (18, 5) NULL, PRIMARY KEY CLUSTERED ([ID] ASC), FOREIGN KEY ([IdTransformacionServicio]) REFERENCES [Maestro].[TransformacionServicio] ([ID]), CONSTRAINT [FK__Transform__IdTra__149D980F] FOREIGN KEY ([IdTransformacion]) REFERENCES [ERP].[Transformacion] ([ID]) );
CREATE DATABASE IF NOT EXISTS `ecolephp` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `ecolephp`; -- MySQL dump 10.13 Distrib 5.7.12, for Win64 (x86_64) -- -- Host: localhost Database: ecolephp -- ------------------------------------------------------ -- 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 `cours` -- DROP TABLE IF EXISTS `cours`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `cours` ( `codecours` int(11) NOT NULL, `titre` varchar(45) NOT NULL, `duree` int(11) NOT NULL, PRIMARY KEY (`codecours`), UNIQUE KEY `codecours_UNIQUE` (`codecours`), UNIQUE KEY `titre_UNIQUE` (`titre`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `cours` -- LOCK TABLES `cours` WRITE; /*!40000 ALTER TABLE `cours` DISABLE KEYS */; INSERT INTO `cours` VALUES (11313,'Philo',100),(12131,'Maths',300),(12409,'Comptabilité',230),(21938,'PHP',300); /*!40000 ALTER TABLE `cours` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `etudiant` -- DROP TABLE IF EXISTS `etudiant`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `etudiant` ( `username` varchar(15) NOT NULL, `password` varchar(15) NOT NULL, `nom` varchar(45) NOT NULL, `notelephone` varchar(10) NOT NULL, `courriel` varchar(45) NOT NULL, PRIMARY KEY (`username`), UNIQUE KEY `username_UNIQUE` (`username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `etudiant` -- LOCK TABLES `etudiant` WRITE; /*!40000 ALTER TABLE `etudiant` DISABLE KEYS */; INSERT INTO `etudiant` VALUES ('dayvhy','ouioui','david','1293019234','lala@popo.com'),('lola','popo','Jean-Paul','5142149201','lala@gmail.com'),('simonlegosu','qwqw','Simon','9874561230','simon@gmail.com'),('tigars','lala','Caillou','1238181828','sijdak@aofk.com'); /*!40000 ALTER TABLE `etudiant` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `inscription` -- DROP TABLE IF EXISTS `inscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `inscription` ( `idinscription` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(15) NOT NULL, `codecours` int(11) NOT NULL, PRIMARY KEY (`idinscription`), UNIQUE KEY `idinscription_UNIQUE` (`idinscription`), KEY `FK_username` (`username`), KEY `FK_codecours` (`codecours`), CONSTRAINT `FK_codecours` FOREIGN KEY (`codecours`) REFERENCES `cours` (`codecours`), CONSTRAINT `FK_username` FOREIGN KEY (`username`) REFERENCES `etudiant` (`username`) ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `inscription` -- LOCK TABLES `inscription` WRITE; /*!40000 ALTER TABLE `inscription` DISABLE KEYS */; INSERT INTO `inscription` VALUES (27,'lola',12131),(28,'lola',11313),(31,'simonlegosu',12131),(32,'simonlegosu',11313),(33,'dayvhy',11313),(34,'dayvhy',12131),(35,'tigars',11313),(36,'simonlegosu',12409),(37,'simonlegosu',21938); /*!40000 ALTER TABLE `inscription` ENABLE KEYS */; UNLOCK TABLES; -- -- Dumping events for database 'ecolephp' -- -- -- Dumping routines for database 'ecolephp' -- /*!50003 DROP PROCEDURE IF EXISTS `addCours` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `addCours`(IN in_codecours int, IN in_titre varchar(45), IN in_duree int) BEGIN INSERT INTO cours(codecours,titre,duree) VALUES (in_codecours,in_titre,in_duree); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `addInscription` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `addInscription`(in_username varchar(15), in_titre varchar(45)) BEGIN SET @varcodecours = (SELECT codecours FROM cours WHERE in_titre = cours.titre); IF NOT EXISTS (SELECT codecours FROM inscription WHERE inscription.username = in_username AND inscription.codecours = @varcodecours) THEN INSERT INTO inscription(username,codecours) VALUES (in_username,@varcodecours); END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `addStudent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `addStudent`(IN in_username varchar(15),IN in_password varchar(15),IN in_nom varchar(45),IN in_notelephone varchar(10),IN in_courriel varchar(45)) BEGIN INSERT INTO etudiant(username,password,nom,notelephone,courriel) VALUES (in_username,in_password,in_nom,in_notelephone,in_courriel); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `afficherCours` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `afficherCours`() BEGIN SELECT titre FROM cours; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `afficherCoursIncrit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `afficherCoursIncrit`(IN in_username varchar(15)) BEGIN SELECT * FROM cours INNER JOIN inscription ON cours.codecours = inscription.codecours WHERE inscription.username = in_username; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `afficherCoursNonInscrit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `afficherCoursNonInscrit`(IN in_username varchar(15)) BEGIN SELECT titre FROM cours WHERE NOT EXISTS (SELECT username FROM inscription WHERE cours.codecours = inscription.codecours AND in_username = inscription.username); -- ON cours.codecours = inscription.codecours -- WHERE in_username != inscription.username; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `checkLogin` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `checkLogin`(IN in_username varchar(15), IN in_password varchar(15), OUT out_nom varchar(45), OUT result tinyint(1)) BEGIN SELECT nom INTO out_nom FROM etudiant WHERE etudiant.username = in_username AND etudiant.password = in_password; SELECT if(count(*)>0,1,0) INTO result FROM etudiant WHERE etudiant.username = in_username AND etudiant.password = in_password; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `deleteCours` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `deleteCours`(IN in_titre varchar(45)) BEGIN -- vérifier si un étudiant est incrit au cours avant de le supprimer SET @varcodecours = (SELECT codecours FROM cours WHERE in_titre = cours.titre); SET @lala = (SELECT codecours FROM inscription WHERE inscription.codecours = @varcodecours); IF @lala is NULL THEN DELETE from cours WHERE cours.codecours = @varcodecours; END IF; -- SELECT if(count(*)>0,1,0) INTO result -- FROM cours WHERE -- cours.codecours = @varcodecours AND cours.titre = in_titre; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!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 2019-06-18 17:06:18
CREATE TABLE Customer ( customerId INTEGER NOT NULL generated by default AS IDENTITY( START WITH 1, INCREMENT BY 1), customerCode VARCHAR(100) NOT NULL, customerName VARCHAR(100) NOT NULL, mailAddress VARCHAR(100) NOT NULL, PRIMARY KEY (customerId) ); CREATE INDEX IdxCustomerCode ON Customer ( customerCode ASC ); CREATE TABLE MeterCheck ( meterCheckId INTEGER NOT NULL generated by default AS IDENTITY( START WITH 1, INCREMENT BY 1), meterCheckDate TIMESTAMP NOT NULL, meterIndication INTEGER NOT NULL, billCode VARCHAR(100), billAmount INTEGER, paymentAmount INTEGER, customerId INTEGER, PRIMARY KEY (meterCheckId) ); ALTER TABLE MeterCheck ADD FOREIGN KEY (customerId) REFERENCES Customer ON DELETE SET NULL; CREATE INDEX IdxBillCode ON MeterCheck ( billCode ASC );
##### trap count #### select `trap_sampling_events`.`sampling_event_id`, count(distinct `trap_sampling_events`.`trap_sampling_event_id`) as trapcount from `trap_sampling_events` where NOT ( `trap_sampling_events`.`flags` LIKE 'trap not collected' OR `trap_sampling_events`.`flags` LIKE 'missing' ) OR `trap_sampling_events`.`flags` is null OR `trap_sampling_events`.`flags` = "" group by sampling_event_id limit 50000; -- totals for each taxon select `trap_specimens`.`arthropod_taxon_id`, sum( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, # sum(trap_specimens.unsized), `arthropod_taxonomies`.`arth_class`, `arthropod_taxonomies`.`arth_order`, `arthropod_taxonomies`.`arth_family`, `arthropod_taxonomies`.`arth_genus_subgenus`, `arthropod_taxonomies`.`display_name` FROM trap_specimens JOIN `arthropod_taxonomies`ON (`arthropod_taxonomies`.`arthropod_taxon_id` = `trap_specimens`.`arthropod_taxon_id`) group by `trap_specimens`.`arthropod_taxon_id` order by arth_class, arth_order, arth_family, arth_genus_subgenus ; ##### McDowell query #### select se.sampling_event_id, sub.sumoftaxa, tc.trapcount, (sub.sumoftaxa/tc.trapcount) as average, se.site_id, se.sample_date, sub.display_name from sampling_events as se inner join( select sum(s.allsizes) as sumoftaxa, s.arthropod_taxon_id, atl.display_name, se_2.sampling_event_id FROM( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, arthropod_taxon_id, trap_sampling_event_id FROM trap_specimens ) as s inner join trap_sampling_events as se_2 on s.trap_sampling_event_id = se_2.trap_sampling_event_id inner join arthropod_taxonomies as atl on s.arthropod_taxon_id = atl.arthropod_taxon_id group by s.arthropod_taxon_id, se_2.sampling_event_id ) as sub on (se.sampling_event_id = sub.sampling_event_id) inner join ( select `trap_sampling_events`.`sampling_event_id`, count(distinct `trap_sampling_events`.`trap_sampling_event_id`) as trapcount from `trap_sampling_events` where NOT ( `trap_sampling_events`.`flags` LIKE 'trap not collected' OR `trap_sampling_events`.`flags` LIKE 'NotCollected' ) OR `trap_sampling_events`.`flags` is null OR `trap_sampling_events`.`flags` = "" group by sampling_event_id ) as tc on (tc.sampling_event_id = sub.sampling_event_id) # where se.sampling_event_id = 4177 # where se.site_id = 5 order by se.site_id, se.sample_date limit 50000; ##### po10 query #### select sub.sumoftaxa, tc.trapcount, (sub.sumoftaxa/tc.trapcount) as average, se.site_id, se.sample_date, sub.display_name from sampling_events as se inner join( select sum(s.allsizes) as sumoftaxa, s.arthropod_taxon_id, atl.display_name, se_2.sampling_event_id FROM( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, arthropod_taxon_id, trap_sampling_event_id FROM trap_specimens ) as s inner join trap_sampling_events as se_2 on s.trap_sampling_event_id = se_2.trap_sampling_event_id inner join arthropod_taxonomies as atl on s.arthropod_taxon_id = atl.arthropod_taxon_id group by s.arthropod_taxon_id, se_2.sampling_event_id ) as sub on (se.sampling_event_id = sub.sampling_event_id) inner join ( select `trap_sampling_events`.`sampling_event_id`, count(distinct `trap_sampling_events`.`trap_sampling_event_id`) as trapcount from `trap_sampling_events` where NOT ( `trap_sampling_events`.`flags` LIKE 'trap not collected' OR `trap_sampling_events`.`flags` LIKE 'missing' ) OR `trap_sampling_events`.`flags` is null OR `trap_sampling_events`.`flags` = "" group by sampling_event_id ) as tc on (tc.sampling_event_id = sub.sampling_event_id) # where se.site_id = 5 order by se.sample_date ################################################################# ##### vegetation dwelling #### # note that this query does not add the organisms that are sized. # given how few there are, it is/was easier to change the single # instance (as of 2014-06-04) of a sized organism (plant_specimen_id = 225) # to unsized. ################################################################# SELECT # `plant_specimens`.`plant_specimen_id`, # `plant_specimens`.`plant_sampling_event_id`, # `plant_specimens`.`arthropod_taxon_id`, # `plant_specimens`.`lt2mm`, # `plant_specimens`.`_2_5mm`, # `plant_specimens`.`_5_10mm`, # `plant_specimens`.`gt10mm`, `sites`.`sitename`, `sampling_events`.`sample_date`, `plant_taxonomies`.`scientific_name` as plantTaxon, `arthropod_taxonomies`.`display_name` as arthropodTaxon, `plant_specimens`.`unsized` as number, `plant_sampling_events`.`plant_sampling_event_id`, # `plant_sampling_events`.`sampling_event_id`, # `plant_sampling_events`.`plant_taxon_id`, `plant_sampling_events`.`comments`, `plant_sampling_events`.`flags` # `sampling_events`.`sampling_event_id` # `sampling_events`.`site_id`, FROM mcdowell_arthropods.plant_specimens JOIN `arthropod_taxonomies` ON (`arthropod_taxonomies`.`arthropod_taxon_id` = `plant_specimens`.`arthropod_taxon_id`) JOIN `plant_sampling_events` ON (`plant_sampling_events`.`plant_sampling_event_id` = `plant_specimens`.`plant_sampling_event_id`) JOIN `sampling_events` ON (`sampling_events`.`sampling_event_id` = `plant_sampling_events`.`sampling_event_id`) JOIN `plant_taxonomies` ON (`plant_taxonomies`.`plant_taxon_id` = `plant_sampling_events`.`plant_taxon_id`) JOIN `sites` ON (`sites`.`site_id` = `sampling_events`.`site_id`) # where `sampling_events`.`sampling_event_id` = 50 #group by display_name, plant_sampling_event_id order by sample_date, sitename ; ################################################################# # McDowells by finer taxon, here order but change to desired # level of resolution ################################################################# select se.sampling_event_id, sub.sumoftaxa, tc.trapcount, (sub.sumoftaxa/tc.trapcount) as average, se.site_id, se.sample_date, # sub.display_name sub.arth_order from sampling_events as se inner join( select sum(s.allsizes) as sumoftaxa, s.arthropod_taxon_id, atl.arth_order, se_2.sampling_event_id FROM( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, arthropod_taxon_id, trap_sampling_event_id FROM trap_specimens ) as s inner join trap_sampling_events as se_2 on s.trap_sampling_event_id = se_2.trap_sampling_event_id inner join arthropod_taxonomies as atl on s.arthropod_taxon_id = atl.arthropod_taxon_id group by atl.arth_order, se_2.sampling_event_id ) as sub on (se.sampling_event_id = sub.sampling_event_id) inner join ( select `trap_sampling_events`.`sampling_event_id`, count(distinct `trap_sampling_events`.`trap_sampling_event_id`) as trapcount from `trap_sampling_events` where NOT ( `trap_sampling_events`.`flags` LIKE 'trap not collected' OR `trap_sampling_events`.`flags` LIKE 'NotCollected' ) OR `trap_sampling_events`.`flags` is null OR `trap_sampling_events`.`flags` = "" group by sampling_event_id ) as tc on (tc.sampling_event_id = sub.sampling_event_id) # where se.sampling_event_id = 4177 # where se.site_id = 5 order by se.site_id, se.sample_date limit 50000; ################################################################# # The following has been adjusted to the new arthropods schema ################################################################# # This is from Dave - does not work; yields number of traps with # particular taxon as trap count see above for working queries. # Below this query that Dave generated are additional queries # relevant only to the old DB structure, but maintained here # as examples of past queries. ################################################################# -- sums all insects of each TAXON (by display_name) at a given site and date (here site 5) select sub.sumoftaxa, sub.trapcount, (sub.sumoftaxa/sub.trapcount) as average, se.site_id, se.sample_date, sub.display_name from sampling_events as se inner join( select sum(s.allsizes) as sumoftaxa, count(se_2.sampling_event_id) as trapcount, s.arthropod_taxon_id, atl.display_name, se_2.sampling_event_id FROM( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, arthropod_taxon_id, trap_sampling_event_id FROM trap_specimens ) as s inner join trap_sampling_events as se_2 on s.trap_sampling_event_id = se_2.trap_sampling_event_id inner join arthropod_taxonomies as atl on s.arthropod_taxon_id = atl.arthropod_taxon_id group by s.arthropod_taxon_id, se_2.sampling_event_id ) as sub on (se.sampling_event_id = sub.sampling_event_id) where se.site_id = 5 order by se.sample_date; ################################################################# ################################################################# # The following has NOT been adjusted to the new schema # email me if you have questions. ################################################################# -- sums all insect at a given site and date (here site 5) SELECT sum(s.allsizes) AS allorgs, se.site_id, se.sample_date FROM (SELECT ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, sampling_event_id FROM specimens) AS s INNER JOIN sampling_events AS se ON s.sampling_event_id = se.sampling_event_id WHERE se.site_id = 5 group by se.sample_date ORDER BY se.sample_date; -- sums all insects of each ORDER at a given site and date (here site 5) select sub.sumoftaxa, se.trapcount, (sub.sumoftaxa/se.trapcount) as average, sub.site_id, sub.sample_date, -- sub.display_name sub.arth_order FROM ( SELECT count(sampling_event_id) as trapcount, site_id, sample_date FROM lter10arthropods_production.sampling_events where site_id = 5 group by sample_date ) as se inner join ( select sum(s.allsizes) as sumoftaxa, s.taxon_id, tl.display_name, tl.arth_order, se_2.site_id, se_2.sample_date FROM ( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, taxon_id, sampling_event_id FROM specimens ) as s inner join sampling_events as se_2 on s.sampling_event_id = se_2.sampling_event_id inner join taxon_list as tl on s.taxon_id = tl.taxon_id where site_id = 5 group by tl.arth_order, se_2.site_id, se_2.sample_date -- limit 500 -- group by sample_date ) as sub on (se.site_id = sub.site_id and se.sample_date = sub.sample_date) order by sub.sample_date; -- sums all insects of each TAXON (by display_name) for all sites in McDowells, careful that trap count is misleading as there are always 10 traps due to notes or whathave you in database select sub.sumoftaxa, se.trapcount, (sub.sumoftaxa/se.trapcount) as average, sub.site_id, sub.sample_date, sub.display_name FROM ( SELECT count(sampling_event_id) as trapcount, site_id, sample_date FROM McDowellArthropods.sampling_events -- include this where statement to omit cups that were not collected -- where (`sampling_events`.`flags` <> 'NotCollected' or `sampling_events`.`flags` IS NULL) group by site_id, sample_date ) as se inner join ( select sum(s.allsizes) as sumoftaxa, s.taxon_id, tl.display_name, se_2.site_id, se_2.sample_date FROM ( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, taxon_id, sampling_event_id FROM specimens ) as s inner join sampling_events as se_2 on s.sampling_event_id = se_2.sampling_event_id inner join taxon_list as tl on s.taxon_id = tl.taxon_id -- where site_id = 5 group by s.taxon_id, se_2.site_id, se_2.sample_date -- limit 500 -- group by sample_date ) as sub on (se.site_id = sub.site_id and se.sample_date = sub.sample_date) order by sub.site_id, sub.sample_date; -- sums all insects of each ORDER for all sites in the McDowells, careful that trap count is misleading as there are always 10 traps due to notes or whathave you in the database select sub.sumoftaxa, se.trapcount, (sub.sumoftaxa/se.trapcount) as average, sub.site_id, sub.sample_date, -- sub.display_name sub.arth_order FROM ( SELECT count(sampling_event_id) as trapcount, site_id, sample_date FROM McDowellArthropods.sampling_events -- include this where statement to omit cups that were not collected -- where (`sampling_events`.`flags` <> 'NotCollected' or `sampling_events`.`flags` IS NULL) group by site_id, sample_date ) as se inner join ( select sum(s.allsizes) as sumoftaxa, s.taxon_id, tl.display_name, tl.arth_order, se_2.site_id, se_2.sample_date FROM ( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, taxon_id, sampling_event_id FROM specimens ) as s inner join sampling_events as se_2 on s.sampling_event_id = se_2.sampling_event_id inner join taxon_list as tl on s.taxon_id = tl.taxon_id -- where site_id = 5 group by tl.arth_order, se_2.site_id, se_2.sample_date -- limit 500 -- group by sample_date ) as sub on (se.site_id = sub.site_id and se.sample_date = sub.sample_date) order by sub.site_id, sub.sample_date; -- sums all insects at McDowell sites by date and site SELECT sum(s.allsizes) AS allorgs, se.site_id, se.sample_date FROM (SELECT ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, sampling_event_id FROM specimens) AS s INNER JOIN sampling_events AS se ON s.sampling_event_id = se.sampling_event_id -- WHERE se.site_id = 5 group by se.sample_date, se.site_id ORDER BY se.site_id, se.sample_date; -- simple summary stats for investigating common taxa select s.taxon_id, sum(s.unsized), tl.arth_Class, tl.arth_order, tl.arth_family, tl.arth_genus_subgenus, tl.display_name from McDowellArthropods.specimens as s inner join taxon_list as tl on s.taxon_id = tl.taxon_id group by tl.arth_genus_subgenus order by s.unsized; -- table of all taxa collected at McDowell sites select `taxon_list`.`taxon_id` as t_id, `specimens`.`taxon_id` as s_id, `specimens`.`sampling_event_id`, ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, `taxon_list`.`arth_Class`, `taxon_list`.`arth_order`, `taxon_list`.`arth_family`, `taxon_list`.`arth_genus_subgenus`, `taxon_list`.`old_name`, `taxon_list`.`display_name` FROM specimens JOIN taxon_list ON `taxon_list`.`taxon_id` = `specimens`.`taxon_id` GROUP BY t_id LIMIT 50000 -- sums all insects of each TAXON (by display_name) at a given core site (here site 5) for a given year (here 2012) select sub.sumoftaxa, se.trapcount, (sub.sumoftaxa/se.trapcount) as average, sub.site_id, year(sub.sample_date) as year, sub.display_name FROM ( SELECT count(sampling_event_id) as trapcount, site_id, sample_date FROM lter10arthropods_production.sampling_events where site_id = 5 and (flags <> 'missing' or flags IS NULL) and year(`sampling_events`.`sample_date`) = 2012 ) as se inner join ( select sum(s.allsizes) as sumoftaxa, s.taxon_id, tl.display_name, se_2.site_id, se_2.sample_date FROM ( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, taxon_id, sampling_event_id FROM specimens ) as s inner join sampling_events as se_2 on s.sampling_event_id = se_2.sampling_event_id inner join taxon_list as tl on s.taxon_id = tl.taxon_id group by s.taxon_id, se_2.site_id, year(se_2.sample_date) ) as sub on (se.site_id = sub.site_id and year(se.sample_date) = year(sub.sample_date)) order by display_name ; -- sums all insects of each TAXON (by display_name) at all McDowell sites for a given year (here 2012); make appropriate changes for specific taxonomic levels select sub.sumoftaxa, se.trapcount, (sub.sumoftaxa/se.trapcount) as average, sub.site_id, year(sub.sample_date), sub.display_name /*change to sub.arth_order for order */ FROM ( SELECT count(sampling_event_id) as trapcount, site_id, sample_date FROM McDowellArthropods.sampling_events -- include this where statement to omit cups that were not collected where (`sampling_events`.`flags` <> 'NotCollected' or `sampling_events`.`flags` IS NULL) and year(`sampling_events`.`sample_date`) = 2012 group by site_id#, sample_date ) as se inner join ( select sum(s.allsizes) as sumoftaxa, s.taxon_id, tl.display_name, /*add tl.arth_order for order*/ se_2.site_id, se_2.sample_date FROM ( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, taxon_id, sampling_event_id FROM specimens ) as s inner join sampling_events as se_2 on s.sampling_event_id = se_2.sampling_event_id inner join taxon_list as tl on s.taxon_id = tl.taxon_id group by s.taxon_id, /* change to tl.arth_order for order */ se_2.site_id, year(se_2.sample_date) ) as sub on (se.site_id = sub.site_id and year(se.sample_date) = year(sub.sample_date)) order by site_id, display_name ; -- sums all insects at McDowell sites by site and provides average number per trap select sub.sumoftaxa, se.trapcount, (sub.sumoftaxa/se.trapcount) as average, sub.site_id FROM ( SELECT count(sampling_event_id) as trapcount, site_id, sample_date FROM McDowellArthropods.sampling_events # include this where statement to omit cups that were not collected where (`sampling_events`.`flags` <> 'NotCollected' or `sampling_events`.`flags` IS NULL) group by site_id ) as se inner join ( select sum(s.allsizes) as sumoftaxa, s.taxon_id, tl.display_name, se_2.site_id, se_2.sample_date FROM ( select ( IF(isnull(lt2mm), 0, lt2mm) + IF(isnull(_2_5mm), 0, _2_5mm) + IF(isnull(_5_10mm), 0, _5_10mm) + IF(isnull(gt10mm), 0, gt10mm) + IF(isnull(unsized), 0, unsized) ) as allsizes, taxon_id, sampling_event_id FROM specimens ) as s inner join sampling_events as se_2 on s.sampling_event_id = se_2.sampling_event_id inner join taxon_list as tl on s.taxon_id = tl.taxon_id group by se_2.site_id ) as sub on (se.site_id = sub.site_id ) order by sub.site_id, sub.sample_date ;
INSERT INTO department (name) VALUES ("Marketing"); INSERT INTO department (name) VALUES ("Sales"); INSERT INTO department (name) VALUES ("Engineering"); INSERT INTO department (name) VALUES ("Legal"); INSERT INTO department (name) VALUES ("Accounting"); INSERT INTO role (title, salary, department_id) VALUES ("Social Media Manager", 51406, 1); INSERT INTO role (title, salary, department_id) VALUES ("Digital Marketing Director", 90405, 1); INSERT INTO role (title, salary, department_id) VALUES ("Sales Support", 44877, 2); INSERT INTO role (title, salary, department_id) VALUES ("Account Sales Manager", 62236, 2); INSERT INTO role (title, salary, department_id) VALUES ("Junior Software Developer", 64056, 3); INSERT INTO role (title, salary, department_id) VALUES ("Senior Software Developer", 92345, 3); INSERT INTO role (title, salary, department_id) VALUES ("Chief Technology Officer", 44877, 3); INSERT INTO role (title, salary, department_id) VALUES ("Legal Analyst", 51918, 4); INSERT INTO role (title, salary, department_id) VALUES ("Legal Director", 175330, 4); INSERT INTO role (title, salary, department_id) VALUES ("General Accountant", 53160, 5); INSERT INTO role (title, salary, department_id) VALUES ("Accounting Supervisor", 84827, 5); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Carolyn", "Hilpisch", null, 5); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Rebecca", "Norgaard-Peterson", null, 6); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Khang", "Nguyen", null, 7); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Jenn", "Brunner", null, 1); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Michael", "Buckelew", null, 2); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Sara", "Blascyk", null, 3); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Johnny", "Grzeskowiak", null, 4); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Brianna", "Sadler", null, 8); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("James", "Leon", null, 9); INSERT INTO employee (first_name, last_name, manager_id, role_id) VALUES ("Andrea", "Hintz", null, 11);
Select * From EMP Where DEPT_CODE is NULL;
-- Delete non-exist user data DELETE FROM query_history_attribute WHERE query_history_pk_id IN (SELECT query_history_pk_id FROM query_history WHERE user_id NOT IN (SELECT user_id FROM csm_user)); DELETE FROM query_history WHERE user_id NOT IN (SELECT user_id FROM csm_user); DELETE FROM saved_query_attribute WHERE saved_query_pk_id IN (SELECT saved_query_pk_id FROM saved_query WHERE user_id NOT IN (SELECT user_id FROM csm_user)); DELETE FROM saved_query WHERE user_id NOT IN (SELECT user_id FROM csm_user);
-- 授权 GRANT select ON UMAN.* TO dbser@localhost IDENTIFIED BY 'something';
CREATE DATABASE IF NOT EXISTS DbCorona; USE DbCorona; CREATE TABLE TbPaciente ( ID_Paciente int(11) NOT NULL AUTO_INCREMENT, Usuario varchar(100) NOT NULL, Senha varchar(14) NOT NULL, DescSintomas varchar(100) NOT NULL, PRIMARY KEY (ID_Paciente) ); CREATE TABLE TbTesteCovid ( TesteID int(11) not null auto_increment, ID_Paciente int(11) not null, resultado bool not null, IntegranteEquipeID int(11) not null, CONSTRAINT FK_ID_Paciente FOREIGN KEY (ID_Paciente) REFERENCES TbPaciente (ID_Paciente), CONSTRAINT FK_IntegranteEquipeID FOREIGN KEY (IntegranteEquipeID) REFERENCES TbEquipe (IntegranteEquipeID), primary key(TesteID) ); CREATE TABLE TbEquipe ( IntegranteEquipeID int(11) NOT NULL AUTO_INCREMENT, Senha varchar(50) NOT NULL, Usuario varchar(20) NOT NULL, CodEspecial varchar(50) NOT NULL, TesteID int(11) NOT NULL, PRIMARY KEY (IntegranteEquipeID), CONSTRAINT FK_TesteID FOREIGN KEY (TesteID) REFERENCES TbTesteCovid (TesteID) ); CREATE TABLE TbForum ( ID_Paciente int(11) NOT NULL , Mensagem varchar(18) NOT NULL, IntegranteEquipeID int(11) NOT NULL auto_increment, Data date not null, datetime datetime not null, CONSTRAINT FK_ID_Paciente FOREIGN KEY (ID_Paciente) REFERENCES TbPaciente (ID_Paciente), CONSTRAINT FK_IntegranteEquipeID FOREIGN KEY (IntegranteEquipeID) REFERENCES TbEquipe (IntegranteEquipeID), PRIMARY KEY (IntegranteEquipeId) ); CREATE TABLE TbPessoa ( Nome varchar(50) NOT NULL , telefone varchar(11) NOT NULL, CPF varchar(14) NOT NULL, UF varchar(2) NOT NULL, Email varchar(50) NOT NULL, RG varchar(10) NOT NULL, Rua varchar(50) NOT NULL, Complemento varchar(50) NOT NULL, Bairro varchar(50) NOT NULL, Sexo varchar(50) NOT NULL, Cep varchar(9) NOT NULL, NumCasa varchar(7) NOT NULL, Idade int(3) NOT NULL, PRIMARY KEY (Codigo), KEY FK_CodigoCliente_idx (ID_Pessoa) ); CREATE TABLE TbAgendamento ( Date date not null, datetime datetime not null, Status_Agendamento varchar(50) );
UPDATE "FileMetadata" fm SET "PropertyName" = fp."Name" FROM "FileProperty" fp WHERE fm."PropertyId" = fp."PropertyId"; ALTER TABLE "FileMetadata" DROP COLUMN "PropertyId"; ALTER TABLE "FileProperty" DROP COLUMN "PropertyId"; ALTER TABLE "FileMetadata" ALTER COLUMN "PropertyName" SET NOT NULL; INSERT INTO "FileMetadata" SELECT uuid_generate_v4(), f."FileId", "OriginalPath", cfm."Datetime", "UserId", 'ClientSideOriginalFilepath' FROM "ClientFileMetadata" cfm JOIN "File" f on f."FileId" = cfm."FileId"; INSERT INTO "FileMetadata" SELECT uuid_generate_v4(), f."FileId", "LastModified", cfm."Datetime", "UserId", 'ClientSideFileLastModifiedDate' FROM "ClientFileMetadata" cfm JOIN "File" f on f."FileId" = cfm."FileId"; INSERT INTO "FileMetadata" SELECT uuid_generate_v4(), f."FileId", "Filesize", cfm."Datetime", "UserId", 'ClientSideFileSize' FROM "ClientFileMetadata" cfm JOIN "File" f on f."FileId" = cfm."FileId"; INSERT INTO "FileMetadata" SELECT uuid_generate_v4(), f."FileId", "Checksum", cfm."Datetime", "UserId", 'SHA256ClientSideChecksum' FROM "ClientFileMetadata" cfm JOIN "File" f on f."FileId" = cfm."FileId"; DROP TABLE "ClientFileMetadata";
CREATE DATABASE JUSTICA; USE JUSTICA; CREATE TABLE ADVOGADO( adv_codigo int primary key not null AUTO_INCREMENT, adv_nome varchar(20), adv_apelido varchar(10), adv_sexo char(1), adv_faculdade varchar(10), adv_dtformatura date ); CREATE TABLE PROCESSO( pro_codigo int primary key not null AUTO_INCREMENT, pro_nomereu varchar(20), pro_descricao varchar(20), pro_varatribunal varchar(15), pro_dataprocesso varchar(10), adv_codigo int, constraint fk_advogado_processo foreign key(adv_codigo) references ADVOGADO(adv_codigo) ); INSERT INTO ADVOGADO( adv_codigo, adv_nome, adv_apelido, adv_sexo, adv_faculdade, adv_dtformatura ) VALUES(1, 'Advogado 1', 'adv 1', 'M', 'FATEC', '2018-12-10'), (2, 'Advogado 2', 'adv 2', 'M', 'FATEC', '2018-12-10'), (3, 'Advogado 3', 'adv 3', 'F', 'FATEC', '2018-12-10'); INSERT INTO PROCESSO( pro_codigo, pro_nomereu, pro_descricao, pro_varatribunal, pro_dataprocesso, adv_codigo ) VALUES(1, 'Reu 1', 'transito', 'tribunal 1', '2018-05-01', 1), (2, 'Reu 2', 'roubo', 'tribunal 2', '2018-06-01', 2), (3, 'Reu 3', 'homicidio', 'tribunal 3', '2018-06-10', 3);
SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for operation -- ---------------------------- CREATE TABLE IF NOT EXISTS `rpd_operation` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(150) DEFAULT NULL, `business_name` VARCHAR(150) NOT NULL, `description` VARCHAR(250) DEFAULT NULL, `needs_authorization` ENUM ('1', '0') NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- ---------------------------- -- Table structure for role -- ---------------------------- CREATE TABLE IF NOT EXISTS `rpd_role` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(150) DEFAULT NULL, `business_name` VARCHAR(150) NOT NULL, `description` VARCHAR(250) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- ---------------------------- -- Table structure for role_has_task -- ---------------------------- CREATE TABLE IF NOT EXISTS `rpd_role_has_task` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id_role` INT(10) UNSIGNED NOT NULL, `id_task` INT(10) UNSIGNED NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `key_rpd_role_has_task` (`id_role`, `id_task`), KEY `id_role` (`id_role`) USING BTREE, KEY `id_task` (`id_task`) USING BTREE, CONSTRAINT `rpd_role_has_task_role` FOREIGN KEY (`id_role`) REFERENCES `rpd_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `rpd_role_has_task_task` FOREIGN KEY (`id_task`) REFERENCES `rpd_task` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- ---------------------------- -- Table structure for task -- ---------------------------- CREATE TABLE IF NOT EXISTS `rpd_task` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(150) DEFAULT NULL, `business_name` VARCHAR(150) NOT NULL, `description` VARCHAR(250) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- ---------------------------- -- Table structure for task_has_operation -- ---------------------------- CREATE TABLE IF NOT EXISTS `rpd_task_has_operation` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id_task` INT(10) UNSIGNED NOT NULL, `id_operation` INT(10) UNSIGNED NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `key_rpd_task_has_operation` (`id_operation`, `id_task`), KEY `id_task` (`id_task`) USING BTREE, KEY `id_operation` (`id_operation`) USING BTREE, CONSTRAINT `rpd_task_has_operation_task` FOREIGN KEY (`id_task`) REFERENCES `rpd_task` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `rpd_task_has_operation_operation` FOREIGN KEY (`id_operation`) REFERENCES `rpd_operation` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- ---------------------------- -- Table structure for user -- ---------------------------- CREATE TABLE IF NOT EXISTS `user` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- ---------------------------- -- Table structure for user_has_role -- ---------------------------- CREATE TABLE IF NOT EXISTS `rpd_user_has_role` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id_user` INT(10) UNSIGNED NOT NULL, `id_role` INT(10) UNSIGNED NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `key_rpd_user_has_role` (`id_user`, `id_role`), KEY `id_user` (`id_user`), KEY `id_role` (`id_role`), -- If needed add manually -- CONSTRAINT `rpd_user_has_role_user` FOREIGN KEY (`id_user`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `rpd_user_has_role_role` FOREIGN KEY (`id_role`) REFERENCES `rpd_role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET = utf8;
DROP TABLE IF EXISTS budget_user CASCADE; ALTER TABLE category DROP COLUMN user_id;
create database ar; create table dishes ( id serial primary key, image varchar(100), description text, price numeric(4,2), category varchar(100), dish_name varchar(100), url text ); create table users ( id serial primary key, user_name varchar(50), user_password text ); create table orders ( id serial primary key, user_id int, foreign key (user_id) references users (id) ); create table dishes_orders ( id serial primary key, dish_id int, quantity int not null, order_id int, foreign key (order_id) references orders (id), foreign key (dish_id) references dishes (id) ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/pmGBEfwi1b2jwL6lb29uE_pmGIlBy9Mt8Dsz-_wwZSk_N16JRCLbqRxOlAr1JS-v', 'Assorted sushi set with salmon nigiri,salmon uramaki, California uramaki.', 12, 'main', 'Assorted sushi', 'https://poly.googleapis.com/downloads/bWRnM-3pmS5/bbJIjF-59Ut' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/GewMgUIDU24-ViwS2osK4SF2GUGZkJdyKdXN8fYuAYx0Xu-WPbxfRwcLwH2k9IY', 'Chipotle rubbed chicken. Habanero & pumpkin seed salsa.', 7.5, 'main', 'Grilled chicken tacos', 'https://poly.googleapis.com/downloads/33nYH5Sdxqb/1Qr8ITDI3b9' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/CZ6ZmNxWH6XDb98Uy52Wpg0YBWTZQVIvzQcPBCVxeLYFVtDKHjWug5lMet86Jwwa4A', 'Finger sandwiches, scones with clotted cream and jam, sweet pastries and cakes.', 21.5, 'main', 'Afternoon tea', 'https://poly.googleapis.com/downloads/2cX88a40PMz/fqrE8mMo9fi' ); alter table dishes drop column url; alter table dishes add column obj text; alter table dishes add column mtl text; update dishes set obj='https://lh3.googleusercontent.com/pmGBEfwi1b2jwL6lb29uE_pmGIlBy9Mt8Dsz-_wwZSk_N16JRCLbqRxOlAr1JS-v/model.obj' where id =1; update dishes set mtl='https://lh3.googleusercontent.com/pmGBEfwi1b2jwL6lb29uE_pmGIlBy9Mt8Dsz-_wwZSk_N16JRCLbqRxOlAr1JS-v/materials.mtl' where id =1; update dishes set obj='https://lh3.googleusercontent.com/GewMgUIDU24-ViwS2osK4SF2GUGZkJdyKdXN8fYuAYx0Xu-WPbxfRwcLwH2k9IY/model.obj' where id =2; update dishes set mtl='https://lh3.googleusercontent.com/GewMgUIDU24-ViwS2osK4SF2GUGZkJdyKdXN8fYuAYx0Xu-WPbxfRwcLwH2k9IY/materials.mtl' where id =2; update dishes set category='starter' where id =2; delete from dishes where id=3; insert into dishes values ( default, 'https://lh3.googleusercontent.com/H9uT-g2uXMRdAGlCjuRuhG1Leogxjvn7sf6HM4LkTo-tlAHC4AQSECLgtEr8GfA-Jg', 'It is made from cured pork and beef mixed together and seasoned with paprika or other chili pepper. Pepperoni Pizza is characteristically soft, slightly smoky, and bright red in color.', 9.49, 'main', 'Pepperoni Pizza', 'https://poly.googleapis.com/downloads/1A7p4z5tJd9/1Qp8zjEst0G/model.obj', 'https://poly.googleapis.com/downloads/1A7p4z5tJd9/1Qp8zjEst0G/materials.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/GqNhzRx7s157WQERy6v5_1oTRXoSS28C6afzeCU3TesGuTLkU_aZFRkKomwez7fN', 'Crème caramel dessert is a custard dessert with a layer of clear caramel sauce.', 6, 'dessert', 'Flan', 'https://poly.googleapis.com/downloads/6_9ioxcIar4/65nomqSWV47/Flan_01.obj', 'https://poly.googleapis.com/downloads/6_9ioxcIar4/65nomqSWV47/Flan_01.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/gcc3kmMm_N_FGkjVw0o1qgLmc3anHb26EgGkBaDyqKdj62YYgfCC9jQWkOg5yEY5', 'A shish kebab is a skewer with meat and vegetables and is grilled. It has lamb, green peppers, onions, and mushrooms.', 7, 'main', 'Shish keba', 'https://poly.googleapis.com/downloads/6uTsH2jqgVn/arWtwoZ4eSS/Shishkebab_251.obj', 'https://poly.googleapis.com/downloads/6uTsH2jqgVn/arWtwoZ4eSS/Shishkebab_251.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/ciwQjPD-iB7c_ZzaO7d5S9Gqxcm9HXEd0-u_HF2rOZEBeHbm03l9qsQLIYSQ-vq1rg', 'All their beef is from the Argentinian Pampas.', 17, 'main', 'Fillet steak', 'https://poly.googleapis.com/downloads/8EnDRHkPSXG/5x8u0E0vKgD/Steak_245.obj', 'https://poly.googleapis.com/downloads/8EnDRHkPSXG/5x8u0E0vKgD/Steak_245.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/k00KQIMNXJqkXxqbGpUUzcgMdDFkxqVINYg18q88PkGuCWUzpPIJcYRL-x9PTcC9', 'Steamed crawfish.', 15.5, 'main', 'Crawfish', 'https://poly.googleapis.com/downloads/ct4Z0kUIHdT/9QIqKfubrNc/NOVELO_CRAYFISH.obj', 'https://poly.googleapis.com/downloads/ct4Z0kUIHdT/9QIqKfubrNc/NOVELO_CRAYFISH.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/jfSpge6AmpvOadB86nOnOA7s2CkKbSqh7a8PYwHxDy0r9px3Nuo_cKLmo-kfqFdiJA', 'Burger with beef and vegetables, large chips and large soft drink (coke, fanta, sprite or water).', 5.99, 'main', 'Burger, chips and soft drink.', 'https://poly.googleapis.com/downloads/87iQkav6g6f/931m9fonjuP/model.obj', 'https://poly.googleapis.com/downloads/87iQkav6g6f/931m9fonjuP/materials.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/hVTi1BASgzrX2zv41gpg3IyOnwrLsli_FMzcZLfrrNgHXxR2oqjKUmFd2aVx3_igXg', 'Chorizo, sweet pepper pearls, roasted peppers, sweetcorn, tortilla chips, ranch dressing.', 4.69, 'starter', 'Salad Bowl', 'https://poly.googleapis.com/downloads/9lnNCNuF5w0/4A5TYe-U8sg/model.obj', 'https://poly.googleapis.com/downloads/9lnNCNuF5w0/4A5TYe-U8sg/materials.mtl' ); delete from dishes_orders; delete from dishes where id=1; delete from dishes where id=2; insert into dishes values ( default, 'https://lh3.googleusercontent.com/pmGBEfwi1b2jwL6lb29uE_pmGIlBy9Mt8Dsz-_wwZSk_N16JRCLbqRxOlAr1JS-v', 'Crispy Soft Shell Crab with a delicate burst of Flying Fish Roe, Avocado and a dash of Mayonnaise.', 15, 'main', 'Assorted sushi', 'https://poly.googleapis.com/downloads/bWRnM-3pmS5/bbJIjF-59Ut/model.obj', 'https://poly.googleapis.com/downloads/bWRnM-3pmS5/bbJIjF-59Ut/materials.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/GewMgUIDU24-ViwS2osK4SF2GUGZkJdyKdXN8fYuAYx0Xu-WPbxfRwcLwH2k9IY', 'Tacos is a traditional Mexican dish in which crunchy or soft corn tortillas are stuffed with meat, fresh veg or seafood with tasty taco seasoning, crisp lettuce, grated cheese and a dash of tangy salsa.', 7.49, 'starter', 'Tacos', 'https://poly.googleapis.com/downloads/33nYH5Sdxqb/1Qr8ITDI3b9/model.obj', 'https://poly.googleapis.com/downloads/33nYH5Sdxqb/1Qr8ITDI3b9/materials.mtl' ); delete from dishes where id =7; delete from dishes where id =8; delete from dishes where id =9; insert into dishes values ( default, 'https://lh3.googleusercontent.com/1ZEYWeKXgaFLzKcdp24GfqX3flrmvlxqEoIsqg5CGQi_mu3NC4dDD2J59blst1g', 'It is wonderful eaten in golden shards or crumbled into the best vanilla ice cream.', 5.49, 'dessert', 'Honeycomb', 'https://poly.googleapis.com/downloads/1eRck4iVlMy/3x0vbmLyc5a/model.obj', 'https://poly.googleapis.com/downloads/1eRck4iVlMy/3x0vbmLyc5a/materials.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/lTy9k6wFtEttR9Je74WRweDBwKfb2cA8MM9BbCgdMxErzHyZxC2U-8Uebp_z6C3p', '6 donuts with yellow cream on top.', 6.00, 'dessert', 'Donuts', 'https://poly.googleapis.com/downloads/2Pa18cw09ou/b95cr6zBiTT/model.obj', 'https://poly.googleapis.com/downloads/2Pa18cw09ou/b95cr6zBiTT/materials.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/pXEeGMQxGQEQWEEgXOxK4BBs1txC4P4fYwrfAXkTMZvGHO3kesiXxaAm3vDb1LGNTg', 'Chocolate cake with marshmallows.', 9.99, 'dessert', 'Cake', 'https://poly.googleapis.com/downloads/arJdqW51n24/fzXIgGvvNz7/Cake.obj', 'https://poly.googleapis.com/downloads/arJdqW51n24/fzXIgGvvNz7/Cake.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/CcIvhqbQCP9rEd1IW0KndqK83vOwSF078v0p2C0YY1w8pmbR1uV8iUWAVLFZ9SXu', 'Dancing hotdog with mustard', 4.99, 'starter', 'Dancing hotdog', 'https://poly.googleapis.com/downloads/24ZH95hPHKK/es9OGQ_BoV5/model.obj', 'https://poly.googleapis.com/downloads/24ZH95hPHKK/es9OGQ_BoV5/materials.mtl' ); insert into dishes values ( default, 'https://lh3.googleusercontent.com/KbBiylLH5G5OkO4sooKbGyN06tEHiMjyZnSXw8a2uxaDqX3WZv2CgoNeWX-lsmJWwg', '6 cups of juice - different tastes!', 7.49, 'starter', 'Fresh juice', 'https://poly.googleapis.com/downloads/5-EjPXozm2Q/bhBm_z4awYz/juice.obj', 'https://poly.googleapis.com/downloads/5-EjPXozm2Q/bhBm_z4awYz/juice.mtl' ); delete from dishes where id =15; delete from dishes where id =13; update dishes set dish_name='Burger, chips and drink' where id=9; update dishes set dish_name='Salad bowl' where id=10; update dishes set dish_name='Pepperoni pizza' where id=4; alter table dishes add column quantity int; update dishes set quantity=0; alter table users drop column user_password; alter table users add column phone varchar(50);
-- extension needs to be added as admin (i.e. postgres user) CREATE EXTENSION IF NOT EXISTS pgcrypto; CREATE EXTENSION IF NOT EXISTS postgis; CREATE TABLE appusers( user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), -- why not just use firebase_token as primary-key if that's unique? -- well it's a long-string, rather than a space (and join) efficient UUID firebase_token TEXT UNIQUE NOT NULL, default_nickname TEXT NOT NULL, the_usual TEXT NOT NULL, -- current_making_kettle // this is cool. cos when boot can go auto straight to kettle-page....IF close geolocation. otherwise list/add. -- but this wouldnt be kettle-id user drink-responds to when opening app, that could be a different kettle. -- open_app_with_kettle......it seems better to just have a `drink_round` table, and we look for users newest offer last_known_location geography(POINT,4326) ); CREATE TABLE kettles( kettle_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), wireless_id TEXT UNIQUE NOT NULL, name TEXT NOT NULL, current_maker UUID REFERENCES appusers, location geography(POINT,4326) NOT NULL ); CREATE INDEX users_location_gix ON appusers USING GIST (last_known_location); CREATE INDEX kettles_location_gix ON kettles USING GIST (location); CREATE INDEX kettles_appusers ON kettles(current_maker);
/* Navicat MySQL Data Transfer Source Server : mysql Source Server Version : 50150 Source Host : localhost:3306 Source Database : fgzb Target Server Type : MYSQL Target Server Version : 50150 File Encoding : 65001 Date: 2014-07-16 21:24:15 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for guanyu -- ---------------------------- DROP TABLE IF EXISTS `guanyu`; CREATE TABLE `guanyu` ( `id` int(11) NOT NULL AUTO_INCREMENT, `gsjianjie` text, `tzcelue` text, `zzfuwu` text, `engsjianjie` text, `entzcelue` text, `enzzfuwu` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of guanyu -- ---------------------------- INSERT INTO `guanyu` VALUES ('1', '方广资本成立于2012年9月,是一家专注于中国IT垂直领域的风险投资基金。本着\"价值为本、以人为先、合作共赢\"的投资理念,凭借丰富的IT产业资源及国际化投资管理经验,方广资本旨在为中早期科技企业提供增值服务。\r\n方广资本拥有一流的管理合伙人团队。其合伙人曾为国际知名IT企业创始团队和高级管理人员、国际风险投资机构投资合伙人,具有丰富的IT领域投资及企业管理经验,曾参与或主导过许多知名公司的投资。\r\n方广资本丰富的本土资源和优势,结合一流的国际化视野和投资管理经验,旨在给企业带来国际化的资源嫁接,助力企业更健康地发展。', '方广资本成立于2012年9月,是一家专注于中国IT垂直领域的风险投资基金。本着\"价值为本、以人为先、合作共赢\"的投资理念,凭借丰富的IT产业资源及国际化投资管理经验,方广资本旨在为中早期科技企业提供增值服务。\r\n方广资本拥有一流的管理合伙人团队。其合伙人曾为国际知名IT企业创始团队和高级管理人员、国际风险投资机构投资合伙人,具有丰富的IT领域投资及企业管理经验,曾参与或主导过许多知名公司的投资。\r\n方广资本丰富的本土资源和优势,结合一流的国际化视野和投资管理经验,旨在给企业带来国际化的资源嫁接,助力企业更健康地发展。', ' 凭借合伙人深厚的行业资源、人脉关系及国际化管理经验,方广资本旨在为被投公司提供增值服务,在诸多方面为企业带来增值服务,助力企业成长:', null, null, null);
--Incluindo QUATRO Autores: INSERT INTO AUTOR(nome, descricao) VALUES('Paulo Silveira', 'Bacharel e mestre em Ciência da Computação pela USP, possui mais de 10 anos de experiência com desenvolvimento, passando pela Alemanha e pelo IBOPE.'); INSERT INTO AUTOR(nome, descricao) VALUES('Adriano Almeida', 'Formado em Sistemas de Informação pela FIAP, começou sua carreira com Editoração Eletrônica e desenvolveu sistemas em Java, Ruby on Rails, PHP e VB.'); INSERT INTO AUTOR(nome, descricao) VALUES('Nelson Fabbri Gerbelli', 'Tecnólogo em Processamento de Dados pela faculdade FAINAM, pós-graduado em Análise de Sistemas pela faculdade ESAN.'); INSERT INTO AUTOR(nome, descricao) VALUES('Valéria Helena P. Gerbelli', 'Tecnóloga em Processamento de Dados pela faculdade IESA. Pedagoga e com licenciatura plena em Informática. Pós-graduanda em Educação Profissional e Tecnológica.'); INSERT INTO AUTOR(nome, descricao) VALUES('Lucas Mazza', 'faz parte da equipe de desenvolvedores da Plataformatec, empresa de desenvolvimento de São Paulo, especializada em Ruby on Rails. Combinando a linguagem Ruby com HTML, CSS e JavaScript.'); --Incluinco QUATRO Categorias: INSERT INTO CATEGORIA(nome) VALUES('Programação'); INSERT INTO CATEGORIA(nome) VALUES('Mobile'); INSERT INTO CATEGORIA(nome) VALUES('Front-end'); INSERT INTO CATEGORIA(nome) VALUES('Infraestrutura'); --Incluindo SEIS SubCategorias: INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('Lógica', 1); INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('Java', 1); INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('Android', 2); INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('iOS', 2); INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('HTML e CSS', 3); INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('JavaScript', 3); INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('Web', 4); INSERT INTO SUB_CATEGORIA(nome, categoria_id) VALUES('Dados', 4); --Incluindo o PRIMEIRO Livro INSERT INTO LIVRO(categoria_id, sub_categoria_id, titulo, sub_titulo, conteudo, autor_id, numero_paginas, isbn) VALUES(1, 1, 'Lógica de Programação', 'Crie seus primeiros programas usando Javascript e HTML', 'O livro explora os recursos do HTML e Javascript, criando a familiaridade desde o começo dos estudos com a sintaxe da linguagem de programação, instruções, funções específicas e problemas corriqueiros da programação', 1, 180, '978-85-66250-22-0'); --Incluindo o SEGUNDO Livro INSERT INTO LIVRO(categoria_id, sub_categoria_id, titulo, sub_titulo, conteudo, autor_id, numero_paginas, isbn) VALUES(2, 2, 'App Inventor', 'Seus primeiros aplicativos Android', 'Após ser apresentado ao ambiente, você aprenderá na prática a desenvolver alguns aplicativos do zero, partindo de alguns cálculos, até chegar a resultados mais complexos, com um recurso de localização de GPS', 2, 311, '978-85-94188-30-4'); --Incluindo o TERCEIRO Livro INSERT INTO LIVRO(categoria_id, sub_categoria_id, titulo, sub_titulo, conteudo, autor_id, numero_paginas, isbn) VALUES(3, 3, 'HTML5 e CSS3', 'Domine a web do futuro', 'Crie páginas elegantes de forma simples! HTML e CSS, quando bem utilizados, podem ser o sucesso de um projeto', 3, 228, '978-85-66250-05-3');
/* Formatted on 21/07/2014 18:44:01 (QP5 v5.227.12220.39754) */ CREATE OR REPLACE FORCE VIEW MCRE_OWN.V_MCRES_FEN_NUOVI_INGR_CONT_N ( COD_ABI, VAL_ANNOMESE, FLG_GAR_REALI_PERSONALI, FLG_GAR_REALI, VAL_TOT_NDG, VAL_VANTATO, VAL_GBV, VAL_NBV ) AS SELECT cod_abi, val_annomese, 0 FLG_GAR_REALI_PERSONALI, 0 FLG_GAR_REALI, COUNT (DISTINCT (cod_ndg)) VAL_TOT_NDG, SUM (val_vant) VAL_VANTATO, SUM (val_uti_ret) val_gbv, SUM (val_att) val_nbv FROM (SELECT cp.cod_abi, SUBSTR (cp.id_dper, 1, 6) val_annomese, cp.cod_ndg, cp.val_uti_ret, cp.val_att, cp.val_vant, s.val_imp_garanzie_personali, s.val_imp_garanzia_ipotecaria, s.val_imp_garanzie_pignoratizie FROM t_mcres_app_sisba_cp cp, T_MCRES_APP_SISBA S WHERE cp.cod_abi = s.cod_abi(+) AND cp.cod_ndg = s.cod_ndg(+) AND cp.id_dper = s.id_dper(+) AND cp.cod_rapporto = s.cod_rapporto_sisba(+) AND cp.cod_sportello = s.cod_filiale_rapporto(+) AND cp.val_firma != 'FIRMA' AND CP.COD_STATO_RISCHIO = 'S' AND TO_CHAR (cp.dta_decorrenza_stato, 'YYYY') = SUBSTR (cp.id_dper, 1, 4)) GROUP BY cod_abi, val_annomese UNION ALL SELECT cod_abi, val_annomese, 1 FLG_GAR_REALI_PERSONALI, 1 FLG_GAR_REALI, COUNT (DISTINCT (cod_ndg)) tot_ndg, SUM (val_vant) VAL_VANTATO, SUM (val_uti_ret) val_gbv, SUM (val_att) val_nbv FROM (SELECT cp.cod_abi, SUBSTR (cp.id_dper, 1, 6) val_annomese, cp.cod_ndg, cp.val_uti_ret, cp.val_att, cp.val_vant, s.val_imp_garanzie_personali, s.val_imp_garanzia_ipotecaria, s.val_imp_garanzie_pignoratizie FROM t_mcres_app_sisba_cp cp, T_MCRES_APP_SISBA S WHERE cp.cod_abi = s.cod_abi(+) AND cp.cod_ndg = s.cod_ndg(+) AND cp.id_dper = s.id_dper(+) AND cp.cod_rapporto = s.cod_rapporto_sisba(+) AND cp.cod_sportello = s.cod_filiale_rapporto(+) AND cp.val_firma != 'FIRMA' AND CP.COD_STATO_RISCHIO = 'S' AND TO_CHAR (cp.dta_decorrenza_stato, 'YYYY') = SUBSTR (cp.id_dper, 1, 4)) WHERE NVL (val_imp_garanzie_personali, 0) > 0 OR NVL (val_imp_garanzia_ipotecaria, 0) > 0 OR NVL (val_imp_garanzie_pignoratizie, 0) > 0 GROUP BY cod_abi, val_annomese UNION ALL SELECT cod_abi, val_annomese, 0 FLG_GAR_REALI_PERSONALI, 1 FLG_GAR_REALI, COUNT (DISTINCT (cod_ndg)) VAL_TOT_NDG, SUM (val_vant) val_vantato, SUM (val_uti_ret) val_gbv, SUM (val_att) val_nbv FROM (SELECT cp.cod_abi, SUBSTR (cp.id_dper, 1, 6) val_annomese, cp.cod_ndg, cp.val_uti_ret, cp.val_att, cp.val_vant, s.val_imp_garanzie_personali, s.val_imp_garanzia_ipotecaria, s.val_imp_garanzie_pignoratizie FROM t_mcres_app_sisba_cp cp, T_MCRES_APP_SISBA S WHERE cp.cod_abi = s.cod_abi(+) AND cp.cod_ndg = s.cod_ndg(+) AND cp.id_dper = s.id_dper(+) AND cp.cod_rapporto = s.cod_rapporto_sisba(+) AND cp.cod_sportello = s.cod_filiale_rapporto(+) AND cp.val_firma != 'FIRMA' AND CP.COD_STATO_RISCHIO = 'S' AND TO_CHAR (cp.dta_decorrenza_stato, 'YYYY') = SUBSTR (cp.id_dper, 1, 4)) WHERE NVL (val_imp_garanzie_pignoratizie, 0) > 0 OR NVL (val_imp_garanzia_ipotecaria, 0) > 0 GROUP BY COD_ABI, val_annomese;
/*Borrado de tablas de la base de datos*/ DROP TABLE PARTIDOS; DROP TABLE TENER; DROP TABLE EQUIPO; DROP TABLE JORNADA; DROP TABLE TEMPORADA; DROP TABLE ESTADIO;
DROP SEQUENCE plugins.transferencialoteobservacao_sequencial_seq; DROP TABLE plugins.transferencialoteobservacao;
-- ****************************************************** -- ****************************************************** -- DOG_RACING -- ****************************************************** -- ****************************************************** -- 1. -- Pays avec ‘U’ USE Dog_Racing; SELECT * FROM pays WHERE pays.nomP LIKE '%U%'; -- 2. -- Pays sans ‘U’ USE Dog_Racing; SELECT * FROM Dog_Racing.pays where nomP NOT LIKE '%U%'; -- 3. -- Combien de pays sans ‘U’ USE Dog_Racing; SELECT count(nomP) FROM Dog_Racing.pays WHERE nomP NOT LIKE '%U%'; -- 4. -- Nom des chiens sans description USE Dog_Racing; SELECT * FROM Dog_Racing.chien WHERE descCh IS NULL; -- 5. -- ID, Nom et description des chiens ‘BE’ USE Dog_Racing; SELECT idCh, nomCh, descCh FROM chien WHERE nationCh = 'BE' ORDER BY nomCh ASC; -- 6. -- Combien de pays en tout USE Dog_Racing; SELECT count(nomP) FROM Dog_Racing.pays ORDER BY nomP ASC; -- 7. -- Course en 2014 USE Dog_Racing; SELECT nomC, YEAR(dateC) AS ANNEE FROM Dog_Racing.course HAVING ANNEE = '2014' ORDER BY nomC ASC; -- 8. -- Combien de pays DIFFÉRENTs accueillent des courses USE Dog_Racing; SELECT DISTINCT nomP FROM Dog_Racing.course INNER JOIN Dog_Racing.pays ON Dog_Racing.course.lieuC = Dog_Racing.pays.codeP ORDER BY nomP ASC; -- ****************************************************** -- ****************************************************** -- TINTIN -- ****************************************************** -- ****************************************************** -- 9. -- Pers (Nom, Prénom) ASC USE tintin; SELECT nomPers, prenomPers FROM personnage ORDER BY nomPers ASC; -- 10. -- Pers F sans prénom DESC USE tintin; SELECT nomPers, prenomPers, sexePers FROM personnage WHERE sexePers = 'F' AND prenomPers IS NULL ORDER BY nomPers DESC; -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1. -- Affichez la liste (par ordre alphabétique sur le nom) -- des personnages féminins ne possédant pas de prénom. USE tintin; SELECT nomPers FROM personnage WHERE sexePers = 'F' and prenomPers IS NULL ORDER BY nomPers ASC; -- 2. -- Affichez la liste des personnages (Nom et Prénom) présents -- dans l'album "L'ILE NOIRE" classés par idPers. USE tintin; SELECT nomPers, prenomPers FROM personnage INNER JOIN pers_album on personnage.idPers = pers_album.idPers INNER JOIN album on pers_album.idAlb = album.idAlb WHERE titreAlb = 'L''ILE NOIRE' ORDER BY personnage.idPers; -- 3. -- Quelles sont les dates de début et de fin des aventures de Tintin ? SELECT (SELECT dateAlb FROM album ORDER BY dateAlb ASC LIMIT 1) AS dateMin, (SELECT dateAlb FROM album ORDER BY dateAlb DESC LIMIT 1) AS dateMax; -- other solution SELECT MIN(dateAlb) AS dateMin, MAX(dateAlb) AS dateMax FROM album; -- 4. -- Quelle est l'année durant laquelle les personnages ont été les plus "grossiers" ? -- Indiquez le nombre de jurons prononcés durant cette année-là. SELECT count(juron_album.idJur) AS nbrJuron, dateAlb FROM album inner JOIN juron_album ON album.idAlb = juron_album.idAlb GROUP BY dateAlb ORDER BY nbrJuron DESC LIMIT 1; -- 5. -- Quel(s) est(sont) le(s) juron(s) qui est(sont) prononcés exactement 15 fois -- durant les aventures de Tintin ? SELECT count(juron_album.idJur) AS NbrJur, nomJur FROM juron_album inner JOIN juron ON juron_album.idJur = juron.idJur GROUP BY juron_album.idJur HAVING NbrJur = 15 ORDER BY NbrJur DESC; -- 6. -- Affichez le nom et la fonction des personnages féminins gentils classés par nom SELECT nomPers, fonctPers FROM personnage WHERE sexePers = 'F' AND gentilPers = 1 ORDER BY nomPers ASC; -- 7. -- Combien de personnage ont visité la Belgique, le Congo, le Népal ou l'Islande ? -- Affichez la réponse en détaillant le nombre pour chaque pays SELECT count(DISTINCT nomPers) AS nbrPers, GROUP_CONCAT(DISTINCT nomPays) FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays WHERE nomPays in ('BELGIQUE', 'CONGO', 'NEPAL', 'ISLANDE') GROUP BY pays.idPays ORDER BY nbrPers DESC; -- 8. -- Liste des albums classés par idAlb -- + pays associés à chaque album classés par ordre alphabétique -- (titreAlb, dateAlb, nomPays) SELECT titreAlb, dateAlb, nomPays FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays ORDER BY titreAlb ASC; -- 9. -- Quelles sont les dates des 2ème et avant-dernier albums -- des aventures de Tintin en considérant un ordre chronologique ? SELECT 2EME.titreAlb, 2EME.dateAlb, AVTDERN.titreAlb, AVTDERN.dateAlb FROM (SELECT * FROM album ORDER BY dateAlb ASC LIMIT 1,1) AS 2EME, (SELECT * FROM album ORDER BY dateAlb DESC LIMIT 1,1) AS AVTDERN; -- 10. -- Plusieurs albums de Tintin se déroulent dans plusieurs pays. -- Si le nombre de pays fréquentés est au nombre de 3, -- affichez ces pays ainsi que le titre de l'album. USE tintin; SELECT GROUP_CONCAT(DISTINCT nomPays), titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY pays_album.idAlb HAVING COUNT(DISTINCT nomPays) = 3; -- other solution USE tintin; SELECT nomPays, titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays HAVING titreAlb in (SELECT titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY pays_album.idAlb HAVING COUNT(DISTINCT nomPays) = 3); -- 11. -- Liste des jurons (nom,id) commençant par "Espece de" classés par nom SELECT nomJur, idJur FROM juron WHERE nomJur LIKE 'Espece de%' ORDER BY nomJur ASC; -- 12. Liste des 5 plus grands jurons (nom, id, longueur) -- classés par longueur ( length() = longueur d’une chaîne de caractères) SELECT nomJur, idJur, LENGTH(nomJur) as TAILLE FROM juron ORDER BY TAILLE DESC LIMIT 5; -- 13. Pour chaque album (id, titre), -- le nom, le prénom et la fonction des personnages féminins SELECT album.idAlb, album.titreAlb, group_concat('nom : ',personnage.nomPers, ' prénom : ',personnage.nomPers, ' function : ', personnage.fonctPers, '\n' ) FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE personnage.sexePers = 'F' GROUP BY album.idAlb; -- other solution SELECT album.idAlb, album.titreAlb, personnage.nomPers, personnage.nomPers, personnage.fonctPers FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE personnage.sexePers = 'F' ORDER BY titreAlb; -- 14. -- Liste des gentils personnages féminins classé nom SELECT nomPers FROM personnage WHERE gentilPers = 1 and sexePers = 'F' ORDER BY nomPers; -- 15. -- liste des albums classé par id + Nombre de pays associé à chaque album -- (idalb, titre, année, Nb pays visités) SELECT album.idAlb, album.titreAlb, album.dateAlb, COUNT(DISTINCT nomPays) AS CPT FROM album INNER JOIN pays_album on album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY album.idAlb ORDER BY CPT, dateAlb, titreAlb ASC; -- 16. -- Année de réalisation de "Tintin au Congo" SELECT dateAlb FROM album WHERE titreAlb = 'Tintin au Congo'; -- 17. -- Prénom du Capitaine Haddock SELECT prenomPers FROM personnage WHERE nomPers = 'Haddock'; -- 18. -- Dans quel(s) pays se déroule(nt) "On a marche sur la lune" SELECT nomPays FROM pays INNER JOIN pays_album ON pays.idPays = pays_album .idPays INNER JOIN album ON pays_album.idAlb = album.idAlb WHERE titreAlb = 'On a marche sur la lune'; -- 19. -- La "Castafiore" pronnonce-t-elle des jurons ? SELECT CONCAT('La Castafiore a prononcé : ', COUNT(idJur), ' juron(s)') FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers = 'Castafiore'; -- others solutions USE tintin; SELECT IF((SELECT COUNT(idJur) AS CPT FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers = 'Castafiore') > 0, 'Oui', 'non'); -- 20. -- Nom des albums dans lesquels Tintin voyage en Chine SELECT DISTINCT titreAlb FROM personnage INNER JOIN pers_album ON pers_album.idPers = personnage.idPers INNER JOIN album ON album.idAlb = pers_album.idAlb INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays WHERE nomPays = 'CHINE'; -- 21. -- Quels sont les personnages non anonyme ayant prononcé plus de 100 jurons -- durant les aventures de Tintin SELECT nomPers, count(DISTINCT juron_album.idJur) AS CPT FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers != 'anonyme' OR prenomPers != 'anonyme' GROUP BY personnage.idPers HAVING CPT > 100 ORDER BY CPT DESC; -- other solution SELECT nomPers FROM personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers WHERE nomPers != 'anonyme' OR prenomPers != 'anonyme' GROUP BY personnage.idPers HAVING count(DISTINCT juron_album.idJur) > 100; -- 22. -- Quel est le nombre de jurons prononcé par les personnages figurant -- dans "Le Lotus Bleu" SELECT nomPers, prenomPers, count(juron_album.idJur) FROM personnage INNER JOIN juron_album ON personnage.idPers = juron_album.idPers INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE titreAlb = 'Le Lotus Bleu' GROUP BY personnage.idPers; -- 23. -- Quel est l'album ou haddock a prononce le plus de juron SELECT titreAlb, count(DISTINCT idJur) AS CPT FROM album INNER JOIN juron_album on album.idAlb = juron_album.idAlb INNER JOIN personnage on juron_album.idPers = personnage.idPers WHERE nomPers = 'haddock' GROUP BY album.idAlb ORDER BY CPT DESC LIMIT 1; -- 24. -- Album et N° Page où on peut lire : -- "REVOLUTIONNAIRE EN PEAU DE LAPIN" SELECT album.titreAlb, juron_album.numPage FROM album INNER JOIN juron_album ON album.idAlb = juron_album.idAlb INNER JOIN juron ON juron_album.idJur = juron.idJur WHERE nomJur = 'REVOLUTIONNAIRE EN PEAU DE LAPIN'; -- 25. -- Liste des pays visités par le Prof TOURNESOL SELECT DISTINCT nomPays FROM pays INNER JOIN pays_album ON pays.idPays = pays_album.idPays INNER JOIN album ON pays_album.idAlb = album.idAlb INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE nomPers = 'TOURNESOL' ORDER BY nomPays ASC; -- -- -- -- -- -- -- -- -- -- OTHERS -- 1. -- Affichez les albums de Tintin classés par ordre chronologique décroissant. SELECT titreAlb FROM album ORDER BY titreAlb DESC; -- 2. -- Affichez les personnages féminins dont la fonction dans les aventures de TINTIN est connue. SELECT nomPers, prenomPers, fonctPers FROM personnage WHERE sexePers= 'F' AND fonctPers IS NOT NULL ORDER BY nomPers ASC; -- 3. -- Affichez la liste des jurons prononcés dans l'album "OBJECTIF LUNE" à la dixième page. SELECT nomJur FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE titreAlb = 'OBJECTIF LUNE' AND numPage = 10 ORDER BY nomJur ASC; -- 4. -- Affichez la liste des jurons (sans doublons) prononcés par les bandits et les perroquets -- dans les albums "TINTIN EN AMERIQUE" et "L'OREILLE CASSEE". Seul le nom des jurons sera affiché -- et ils seront classés alphabétiquement. SELECT DISTINCT nomJur FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb INNER JOIN pers_album pa ON album.idAlb = pa.idAlb INNER JOIN personnage ON juron_album.idPers = personnage.idPers WHERE fonctPers in('bandit', 'perroquet') AND titreAlb IN('TINTIN EN AMERIQUE', 'L''OREILLE CASSEE') ORDER BY nomJur ASC; -- 5. -- Affichez le nom des personnages différents ayant prononcé un ou plusieurs jurons dans les 2 premières pages des albums. SELECT DISTINCT nomPers FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb INNER JOIN pers_album pa ON album.idAlb = pa.idAlb INNER JOIN personnage ON juron_album.idPers = personnage.idPers WHERE numPage = 2 GROUP BY personnage.idPers HAVING count(DISTINCT juron.idJur) > 0; -- 6. -- Combien de juron ont été prononcé par les 2 héros (Tintin et le capitaine Haddock) dans les albums "LE SECRET DE LA LICORNE" et -- "ON A MARCHE SUR LA LUNE". Présentez le rapport en indiquant le nombre par album et par personne. SELECT album.titreAlb, personnage.nomPers, count(juron_album.idJur) AS nb FROM personnage INNER JOIN juron_album ON personnage.idPers = juron_album.idPers INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE (personnage.nomPers = 'tintin' OR personnage.nomPers = 'Haddock') and (album.titreAlb = 'LE SECRET DE LA LICORNE' or album.titreAlb = 'ON A MARCHE SUR LA LUNE') GROUP BY personnage.idPers, album.idAlb; -- 7. -- Affichez le nombre de personnages différents renseignés dans la DB pour tous les albums de Tintin encodés. -- Classez le rapport de manière décroissante sur le nombre. SELECT titreAlb, count(DISTINCT pers_album.idPers) AS nbPers FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers GROUP BY album.idAlb ORDER BY nbPers DESC; -- 8. -- Quelle est l'année et le titre de l'album dans lequel la "CASTAFIORE" est apparue pour la 1ere fois SELECT titreAlb FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE nomPers = 'CASTAFIORE' ORDER BY dateAlb LIMIT 1; -- 9. Quel(s) est(sont) le(s) personnage(s) qui participe(nt) à 5 aventures de Tintin uniquement SELECT nomPers, count(DISTINCT titreAlb) as NbrAlb FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb GROUP BY personnage.idPers HAVING NbrAlb = 5 ORDER BY NbrAlb DESC; -- 10. -- La DB renseigne que le juron "SCOLOPENDRE" a été prononcé par le capitaine Archibald Haddock dans "LE SECRET DE LA LICORNE" -- à la page 20. Vérifiez cette info à l'aide d'une requête SELECT count(nomJur) FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb INNER JOIN juron_album ON album.idAlb = juron_album.idAlb INNER JOIN juron ON juron_album.idJur = juron.idJur WHERE nomPers = 'Haddock' AND titreAlb = 'LE SECRET DE LA LICORNE' AND numPage = 20 AND nomJur = 'SCOLOPENDRE'; -- other solution SELECT IF((SELECT count(nomJur) FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb INNER JOIN juron_album ON album.idAlb = juron_album.idAlb INNER JOIN juron ON juron_album.idJur = juron.idJur WHERE nomPers = 'Haddock' AND titreAlb = 'LE SECRET DE LA LICORNE' AND numPage = 20 AND nomJur = 'SCOLOPENDRE') > 0, 'Oui', 'non'); -- 11. -- Quel(s) est(sont) le(s) titre(s) de(s) albums de Tintin dont l'aventure réunit plus de 15 personnages "gentils" ? -- Indiquez également le nombre de personnage dans la réponse. SELECT titreAlb, count(pers_album.idPers) nbrPers FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE gentilPers = '1' GROUP BY album.idAlb HAVING nbrPers > 15 ORDER BY nbrPers DESC; -- 12. -- Quel(s) est(sont) le(s) titre(s) des albums de Tintin dont l'aventure se déroule dans UN SEUL pays ? SELECT titreAlb FROM album INNER JOIN pays_album ON album.idAlb = pays_album.idAlb INNER JOIN pays ON pays_album.idPays = pays.idPays GROUP BY album.titreAlb HAVING count(nomPays) = 1 ORDER BY titreAlb ASC; -- 13. Combien d'années séparent le premier album de Tintin du dernier ? Faites-en sorte que l'affichage soit complet (Ex : 52 ans) SELECT concat(max(dateAlb) - min(dateAlb), ' ans') FROM album; -- other solution SELECT concat( ( (SELECT dateAlb FROM album order by dateAlb desc LIMIT 1) - (SELECT dateAlb FROM album order by dateAlb asc LIMIT 1) ), ' ans'); -- 14. -- Regroupez et affichez par pays, le(les) ID du(des) pays fréquenté(s) dans chaque album de Tintin. SELECT titreAlb, GROUP_CONCAT(DISTINCT pays_album.idPays) FROM pays INNER JOIN pays_album ON pays.idPays = pays_album.idPays INNER JOIN album ON pays_album.idAlb = album.idAlb GROUP BY album.titreAlb; -- 15. -- Combien de jurons sont prononcés au total dans les albums écrits avant 1945 ? Affichez la réponse en détaillant pour -- chaque album. Soignez la lecture du rapport. SELECT coalesce(titreAlb, 'Nombre Total de jurons') AS 'Titre des Albums', count(juron_album.idJur) AS 'Nombre de jurons par album' FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur INNER JOIN album ON juron_album.idAlb = album.idAlb WHERE dateAlb < 1945 GROUP BY album.titreAlb WITH ROLLUP; -- 16. -- Affichez la liste (clé, nom et prénom) sans doublons des personnages méchants présents dans les albums "TINTIN AU CONGO" -- et "TINTIN ET LES PICAROS" classés par clé. SELECT DISTINCT personnage.idPers, personnage.nomPers, personnage.prenomPers FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb WHERE album.titreAlb in('TINTIN AU CONGO','TINTIN ET LES PICAROS') AND personnage.gentilPers = 0 ORDER BY personnage.idPers; -- 17. -- Dans la requête 16, quels sont les doublons qui ont été masqué ainsi que le nombre de fois qu’ils auraient dû apparaitre ? SELECT concat(personnage.nomPers, ' apparaît ', coalesce(personnage.prenomPers, '')) AS personnage, count(personnage.idPers) AS DOUBLON FROM personnage INNER JOIN pers_album ON personnage.idPers = pers_album.idPers INNER JOIN album ON pers_album.idAlb = album.idAlb WHERE album.titreAlb in ('TINTIN AU CONGO', 'TINTIN ET LES PICAROS') AND personnage.gentilPers = 0 GROUP BY personnage.idPers HAVING DOUBLON > 1 ORDER BY personnage.idPers; -- other solution SELECT idPers, nomPers, count(nomPers) nb FROM personnage INNER JOIN pers_album USING (idPers) INNER JOIN album USING (idAlb) WHERE gentilPers = 0 AND titreAlb in ('tintin au congo', 'tintin et les picaros') GROUP BY idPers HAVING nb > 1 ORDER BY idPers; -- 18. -- Affichez les pays visités lors des aventures de Tintin entre 1955 et 1962 (années incluses) SELECT titreAlb FROM album WHERE dateAlb BETWEEN 1955 AND 1962 ORDER BY titreAlb ASC; -- other solution SELECT titreAlb FROM album WHERE dateAlb >= 1955 AND dateAlb <= 1962 ORDER BY titreAlb ASC; -- 19. -- Affichez les personnages "non anonyme" ayant participés aux albums dont le titre comporte le mot "Tintin" SELECT nomPers, titreAlb FROM album INNER JOIN pers_album ON album.idAlb = pers_album.idAlb INNER JOIN personnage ON pers_album.idPers = personnage.idPers WHERE titreAlb like '%Tintin%' AND nomPers != 'ANONYME'; -- 20. -- Un impoli se voit infliger une amende de 0,10 € par juron s'il en a prononcé plus de 20. -- D'après les jurons répertoriés, quelle sera l'amende à payer par les inconvenants ? -- Etant donné qu'on ne sait poursuivre un "Anonyme", ils seront retirés de la liste SELECT nomPers, 0.10 * count(juron_album.idJur) AS Amande FROM personnage INNER JOIN juron_album ON personnage.idPers = juron_album.idPers WHERE nomPers != 'ANONYME' GROUP BY personnage.idPers HAVING count(juron_album.idJur) > 20 ORDER BY Amande DESC; -- 21. -- Affichez le podium (3 premiers) des jurons les plus prononcés. SELECT nomJur, count(juron_album.idJur) AS nbrJur FROM juron INNER JOIN juron_album ON juron.idJur = juron_album.idJur GROUP BY juron.idJur ORDER BY nbrJur DESC LIMIT 3; -- 22. -- Affichez le nombre de personnage n'ayant pas de prénom connu en détaillant le nombre pour chaque album -- ****************************************************** -- ****************************************************** -- LOCAVOIT -- ****************************************************** -- ****************************************************** -- 23. -- Affichez la liste des clients (id, nom, prenom) classée par ordre alphabétique USE locavoit; SELECT idCli, nomCli, prenomCli FROM clients ORDER BY nomCli ASC; -- 24. -- Affichez les voitures toujours en service de catégorie A ou B SELECT * from voitures WHERE catvoit IN ('A','B') AND dfinvoit IS NULL; -- 25. -- Affichez la liste des voitures en location (id, modele, categ, carbu, km, dDebLoc) SELECT idVoit, modVoit, catVoit, carbvoit, kmVoit, dDebloc from voitures INNER JOIN locations ON voitures.idvoit = locations.voitureLoc WHERE ddebloc IS NOT NULL AND dfinloc IS NULL; -- 26. NOT END -- Affichez la liste des voitures disponibles à la location (en service et pas de location en cours) - (id, modele, categ, carbu, km, nbPortes, nbPlaces, nbBaggages) SELECT idVoit, modVoit, catVoit, carbVoit, kmVoit, nbportescat, nbplacescat, nbbagcat FROM voitures LEFT JOIN locations ON voitureLoc=idvoit --ATTENTION OBLIGATOIRE LEFT(pour avoir meme les-- LEFT JOIN categories ON idcat=catvoit --FK null-- WHERE dfinvoit IS NULL GROUP BY idvoit HAVING (COUNT(ddebloc)-COUNT(dfinloc))= 0 --pas de locations en cours--; -- 27. -- Pour chaque catégorie : id, desc, nb voitures en service, nb voitures pas en service SELECT idvoit, desccat, COUNT(idvoit)-COUNT(dfinvoit) as NbvoitOK, COUNT(dfinvoit) as nbvoitOUT from categories INNER JOIN voitures ON voitures.catvoit = categories.idcat GROUP BY idcat; -- 28. -- Affichez la liste des voitures (id, modele, categ, carbu, km) qui n'ont jamais été louées SELECT idvoit, modvoit, catvoit, carbvoit, kmvoit from Voitures LEFT JOIN locations ON voitures.idvoit = locations.voitureloc WHERE idloc IS NULL; -- 29. -- Affichez la liste des locations en cours: idLoc, dDebLoc, voiture, nomCli, prenomCli, nb de jours de location SELECT idloc, ddebloc, voitureLoc, nomcli, prenomcli, DATEDIFF(CURDATE(), ddebloc)+1 as nbjourloc from locations INNER JOIN clients ON locations.clientloc = clients.idcli WHERE dfinloc IS NULL; -- 30. -- Quel est le meilleur client (plus grand nombre de locations) ? (id, nom, prénom, nbre de locations, prix total des locations) SELECT idcli, Nomcli, prenomcli, COUNT(clientloc) as nombreloc, SUM(prixloc) as TOTLOC from locations INNER JOIN clients ON locations.clientloc = clients.idcli GROUP BY idcli ORDER BY nombreloc desc LIMIT 1; -- 31. -- Affichez la liste des clients ayant loué pour plus de 1000 € (id, nom, prénom) SELECT idcli, Nomcli, prenomcli, SUM(prixloc) as TOTLOC from locations INNER JOIN clients ON locations.clientloc = clients.idcli GROUP BY idcli HAVING TOTLOC>1000; -- 32. -- Affichez toutes les locations du client 1, la durée de location et les km parcourus SELECT idloc, voitureloc as voiture, (dfinloc-ddebloc +1) as durée, (kmfinloc-kmdebloc) as km, prixloc,remloc FROM locations INNER JOIN voitures ON idvoit= voitureloc WHERE clientloc=1; -- 33. -- Affichez le nombre de locations pour tous les clients SELECT idcli, nomcli, prenomcli, COUNT(idloc) as nbloc from clients INNER JOIN locations ON idcli = clientloc GROUP BY idcli; -- 34. -- Affichez la liste des clients ayant plus d’une location en cours SELECT idcli, nomcli, prenomcli, COUNT(idloc) from clients INNER JOIN locations ON idcli = clientloc WHERE dfinloc is NULL GROUP BY idcli HAVING COUNT(idloc)>1; -- 35. -- Affichez le nombre de locations pour tous les clients, le km total parcouru, la durée totale SELECT idcli, nomcli, prenomcli, COUNT(clientloc) as nbloc, SUM(kmfinloc-kmdebloc) as kmparcouru, SUM(DATEDIFF(dfinloc,dDebloc)) as dureetot from locations INNER JOIN clients ON clientloc=idcli GROUP BY idcli ORDER BY nomcli; -- -- -- -- -- -- -- EVALUATION PERSONNEL -- 1. -- Donnez les noms et prénoms des personnages méchants présent dans l'album "Le Lotus Bleu". select nomPers, prenomPers, gentilPers from personnage inner join pers_album on personnage.idPers = pers_album.idPers inner join album on pers_album.idAlb = album.idAlb WHERE titreAlb = 'le Lotus Bleu' and gentilPers = 0 ORDER BY nomPers; -- 2. -- Etablissez la liste des différents jurons prononcés par Milou. select nomPers, nomJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers = 'Milou' GROUP BY juron.idJur; -- 3. -- Donnez le nombre de jurons prononcés par chaque personnage non anonyme. -- Le rapport sera classé de manière décroissante en fonction du nombre. select nomPers, count(juron_album.idJur) AS nbrJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers != 'ANONYME' GROUP BY juron_album.idPers ORDER BY nbrJur DESC; -- 4. WRONG ! -- Quels sont les personnages (id, Nom et prénom) n'ayant pas prononcé de juron dans les album de tintin. select personnage.idPers, nomPers, prenomPers from personnage INNER JOIN juron_album on personnage.idPers = juron_album.idPers INNER JOIN juron on juron_album.idJur = juron.idJur WHERE juron_album.idJur IS NULL GROUP BY juron_album.idPers; -- 5. -- Etablissez la liste des 10 personnages non anonyme prononçant le plus de jurons différents et -- classez la par le nombre de jurons décroissant. select nomPers, group_concat(nomJur), count(DISTINCT juron_album.idJur) nbrJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers != 'ANONYME' GROUP BY juron_album.idPers ORDER BY nbrJur DESC limit 10; -- 6. -- Lequel des 2 Dupont (T ou D) a prononcé le plus souvant des jurons ? Combien ? select nomPers, count(juron_album.idJur) AS nbrJur from personnage inner join juron_album on personnage.idPers = juron_album.idPers inner join juron on juron_album.idJur = juron.idJur WHERE nomPers = 'DUPONT' OR nomPers = 'DUPOND' GROUP BY juron_album.idPers ORDER BY nbrJur DESC; -- 7. -- En quelle année et dans quel album le capitaine HADDOCK apparaît il pour la premère fois ? select nomPers, titreAlb, dateAlb from personnage inner join pers_album on personnage.idPers = pers_album.idPers inner join album on pers_album.idAlb = album.idAlb WHERE nomPers = 'HADDOCK' ORDER BY dateAlb LIMIT 1; -- 8. WRONG ! -- Pour les jurons "FORBAN" et "GREDIN", donnez le nom du juron, l'année durant laquelle il a été -- écrit pour la première fois ainsi que le nombre de personnage différent les ayant prononcés. SELECT DISTINCT nomJur, MIN(dateAlb), count(juron_album.idPers) from juron INNER JOIN juron_album USING (idJur) INNER JOIN personnage USING (idPers) INNER JOIN pers_album USING (idPers) INNER JOIN album on pers_album.idAlb = album.idAlb WHERE nomJur = 'FORBAN' OR nomJur = 'GREDIN' GROUP BY juron_album.idJur; -- 9. -- Quels sont les personnages différents non anonyme autre que milou, HADDOCK, Tintin, Dupont et Dupond, -- présent dans les aventures de Tintin entre 1937 et 1940. On retrouve la date, ID et le nom du personnage dans le rapport. select personnage.idPers, nomPers, prenomPers, dateAlb, titreAlb from personnage inner join pers_album on personnage.idPers = pers_album.idPers inner join album on pers_album.idAlb = album.idAlb WHERE nomPers != 'Milou' and nomPers != 'HADDOCK' and nomPers != 'TINTIN' and nomPers != 'Dupont' and nomPers != 'Dupond' and nomPers != 'ANONYME' and dateAlb BETWEEN '1937' AND '1940' ORDER BY dateAlb; -- ****************************************************** -- ****************************************************** -- ECOLE / DOG_RACING -- ****************************************************** -- ****************************************************** -- 1. -- a. -- Dans la table "pays", ajouter un enregistrement dont le "codeP" sera 'XX' et le "nomP" sera 'Indéterminé' DELETE FROM Dog_Racing.pays WHERE codeP = 'XX'; USE Dog_Racing; INSERT INTO Dog_Racing.pays (codeP, nomP) VALUES ('XX', 'Indéterminé'); UPDATE Dog_Racing.pays SET codeP= 'XX' WHERE codeP = 'XY'; -- b. -- Dans la table "chien", mettre à jour la valeur du champ "nationCh". -- Si "nationCh" est NULL, il prendra la valeur 'XX'. UPDATE Dog_Racing.chien SET descCh = 'Indéterminé' WHERE descCh IS NULL; -- c. -- Créer une requête préparée qui permettra d'afficher le nom des chiens et leur pays -- d'origine en toutes lettres ainsi que le temps qu'ils ont mis lors d'une course rentrée en -- paramètre. La requête présentera les données en classant les enregistrements par ordre -- croissant de leurs résultats. PREPARE P_details_Courses FROM 'SELECT nomCh, nomP, temps FROM chien INNER JOIN resultat ON resultat.idCh = chien.idCh INNER JOIN course ON course.idC = resultat.idC INNER JOIN pays ON pays.codeP = chien.nationCh WHERE nomC = ? ORDER BY temps ASC'; SET @course = "IEPSCF, du C308 au C313"; EXECUTE P_details_Courses USING @course -- 2. -- Créer une vue qui affichera la course la plus rapide en fonction du temps mis par le 1er. drop view v_courserapide; CREATE VIEW V_courseRapide AS SELECT nomC FROM course WHERE idC = ( SELECT idC FROM resultat ORDER BY temps ASC LIMIT 1 ) ; SELECT * FROM V_courseRapide; -- 3. -- Créez une vue qui permettra d'afficher le nom et le pays d'origine en toutes lettres des chiens -- n'ayant participés à aucune course. CREATE VIEW V_chien_noCourse AS SELECT nomCh, nomP FROM chien LEFT JOIN resultat ON chien.idCh = resultat.idCh LEFT JOIN course ON resultat.idC = course.idC LEFT JOIN pays ON chien.nationCh = pays.codeP WHERE temps IS NULL ORDER BY nomCh ASC; SELECT * FROM V_chien_noCourse; -- 4. -- Créer une requête préparée qui prendra en paramètre le nom d'une course ainsi que le nom -- d'un chien (les 2 en toutes lettres). -- La vue renverra le temps mis par ce chien lors de cette course s' il y a participé. SELECT * FROM course LEFT JOIN resultat ON course.idC = resultat.idC LEFT JOIN chien ON resultat.idC = chien.idCh WHERE nomCh = "Bill" AND nomC = "ami de Boule"; SELECT nomCh, nomC, temps FROM chien LEFT JOIN resultat ON chien.idCh = resultat.idCh LEFT JOIN course ON resultat.idC = course.idC WHERE nomCh = "Bill" AND nomC = "Paris en motocrotte"; PREPARE V_dog_course FROM 'SELECT temps FROM chien LEFT JOIN resultat ON chien.idCh = resultat.idCh LEFT JOIN course ON resultat.idC = course.idC WHERE nomCh = ? AND nomC = ?' ; SET @nomChien = 'Bill', SET SET @nomCourse = 'Paris en motocrotte'; SELECT @nomChien, @nomCourse; EXECUTE V_dog_course USING @nomChien, @nomCourse; -- 5. -- Affichez la clé primaire, le nom et le prénom des étudiants et des professeurs de la formation «Fleuriste » (FLEU). USE ecole; SELECT PK_Pers, Nom, Prenom FROM t_pers INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_pers INNER JOIN t_branche ON t_inscription.FK_Cours = t_branche.PK_Branche WHERE PK_Branche = 'FLEU' UNION ALL SELECT PK_Pers, Nom, Prenom FROM t_pers INNER JOIN t_Prof ON t_pers.PK_Pers = t_Prof.FK_pers INNER JOIN t_branche ON t_Prof.FK_Branche = t_branche.PK_Branche WHERE PK_Branche = 'FLEU' -- 6. -- Combien y a-t-il d'étudiants masculins par niveau d’étude inscrits dans l’établissement ? -- L’affichage nous donnera également le nombre total. SELECT COALESCE(Etude, '-- Total --') AS total, count(DISTINCT FK_Pers) AS nbr FROM t_pers INNER JOIN t_inscription ON PK_Pers = FK_Pers WHERE Sexe= 'M' GROUP BY Etude WITH ROLLUP; -- 7. -- Combien y a-t-il de localité différente abritant un professeur ou un étudiant faisant partie de l'établissement. SELECT count(*) FROM ( SELECT DISTINCT PK_Loc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers union SELECT DISTINCT PK_Loc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_prof ON t_pers.PK_Pers = t_prof.FK_Pers ) AS nbr -- 8. -- Quelle est la durée totale de la formation d’un étudiant désirant suivre les cours de Carrosserie, Horlogerie et Construction. SELECT SUM(Duree) FROM ( SELECT Duree FROM t_branche WHERE branche in('Carrosserie', 'Horlogerie', 'Construction') ) AS nbr; -- other Solution USE ecole; SELECT SUM( (SELECT Duree FROM t_branche WHERE Branche = 'Carrosserie') + (SELECT Duree FROM t_branche WHERE Branche = 'Horlogerie') + (SELECT Duree FROM t_branche WHERE Branche = 'Construction') ); -- 9. -- a. -- Quelle est(sont) la(les) localité(s) la(les) mieux représentée(s) dans l'école en -- tenant compte des étudiants uniquement. SELECT count(FK_Loc) AS nbr, localite FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc HAVING nbr >= ( SELECT count(FK_Loc) AS nbrLoc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc ORDER BY nbrLoc DESC LIMIT 1,1 ) ORDER BY nbr DESC; -- b. -- Cela change-t-il si on tient compte des professeurs également ? SELECT count(FK_Loc) AS nbr, localite FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc HAVING nbr >= ( SELECT count(FK_Loc) AS nbrLoc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_loc UNION ALL SELECT count(FK_Loc) AS nbrLoc FROM t_loc INNER JOIN t_pers ON t_loc.PK_Loc = t_pers.FK_Loc INNER JOIN t_prof ON t_pers.PK_Pers = t_prof.FK_Pers GROUP BY PK_loc ORDER BY nbrLoc DESC LIMIT 1,1 ) ORDER BY nbr DESC; -- 10. -- Quelle est(sont) la(les) localité(s) qui ont le même nombre de représentants que la localité de "BOUGE" SELECT count(PK_Pers) AS nbr , localite FROM t_pers INNER JOIN t_loc ON t_pers.FK_Loc = t_loc.PK_Loc GROUP BY PK_Loc HAVING nbr = ( SELECT count(PK_Pers) FROM t_pers INNER JOIN t_loc ON t_pers.FK_Loc = t_loc.PK_Loc WHERE localite = 'BOUGE' GROUP BY PK_Loc ) ; -- 11. -- Quelles sont les étudiants (clé primaire, nom et prénom) inscrits à plus de 2 formations ? SELECT PK_Pers, Nom, prenom FROM t_pers INNER JOIN t_inscription ON t_pers.PK_Pers = t_inscription.FK_Pers GROUP BY PK_Pers HAVING count(FK_Cours) > 2; -- ****************************************************** -- ****************************************************** -- Exercices 17/12/2019 -- ****************************************************** -- ****************************************************** -- 1. -- Afficher les initiales des professeurs (M.V.) SELECT DISTINCT Nom, Prenom, CONCAT(LEFT(Nom,1), '.', LEFT(Prenom,1), '.' )AS Initiales FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers ; SELECT DISTINCT Nom, Prenom, CONCAT(SUBSTRING(Nom FROM 1 FOR 1), '.', SUBSTRING(Prenom FROM 1 FOR 1), '.' )AS Initiales FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers ORDER BY Nom ; SELECT DISTINCT Nom, Prenom, CONCAT(SUBSTRING(Nom FROM 2 FOR 3), '.', SUBSTRING(Prenom FROM 1 FOR 1), '.' )AS Initiales FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers ; -- 2. -- Afficher les intitulés des cours qui ne sont suivis par personne SELECT branche FROM T_Branche LEFT JOIN T_Inscription ON T_Inscription.FK_Cours = T_Branche.PK_Branche WHERE FK_Pers IS NULL ; -- 3. -- Afficher les intitulés des cours qui sont donnés par plus d'un professeur SELECT branche, COUNT(FK_Pers) AS Prof FROM T_Branche INNER JOIN T_Prof ON T_Prof.FK_Branche = T_Branche.PK_Branche GROUP BY PK_Branche HAVING Prof > 1 ; -- 4. NOT END -- Afficher les noms et prénoms des étudiants inscrits à au moins un cours qui ont moins de 30 ans UPDATE T_Pers SET DateNaissance = ( SELECT FROM_UNIXTIME(FLOOR(RAND()*UNIX_TIMESTAMP())) ); UPDATE T_Pers SET DateNaissance = ( SELECT ADDDATE(DateNaissance, INTERVAL -18 YEAR) ) ; SELECT CURRENT_DATE; SELECT CURRENT_DATE(); SELECT CURRENT_TIMESTAMP; SELECT CURRENT_TIMESTAMP(); SELECT Prenom, DateNaissance, TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE()) AS age FROM T_Pers WHERE PK_Pers <= 10; SELECT '1994-03-13', TIMESTAMPDIFF(second, '1994-03-13', CURDATE()) AS age; SELECT Prenom, DateNaissance, TIMESTAMPDIFF(SECOND, DateNaissance, CURDATE()) AS age FROM T_Pers WHERE PK_Pers <= 10; SELECT Nom, Prenom, DateNaissance, CONCAT(TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE()), ' ans') AS age FROM T_Pers INNER JOIN T_Inscription ON T_Inscription.FK_Pers = T_Pers.PK_Pers HAVING age < 30 ORDER BY age; -- other UPDATE t_pers SET t_pers.DateNaissance = (SELECT FROM_UNIXTIME(FLOOR(RAND()*UNIX_TIMESTAMP()))); UPDATE t_pers SET DateNaissance = (SELECT ADDDATE(DateNaissance, INTERVAL -18 YEAR)); -- 5. -- Afficher les noms et prénoms des professeurs qui donnent un cours de plus de 70 heures SELECT Nom, Prenom, Nb_Heure FROM T_Pers INNER JOIN T_Prof ON T_Prof.FK_Pers = T_Pers.PK_Pers INNER JOIN T_Branche ON T_Prof.FK_Branche = T_Branche.PK_Branche WHERE Nb_Heure > 70 ; -- 6. NOT END -- Afficher le nombre d’élèves qui suivent les cours de Corentin PIGEON SELECT COUNT(DISTINCT PK_Pers) AS Nb_Etudiant FROM T_Pers INNER JOIN T_Inscription ON T_Inscription.FK_Pers = T_Pers.PK_Pers WHERE FK_Cours IN ( SELECT PK_Branche FROM T_Branche INNER JOIN T_Prof ON T_Prof.FK_Branche = T_Branche.PK_Branche INNER JOIN T_Pers ON T_Prof.FK_Pers = T_Pers.PK_Pers WHERE nom = 'Pigeon' AND Prenom = 'Corentin' AND Nb_Heure IS NOT NULL ) ; SELECT COUNT(DISTINCT PK_Pers) AS Nb_Etudiant FROM T_Pers INNER JOIN T_Inscription ON T_Inscription.FK_Pers = T_Pers.PK_Pers WHERE FK_Cours IN ( SELECT PK_Branche FROM T_Branche INNER JOIN T_Prof ON T_Prof.FK_Branche = T_Branche.PK_Branche INNER JOIN T_Pers ON T_Prof.FK_Pers = T_Pers.PK_Pers WHERE nom = 'Pigeon' AND Prenom = 'Corentin' ) ; -- 7. -- Afficher les élèves qui suivent les cours d’un professeur qui a un âge supérieur à la moyenne des -- âges des élèves -- Explication d'une solution possible -- a : 1ère Sous-requête -- Afin de ne pas fausser la moyenne, il faut éliminer les doublons "Etudiant" -- b : 2de Sous-requête -- Calcul de la moyenne d'age de ces "Etudiant" -- c : 3ème Sous-requête -- PK des Profs plus agé que cette moyenne -- d : 4ème Sous-requête -- Détermination des cours donnés par ces profs -- e : Requête finale -- Affichage des étudiants SELECT DISTINCT PK_Pers, Nom, Prenom FROM T_Pers INNER JOIN T_Inscription ON T_Pers.PK_Pers = T_Inscription.FK_Pers WHERE FK_Cours IN ( SELECT DISTINCT FK_Branche FROM T_Prof WHERE FK_Pers IN ( SELECT DISTINCT PK_Pers FROM T_Prof INNER JOIN T_Pers ON T_Pers.PK_Pers = T_Prof.FK_Pers WHERE TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE()) > ( SELECT AVG(TIMESTAMPDIFF(YEAR, DateNaissance, CURDATE())) AS age FROM T_Pers WHERE PK_Pers IN ( SELECT DISTINCT PK_Pers FROM T_Pers INNER JOIN T_Inscription ON T_Pers.PK_Pers = T_Inscription.FK_Pers ) ) ) ) ;
create database db_ecommerce; use db_ecommerce; create table tb_usuario( id bigint auto_increment, nome_completo varchar(100) not null, email varchar(100) not null, senha varchar(60) not null, localizacao varchar(150) not null, avaliacao_usuario int, vendedor boolean not null, consumidor boolean not null, primary key (id) ); create table tb_categoria( id bigint auto_increment, produtos_servicos varchar(100) not null, ativo boolean not null, vegano boolean, primary key (id) ); create table tb_produtos( id bigint auto_increment, usuario_id bigint, categoria_id bigint, nome_produto_servico varchar(100) not null, preco_produto_servico decimal(8,2) not null, quantidade_consumidor int not null, estoque_vendedor int, localizacao varchar(150) not null, descricao_produto_servico varchar(300) not null, avaliacao_produto_servico int, primary key (id), foreign key (usuario_id) references tb_usuario (id), foreign key (categoria_id) references tb_categoria (id) );
/* Chapter 2: SELECT Overview */ /* Display an Entry */ /* We must first provide the contents for the sample entry. This is done by updating the existing row. Notice the WHERE clause at the end of the UPDATE statement. */ UPDATE entries SET content = 'When I was about nine or ten, my Uncle Karl, who would''ve been in his late teens or early twenties, once performed what to me seemed like a magic trick. Using a rubber hose, which he snaked down into the gas tank of my father''s car, he siphoned some gasoline into his mouth, lit a match, held it up a few inches in front of his face, and then, with explosive force, sprayed the gasoline out towards the lit match. Of course, a huge fireball erupted, much to the delight of the kids watching. I don''t recall if he did it more than once. The funny part of this story? We lived to tell it. Karl was like that.' WHERE id = 524 ; SELECT title , created , content FROM entries WHERE id = 524 ; /* Results should look like this -- title created content Uncle Karl and the Gasoline 2009-02-28 When I was about nine or ten, my Uncle Karl, who would've been in his late teens or early twenties, once performed what to me seemed like a magic trick. Using a rubber hose, which he snaked down into the gas tank of my father's car, he siphoned some gasoline into his mouth, lit a match, held it up a few inches in front of his face, and then, with explosive force, sprayed the gasoline out towards the lit match. Of course, a huge fireball erupted, much to the delight of the kids watching. I don't recall if he did it more than once. The funny part of this story? We lived to tell it. Karl was like that. */
-- phpMyAdmin SQL Dump -- version 4.1.14.8 -- http://www.phpmyadmin.net -- -- Servidor: db650071409.db.1and1.com -- Tiempo de generación: 16-07-2018 a las 20:22:37 -- Versión del servidor: 5.5.60-0+deb7u1-log -- Versión de PHP: 5.4.45-0+deb7u14 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 */; -- -- Base de datos: `db650071409` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `classes` -- CREATE TABLE IF NOT EXISTS `classes` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `startDate` date NOT NULL, `endDate` date NOT NULL, `startTime` time NOT NULL, `endTime` time NOT NULL, `days` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `maxQuota` int(11) NOT NULL, `currentQuota` int(11) NOT NULL, `state` enum('1','0') COLLATE utf8_unicode_ci NOT NULL, `cost1` int(11) NOT NULL, `cost2` int(11) NOT NULL, `cost3` int(11) NOT NULL, `semester_id` int(10) unsigned NOT NULL, `course_id` int(10) unsigned NOT NULL, `place_id` int(10) unsigned NOT NULL, `type_id` int(10) unsigned NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `classes_id_unique` (`id`), KEY `classes_semester_id_foreign` (`semester_id`), KEY `classes_course_id_foreign` (`course_id`), KEY `classes_place_id_foreign` (`place_id`), KEY `classes_type_id_foreign` (`type_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=283 ; -- -- Estructura de tabla para la tabla `classestypes` -- CREATE TABLE IF NOT EXISTS `classestypes` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `classestypes_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ; -- -- Volcado de datos para la tabla `classestypes` -- INSERT INTO `classestypes` (`id`, `description`) VALUES (1, 'Taller'), (2, 'Curso intersemestral'), (3, 'Curso semestral'), (4, 'Curso sabatino'), (5, 'Evento'), (6, 'Conferencia'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `courses` -- CREATE TABLE IF NOT EXISTS `courses` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `syllabus` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `hours` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `background` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `image` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `material` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `courses_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=75 ; -- -- Estructura de tabla para la tabla `inscriptions` -- CREATE TABLE IF NOT EXISTS `inscriptions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fullPayment` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `partialPayment` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `user_id` int(10) unsigned NOT NULL, `state_id` int(10) unsigned NOT NULL, `scholarship_id` int(10) unsigned DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `inscriptions_id_unique` (`id`), KEY `inscriptions_user_id_foreign` (`user_id`), KEY `inscriptions_state_id_foreign` (`state_id`), KEY `inscriptions_scholarship_id_foreign` (`scholarship_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3297 ; -- -- Estructura de tabla para la tabla `inscriptionsstates` -- CREATE TABLE IF NOT EXISTS `inscriptionsstates` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `inscriptionsstates_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ; -- -- Volcado de datos para la tabla `inscriptionsstates` -- INSERT INTO `inscriptionsstates` (`id`, `description`) VALUES (1, 'Pagado'), (2, 'Becado'), (3, 'Pago parcial'), (4, 'Reembolso'), (5, 'Pendiente'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `migrations` -- CREATE TABLE IF NOT EXISTS `migrations` ( `migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `batch` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Volcado de datos para la tabla `migrations` -- INSERT INTO `migrations` (`migration`, `batch`) VALUES ('2014_10_12_100000_create_password_resets_table', 1), ('2016_05_15_211603_create_semesters_table', 1), ('2016_05_16_064144_create_places_table', 1), ('2016_05_16_064157_create_userstypes_table', 1), ('2016_05_16_064158_create_users_table', 1), ('2016_05_16_064220_create_classestypes_table', 1), ('2016_05_16_064315_create_inscriptionsstates_table', 1), ('2016_05_16_064335_create_scholarships_table', 1), ('2016_05_16_064347_create_courses_table', 1), ('2016_05_16_064409_create_posts_table', 1), ('2016_05_16_064507_create_inscriptions_table', 1), ('2016_05_16_064604_create_classes_table', 1), ('2016_05_16_064743_create_registeredclass_table', 1), ('2016_05_18_215457_create_tags_table', 1), ('2016_05_18_215744_create_tag_class_table', 1), ('2016_05_18_215751_create_tag_post_table', 1), ('2016_06_07_181542_create_tickets_table', 2); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `password_resets` -- CREATE TABLE IF NOT EXISTS `password_resets` ( `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `token` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, KEY `password_resets_email_index` (`email`), KEY `password_resets_token_index` (`token`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Estructura de tabla para la tabla `places` -- CREATE TABLE IF NOT EXISTS `places` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `places_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=16 ; -- -- Estructura de tabla para la tabla `posts` -- CREATE TABLE IF NOT EXISTS `posts` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `content` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `image` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `state` enum('1','0') COLLATE utf8_unicode_ci NOT NULL, `user_id` int(10) unsigned NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `posts_id_unique` (`id`), KEY `posts_user_id_foreign` (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `registeredclass` -- CREATE TABLE IF NOT EXISTS `registeredclass` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `inscription_id` int(10) unsigned NOT NULL, `class_id` int(10) unsigned NOT NULL, `approved` enum('1','0') COLLATE utf8_unicode_ci NOT NULL, `attendance` int(11) NOT NULL, `note` int(11) NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `registeredclass_id_unique` (`id`), KEY `registeredclass_inscription_id_foreign` (`inscription_id`), KEY `registeredclass_class_id_foreign` (`class_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7572 ; -- -- Estructura de tabla para la tabla `scholarships` -- CREATE TABLE IF NOT EXISTS `scholarships` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `scholarships_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `semesters` -- CREATE TABLE IF NOT EXISTS `semesters` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `semesters_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=10 ; -- -- Volcado de datos para la tabla `semesters` -- INSERT INTO `semesters` (`id`, `description`) VALUES (1, '20141'), (2, '20142'), (3, '20151'), (4, '20152'), (5, '20161'), (6, '20162'), (7, '20171'), (8, '20172'), (9, '20181'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `tag_class` -- CREATE TABLE IF NOT EXISTS `tag_class` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `class_id` int(10) unsigned NOT NULL, `tag_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `tag_class_id_unique` (`id`), KEY `tag_class_class_id_foreign` (`class_id`), KEY `tag_class_tag_id_foreign` (`tag_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `tag_post` -- CREATE TABLE IF NOT EXISTS `tag_post` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `post_id` int(10) unsigned NOT NULL, `tag_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `tag_post_id_unique` (`id`), KEY `tag_post_post_id_foreign` (`post_id`), KEY `tag_post_tag_id_foreign` (`tag_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `tags` -- CREATE TABLE IF NOT EXISTS `tags` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `tags_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ; -- -- Volcado de datos para la tabla `tags` -- INSERT INTO `tags` (`id`, `description`) VALUES (1, 'Lenguaje C'), (2, 'Java'), (3, 'Arduino'), (4, 'PHP'), (5, 'Fortran'), (6, 'Raspberry'); -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `tickets` -- CREATE TABLE IF NOT EXISTS `tickets` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `inscription_id` int(10) unsigned NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `tickets_id_unique` (`id`), UNIQUE KEY `tickets_description_unique` (`description`), KEY `tickets_inscription_id_foreign` (`inscription_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1664 ; -- -- Estructura de tabla para la tabla `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `firstLastName` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `secondLastName` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `account` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `newsletter` enum('1','0') COLLATE utf8_unicode_ci NOT NULL, `usertype_id` int(10) unsigned NOT NULL, `remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `users_id_unique` (`id`), UNIQUE KEY `users_email_unique` (`email`), UNIQUE KEY `users_account_unique` (`account`), KEY `users_usertype_id_foreign` (`usertype_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2692 ; -- -- Estructura de tabla para la tabla `userstypes` -- CREATE TABLE IF NOT EXISTS `userstypes` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `userstypes_id_unique` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ; -- -- Volcado de datos para la tabla `userstypes` -- INSERT INTO `userstypes` (`id`, `description`) VALUES (1, 'Estudiante UNAM'), (2, 'Estudiante externo'), (3, 'Publico general'), (4, 'Becario'), (5, 'Administrador'); /*!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 */;
select l.line_no, ls.veh_time, group_concat(s.name order by ls.sequence) from line_station ls left join station_no_repeat s on ls.station_id = s.id, line l where l.line_id = ls.line_id and ls.line_id in (972,81333,976,973,975,974,971,970,1539,1536,1538,1537,4355,4356,4363,4364,4378,4379,4380,4381,4384,4385,5409,5410,5412,5745,5746,5747,5748,6801,6802,7094, 7095,7620,7621,7655,7656,128630,7863,7864,32118,8965,8966,14967,11128,11129,11895,15170,12744,12745,14950,14951,14542,14543,17242,17243,16657,44073,44074, 45368,45369,59945,48887,48888,81331,56976,56977,59602,59603,67022,66420,66421,136499,81747,81749,81754,81755,81757,81759,112336,111602,111603,128789,111600, 111601,111598,111599,112930,112931,113786,115650,115653,138064,138065) group by ls.line_id order by ls.veh_time -- select distinct(line_id) from line_station; -- select count(*) from line_station; -- select distinct(id) from station where name like '%东城国际%' /* (select l.line_no as lno, l.on_station_name as lonname, l.off_station_name as loffname,ls.veh_time as lvtime -- , s.name from line_station ls left join line l on ls.line_id = l.line_id -- left join station s on ls.station_id = s.id where ls.station_id in (553706,5197,5198,553711,553713,553548,553724,553727,553734,553703,553737,553776) -- group by l.line_no order by ls.veh_time) */ -- select ls.line_id from line_station ls -- where ls.station_id in (553706,5197,5198,553711,553713,553548,553724,553727,553734,553703,553737,553776) -- select distinct(id) from station; -- select count(id) from station; -- select * from station where name ='' insert into station_no_repeat (select * from station group by id);
CREATE TABLE da_area ( area_cd varchar2(8) NOT NULL, area_name varchar2(64), area_desc varchar2(64), city_cd varchar2(8), district_cd varchar2(8), state_cd varchar2(8), country_cd varchar2(8), grp_cd varchar2(15) NOT NULL, record_status CHAR(1), dw_last_updated_dt date, dw_facility_cd varchar2(16), dw_row_id varchar2(128), dw_job_run_no integer );
CREATE TABLE administrador(id Integer NOT NULL PRIMARY KEY AUTO_INCREMENT, nome varchar(100) NOT NULL, email varchar(100) NOT NULL, token varchar(32), senha varchar(32), telefone varchar(13) NOT NULL, ativado Integer not null check(ativado = 0 or ativado = 1)); CREATE TABLE cliente(id Integer NOT NULL PRIMARY KEY AUTO_INCREMENT, nome varchar(100) NOT NULL, email varchar(30) NOT NULL, senha varchar(32) NOT NULL, situacao varchar(500) NOT NULL, ultimoacesso date NOT NULL, id_adm Integer NOT NULL, CONSTRAINT `foreignkey` FOREIGN KEY (id_adm) REFERENCES administrador (id)); CREATE TABLE mensagens(id Integer NOT NULL PRIMARY KEY AUTO_INCREMENT, id_usuario_recebe Integer NOT NULL, id_usuario_envia Integer NOT NULL, texto varchar(100) NOT NULL, data_envio Date NOT NULL, lida boolean, CONSTRAINT `foreignkey_envio` FOREIGN KEY (id_usuario_envia) REFERENCES administrador (id), CONSTRAINT `foreignkey_recebe` FOREIGN KEY (id_usuario_recebe) REFERENCES administrador (id));
USE Northwind SELECT COUNT(ProductName) AS Product_Count ,CategoryName FROM Products JOIN Categories ON Products.CategoryID = Categories.CategoryID GROUP BY CategoryName ORDER BY Product_Count DESC;
# Write your MySQL query statement below # Report the latest login for all users in the year 2020 ## Use MAX() is more efficient than RANK() as we only need the latest login SELECT user_id, MAX(time_stamp) as last_stamp FROM Logins WHERE YEAR(time_stamp) = 2020 GROUP BY user_id
-- The format of the createdAt and modifiedAt dates is 'AAAA-MM-DD HH:MM:SS', as can be seen, -- for example, at https://springbootdev.com/2018/03/13/spring-data-jpa-auditing-with-createdby-createddate-lastmodifiedby-and-lastmodifieddate/ -- The exact name of the table fields can be seen at the H2 console INSERT INTO MANUFACTURER (CODE, NAME) VALUES (100, 'Audi'); INSERT INTO MANUFACTURER (CODE, NAME) VALUES (101, 'Chevrolet'); INSERT INTO MANUFACTURER (CODE, NAME) VALUES (102, 'Ford'); INSERT INTO MANUFACTURER (CODE, NAME) VALUES (103, 'BMW'); INSERT INTO MANUFACTURER (CODE, NAME) VALUES (104, 'Dodge'); -- INSERT INTO CAR (ID, CREATED_AT, MODIFIED_AT, CONDITION, BODY, MODEL, MANUFACTURER_CODE, NUMBER_OF_DOORS, -- FUEL_TYPE, ENGINE, MILEAGE, MODEL_YEAR, PRODUCTION_YEAR, EXTERNAL_COLOR, -- LAT, LON) -- VALUES (1, '2018-06-01 15:46:36.951', '2018-06-01 15:46:36.951', 'USED', 'sedan', 'Impala', 101, -- 4, 'Gasoline', '3.6L V6', 32280, 2018, 2018, 'white', 40.73061, -73.935242);
insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234'); insert into addr_book(ab_birth,ab_comdept,ab_email,ab_memo,ab_name,ab_tel) values('2010-10-10','잘나간다주식회사','test@test.net','hahahahah','hwang','010-1234-1234');
CREATE TABLE public.unidadesfederacao ( cod_ibge character varying(3) COLLATE pg_catalog."default", estado text COLLATE pg_catalog."default", uf character varying(2) COLLATE pg_catalog."default", regiao text COLLATE pg_catalog."default", num_municipios integer )
-- drop database if exists FoodBlog; -- create database FoodBlog; -- use FoodBlog; DROP TABLE IF EXISTS WebBlog_Comment; DROP TABLE IF EXISTS BlogUser_WebBlog; DROP TABLE IF EXISTS Comment; DROP TABLE IF EXISTS WebBlog; DROP TABLE IF EXISTS BlogUser; -- 用户表 CREATE TABLE BlogUser ( user_name varchar(255) NOT NULL, -- 用户名 pass_word varchar(255) NOT NULL, -- 密码 email varchar(50) NOT NULL, -- 邮箱 CONSTRAINT BlogUser_PK PRIMARY KEY (user_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- 博客表 CREATE TABLE WebBlog ( id INT auto_increment NOT NULL, publish_time DATETIME NOT NULL, -- 发布时间 title varchar(255) NULL, -- 标题 content TEXT NULL, -- 内容 img MEDIUMTEXT NULL, -- 图片 likes INT DEFAULT 0 NOT NULL, -- 点赞数 CONSTRAINT WebBlog_PK PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- 评论表 CREATE TABLE Comment ( id INT auto_increment NOT NULL, content TEXT NULL, -- 评论内容 CONSTRAINT Comment_PK PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- 用户×博客 关系表 (一个用户对应多篇博客) CREATE TABLE BlogUser_WebBlog ( user_name varchar(255) NOT NULL, blog_id INT NOT NULL, CONSTRAINT BlogUser_WebBlog_FK1 FOREIGN KEY (user_name) REFERENCES BlogUser(user_name) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT BlogUser_WebBlog_FK2 FOREIGN KEY (blog_id) REFERENCES WebBlog(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- 博客 × 评论 关系表 (一篇博客对应多个评论) CREATE TABLE WebBlog_Comment ( blog_id INT NOT NULL, comment_id INT NOT NULL, CONSTRAINT WebBlog_Comment_FK1 FOREIGN KEY (blog_id) REFERENCES WebBlog(id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT WebBlog_Comment_FK2 FOREIGN KEY (comment_id) REFERENCES Comment(id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TEMPORARY TABLE temp( id VARCHAR(255), soundex VARCHAR(255), doublemetaphone VARCHAR(255) ); --de-en INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-en".word1; DROP TABLE "de-en".word1; CREATE TABLE "de-en"."word1" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-en"."word1" OWNER TO dict; CREATE INDEX "word1_similar_idx" ON "de-en"."word1" USING btree(soundex, doublemetaphone); CREATE INDEX "word1_random_idx" ON "de-en"."word1" USING btree(id,random); INSERT INTO "de-en".word1 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DELETE FROM temp; INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-en".word2; DROP TABLE "de-en".word2; CREATE TABLE "de-en"."word2" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-en"."word2" OWNER TO dict; CREATE INDEX "word2_similar_idx" ON "de-en"."word2" USING btree(soundex, doublemetaphone); CREATE INDEX "word2_random_idx" ON "de-en"."word2" USING btree(id,random); INSERT INTO "de-en".word2 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; --de-es INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-es".word1; DROP TABLE "de-es".word1; CREATE TABLE "de-es"."word1" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-es"."word1" OWNER TO dict; CREATE INDEX "word1_similar_idx" ON "de-es"."word1" USING btree(soundex, doublemetaphone); CREATE INDEX "word1_random_idx" ON "de-es"."word1" USING btree(id,random); INSERT INTO "de-es".word1 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DELETE FROM temp; INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-es".word2; DROP TABLE "de-es".word2; CREATE TABLE "de-es"."word2" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-es"."word2" OWNER TO dict; CREATE INDEX "word2_similar_idx" ON "de-es"."word2" USING btree(soundex, doublemetaphone); CREATE INDEX "word2_random_idx" ON "de-es"."word2" USING btree(id,random); INSERT INTO "de-es".word2 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; --de-fr INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-fr".word1; DROP TABLE "de-fr".word1; CREATE TABLE "de-fr"."word1" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-fr"."word1" OWNER TO dict; CREATE INDEX "word1_similar_idx" ON "de-fr"."word1" USING btree(soundex, doublemetaphone); CREATE INDEX "word1_random_idx" ON "de-fr"."word1" USING btree(id,random); INSERT INTO "de-fr".word1 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DELETE FROM temp; INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-fr".word2; DROP TABLE "de-fr".word2; CREATE TABLE "de-fr"."word2" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-fr"."word2" OWNER TO dict; CREATE INDEX "word2_similar_idx" ON "de-fr"."word2" USING btree(soundex, doublemetaphone); CREATE INDEX "word2_random_idx" ON "de-fr"."word2" USING btree(id,random); INSERT INTO "de-fr".word2 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; --de-it INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-it".word1; DROP TABLE "de-it".word1; CREATE TABLE "de-it"."word1" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-it"."word1" OWNER TO dict; CREATE INDEX "word1_similar_idx" ON "de-it"."word1" USING btree(soundex, doublemetaphone); CREATE INDEX "word1_random_idx" ON "de-it"."word1" USING btree(id,random); INSERT INTO "de-it".word1 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DELETE FROM temp; INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "de-it".word2; DROP TABLE "de-it".word2; CREATE TABLE "de-it"."word2" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "de-it"."word2" OWNER TO dict; CREATE INDEX "word2_similar_idx" ON "de-it"."word2" USING btree(soundex, doublemetaphone); CREATE INDEX "word2_random_idx" ON "de-it"."word2" USING btree(id,random); INSERT INTO "de-it".word2 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; --en-es INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "en-es".word1; DROP TABLE "en-es".word1; CREATE TABLE "en-es"."word1" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "en-es"."word1" OWNER TO dict; CREATE INDEX "word1_similar_idx" ON "en-es"."word1" USING btree(soundex, doublemetaphone); CREATE INDEX "word1_random_idx" ON "en-es"."word1" USING btree(id,random); INSERT INTO "en-es".word1 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DELETE FROM temp; INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "en-es".word2; DROP TABLE "en-es".word2; CREATE TABLE "en-es"."word2" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "en-es"."word2" OWNER TO dict; CREATE INDEX "word2_similar_idx" ON "en-es"."word2" USING btree(soundex, doublemetaphone); CREATE INDEX "word2_random_idx" ON "en-es"."word2" USING btree(id,random); INSERT INTO "en-es".word2 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; --en-fr INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "en-fr".word1; DROP TABLE "en-fr".word1; CREATE TABLE "en-fr"."word1" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "en-fr"."word1" OWNER TO dict; CREATE INDEX "word1_similar_idx" ON "en-fr"."word1" USING btree(soundex, doublemetaphone); CREATE INDEX "word1_random_idx" ON "en-fr"."word1" USING btree(id,random); INSERT INTO "en-fr".word1 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DELETE FROM temp; INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "en-fr".word2; DROP TABLE "en-fr".word2; CREATE TABLE "en-fr"."word2" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "en-fr"."word2" OWNER TO dict; CREATE INDEX "word2_similar_idx" ON "en-fr"."word2" USING btree(soundex, doublemetaphone); CREATE INDEX "word2_random_idx" ON "en-fr"."word2" USING btree(id,random); INSERT INTO "en-fr".word2 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; --en-it INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "en-it".word1; DROP TABLE "en-it".word1; CREATE TABLE "en-it"."word1" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "en-it"."word1" OWNER TO dict; CREATE INDEX "word1_similar_idx" ON "en-it"."word1" USING btree(soundex, doublemetaphone); CREATE INDEX "word1_random_idx" ON "en-it"."word1" USING btree(id,random); INSERT INTO "en-it".word1 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DELETE FROM temp; INSERT INTO temp (id, soundex, doublemetaphone) SELECT DISTINCT id, soundex, doublemetaphone FROM "en-it".word2; DROP TABLE "en-it".word2; CREATE TABLE "en-it"."word2" ( id varchar(16) NOT NULL, pronunciation varchar(64) DEFAULT NULL, soundex char(4) NOT NULL, doublemetaphone varchar(16) DEFAULT NULL, random DOUBLE PRECISION NOT NULL DEFAULT RANDOM(), count int4 DEFAULT 0, Primary KEY(id) ); ALTER TABLE "en-it"."word2" OWNER TO dict; CREATE INDEX "word2_similar_idx" ON "en-it"."word2" USING btree(soundex, doublemetaphone); CREATE INDEX "word2_random_idx" ON "en-it"."word2" USING btree(id,random); INSERT INTO "en-it".word2 (id, soundex, doublemetaphone) SELECT id, soundex, doublemetaphone FROM temp; DROP TABLE temp;
DROP TABLE BuriState; DROP TABLE BuriBranch; DROP TABLE BuriDataPathHistory; DROP TABLE BuriData; DROP TABLE BuriPath;
SET ANSI_NULLS ON; SET ANSI_WARNINGS ON; SET NOCOUNT ON; IF NOT EXISTS(SELECT * FROM [должности]) BEGIN PRINT N'INSERTING INTO [должности] STARTED' SET IDENTITY_INSERT [должности] ON INSERT INTO [должности](ID, Наименование) VALUES (1, N'Директор') INSERT INTO [должности](ID, Наименование) VALUES (2, N'Бухгалтер') INSERT INTO [должности](ID, Наименование) VALUES (3, N'Главный бухгалтер') INSERT INTO [должности](ID, Наименование) VALUES (4, N'Заместитель директора') INSERT INTO [должности](ID, Наименование) VALUES (5, N'Тренер') INSERT INTO [должности](ID, Наименование) VALUES (6, N'Методист') SET IDENTITY_INSERT [должности] OFF PRINT N'INSERTING INTO [должности] COMPLETED' END SET NOCOUNT OFF;
-- 创建表 create table test( id int, name varchar(10), sex varchar(10), qq varchar(12) ); -- 显示表的结构 desc test; -- 插入数据 insert into test values (1, "温婷歌", "女", "31984892"); insert into test values (2, "冷千绝", "男", "36546562"); insert into test values (3, "许艺笙", "女", "45263272"); insert into test values (4, "秦亦然", "男", "98234612"); -- 查看表中数据 select * from test; -- 修改某一字段的属性, 属性要重新定义 alter table test change sex gender varchar(60); desc test; -- 删除某一字段 alter table test drop qq; desc test; select * from test; -- 修改表的名字 alter table test rename to mytest; desc test; -- 删除表 drop table mytest; show tables;
CREATE SCHEMA IF NOT EXISTS STUDY_INFINITE; CREATE TABLE users ( seq bigint PRIMARY KEY auto_increment, name varchar(50) NOT NULL, email varchar(50) NOT NULL UNIQUE, password varchar(255) NOT NULL, login_count int NOT NULL default 0, create_at datetime default now() NOT null, last_login_at datetime default now() ); CREATE TABLE posts ( seq bigint auto_increment PRIMARY KEY, user_seq bigint NOT NULL, contents varchar(500) NOT NULL, like_count int NOT NULL DEFAULT 0, comment_count int NOT NULL DEFAULT 0, create_at DATETIME DEFAULT now() NOT null, title varchar(100) NOT NULL ); CREATE TABLE post_comments ( seq bigint auto_increment primary key, user_seq bigint NOT NULL, post_seq bigint NOT NULL, contents varchar(500) NOT NULL, create_at datetime default now() NOT null ); CREATE TABLE likes ( seq bigint auto_increment primary key, user_seq bigint NOT NULL, post_seq bigint NOT NULL, create_at datetime default now() NOT null ); CREATE TABLE study ( seq bigint auto_increment primary key, user_seq bigint NOT NULL, title varchar(100) NOT NULL, shortDescription varchar(100) NOT NULL, fullDescription varchar(1000) NOT NULL, publishDateTime datetime default now() NOT null, zones varchar(50) NOT NULL ); CREATE TABLE study_comment ( seq bigint auto_increment primary key, user_seq bigint NOT NULL, study_seq bigint NOT NULL, comments varchar(500) NOT NULL, create_at datetime default now() NOT null ); ALTER table posts add foreign key (user_seq) references users(seq) ON DELETE RESTRICT ON UPDATE RESTRICT ; ALTER table post_comments add foreign key (user_seq) references users(seq) ON DELETE RESTRICT ON UPDATE RESTRICT ; ALTER table post_comments add foreign key (post_seq) references posts(seq) ON DELETE CASCADE ON UPDATE CASCADE ; ALTER table likes add foreign key (user_seq) references users(seq) ON DELETE RESTRICT ON UPDATE RESTRICT ; ALTER table likes add foreign key (post_seq) references posts(seq) ON DELETE CASCADE ON UPDATE CASCADE ; ALTER table study add foreign key (user_seq) references users(seq) ON DELETE RESTRICT ON UPDATE RESTRICT ; ALTER table study_comment add foreign key (user_seq) references users(seq) ON DELETE RESTRICT ON UPDATE RESTRICT ; ALTER table study_comment add foreign key (study_seq) references study(seq) ON DELETE CASCADE ON UPDATE CASCADE ;
use company; select D.Mgr_ssn, count(*) as No_of_project from department D, project P2 where D.Dnumber in (select P.Dnum from project P where P.Pname='ProductY' ) and P2.Dnum=D.Dnumber group by P2.Dnum ;
# Write your MySQL query statement below # Encode the result to 1,2,3 and then do rank() WITH cte AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY player_id ORDER BY match_day) ck1, ROW_NUMBER() OVER (PARTITION BY player_id, result ORDER BY match_day) ck2 FROM Matches), all_player as ( select distinct player_id from Matches ), steaks as ( SELECT player_id, COUNT(match_day) streak FROM cte WHERE result = 'Win' GROUP BY 1, ck1-ck2 ) SELECT m.player_id, IFNULL(MAX(streak), 0) longest_streak FROM all_player m LEFT JOIN steaks t using (player_id) GROUP BY 1
CREATE TABLE `employee` ( `id` int(11) NOT NULL, `first` varchar(64) DEFAULT NULL, `last` varchar(64) DEFAULT NULL, `municipality` varchar(64) DEFAULT NULL, `started` varchar(64) DEFAULT NULL, `ended` varchar(64) DEFAULT NULL, `department` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=ndbcluster DEFAULT CHARSET=latin1
-- phpMyAdmin SQL Dump -- version 4.5.4.1deb2ubuntu2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jan 31, 2018 at 11:01 PM -- Server version: 5.7.21-0ubuntu0.16.04.1 -- PHP Version: 7.0.22-0ubuntu0.16.04.1 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `a_r_s` -- -- -------------------------------------------------------- -- -- Table structure for table `aircraft` -- CREATE TABLE `aircraft` ( `aircraftTypeID` varchar(10) NOT NULL, `description` varchar(50) DEFAULT NULL, `bseats` int(2) DEFAULT NULL, `xseats` int(3) DEFAULT NULL, `eseats` int(3) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `aircraft` -- INSERT INTO `aircraft` (`aircraftTypeID`, `description`, `bseats`, `xseats`, `eseats`) VALUES ('JA075', 'JAVA AIRBUS 075', 0, 50, 110), ('JA085', 'JAVA AIRBUS 085', 30, 75, 110), ('JA090', 'JAVA AIRBUS 090', 30, 150, 200), ('JA092', 'JAVA AIRBUS 092', 40, 80, 0), ('JA191', 'JAVA AIRBUS 191', 75, 200, 200), ('JA192', 'JAVA AIRBUS 192', 75, 200, 0), ('JA253', 'JAVA AIRBUS 253', 80, 80, 80), ('JA273', 'JAVA AIRBUS 273', 80, 55, 100), ('JA331', 'JAVA AIRBUS 331', 0, 0, 250), ('JA332', 'JAVA AIRBUS 332', 0, 0, 250), ('JA491', 'JAVA AIRBUS 491', 30, 150, 200), ('JA927', 'JAVA AIRBUS 927', 60, 75, 80), ('JA928', 'JAVA AIRBUS 928', 60, 130, 130), ('JA930', 'JAVA AIRBUS 930', 80, 150, 200), ('JA991', 'JAVA AIRBUS 991', 80, 0, 120), ('JA992', 'JAVA AIRBUS 992', 0, 100, 120); -- -------------------------------------------------------- -- -- Table structure for table `dailycollections` -- CREATE TABLE `dailycollections` ( `pnrno` varchar(8) DEFAULT NULL, `trandate` date DEFAULT NULL, `trantype` varchar(15) DEFAULT NULL, `amount` decimal(9,2) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `flights` -- CREATE TABLE `flights` ( `flightno` varchar(6) NOT NULL, `deptime` varchar(5) DEFAULT NULL, `arrtime` varchar(5) DEFAULT NULL, `aircrafttypeID` varchar(6) DEFAULT NULL, `sectorID` varchar(5) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `flights` -- INSERT INTO `flights` (`flightno`, `deptime`, `arrtime`, `aircrafttypeID`, `sectorID`) VALUES ('FJA11', '18:00', NULL, 'JA075', 'ad-ko'), ('FJA12', '08:30', NULL, 'JA927', 'dl-ko'), ('FJA16', NULL, NULL, NULL, 'dl-ch'), ('FJA19', '17:55', NULL, 'JA991', 'dl-ad'), ('FJA22', NULL, NULL, NULL, 'ko-mu'), ('FJA23', '00:30', NULL, 'JA930', 'ko-ad'), ('FJA24', '21:40', NULL, 'JA991', 'ko-ad'), ('FJA26', NULL, NULL, NULL, 'ch-mu'), ('FJA27', NULL, NULL, NULL, 'ko-mu'), ('FJA31', '08:00', NULL, 'JA090', 'ad-dl'), ('FJA33', '15:00', NULL, 'JA192', 'ko-mu'), ('FJA40', '08:00', NULL, 'JA090', 'ad-dl'), ('FJA42', '07:35', NULL, 'JA332', 'dl-ko'), ('FJA43', NULL, NULL, NULL, 'dl-mu'), ('FJA45', NULL, NULL, NULL, 'dl-mu'), ('FJA47', NULL, NULL, NULL, 'mu-ch'), ('FJA55', '13:15', NULL, 'JA191', 'ko-dl'), ('FJA58', '20:00', NULL, 'JA253', 'ko-dl'), ('FJA67', '09:00', NULL, 'JA491', 'dl-ko'), ('FJA71', NULL, NULL, NULL, 'dl-mu'), ('FJA78', '21:30', NULL, 'JA273', 'dl-ad'), ('FJA81', NULL, NULL, NULL, 'dl-ad'), ('FJA87', '10:00', NULL, 'JA092', 'ad-dl'), ('FJA88', NULL, NULL, NULL, 'dl-ad'), ('FJA91', '00:25', NULL, 'JA330', 'dl-ko'), ('FJA95', NULL, NULL, NULL, 'dl-ad'), ('FJA98', '13:00', NULL, 'JA085', 'ad-ko'), ('FJA99', '12:30', NULL, 'JA992', 'ko-ad'); -- -------------------------------------------------------- -- -- Table structure for table `passengers` -- CREATE TABLE `passengers` ( `pnrno` varchar(8) NOT NULL, `flightno` varchar(5) DEFAULT NULL, `traveldate` date DEFAULT NULL, `fname` varchar(50) DEFAULT NULL, `lname` varchar(50) DEFAULT NULL, `age` int(2) DEFAULT NULL, `gender` varchar(1) DEFAULT NULL, `class` varchar(15) DEFAULT NULL, `mealpref` varchar(15) DEFAULT NULL, `noa` int(2) DEFAULT '1', `noc` int(2) NOT NULL DEFAULT '0', `status` varchar(15) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `scheduledflights` -- CREATE TABLE `scheduledflights` ( `scheduleID` varchar(5) NOT NULL, `flightno` varchar(5) DEFAULT NULL, `flightdate` date DEFAULT NULL, `bcsavailable` int(2) DEFAULT NULL, `xcsavailable` int(3) DEFAULT NULL, `ecsavailable` int(3) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `scheduledflights` -- INSERT INTO `scheduledflights` (`scheduleID`, `flightno`, `flightdate`, `bcsavailable`, `xcsavailable`, `ecsavailable`) VALUES ('00001', 'FJA11', '2016-01-18', 0, 50, 110), ('00002', 'FJA12', '2016-01-18', 60, 75, 80), ('00003', 'FJA24', '2016-01-18', 80, 150, 200), ('00004', 'FJA19', '2016-01-18', 80, 0, 120), ('00005', 'FJA31', '2016-01-18', 30, 150, 200), ('00006', 'FJA33', '2016-01-18', 75, 200, 0), ('00007', 'FJA40', '2016-01-18', 30, 150, 200), ('00008', 'FJA42', '2016-01-18', 0, 0, 250), ('00009', 'FJA55', '2016-01-18', 75, 200, 200), ('00010', 'FJA58', '2016-01-18', 80, 80, 80), ('00011', 'FJA67', '2016-01-18', 30, 150, 200), ('00012', 'FJA78', '2016-01-18', 80, 55, 100), ('00013', 'FJA87', '2016-01-18', 40, 80, 0), ('00014', 'FJA91', '2016-01-18', 0, 0, 250), ('00015', 'FJA98', '2016-01-18', 30, 75, 110), ('00016', 'FJA99', '2016-01-18', 0, 100, 120); -- -------------------------------------------------------- -- -- Table structure for table `sector` -- CREATE TABLE `sector` ( `sectorID` varchar(5) NOT NULL, `source` varchar(25) DEFAULT NULL, `destination` varchar(25) NOT NULL, `weekday1` varchar(4) DEFAULT NULL, `weekday2` varchar(4) DEFAULT NULL, `weekday3` varchar(4) DEFAULT NULL, `bfare` decimal(8,2) DEFAULT '0.00', `xfare` decimal(8,2) DEFAULT '0.00', `efare` decimal(8,2) DEFAULT '0.00' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `sector` -- INSERT INTO `sector` (`sectorID`, `source`, `destination`, `weekday1`, `weekday2`, `weekday3`, `bfare`, `xfare`, `efare`) VALUES ('ad-ch', 'Athens', 'Thesaloniki', 'WED', 'MON', 'NULL', '9565.00', '7500.00', '0.00'), ('ad-dl', 'Athens', 'Giannena', 'TUE', 'TUE', 'THR', '6330.00', '0.00', '5664.00'), ('ad-ko', 'Athens', 'Kalamaria', 'MON', 'TUE', 'WED', '4290.00', '3560.00', '2563.00'), ('ad-mu', 'Athens', 'Mani', 'SUN', 'SAT', 'NULL', '0.00', '5700.00', '4500.00'), ('ch-ad', 'Thesaloniki', 'LamiaDomoko', 'FRI', 'SAT', 'NULL', '8500.00', '6500.00', '4500.00'), ('ch-dl', 'Thesaloniki', 'LamiaDomoko', 'FRI', 'WED', 'MON', '10253.00', '8954.00', '6789.00'), ('ch-ko', 'Thesaloniki', 'Mani', 'THR', 'TUE', 'SAT', '12500.00', '9800.00', '6555.00'), ('ch-kr', 'Thesaloniki', 'Athens', 'SAT', 'FRI', 'SUN', '5600.00', '4400.00', '3200.00'), ('ch-mu', 'Thesaloniki', 'Mani', 'MON', 'TUE', 'WED', '15500.00', '11550.00', '9540.00'), ('dl-ad', 'Giannena', 'Thesaloniki', 'TUE', 'WED', 'THR', '0.00', '7500.00', '4660.00'), ('dl-ch', 'Giannena', 'Mani', 'FRI', 'MON', 'WED', '0.00', '8990.00', '6450.00'), ('dl-ko', 'Giannena', 'Thesaloniki', 'SUN', 'TUE', 'WED', '11800.00', '9900.00', '5630.00'), ('dl-mu', 'Giannena', 'Thesaloniki', 'TUE', 'SAT', 'NULL', '5800.00', '4200.00', '3200.00'), ('go-ko', 'Iraklio', 'Giannena', 'MON', 'NULL', 'NULL', '10000.00', '8700.00', '0.00'), ('ko-ad', 'Kalamaria', 'LamiaDomoko', 'SUN', 'MON', 'MON', '8600.00', '0.00', '5750.00'), ('ko-ch', 'Kalamaria', 'Giannena', 'TUE', 'MON', 'WED', '9450.00', '0.00', '6450.00'), ('ko-dl', 'Kalamaria', 'Iraklio', 'MON', 'TUE', 'NULL', '15550.00', '12300.00', '8600.00'), ('ko-go', 'Kalamaria', 'Iraklio', 'WED', 'NULL', 'NULL', '12000.00', '10000.00', '0.00'), ('ko-mu', 'Kalamaria', 'Mani', 'TUE', 'SAT', 'FRI', '12500.00', '11000.00', '10000.00'), ('kr-ch', 'Kalamaria', 'Mani', 'WED', 'THR', 'NULL', '6000.00', '5000.00', '4000.00'), ('mu-ad', 'Mani', 'LamiaDomoko', 'THR', 'FRI', 'SAT', '6262.00', '5120.00', '0.00'), ('mu-ch', 'LamiaDomoko', 'Iraklio', 'FRI', 'SAT', 'SUN', '7990.00', '6375.00', '4550.00'), ('mu-dl', 'LamiaDomoko', 'Athens', 'SAT', 'TUE', 'THR', '16000.00', '12500.00', '10500.00'), ('mu-ko', 'LamiaDomoko', 'Athens', 'SUN', 'SAT', 'FRI', '0.00', '0.00', '6800.00'); -- -------------------------------------------------------- -- -- Table structure for table `user_profile` -- CREATE TABLE `user_profile` ( `userid` int(10) NOT NULL, `firstname` text NOT NULL, `lastname` text NOT NULL, `contactno` bigint(10) NOT NULL, `dob` date NOT NULL, `address` text NOT NULL, `city` text NOT NULL, `state` text NOT NULL, `country` text NOT NULL, `emailid` text NOT NULL, `password` text NOT NULL, `usertype` text NOT NULL, `username` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_profile` -- INSERT INTO `user_profile` (`userid`, `firstname`, `lastname`, `contactno`, `dob`, `address`, `city`, `state`, `country`, `emailid`, `password`, `usertype`, `username`) VALUES (1, 'Euterpi', 'Xalimourda', 2107483647, '1977-08-05', 'Tzitzifias 22', 'Katafugio', 'Zvounia', 'Greece', 'papadia22@gmail.com', 'admin', 'ADMIN', 'admin'), (2, 'Emanouil', 'Mpasilaris', 6456998235, '1992-07-27', 'Prionokordelas 12', 'Kilkis', 'Patlia', 'Greece', 'emanouil_sexokounelos@gmail.com', 'manager', 'MANAGER', 'manager1'), (3, 'Oisofagos', 'Larigkios', 6452633200, '1992-03-25', 'GavGav 3Alfa', 'Kastelorizo', 'Kouroumplia', 'Greece', 'gloupgloup@yahoo.co.in', 'manager', 'MANAGER', 'manager2'), (4, 'Tasos', 'Protaprilias', 6656923534, '1980-07-07', 'Podovolitou 32misi', 'Vrusoula', 'Gournokoumaso', 'Greece', 'leo_psemata1980@yahoo.com', 'operator', 'OPERATOR', 'operator1'), (5, 'Nikos', 'Korompos', 6632126377, '1983-10-25', 'Karotserh 12', 'Eratinh', 'Akaitsamalois', 'Greece', 'einai_kinito@yahoo.com', 'operator', 'OPERATOR', 'operator2'), (6, 'Efi', 'Thodi', 6953382350, '1982-10-17', 'Kaprolaxanou 6', 'Amorani', 'Houston', 'Greece', 'kontoulalemonia1982@yahoo.co.in.', 'operator', 'OPERATOR', 'operator3'); -- -- Indexes for dumped tables -- -- -- Indexes for table `aircraft` -- ALTER TABLE `aircraft` ADD PRIMARY KEY (`aircraftTypeID`); -- -- Indexes for table `flights` -- ALTER TABLE `flights` ADD PRIMARY KEY (`flightno`); -- -- Indexes for table `passengers` -- ALTER TABLE `passengers` ADD PRIMARY KEY (`pnrno`); -- -- Indexes for table `scheduledflights` -- ALTER TABLE `scheduledflights` ADD PRIMARY KEY (`scheduleID`); -- -- Indexes for table `sector` -- ALTER TABLE `sector` ADD PRIMARY KEY (`sectorID`); -- -- Indexes for table `user_profile` -- ALTER TABLE `user_profile` ADD PRIMARY KEY (`userid`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `user_profile` -- ALTER TABLE `user_profile` MODIFY `userid` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
CREATE VIEW `patrimonios`.`timeline_cliente` AS select `cli`.`id` AS `id_cliente`, concat('Solicitação de Cotação ', `ras`.`nome`, ' de número ', `cot`.`id`, ' pelo site') AS `descricao_evento`, `sta`.`data_status` AS `data_evento`, concat('fa-check') AS `icone_evento`, `cot`.`id` AS `id_registro` from ((((`cotacao` `cot` join `cliente` `cli` ON ((`cot`.`cliente_id` = `cli`.`id`))) join `ramo_seguro` `ras` ON ((`cot`.`ramo_seguro_id` = `ras`.`id`))) join `status_cotacao` `sta` ON ((`cot`.`id` = `sta`.`cotacao_id`))) join `tipo_status_cotacao` `tsc` ON ((`sta`.`tipo_status_cotacao_id` = `tsc`.`id`))) where (`tsc`.`id` = 1)
/* Aufgabe 8.1.a: Vorlesungstitel Kant */ SELECT vl.Titel FROM vorlesungen vl JOIN professoren prof ON vl.gelesenVon = prof.PersNr WHERE prof.Name = "Kant"; /* Aufgabe 8.1.b: Kant's Studenten */ SELECT DISTINCT stud.Name AS Student FROM studenten stud NATURAL JOIN hoeren h NATURAL JOIN vorlesungen vl JOIN professoren prof ON vl.gelesenVon = prof.PersNr WHERE prof.Name = "Kant"; /* Aufgabe 8.1.c: Kant's gepruefte Studenten */ SELECT stud.Name AS Student, pr.Note AS Note FROM studenten stud NATURAL JOIN pruefen pr JOIN professoren prof ON pr.PersNr = prof.PersNr WHERE prof.Name = "Kant"; /* Aufgabe 8.1.d: Ueber Kant gepruefte Studenten */ SELECT stud.Name AS Student, pr.Note AS Note FROM studenten stud JOIN pruefen pr ON stud.MatrNr = pr.MatrNr JOIN hoeren h ON h.MatrNr = stud.MatrNr JOIN vorlesungen vl ON vl.VorlNr = h.VorlNr JOIN professoren prof ON vl.gelesenVon = prof.PersNr WHERE prof.Name = "Kant"; /* Aufgabe 8.2.a: Studentenarbeit */ SELECT stud.Name AS Student, COUNT(*), SUM(vl.SWS) as Wochenarbeitsstunden FROM studenten stud JOIN hoeren h ON h.MatrNr = stud.MatrNr JOIN vorlesungen vl ON vl.VorlNr = h.VorlNr GROUP BY stud.MatrNr, stud.Name; /* Aufgabe 8.2.c.a: Studentenarbeit */ SELECT stud.Name AS Student, COUNT(*), IFNULL(SUM(vl.SWS),0) as Wochenarbeitsstunden FROM studenten stud LEFT OUTER JOIN hoeren h ON h.MatrNr = stud.MatrNr LEFT OUTER JOIN vorlesungen vl ON vl.VorlNr = h.VorlNr GROUP BY stud.MatrNr, stud.Name; /* Aufgabe 8.2.b: Professorenarbeit */ SELECT prof.Name as Professor, COUNT(DISTINCT h.MatrNr) FROM professoren prof JOIN vorlesungen vl ON vl.gelesenVon = prof.PersNr JOIN hoeren h ON h.VorlNr = vl.VorlNr GROUP BY prof.PersNr, prof.Name; /* Aufgabe 8.2.c.b: Professorenarbeit */ SELECT prof.Name as Professor, COUNT(DISTINCT h.MatrNr) FROM professoren prof LEFT OUTER JOIN vorlesungen vl ON vl.gelesenVon = prof.PersNr LEFT OUTER JOIN hoeren h ON h.VorlNr = vl.VorlNr GROUP BY prof.PersNr, prof.Name; /* Aufgabe 8.3: NULL-Werte */ /* a: Die Professoren, die keine Vorlesung lesen. */ /* b: In der oberen Abfrage liefert die Subquery u.a. einen null-Wert, also prüft die Abfrage bei mind. einem NULL-Wert * WHERE PersNr NOT IN (null, ...) und das ist NOT (TRUE oder UNKNOWN) und das ist nur FALSE oder UNKNOWN. Das Ergebnis ist leer. /* c: Die obere, unkorrellierte Abfrage muss nur einmal das Subquery ausführen, die untere muss pro Professor einmal das Subquery ausführen. */ /* Aufgabe 8.4: Recursive */ WITH RECURSIVE maze AS ( SELECT e.n1 AS x1, e.n2 AS x2, e.weight AS distance FROM edge e JOIN node nod ON nod.nid = e.n2 WHERE nod.color = 'red' UNION ALL SELECT e1.n1 AS x1, maze.x2 AS x2, (e1.weight + maze.distance) AS distance FROM edge e1 CROSS JOIN maze WHERE maze.x1 = e1.n2 ) SELECT DISTINCT y1.nid AS von, y2.nid AS nach --, maz.distance AS distanz FROM maze maz JOIN node y1 ON y1.nid = maz.x1 JOIN node y2 ON y2.nid = maz.x2 WHERE y1.color = 'red' ORDER BY von ASC; /* Aufgabe 8.4.c */ WITH RECURSIVE maze AS ( SELECT e.n1 AS x1, e.n2 AS x2, e.weight AS distance FROM edge e JOIN node nod ON nod.nid = e.n1 WHERE nod.color = 'red' UNION ALL SELECT maze.x1 AS x1, e1.n2 AS x2, (e1.weight + maze.distance) AS distance FROM maze CROSS JOIN edge e1 WHERE maze.x2 = e1.n1 ) SELECT DISTINCT y1.nid AS von, y2.nid AS nach --, maz.distance AS distanz FROM maze maz JOIN node y1 ON y1.nid = maz.x1 JOIN node y2 ON y2.nid = maz.x2 WHERE y2.color = 'red' ORDER BY von ASC; /* Aufgabe 8.4.d: */ WITH RECURSIVE maze AS ( SELECT e.n1 AS x1, e.n2 AS x2, e.weight AS distance FROM edge e JOIN node nod ON nod.nid = e.n2 WHERE nod.color = 'red' UNION ALL SELECT e1.n1 AS x1, maze.x2 AS x2, (e1.weight + maze.distance) AS distance FROM edge e1 CROSS JOIN maze WHERE maze.x1 = e1.n2 ) SELECT y1.nid AS von, y2.nid AS nach, MIN(maz.distance) AS min_distanz, MAX(maz.distance) AS max_distanz FROM maze maz JOIN node y1 ON y1.nid = maz.x1 JOIN node y2 ON y2.nid = maz.x2 WHERE y1.color = 'red' GROUP BY y1.nid, y2.nid ORDER BY y1.nid ASC, min_distanz DESC;
ALTER TABLE song ADD name NVARCHAR(128), ADD link VARCHAR(256), ADD views INT(100) DEFAULT 0, ADD created_date DATETIME;
delete from userData where display_name = $1;
 -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [CoreFacade].[RemoveCustomerPolicy] @CustomerId int, @PolicyId int AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DELETE FROM CoreModel.CustomerPolicies WHERE CustomerId = @CustomerId AND PolicyId = @PolicyId END
INSERT INTO `option` (`plugin`, `typ`, `value`, `default_value`, `beschreibung`, `format`) VALUES ('MARKTPLATZ', 'CHAT_SHOW_CONTACT', '0', '0', 'Kontaktdaten des Absenders bei Nachrichten darstellen', 'check'); ALTER TABLE `chat` ADD COLUMN `FK_CHAT_USER` INT(11) NULL DEFAULT NULL AFTER `SUBJECT`; UPDATE `chat` SET FK_CHAT_USER=(SELECT SENDER FROM `chat_message` WHERE FK_CHAT=ID_CHAT ORDER BY ID_CHAT_MESSAGE ASC LIMIT 1) WHERE FK_CHAT_USER IS NULL; ALTER TABLE `news` ADD COLUMN `SER_MEDIA` TEXT NULL AFTER `SER_IMAGES`; ALTER TABLE `faqkat` ADD COLUMN `FK_NAV` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `ID_FAQKAT`, ADD INDEX `FK_NAV` (`FK_NAV`); CREATE TABLE `cache_storage` ( `ID_CACHE_STORAGE` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `IDENT_HASH` VARCHAR(64) NOT NULL, `STAMP_VALID_UNTIL` DATETIME NOT NULL, `CONTENT` MEDIUMBLOB NOT NULL, PRIMARY KEY (`ID_CACHE_STORAGE`), UNIQUE INDEX `IDENT_HASH` (`IDENT_HASH`), INDEX `STAMP_VALID_UNTIL` (`STAMP_VALID_UNTIL`) ) ENGINE=MyISAM; CREATE TABLE `cache_storage_relation` ( `FK_CACHE_STORAGE` INT(10) UNSIGNED NOT NULL, `RELATION_TYPE` VARCHAR(64) NOT NULL, `FK_RELATION` INT(10) UNSIGNED NOT NULL, UNIQUE INDEX `FK_CACHE_STORAGE_RELATION_TYPE_FK_RELATION` (`FK_CACHE_STORAGE`, `RELATION_TYPE`, `FK_RELATION`) ) ENGINE=MyISAM; INSERT INTO `crontab` (`PRIO`, `DSC`, `FIRST`, `EINHEIT`, `ALL_X`, `DATEI`, `FUNKTION`) VALUES (1, 'Löschen von nicht mehr benötigten Daten (z.B. alte Cache-Dateien)', '2016-10-28 12:00:00', 'hour', 1, 'cron/cleanup.php', '');
/*使用mysql数据库*/ CREATE SCHEMA `bomoda` DEFAULT CHARACTER SET utf8 ; CREATE TABLE `Biz` ( `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Source database incremental id', `Biz_ID` varchar(64) NOT NULL COMMENT 'Biz account unique id', `Biz_Name` varchar(512) DEFAULT NULL COMMENT 'Account name shown on the platform', `Biz_Code` varchar(512) DEFAULT NULL COMMENT 'Account registered name', `Biz_Description` varchar(512) DEFAULT NULL COMMENT 'Description of account', `QRcode` varchar(512) DEFAULT NULL COMMENT 'Account’s QR code', `Timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Time of record creation', PRIMARY KEY (`ID`), UNIQUE KEY `Biz_ID_UNIQUE` (`Biz_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `Page` ( `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Source database incremental id', `URL` varchar(512) DEFAULT NULL COMMENT 'URL for page content', `Title` varchar(512) DEFAULT NULL COMMENT 'Page title', `Content` varchar(1024) DEFAULT NULL COMMENT 'Page raw html content', `Timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Time of record creation', PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `Click` ( `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Source database incremental id', `URL` varchar(512) DEFAULT NULL COMMENT 'Corresponding page URL', `Title` varchar(512) DEFAULT NULL COMMENT 'Corresponding page title', `Read_Number` int(11) DEFAULT NULL COMMENT 'Page’s read number', `Like_Number` int(11) DEFAULT NULL COMMENT 'Page’s like number', `Timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Time of record creation', PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Questions/settings/my.sql DROP TABLE IF EXISTS engine4_question_question; CREATE TABLE engine4_question_questions ( question_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, title VARCHAR(128) NOT NULL, description MEDIUMTEXT NULL, snapshot MEDIUMTEXT NULL, providers MEDIUMTEXT NULL, owner_id INT(11) UNSIGNED NOT NULL, owner_type INT(11) UNSIGNED NOT NULL, photo_id INT(11) UNSIGNED NOT NULL, creation_date DATETIME NOT NULL, modified_date DATETIME NOT NULL, view_count INT(11) UNSIGNED NOT NULL, comment_count INT(11) UNSIGNED NOT NULL, search TINYINT(1) NOT NULL, PRIMARY KEY (question_id), INDEX (photo_id), INDEX (owner_id) ); INSERT IGNORE INTO engine4_core_menus (`name`, `type`, `title`, `order`) VALUES ('question_main', 'standard', 'Question Main Navigation Menu', 999); INSERT IGNORE INTO engine4_core_menuitems (`name`, `module`, `label`, `plugin`, `params`, `menu`, `submenu`, `enabled`, `custom`, `order`) VALUES ('question_main_browse', 'question', 'Browse Questions', 'Question_Plugin_Menus::canViewQuestions', '{"route":"question_general","action":"browse"}', 'question_main', '', 1, 0, 1), ('question_main_manage', 'question', 'My Questions', 'Question_Plugin_Menus::canCreateQuestions', '{"route":"question_general","action":"manage"}', 'question_main', '', 1, 0, 2), ('question_main_create', 'question', 'Create Question', 'Question_Plugin_Menus::canCreateQuestions', '{"route":"question_general","action":"create"}', 'question_main', '', 1, 0, 3); INSERT INTO engine4_activity_actiontypes (`type`, `module`, `body`, `enabled`, `displayable`, `attachable`, `commentable`, `shareable`, `is_generated`) VALUES ('question', 'question', '{item:$subject} asked {var:$question}', 1, 7, 1, 1, 1, 1);
DELETE SportHolding DELETE TCountry DELETE TCounty DELETE TFestivalDay DELETE TFestival DELETE TJamatkhana DELETE TParticipant DELETE TScheduledSportEvent DELETE TScheduledSportEventParticipant DELETE TSportEventTeam DELETE TSport DELETE TTransportPickupPoint DELETE TTransportRequest
CREATE DATABASE dab; USE dab; CREATE TABLE users( id INT NOT NULL AUTO_INCREMENT, google_id varchar(255) COLLATE utf8mb4_unicode_ci, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, institute VARCHAR(255), designation VARCHAR(255), profile_picture LONGBLOB, phone_no VARCHAR(255), remember_token varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, created_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL, PRIMARY KEY(id), UNIQUE KEY(email) ); CREATE TABLE statuses( id INT NOT NULL AUTO_INCREMENT, status VARCHAR(1000) NOT NULL, date_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, user_id INT NOT NULL, PRIMARY KEY(id), FOREIGN KEY(user_id) REFERENCES users(id) ); CREATE TABLE comments( id INT NOT NULL AUTO_INCREMENT, comment VARCHAR(1000) NOT NULL, date_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, user_id INT NOT NULL, status_id INT NOT NULL, PRIMARY KEY(id), FOREIGN KEY(user_id) REFERENCES users(id), FOREIGN KEY(status_id) REFERENCES statuses(id) );
-- -- CREATE TABLES -- create table et_audit (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, createdby varchar(50), createddate datetime, recorddata varchar(512)); -- -- Users create table users (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, username varchar(50) NOT NULL UNIQUE, password varchar(50) NOT NULL, firstname varchar(16), lastname varchar(16), middleinit varchar(1), emailid varchar(32), createddate datetime, lastupdateddate datetime, lastmodifiedby varchar(50), createdby varchar(50), pwdchangeneeded smallint NOT NULL, creditcardnumber varchar(16), phonenumber varchar(32), enabled smallint NOT NULL); -- Roles create table roles (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, role varchar(50) NOT NULL UNIQUE); -- -- authorities create table authorities (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, username varchar(50) NOT NULL, authority varchar(50) NOT NULL, grantedby varchar(50), user_id bigint NOT NULL, constraint fk_authorities_roles foreign key(authority) references roles(role), constraint fk_authorities_grantedby foreign key(grantedby) references users(username), constraint fk_authorities_users_id foreign key(user_id) references users(id), constraint fk_authorities_users_name foreign key(username) references users(username)); -- -- -- -- Settlement table create table et_settlement (id bigint AUTO_INCREMENT NOT NULL PRIMARY KEY, cyclestartdate datetime NOT NULL, cycleenddate datetime NOT NULL, createddate datetime, closeddate datetime, createdby varchar(50), accountmanager varchar(50), volume float NOT NULL, settlementcompleted smallint NOT NULL, constraint fk_settlement_accountmanager foreign key(accountmanager) references users(username), constraint fk_settlement_createdby foreign key(createdby) references users(username)); alter table et_settlement AUTO_INCREMENT = 1000; -- -- Reports Table create table et_reports (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, createddate datetime, reportcontent mediumblob, reporttype varchar(16) NOT NULL, reportname varchar(32) NOT NULL, settlementid bigint NOT NULL, constraint fk_reports_settlementid foreign key(settlementid) references et_settlement(id)); alter table et_reports AUTO_INCREMENT = 1000; -- -- user settlement create table et_user_settlement (id bigint AUTO_INCREMENT NOT NULL PRIMARY KEY, setteleddate datetime, username varchar(50) NOT NULL, settlement_id bigint NOT NULL, amount float NOT NULL, usershare float NOT NULL, userpaid float NOT NULL, settlementcompleted smallint NOT NULL, constraint fk_u_settlement_user foreign key(username) references users(username), constraint fk_u_settlement_settlement foreign key(settlement_id) references et_settlement(id)); alter table et_user_settlement AUTO_INCREMENT = 1000; -- -- expense create table et_expense (id bigint AUTO_INCREMENT NOT NULL PRIMARY KEY, paidby varchar(50) NOT NULL, settlement_id bigint, amount float, date datetime, createdby varchar(50), lastmodifiedby varchar(50), createddate datetime, lastmodifieddate datetime, description varchar(64), category varchar(32), constraint fk_expense_settlement foreign key(settlement_id) references et_settlement(id), constraint fk_exp_createdby_users foreign key(createdby) references users(username), constraint fk_exp_lastmodifiedby_users foreign key(lastmodifiedby) references users(username), constraint fk_expense_users foreign key(paidby) references users(username)); -- -- user_expense create table et_user_expense(id bigint AUTO_INCREMENT NOT NULL PRIMARY KEY, username varchar(50) NOT NULL, discountpercent float NOT NULL, amount float NOT NULL, expense_id bigint NOT NULL, constraint fk_u_expense_users foreign key(username) references users(username), constraint fk_u_expense_expense foreign key(expense_id) references et_expense(id)); -- -- -- Payments Table create table et_payments(id bigint AUTO_INCREMENT NOT NULL PRIMARY KEY, paymentdate datetime NOT NULL, amount float NOT NULL, username varchar(50) NOT NULL, constraint fk_payments_users foreign key(username) references users(username));
-- phpMyAdmin SQL Dump -- version 5.0.2 -- https://www.phpmyadmin.net/ -- -- Servidor: localhost -- Tiempo de generación: 18-08-2020 a las 00:21:09 -- Versión del servidor: 10.4.13-MariaDB -- Versión de PHP: 7.3.20 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 */; -- -- Base de datos: `gestion_certificados` -- -- -------------------------------------------------------- -- -- Estructura de tabla para la tabla `certificados` -- CREATE TABLE `certificados` ( `id` int(255) NOT NULL, `fecha_creacion` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `ip` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `hostname` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `valido_desde` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `valido_hasta` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `ruta_certificado` varchar(500) COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- Volcado de datos para la tabla `certificados` -- INSERT INTO `certificados` (`id`, `fecha_creacion`, `ip`, `hostname`, `valido_desde`, `valido_hasta`, `ruta_certificado`) VALUES (22, '17/08/2020', '10.133.102.2', 'gastonserver', '17/08/2020', '17/08/2021', 'http://localhost/SecOpsCert/certificados/gastonserver'); -- -- Índices para tablas volcadas -- -- -- Indices de la tabla `certificados` -- ALTER TABLE `certificados` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT de las tablas volcadas -- -- -- AUTO_INCREMENT de la tabla `certificados` -- ALTER TABLE `certificados` MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23; 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 */;
CREATE SCHEMA IF NOT EXISTS `SOLUTIS` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; USE `SOLUTIS` ; CREATE TABLE IF NOT EXISTS `SOLUTIS`.`CLONE` ( idClone int unsigned not null auto_increment primary key COMMENT '', nome varchar (45) not null COMMENT '', skill varchar (45) not null COMMENT '', idade int not null COMMENT '', criacao date not null COMMENT '', genero varchar (45) not null COMMENT '', especial varchar (45) not null COMMENT '' );
SELECT COUNT (*) FROM posts WHERE author = 'Supercyndro';
-- phpMyAdmin SQL Dump -- version 4.1.12 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Erstellungszeit: 06. Feb 2015 um 20:13 -- Server Version: 5.6.16 -- PHP-Version: 5.5.11 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 */; -- -- Datenbank: `pokengine` -- -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `activity` -- CREATE TABLE IF NOT EXISTS `activity` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` datetime NOT NULL, `plays` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=44 ; -- -- Daten für Tabelle `activity` -- INSERT INTO `activity` (`id`, `time`, `plays`) VALUES (1, '0000-00-00 00:00:00', 1), (2, '0000-00-00 00:00:00', 1), (3, '0000-00-00 00:00:00', 1), (4, '0000-00-00 00:00:00', 1), (5, '0000-00-00 00:00:00', 1), (6, '0000-00-00 00:00:00', 1), (7, '0000-00-00 00:00:00', 1), (8, '0000-00-00 00:00:00', 1), (9, '0000-00-00 00:00:00', 1), (10, '0000-00-00 00:00:00', 1), (11, '0000-00-00 00:00:00', 1), (12, '0000-00-00 00:00:00', 1), (13, '0000-00-00 00:00:00', 1), (14, '0000-00-00 00:00:00', 1), (15, '0000-00-00 00:00:00', 1), (16, '0000-00-00 00:00:00', 1), (17, '0000-00-00 00:00:00', 1), (18, '0000-00-00 00:00:00', 1), (19, '0000-00-00 00:00:00', 1), (20, '0000-00-00 00:00:00', 1), (21, '0000-00-00 00:00:00', 1), (22, '0000-00-00 00:00:00', 1), (23, '0000-00-00 00:00:00', 1), (24, '0000-00-00 00:00:00', 1), (25, '0000-00-00 00:00:00', 1), (26, '0000-00-00 00:00:00', 1), (27, '0000-00-00 00:00:00', 1), (28, '0000-00-00 00:00:00', 1), (29, '0000-00-00 00:00:00', 1), (30, '0000-00-00 00:00:00', 1), (31, '0000-00-00 00:00:00', 1), (32, '0000-00-00 00:00:00', 1), (33, '0000-00-00 00:00:00', 1), (34, '0000-00-00 00:00:00', 1), (35, '0000-00-00 00:00:00', 1), (36, '0000-00-00 00:00:00', 1), (37, '0000-00-00 00:00:00', 1), (38, '0000-00-00 00:00:00', 1), (39, '0000-00-00 00:00:00', 1), (40, '0000-00-00 00:00:00', 1), (41, '0000-00-00 00:00:00', 1), (42, '0000-00-00 00:00:00', 1), (43, '0000-00-00 00:00:00', 1); -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `groups` -- CREATE TABLE IF NOT EXISTS `groups` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) DEFAULT NULL, `permissions` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `maps` -- CREATE TABLE IF NOT EXISTS `maps` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL, `side_n` varchar(60) NOT NULL, `side_s` varchar(60) NOT NULL, `side_w` varchar(60) NOT NULL, `side_e` varchar(60) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Daten für Tabelle `maps` -- INSERT INTO `maps` (`id`, `name`, `side_n`, `side_s`, `side_w`, `side_e`) VALUES (1, 'Anchore Town', '1', '1', '1', '1'); -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `players` -- CREATE TABLE IF NOT EXISTS `players` ( `id` int(15) NOT NULL AUTO_INCREMENT, `username` varchar(20) NOT NULL, `password` varchar(80) NOT NULL, `name` varchar(32) NOT NULL, `joined` datetime NOT NULL, `group` int(11) NOT NULL, `rank` int(1) NOT NULL, `online` int(11) NOT NULL, `user_color` varchar(6) NOT NULL, `beta` int(1) NOT NULL DEFAULT '1', `x` int(5) NOT NULL, `y` int(5) NOT NULL, `map` int(15) NOT NULL, `facing` int(1) NOT NULL DEFAULT '4', `skin` varchar(10) NOT NULL, `money` int(7) NOT NULL DEFAULT '3000', `last_played` varchar(20) NOT NULL, `skin_color` int(2) NOT NULL, `play_time` int(20) NOT NULL, `health` int(1) NOT NULL DEFAULT '100', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; -- -- Daten für Tabelle `players` -- INSERT INTO `players` (`id`, `username`, `password`, `name`, `joined`, `group`, `rank`, `online`, `user_color`, `beta`, `x`, `y`, `map`, `facing`, `skin`, `money`, `last_played`, `skin_color`, `play_time`, `health`) VALUES (5, 'develix', '098f6bcd4621d373cade4e832627b4f6', 'FELIX', '0000-00-00 00:00:00', 0, 0, 0, '0', 1, 224, 480, 116, 1, '0', 1000, '1423249946.683', 0, 19800, 100); -- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `players_pokemon` -- CREATE TABLE IF NOT EXISTS `players_pokemon` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, `user` int(11) NOT NULL, `box` int(11) NOT NULL DEFAULT '0', `dex` int(11) NOT NULL, `pid` int(11) NOT NULL, `forme` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Daten für Tabelle `players_pokemon` -- INSERT INTO `players_pokemon` (`id`, `name`, `user`, `box`, `dex`, `pid`, `forme`) VALUES (1, 'Bulbasaur', 6, -1, 1, 1, 1), (2, 'Bulbasaur', 7, -1, 1, 1, 1), (3, 'Bulbasaur', 5, -1, 1, 1, 1), (4, 'Bulbasaur', 5, -1, 1, 1, 1); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (1, 'Bennet', 'Abraham'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (2, 'Green', 'Marjorie'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (3, 'Carson', 'Cheryl'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (4, 'Ringer', 'Albert'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (5, 'Ringer', 'Anne'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (6, 'DeFrance', 'Michel'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (7, 'McBadden', 'Heather'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (8, 'Stringer', 'Dirk'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (9, 'Karsen', 'Livia'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (10, 'MacFeather', 'Stearns'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (11, 'Dull', 'Ann'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (12, 'Yokomoto', 'Akiko'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (13, 'O''Leary', 'Michael'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (14, 'Gringlesby', 'Burt'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (15, 'Greene', 'Morningstar'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (16, 'White', 'Johnson'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (17, 'del Castillo', 'Innes'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (18, 'Hunter', 'Sheryl'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (19, 'Locksley', 'Chastity'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (20, 'Blotchet-Halls', 'Reginald'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (21, 'Smith', 'Meander'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (22, 'Tray', 'Raichel'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (23, 'Vodyakov', 'Alexandr'); INSERT INTO bookbiz.authors (au_id, au_lname, au_fname) VALUES (24, 'Sergeev', 'Sergey');
CREATE DATABASE pesquisa CHARACTER SET utf8 COLLATE utf8_general_ci; USE pesquisa; CREATE TABLE cond_condominio ( id INT PRIMARY KEY AUTO_INCREMENT, nome VARCHAR(100) ); CREATE TABLE cond_mes ( id INT PRIMARY KEY AUTO_INCREMENT, nome VARCHAR(100) ); CREATE TABLE cond_usuario ( id INT PRIMARY KEY AUTO_INCREMENT, nome VARCHAR(100), email VARCHAR(100), senha VARCHAR(60), condominio INT, bloco VARCHAR(10), apartamento VARCHAR(10), moradores_residencia INT, turno_manha BOOLEAN, turno_tarde BOOLEAN, turno_noite BOOLEAN, turno_madrugada BOOLEAN, turno_todos BOOLEAN, FOREIGN KEY (condominio) REFERENCES cond_condominio(id) ); CREATE TABLE cond_gastos_usuario ( usuario INT PRIMARY KEY AUTO_INCREMENT, banho INT, lavagem_roupas INT, casa INT, louca INT, banheiro INT, mes_cadastro INT, gasto_mes_01 REAL, gasto_mes_02 REAL, gasto_mes_03 REAL, gasto_mes_04 REAL, gasto_mes_05 REAL, FOREIGN KEY (usuario) REFERENCES cond_usuario(id), FOREIGN KEY (mes_cadastro) REFERENCES cond_mes(id) ); CREATE TABLE cond_diario_usuario ( id INT PRIMARY KEY AUTO_INCREMENT, usuario INT, data DATE, banhos INT, lavou_roupas BOOLEAN, limpou_apartamento BOOLEAN, refeicoes INT, banheiro INT, escovou_dentes INT, FOREIGN KEY (usuario) REFERENCES cond_usuario(id) ); INSERT INTO cond_condominio VALUES (1, "Santa Marta"), (2, "Santa Mônica"); INSERT INTO cond_mes VALUES (1, "Janeiro"), (2, "Fevereiro"), (3, "Março"), (4, "Abril"), (5, "Maio"), (6, "Junho"), (7, "Julho"), (8, "Agosto"), (9, "Setembro"), (10, "Outubro"), (11, "Novembro"), (12, "Dezembro"); CREATE VIEW cond_pontos_usuario AS SELECT id, usuario, data, (banhos+lavou_roupas+limpou_apartamento+refeicoes+banheiro+escovou_dentes) AS 'pontos' FROM cond_diario_usuario; CREATE VIEW cond_resultado_global AS SELECT cond_pontos_usuario.usuario, cond_usuario.nome, cond_usuario.condominio, SUM(cond_pontos_usuario.pontos) AS "pontuacao" FROM cond_usuario, cond_pontos_usuario WHERE cond_usuario.id=cond_pontos_usuario.usuario GROUP BY usuario ORDER BY pontuacao ASC; CREATE VIEW cond_resultado_diario AS SELECT cond_pontos_usuario.usuario, cond_usuario.nome, cond_usuario.condominio, SUM(cond_pontos_usuario.pontos) AS "pontuacao" FROM cond_usuario, cond_pontos_usuario WHERE cond_usuario.id=cond_pontos_usuario.usuario AND cond_pontos_usuario.data=CURRENT_DATE() GROUP BY usuario ORDER BY pontuacao ASC; CREATE VIEW cond_resultado_semanal AS SELECT cond_pontos_usuario.usuario, cond_usuario.nome, cond_usuario.condominio, SUM(cond_pontos_usuario.pontos) AS "pontuacao" FROM cond_usuario, cond_pontos_usuario WHERE cond_usuario.id=cond_pontos_usuario.usuario AND cond_pontos_usuario.data>(CURRENT_DATE() - INTERVAL 7 DAY) GROUP BY usuario ORDER BY pontuacao ASC; CREATE VIEW cond_resultado_mensal AS SELECT cond_pontos_usuario.usuario, cond_usuario.nome, cond_usuario.condominio, SUM(cond_pontos_usuario.pontos) AS "pontuacao" FROM cond_usuario, cond_pontos_usuario WHERE cond_usuario.id=cond_pontos_usuario.usuario AND cond_pontos_usuario.data>(CURRENT_DATE() - INTERVAL 30 DAY) GROUP BY usuario ORDER BY pontuacao ASC;
CREATE TABLE user ( user_id int auto_increment NOT NULL, created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at datetime NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (user_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; CREATE TABLE note ( note_id int auto_increment NOT NULL, user_id int NOT NULL, text varchar(1000) NOT NULL, shared tinyint(1) NOT NULL DEFAULT 0, created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at datetime NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (note_id), KEY user_id (user_id), CONSTRAINT note__user_id_ibfk_1 FOREIGN KEY (user_id) REFERENCES user (user_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; CREATE TABLE shared_item ( shared_item_id int auto_increment NOT NULL, item_type enum('note') NOT NULL, item_id int NOT NULL, created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at datetime NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (shared_item_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
create or replace view linestationview as select LINESTATION."ID", bigstationlist.name1 aname1, b2.name1 bname1, LINESTATION."LINEID",LINESTATION."NUM",LINESTATION."DQH",LINESTATION."ASTATION",LINESTATION."BSTATION",LINESTATION."MILES", LINESTATION."MILESCLASS",LINESTATION."DIRECTION",LINESTATION."JNFLAG",TRAINLINE.LineType,TRAINLINE.LineName from LINESTATION inner join TRAINLINE on LineStation.LineID=TRAINLINE.LineID left outer join bigstationlist on linestation.astation=bigstationlist.name1 left outer join bigstationlist b2 on linestation.bstation=b2.name1
rem Tables prompt .. Dropping table DEBUG_GROUP drop table debug_group cascade constraints; prompt .. Dropping table DEBUG_LOG drop table debug_log cascade constraints; prompt .. Dropping table DEBUG_SESSION drop table debug_session cascade constraints; rem Sequences prompt .. Dropping sequence DEBUG_GROUP_ID drop sequence debug_group_id; prompt .. Dropping sequence DEBUG_SESSION_ID drop sequence debug_session_id; prompt .. Dropping sequence DEBUG_LOG_ID drop sequence debug_log_id; rem Code prompt .. Dropping package DEBUG_TYPES drop package debug_types; prompt .. Dropping package DEBUG_UTIL drop package debug_util; prompt .. Dropping package DEBUG_IMPL drop package debug_impl; prompt .. Dropping package debug_format_IMPL drop package debug_format_impl;
-- 2017-09-24 alter table tree_relationship drop column child_table; alter table tree_relationship drop column parent_table; -- rm overbearing constraint alter table tree_relationship drop constraint tree_relationship_parent_tables_check; alter table tree_relationship drop constraint tree_relationship_child_tables_check; alter table tree_relationship alter parent_tables drop not null; alter table tree_relationship alter child_tables drop not null;
SELECT vehicles.make, vehicles.model, users.email FROM vehicles JOIN users ON vehicles.ownerId = users.id WHERE users.email = $1;
select * from userData;
CREATE TABLE planes{ id SERIAL PRIMARY KEY, name VARCHAR, iata_code VARCHAR, icao_code VARCHAR };
SELECT DISTINCT "subject" FROM "containers" WHERE "subject" IS NOT NULL;
insert into `product_info` ( id,product_name,price,status) values(1,'iPhoneX',8000,0); insert into `product_info` ( id,`product_name`,price,status) values(2,'小米8',3000,0); insert into `product_info` ( id,`product_name`,price,status) values(3,'vivo NEX',4000,0); insert into `product_info` ( id,`product_name`,price,status) values(4,'荣耀10',3000,0);
UPDATE --小切手一括取込履歴 CHEQUE_BATCH_HISTORY_INFO SET -- 取込状況 UPLOAD_STATUS = /*uploadStatus*/'' WHERE -- 一括取込番号 UPLOAD_BATCH_ID = /*uploadBatchId*/
-- MySQL dump 10.13 Distrib 5.7.21, for Win64 (x86_64) -- -- Host: localhost Database: tess -- ------------------------------------------------------ -- 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 `course` -- DROP TABLE IF EXISTS `course`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `course` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(128) DEFAULT NULL, `instructor_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `TITLE_UNIQUE` (`title`), KEY `FK_INSTRUCTOR_idx` (`instructor_id`), CONSTRAINT `FK_INSTRUCTOR` FOREIGN KEY (`instructor_id`) REFERENCES `instructor` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `course` -- LOCK TABLES `course` WRITE; /*!40000 ALTER TABLE `course` DISABLE KEYS */; INSERT INTO `course` VALUES (10,'History',2),(11,'Math',1),(12,'Informatics',1),(13,'Biology',1),(14,'Anthropology',2),(15,'Bionics',1),(16,'Psyhology',1),(18,'Piano',1); /*!40000 ALTER TABLE `course` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `course_students` -- DROP TABLE IF EXISTS `course_students`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `course_students` ( `course_id` int(11) NOT NULL, `student_id` int(11) NOT NULL, PRIMARY KEY (`course_id`,`student_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `course_students` -- LOCK TABLES `course_students` WRITE; /*!40000 ALTER TABLE `course_students` DISABLE KEYS */; INSERT INTO `course_students` VALUES (10,1),(10,2),(11,2),(12,3),(13,1),(13,3),(13,5),(14,3),(15,1),(15,4),(16,1),(16,2),(16,4),(18,3),(18,4); /*!40000 ALTER TABLE `course_students` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `instructor` -- DROP TABLE IF EXISTS `instructor`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `instructor` ( `id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(45) DEFAULT NULL, `last_name` varchar(45) DEFAULT NULL, `email` varchar(45) DEFAULT NULL, `instructor_detail_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK_DETAIL_idx` (`instructor_detail_id`), CONSTRAINT `FK_DETAIL` FOREIGN KEY (`instructor_detail_id`) REFERENCES `instructor_detail` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `instructor` -- LOCK TABLES `instructor` WRITE; /*!40000 ALTER TABLE `instructor` DISABLE KEYS */; INSERT INTO `instructor` VALUES (1,'Steve','Blackman','Steve@school.com',2),(2,'Jorge','Helix','helix@school.com',1); /*!40000 ALTER TABLE `instructor` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `instructor_detail` -- DROP TABLE IF EXISTS `instructor_detail`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `instructor_detail` ( `id` int(11) NOT NULL AUTO_INCREMENT, `youtube_channel` varchar(128) DEFAULT NULL, `hobby` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `instructor_detail` -- LOCK TABLES `instructor_detail` WRITE; /*!40000 ALTER TABLE `instructor_detail` DISABLE KEYS */; INSERT INTO `instructor_detail` VALUES (1,'mammlasToYou','reading'),(2,'KrakenSchool','gaming'); /*!40000 ALTER TABLE `instructor_detail` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `review` -- DROP TABLE IF EXISTS `review`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `review` ( `id` int(11) NOT NULL AUTO_INCREMENT, `comment` varchar(256) DEFAULT NULL, `course_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `review` -- LOCK TABLES `review` WRITE; /*!40000 ALTER TABLE `review` DISABLE KEYS */; INSERT INTO `review` VALUES (1,'Great course!',11),(2,'Wow awesome!',18),(3,'Good enough',10),(4,'So-so',14),(5,'Premium quality',12),(6,'Excellent teacher',18),(7,'Simple to understand',11),(8,'Marvelous!!',13),(9,'Great teacher',15),(10,'Good',12),(11,'Too much history',16),(12,'Master piece ',13),(13,'Way to hard',14),(14,'A lot of information!',16),(15,'Great course!',16); /*!40000 ALTER TABLE `review` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `students` -- DROP TABLE IF EXISTS `students`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `students` ( `id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(100) DEFAULT NULL, `last_name` varchar(100) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `students` -- LOCK TABLES `students` WRITE; /*!40000 ALTER TABLE `students` DISABLE KEYS */; INSERT INTO `students` VALUES (1,'Steve','Rocks','rocks@mail.com'),(2,'John','Klein','klein@mail.com'),(3,'Bob','Anderson','bob@mail.com'),(4,'Helix','Newman','helix@mail.com'),(5,'Oren','Frein','frein@mail.com'); /*!40000 ALTER TABLE `students` 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-02-20 18:42:05
SELECT COUNT(MAKER_CUSTOMER_CODE) FROM VEHICLE_MST WHERE MAKER_CUSTOMER_CODE=/*dto.maker*/ AND BRAND=/*dto.brand*/ AND TYPE=/*dto.type*/