text
stringlengths
6
9.38M
/* Dealing with ORA-24247: network access denied by access control list (ACL) Access Control List. This is how to do it, not diffuclt at all. Cannot connect to internet from Oracle-dbms without. */ BEGIN dbms_network_acl_admin.drop_acl (acl => 'eveapi-permissions.xml'); COMMIT; END; / BEGIN dbms_network_acl_admin.create_acl (acl => 'eveapi-permissions.xml' ,description => 'To access EVE Online Market Data and XML API' ,principal => 'EVE' ,is_grant => TRUE ,privilege => 'connect' ,start_date => NULL ,end_date => NULL); dbms_network_acl_admin.add_privilege(acl => 'eveapi-permissions.xml' ,principal => 'EVE' ,is_grant => TRUE ,privilege => 'resolve'); dbms_network_acl_admin.assign_acl (acl => 'eveapi-permissions.xml' ,host => 'api.eve-central.com'); dbms_network_acl_admin.assign_acl (acl => 'eveapi-permissions.xml' ,host => 'api.eveonline.com'); COMMIT; END; / -- got permission to connect there now? DECLARE pcs utl_http.html_pieces; BEGIN pcs := utl_http.request_pieces('http://api.eve-central.com'); -- basically if Block runs without errors youre fine END; / -- ACL set? - dbms-interface way SELECT dbms_network_acl_admin.check_privilege('eveapi-permissions.xml' ,'EVE' ,'connect') FROM dual; -- ACL set? - from config table (preferred way) SELECT * FROM user_network_acl_privileges; --describe xds_acl; --select aclid, shared, description from xds_acl; --delete FROM xds_acl where aclid = 'DE66B80A74234AE79300D19925729FEB';
CREATE TABLE tt_content ( tx_iconfont_icon varchar(255) DEFAULT '0' NOT NULL, ); CREATE TABLE pages ( tx_iconfont_icon varchar(255) DEFAULT '0' NOT NULL, );
USE native_db; INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Adoption','Family_and_Marriage'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Altar','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ancestor_Spirits','Religion_and_Spirituality'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Communal_Cult','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Communication_with_the_Supernatural','Religion_and_Spirituality'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Cosmology','Religion_and_Spirituality'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Cult_to_the_Dead','Religion_and_Spirituality'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Dance','Visual_and_Performing_Arts'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Divinities','Religion_and_Spirituality'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ecclesiastical_Cult','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Entheogen','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ethnic_Stereotypes','Inter-Ethnic_Relations'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Exchanges_Between_Groups','Inter-Ethnic_Relations'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Female_Behavior_or_Activity','Gender'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Food-Related_Rites','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Funerary_Rites','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Healing_Instruments','Healing_and_Illness'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Healing_Rites','Healing_and_Illness'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ideas_About_Neighbors','Inter-Ethnic_Relations'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Inter-Ethnic_Marriage','Inter-Ethnic_Relations'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Male_Behavior_or_Activity','Gender'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Medicine','Healing_and_Illness'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Music','Visual_and_Performing_Arts'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Offering_and__or_Sacrifice','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Prayer','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Raids','Conflict_and_Resolution'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Removal','Family_and_Marriage'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Rite_of_Passage','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ritual','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ritual_Avoidances','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ritual_Dance','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ritual_Effigy','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Ritual_Specialists','Religion_and_Spirituality'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Season_Rites','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Shamanic_Cult','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Shamanism','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Sorcery','Ritual'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('Theology','Religion_and_Spirituality'); INSERT INTO native_db.ethn_fields (`name`,`main_topic`) VALUES ('War','Conflict_and_Resolution');
use study; drop table if exists other_user_account; create table other_user_account( id bigint(20) auto_increment primary key, account varchar(255) not null comment '账户', is_admin bit(1) default false not null comment '是否是管理员', is_system bit(1) default false not null comment '是否是超级管理员', password varchar(255) not null comment '密码', password_salty varchar(255) not null comment '密码加密盐' )engine = InnoDB default charset = utf8 comment '账户表'; insert into other_user_account values (default ,'admin',true,true,'f7c2f7c26d7c3ecdb7f8f1e15ceeff3e', 'bade8208e4a286d12b67da29ba2c2e6b7f6a935e69f9e4941c471b279eb57dfccb53b966bb008522e33737f44c63b4e7'); drop table if exists other_login_record; create table other_login_record( id bigint(20) auto_increment primary key, user_account bigint(20) not null comment '登录账户', login_time datetime not null comment '登录时间', ip varchar(255) comment '登录的ip地址' )engine = InnoDB default charset = utf8 comment '登录记录表';
create table address ( addressId int(11) NOT NULL AUTO_INCREMENT, firstName varchar(40) not null, lastName varchar(40) not null, emailAddress varchar(40) not null, userName varchar(40) not null, province varchar(40) not null, city varchar(40) not null, street varchar(40) not null, statusorder varchar(40) not null UNIQUE, primary key (addressId), constraint primaryname foreign key (userName) references user (userName) ON DELETE CASCADE ON UPDATE CASCADE );
SELECT A.PlanillaNombre, A.Area, A.Dia, E.Fecha, A.DNI, A.NombreCompleto, A.LoteNombre, A.Labor, A.Turno, A.Horas, A.Condicion, A.AñoID, A.MesID, A.SemanaID, A.PlanillaID, A.FechaID, A.LoteID, A.PeriodoID, A.Sexo, A.VariedadNombre, A.TrabajadorID AS CID, IIf(IsNull(B.CostohoraContable),'',Cstr(Format(B.CostohoraContable,"0.00"))) AS CostoHoraContable, IIf(IsNull(B.CostohoraContable),'',Cstr(Format(Horas*B.CostohoraContable,"0.00"))) AS NetoContable, IIf(IsNull(B.[CostoHoraPagar]),'',Cstr(Format(B.[CostoHoraPagar],"0.00"))) AS CostoHoraPagar, IIf(IsNull(B.CostoHoraPagar),'',Cstr(Format(B.CostoHoraPagar*Horas,"0.00"))) AS NetoPagar, Fundo FROM VT_RecursoHumano_R1 AS A LEFT JOIN TB_CostoPlanilla AS B ON (A.PeriodoID = B.PeriodoID) AND (A.TrabajadorID=B.TrabajadorID);
--44 SELECT * FROM lgdepartment --45 SELECT PROD_SKU, PROD_DESCRIPT, PROD_TYPE, PROD_BASE, PROD_CATEGORY, PROD_PRICE FROM lgproduct WHERE prod_base = 'WATER' AND prod_category = 'SEALER' --46 SELECT EMP_FNAME, EMP_LNAME, EMP_EMAIL FROM lgemployee WHERE EMP_HIREDATE BETWEEN '2003-01-01' AND '2012-12-31' ORDER BY EMP_LNAME, EMP_FNAME --47 SELECT EMP_FNAME, EMP_LNAME, EMP_PHONE, EMP_TITLE, DEPT_NUM FROM lgemployee WHERE dept_num = '300' OR emp_title = 'CLERK I' ORDER BY emp_lname, emp_fname --48 SELECT E.emp_num, emp_lname, emp_fname, SAL_FROM, sal_end, sal_amount FROM lgemployee E inner join lgsalary_history H on E.emp_num = H.emp_num WHERE E.emp_num IN ('83731', '83745', '84039') ORDER BY E.emp_num, sal_from --49 SELECT cust_fname, cust_lname, cust_street, cust_city, cust_state, cust_zip FROM lgcustomer C inner join lginvoice I on C.cust_code = I.cust_code inner join lgline L on I.inv_num = L.inv_num inner join lgproduct P on L.prod_sku = P.prod_sku inner join lgbrand B on P.brand_id = B.brand_id WHERE brand_name = 'FORESTERS BEST' AND prod_category = 'TOP COAT' AND inv_date BETWEEN '2015-07-15' AND '2015-07-31' ORDER BY cust_state, cust_lname, cust_fname --50 SELECT E.EMP_NUM, EMP_LNAME, EMP_EMAIL, EMP_TITLE, DEPT_NAME FROM lgemployee E INNER JOIN lgdepartment D ON E.dept_num = D.dept_num WHERE emp_title LIKE '%ASSOCIATE' ORDER BY dept_name, emp_title --51 SELECT BRAND_NAME, COUNT(PROD_SKU) AS NUM_OF_PRODUCTS FROM lgbrand B INNER JOIN lgproduct P ON B.brand_id = P.brand_id GROUP BY BRAND_NAME ORDER BY BRAND_NAME --52 SELECT PROD_CATEGORY, COUNT(PROD_SKU) AS NUM_OF_PRODUCTS FROM lgproduct WHERE prod_base = 'WATER' GROUP BY prod_category --53 SELECT PROD_BASE, PROD_TYPE, COUNT(PROD_SKU) AS NUM_OF_PRODUCTS FROM lgproduct GROUP BY prod_base, prod_type ORDER BY prod_base --54 SELECT BRAND_ID, SUM(PROD_QOH) FROM lgproduct GROUP BY brand_id ORDER BY brand_id DESC --55 SELECT P.BRAND_ID, BRAND_NAME, ROUND(AVG(PROD_PRICE), 2) AS AVG_PRICE FROM lgproduct P INNER JOIN lgbrand B ON P.brand_id = B.brand_id GROUP BY P.brand_id, brand_name ORDER BY brand_name --56 SELECT DEPT_NUM, MAX(EMP_HIREDATE) AS MOST_RECENT_HIRE FROM lgemployee GROUP BY dept_num ORDER BY dept_num --57 SELECT E.EMP_NUM, EMP_FNAME, EMP_LNAME, MAX(SAL_AMOUNT) AS LARGEST_SAL FROM lgemployee E INNER JOIN lgsalary_history S ON E.emp_num = S.emp_num WHERE dept_num = '200' GROUP BY E.emp_num, emp_fname, emp_lname ORDER BY LARGEST_SAL DESC --58 SELECT C.CUST_CODE, CUST_FNAME, CUST_LNAME, SUM(INV_TOTAL) AS INV_TOTALS FROM lgcustomer C INNER JOIN lginvoice I ON C.cust_code = I.cust_code GROUP BY C.cust_code, cust_fname, cust_lname HAVING SUM(INV_TOTAL) > 1500 ORDER BY INV_TOTALS DESC --59 SELECT D.DEPT_NUM, DEPT_NAME, DEPT_PHONE, D.EMP_NUM, EMP_LNAME FROM lgemployee E INNER JOIN lgdepartment D ON E.emp_num = D.emp_num ORDER BY dept_name --60 SELECT V.VEND_ID, V.VEND_NAME, BRAND_NAME, COUNT(P.PROD_SKU) AS NUM_OF_PRODUCTS FROM lgvendor V INNER JOIN lgsupplies S ON V.vend_id = S.vend_id INNER JOIN lgproduct P ON S.prod_sku = P.prod_sku INNER JOIN lgbrand B ON P.brand_id = B.brand_id GROUP BY V.vend_id, V.vend_name, brand_name ORDER BY vend_name, brand_name --61 SELECT EMP_NUM, EMP_LNAME, EMP_FNAME, SUM(INV_TOTAL) AS INV_TOTALS FROM lgemployee E INNER JOIN lginvoice I ON E.emp_num = I.employee_id GROUP BY emp_num, emp_lname, emp_fname ORDER BY emp_lname, emp_fname --62 SELECT MAX(AVG_PRICE) AS LARGEST_AVG FROM (SELECT BRAND_ID, ROUND(AVG(PROD_PRICE), 2) AS AVG_PRICE FROM lgproduct GROUP BY brand_id) AVG_PRICE --63 SELECT P.BRAND_ID, BRAND_NAME, BRAND_TYPE, ROUND(AVG(PROD_PRICE), 2) AS AVG_PRICE FROM lgproduct P INNER JOIN lgbrand B ON P.brand_id = B.brand_id GROUP BY P.brand_id, brand_name, brand_type HAVING ROUND(AVG(PROD_PRICE), 2) = (SELECT MAX(AVG_PRICE) AS LARGEST_AVG FROM (SELECT brand_id, ROUND(AVG(PROD_PRICE), 2) AS AVG_PRICE FROM lgproduct GROUP BY brand_id) AVG_PRICE) --64 SELECT DE.EMP_FNAME, DE.EMP_LNAME, DEPT_NAME, DEPT_PHONE, E.EMP_FNAME, E.EMP_LNAME, CUST_FNAME, CUST_LNAME, INV_DATE, INV_TOTAL FROM lgemployee DE INNER JOIN lgdepartment D ON DE.emp_num = D.emp_num INNER JOIN lgemployee E ON D.dept_num = E.dept_num INNER JOIN lginvoice I ON E.emp_num = I.employee_id INNER JOIN lgcustomer C ON I.cust_code = C.cust_code WHERE CUST_LNAME = 'HAGAN' AND inv_date = '2015-05-18'
//ACTIVITY 04 SELECT last_name, department_id FROM emps WHERE department_id IN (20,50) ORDER BY last_name;
SELECT * FROM tutorial.aapl_historical_stock_price;
insert into Person values ('Smith', '123 Elm St.', '801-556-2239'); insert into Person values ('Jones', '234 Oak St.', '801-552-2943'); insert into Person values ('Peters', '345 Pine St.', '801-393-2230'); insert into Person values ('Green', '435 Alder St.', '801-933-2320'); insert into Person values ('Rowe', '348 Elder St.', '801-343-2320'); insert into Person values ('Phillips', '395 Pine St.', '801-323-2320'); insert into Person values ('Gates', '285 Kapok St.', '801-493-2203'); insert into Person values ('Clark', '223 Easy St.', '801-193-2320'); insert into Person values ('Warnock', '775 Main St.', '801-303-2222'); insert into Person values ('Hooper', '456 Maple St.', '313-912-2101'); insert into Person values ('Edwards', '567 Spruce St.', '801-228-6729'); insert into Person values ('Majeris', '678 Willow St.', null); insert into Person values ('MacBride', '789 Fir St.', null); insert into Employee values ('Jones', 50000.00, 1001); insert into Employee values ('Peters', 45000.00, 1002); insert into Employee values ('Rowe', 35000.00, 1003); insert into Employee values ('Phillips', 25000.00, 1004); insert into Employee values ('Gates', 5000000.00, 1005); insert into Employee values ('Clark', 150000.00, 1006); insert into Employee values ('Warnock', 500000.00, 1007); insert into Pilot values (1001); insert into Pilot values (1002); insert into Pilot values (1003); insert into Plane values ('Boeing', 'B727'); insert into Plane values ('Boeing', 'B747'); insert into Plane values ('Boeing', 'B757'); insert into Plane values ('MD', 'DC9'); insert into Plane values ('MD', 'DC10'); insert into Plane values ('Airbus', 'A310'); insert into Plane values ('Airbus', 'A320'); insert into Plane values ('Airbus', 'A330'); insert into Plane values ('Airbus', 'A340'); insert into Aircraft values (11, 'B727'); insert into Aircraft values (13, 'B727'); insert into Aircraft values (10, 'B747'); insert into Aircraft values (13, 'B747'); insert into Aircraft values (22, 'B757'); insert into Aircraft values (93, 'B757'); insert into Aircraft values (21, 'DC9'); insert into Aircraft values (22, 'DC9'); insert into Aircraft values (23, 'DC9'); insert into Aircraft values (24, 'DC9'); insert into Aircraft values (21, 'DC10'); insert into Aircraft values (70, 'A310'); insert into Aircraft values (80, 'A320'); insert into Flight values (100, 'SLC', 'BOS', to_date('08:00', 'HH24:MI'), to_date('17:50', 'HH24:MI')); insert into Flight values (206, 'DFW', 'STL', to_date('09:00', 'HH24:MI'), to_date('11:40', 'HH24:MI')); insert into Flight values (334, 'ORD', 'MIA', to_date('12:00', 'HH24:MI'), to_date('14:14', 'HH24:MI')); insert into Flight values (335, 'MIA', 'ORD', to_date('15:00', 'HH24:MI'), to_date('17:14', 'HH24:MI')); insert into Flight values (336, 'ORD', 'MIA', to_date('18:00', 'HH24:MI'), to_date('20:14', 'HH24:MI')); insert into Flight values (337, 'MIA', 'ORD', to_date('20:30', 'HH24:MI'), to_date('23:53', 'HH24:MI')); insert into Flight values (121, 'STL', 'SLC', to_date('07:00', 'HH24:MI'), to_date('09:13', 'HH24:MI')); insert into Flight values (122, 'STL', 'YYV', to_date('08:30', 'HH24:MI'), to_date('10:19', 'HH24:MI')); insert into Flight values (330, 'JFK', 'YYV', to_date('16:00', 'HH24:MI'), to_date('18:53', 'HH24:MI')); insert into Flight values (991, 'BOS', 'ORD', to_date('17:00', 'HH24:MI'), to_date('18:22', 'HH24:MI')); insert into Flight values (394, 'DFW', 'MIA', to_date('19:00', 'HH24:MI'), to_date('21:30', 'HH24:MI')); insert into Flight values (395, 'MIA', 'DFW', to_date('21:00', 'HH24:MI'), to_date('23:43', 'HH24:MI')); insert into Flight values (449, 'CDG', 'DEN', to_date('10:00', 'HH24:MI'), to_date('19:29', 'HH24:MI')); insert into Flight values (930, 'YYV', 'DCA', to_date('13:00', 'HH24:MI'), to_date('16:10', 'HH24:MI')); insert into Flight values (931, 'DCA', 'YYV', to_date('17:00', 'HH24:MI'), to_date('18:10', 'HH24:MI')); insert into Flight values (932, 'DCA', 'YYV', to_date('18:00', 'HH24:MI'), to_date('19:10', 'HH24:MI')); insert into Flight values (112, 'DCA', 'DEN', to_date('14:00', 'HH24:MI'), to_date('18:07', 'HH24:MI')); insert into Departure values (to_date('31.10.2009', 'DD.MM.YYYY'), 100); insert into Departure values (to_date('31.10.2009', 'DD.MM.YYYY'), 112); insert into Departure values (to_date('31.10.2009', 'DD.MM.YYYY'), 206); insert into Departure values (to_date('31.10.2009', 'DD.MM.YYYY'), 334); insert into Departure values (to_date('31.10.2009', 'DD.MM.YYYY'), 335); insert into Departure values (to_date('31.10.2009', 'DD.MM.YYYY'), 337); insert into Departure values (to_date('31.10.2009', 'DD.MM.YYYY'), 449); insert into Departure values (to_date('01.11.2009', 'DD.MM.YYYY'), 100); insert into Departure values (to_date('01.11.2009', 'DD.MM.YYYY'), 112); insert into Departure values (to_date('01.11.2009', 'DD.MM.YYYY'), 206); insert into Departure values (to_date('01.11.2009', 'DD.MM.YYYY'), 334); insert into Departure values (to_date('01.11.2009', 'DD.MM.YYYY'), 395); insert into Departure values (to_date('01.11.2009', 'DD.MM.YYYY'), 991); insert into Booked_On values ('Smith', to_date('31.10.2009', 'DD.MM.YYYY'), 100); insert into Booked_On values ('Green', to_date('31.10.2009', 'DD.MM.YYYY'), 206); insert into Booked_On values ('Hooper', to_date('31.10.2009', 'DD.MM.YYYY'), 334); insert into Booked_On values ('Edwards', to_date('31.10.2009', 'DD.MM.YYYY'), 449); insert into Booked_On values ('MacBride', to_date('01.11.2009', 'DD.MM.YYYY'), 991); insert into Booked_On values ('Gates', to_date('01.11.2009', 'DD.MM.YYYY'), 991); insert into Booked_On values ('Rowe', to_date('01.11.2009', 'DD.MM.YYYY'), 100); insert into Booked_On values ('Clark', to_date('01.11.2009', 'DD.MM.YYYY'), 100); insert into Booked_On values ('Phillips', to_date('31.10.2009', 'DD.MM.YYYY'), 449); insert into Booked_On values ('Warnock', to_date('31.10.2009', 'DD.MM.YYYY'), 449); insert into Booked_On values ('Smith', to_date('01.11.2009', 'DD.MM.YYYY'), 991); insert into Booked_On values ('Peters', to_date('01.11.2009', 'DD.MM.YYYY'), 100); insert into Assigned_To values (1001, to_date('31.10.2009', 'DD.MM.YYYY'), 100); insert into Assigned_To values (1002, to_date('31.10.2009', 'DD.MM.YYYY'), 100); insert into Assigned_To values (1003, to_date('31.10.2009', 'DD.MM.YYYY'), 100); insert into Assigned_To values (1004, to_date('31.10.2009', 'DD.MM.YYYY'), 100); insert into Assigned_To values (1007, to_date('31.10.2009', 'DD.MM.YYYY'), 206); insert into Assigned_To values (1003, to_date('31.10.2009', 'DD.MM.YYYY'), 337); insert into Assigned_To values (1004, to_date('31.10.2009', 'DD.MM.YYYY'), 337); insert into Assigned_To values (1005, to_date('31.10.2009', 'DD.MM.YYYY'), 337); insert into Assigned_To values (1006, to_date('31.10.2009', 'DD.MM.YYYY'), 337); insert into Assigned_To values (1001, to_date('01.11.2009', 'DD.MM.YYYY'), 100); insert into Assigned_To values (1002, to_date('01.11.2009', 'DD.MM.YYYY'), 100); insert into Assigned_To values (1006, to_date('01.11.2009', 'DD.MM.YYYY'), 991); insert into Assigned_To values (1007, to_date('01.11.2009', 'DD.MM.YYYY'), 991); insert into Assigned_To values (1007, to_date('01.11.2009', 'DD.MM.YYYY'), 112); insert into Can_Fly values (1001, 'B727'); insert into Can_Fly values (1001, 'B747'); insert into Can_Fly values (1001, 'DC10'); insert into Can_Fly values (1002, 'DC9'); insert into Can_Fly values (1002, 'A340'); insert into Can_Fly values (1002, 'B757'); insert into Can_Fly values (1002, 'A320'); insert into Can_Fly values (1003, 'A310'); insert into Can_Fly values (1003, 'DC9'); insert into Equipment values (to_date('31.10.2009', 'DD.MM.YYYY'), 100, 11, 'B727'); insert into Equipment values (to_date('31.10.2009', 'DD.MM.YYYY'), 206, 13, 'B727'); insert into Equipment values (to_date('31.10.2009', 'DD.MM.YYYY'), 112, 11, 'B727'); insert into Equipment values (to_date('31.10.2009', 'DD.MM.YYYY'), 337, 24, 'DC9'); insert into Equipment values (to_date('01.11.2009', 'DD.MM.YYYY'), 991, 22, 'B757'); insert into Equipment values (to_date('01.11.2009', 'DD.MM.YYYY'), 112, 21, 'DC10'); commit;
-- phpMyAdmin SQL Dump -- version 4.9.2 -- https://www.phpmyadmin.net/ -- -- Hôte : 127.0.0.1:3306 -- Généré le : jeu. 22 avr. 2021 à 18:37 -- Version du serveur : 10.4.10-MariaDB -- Version de PHP : 7.3.12 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Base de données : `base_arrange` -- -- -------------------------------------------------------- -- -- Structure de la table `produits` -- DROP TABLE IF EXISTS `produits`; CREATE TABLE IF NOT EXISTS `produits` ( `product_id` int(4) NOT NULL AUTO_INCREMENT, `product_img_rel` varchar(128) NOT NULL, `product_categories` varchar(32) NOT NULL, `product_ref` varchar(4) NOT NULL, `product_label` varchar(32) NOT NULL, `product_stock` int(4) NOT NULL, `product_desc` varchar(512) NOT NULL, `product_prix` int(4) NOT NULL, PRIMARY KEY (`product_id`) ) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1; -- -- Déchargement des données de la table `produits` -- INSERT INTO `produits` (`product_id`, `product_img_rel`, `product_categories`, `product_ref`, `product_label`, `product_stock`, `product_desc`, `product_prix`) VALUES (1, 'src=\"./img/produits/Livre/Printemps.jpg\" alt=\"Livre Printemps\"', 'Livre', 'L1', 'Recettes printaniere', 15, 'Notre livre de recette à base de rhum à faire au printemps.<br/> Rhum arrange avec des fruits de saisons et nos meilleurs recettes floral.', 25), (2, 'src=\"./img/produits/Livre/Ete.jpeg\" alt=\"Livre ete\"', 'Livre', 'L2', 'Recettes d ete', 15, 'Notre livre de recette à base de rhum à faire en ete.<br/> Rhum arrange avec des fruits de saisons et nos meilleurs cocktail rafraichissant.', 25), (3, 'src=\"./img/produits/Livre/Automne.jpg\" alt=\"Livre Automne\"', 'Livre', 'L3', 'Recettes d automne', 15, 'Notre livre de recette à base de rhum à faire en automne.<br/> Rhum arrange avec des fruits de saisons et nos meilleurs cocktail pour halloween.', 25), (4, 'src=\"./img/produits/Livre/Hiver.jpg\" alt=\"Livre Hiver\"', 'Livre', 'L4', 'Recettes hiver', 15, 'Notre livre de recette à base de rhum à faire en hiver.<br/> Rhum arrange avec des fruits de saisons ou encore des Grogs à boire au coin du feu.', 25), (5, 'src=\"./img/produits/Livre/Pack.jpg\" alt=\"Pack Livre\"', 'Livre', 'L5', 'Pack de Livre', 10, 'Tous les livres de notre boutique au prix avantageux de 3 !!!', 75), (6, 'src=\"./img/produits/Kit/Miel.jpg\" alt=\"Miel\"', 'Kit', 'K1', 'Miel Bio de France', 10, 'Le miel de lavande est un aliment 100 % naturel produit par les abeilles à partir du nectar de la fleur.<br/> D une couleur ambree à jaune doree, il se caracterise par un arôme delicat typique, une texture onctueuse aux saveurs fruitees.<br/> Moins calorique que le sucre, avec un pouvoir sucrant superieur, il peut le remplacer avantageusement.', 25), (7, 'src=\"./img/produits/Kit/Poivre.jpg\" alt=\"Poivre Voatsiperifery\"', 'Kit', 'K2', 'Poivre Voatsiperifery', 10, 'Poivre Sauvage De Madagascar, appele aussi Voatsiperifery, est un poivre plutôt doux au niveau du piquant.<br/> Son caractere exceptionnel provient de son parfum riche et intense. Dejà à l odeur, on decele des notes de terre fraiche, subtilement boisee.<br/> Une fois en bouche, commence une saveur d herbes fraiches brulees, de dessous de bois qui laisse place rapidement à une fraicheur fruitee d agrume citronne, avec une pointe de note fleurie.', 15), (8, 'src=\"./img/produits/Kit/sucrecoco.jpg\" alt=\"Sucre de fleur de coco\"', 'Kit', 'K3', 'Sucre de fleur de coco', 10, 'C’est un edulcorant sain et naturel, caracterise par son incroyable saveur avec un indice glycemique particulierement bas, il commence tout juste à devenir populaire en Occident.<br/> Au nez, il developpe des notes fleuries de fleur de coco, aux touches d arôme caramelise avec des pointes d’amandes et de noisettes.<br/> Son goût est subtilement caramelise. Il est moins prononce que le sucre complet, mais plus type que le sucre de table sans avoir le goût de la noix de coco.', 25), (9, 'src=\"./img/produits/Kit/Vanille.jpg\" alt=\"Vanille\"', 'Kit', 'K4', 'Vanille', 10, '10 gousse de vanille de Tahiti Raiatea gourmet extra d une longueur de 16 à 20cm.<br/> Cette vanille de Tahiti va se caracteriser par une gousse de vanille tres grasse, huileuse avec une belle robe ridee.<br/> La vanille est tres brillante avec parfum extraordinaire.<br/> Notes principales : d anis et de pruneaux qui laisse place à un goût de vanille florale....', 55), (10, 'src=\"./img/produits/Kit/Cannelle.jpg\" alt=\"Cannelle de Ceylan\"', 'Kit', 'K5', 'Cannelle de Ceylan', 10, 'Parmi les nombreuses especes, la plus reputee est la cannelle de Ceylan (Cinnamomum zeylanicum, synonyme de Cinnamomum verum).<br/> Celle-ci, est ainsi originaire de Ceylan autrement dit du Sri Lanka, appelee « vraie cannelle ».<br/> La cannelle de Ceylan a plusieurs fines couches d’ecorces, celle-ci tres subtile, peut être laissee tout au long de vos macerations. ', 15), (11, 'src=\"./img/produits/Accessoire/3L.jpg\" alt=\"Bocal hermetique 3L\"', 'Accessoire', 'A1', 'Bocal hermetique 3L', 10, 'L incontournalbe, sa contenance vous permettra de faire rentrer n importe quel fruit même les plus volumineux.', 12), (12, 'src=\"./img/produits/Accessoire/Filtre.jpg\" alt=\"Filtre reutilisable\"', 'Accessoire', 'A2', 'Filtre reutilisable', 10, 'Pour filtrer vos preparation avant degustation.<br/> Ce filtre en inox retiendra aisement les pulpes de vos fruits ou encore vos epices les plus fines.', 12), (13, 'src=\"./img/produits/Accessoire/1L.jpg\" alt=\"Bouteille en verre 1L\"', 'Accessoire', 'A3', 'Bouteille en verre 1L', 10, 'Sa simplicite est son atout, son systeme de fermeture hermetique vous garantira securite et longevite à vos preparations.', 5), (14, 'src=\"./img/produits/Accessoire/Zesteur.jpg\" alt=\"Zesteur pour agrume\"', 'Accessoire', 'A4', 'Zesteur pour agrume', 10, 'Ce zesteur tres simple vous permettra de zester vos agrumes en tout simplicite.<br/> Tout en evitant le mesocarpe(Ziste, partie blanche du zeste) de celui-ci.', 8), (15, 'src=\"./img/produits/Accessoire/Fiole.jpg\" alt=\"10 Fiole\"', 'Accessoire', 'A5', '10 Fiole', 10, '10 petites fioles pour offrir vos creations à vos amis et famille !', 20); 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 */;
SET NAMES 'utf8'; CREATE DATABASE buticdb DEFAULT CHARACTER SET utf8 COLLATE utf8_spanish_ci; GRANT ALL ON buticdb.* TO butic@localhost IDENTIFIED BY 'butic+123';
SELECT MIN(k.keyword) AS movie_keyword, MIN(n.name) AS actor_name, MIN(t.title) AS hero_movie, count(*) AS cnt FROM cast_info AS ci, keyword AS k, movie_keyword AS mk, name AS n, title AS t WHERE k.keyword IN ('superhero', 'sequel', 'second-part', 'marvel-comics', 'based-on-comic', 'tv-special', 'fight', 'violence') AND n.name LIKE '%Downey%Robert%' AND t.production_year > 2000 AND k.id = mk.keyword_id AND t.id = mk.movie_id AND t.id = ci.movie_id AND ci.movie_id = mk.movie_id AND n.id = ci.person_id;
-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: bags_of_words; Type: TABLE; Schema: public; Owner: the_owner; Tablespace: -- CREATE TABLE bags_of_words ( id integer NOT NULL, generated_on timestamp with time zone, bag_of_words character varying[], method character varying, response_id integer ); ALTER TABLE bags_of_words OWNER TO the_owner; -- -- Name: bags_of_words_id_seq; Type: SEQUENCE; Schema: public; Owner: the_owner -- CREATE SEQUENCE bags_of_words_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bags_of_words_id_seq OWNER TO the_owner; -- -- Name: bags_of_words_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: the_owner -- ALTER SEQUENCE bags_of_words_id_seq OWNED BY bags_of_words.id; -- -- Name: identities; Type: TABLE; Schema: public; Owner: the_owner; Tablespace: -- CREATE TABLE identities ( response_id integer, identity json, id integer NOT NULL ); ALTER TABLE identities OWNER TO the_owner; -- -- Name: identities_id_seq; Type: SEQUENCE; Schema: public; Owner: the_owner -- CREATE SEQUENCE identities_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE identities_id_seq OWNER TO the_owner; -- -- Name: identities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: the_owner -- ALTER SEQUENCE identities_id_seq OWNED BY identities.id; -- -- Name: responses; Type: TABLE; Schema: public; Owner: the_owner; Tablespace: -- CREATE TABLE responses ( id integer NOT NULL, source_url character varying, cleaned_content character varying, raw_content character varying, raw_content_md5 character varying(40), initial_harvest_date timestamp with time zone, source_url_sha character varying(100), inlinks character varying[], outlinks character varying[], host character varying, schemas character varying[], format character varying(20), headers json, namespaces json ); ALTER TABLE responses OWNER TO the_owner; -- -- Name: responses_id_seq; Type: SEQUENCE; Schema: public; Owner: the_owner -- CREATE SEQUENCE responses_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE responses_id_seq OWNER TO the_owner; -- -- Name: responses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: the_owner -- ALTER SEQUENCE responses_id_seq OWNED BY responses.id; -- -- Name: validations; Type: TABLE; Schema: public; Owner: the_owner; Tablespace: -- CREATE TABLE validations ( id integer NOT NULL, validated_on timestamp with time zone, errors character varying[], valid boolean, response_id integer ); ALTER TABLE validations OWNER TO the_owner; -- -- Name: validations_id_seq; Type: SEQUENCE; Schema: public; Owner: the_owner -- CREATE SEQUENCE validations_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE validations_id_seq OWNER TO the_owner; -- -- Name: validations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: the_owner -- ALTER SEQUENCE validations_id_seq OWNED BY validations.id; -- -- Name: id; Type: DEFAULT; Schema: public; Owner: the_owner -- ALTER TABLE ONLY bags_of_words ALTER COLUMN id SET DEFAULT nextval('bags_of_words_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: the_owner -- ALTER TABLE ONLY identities ALTER COLUMN id SET DEFAULT nextval('identities_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: the_owner -- ALTER TABLE ONLY responses ALTER COLUMN id SET DEFAULT nextval('responses_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: the_owner -- ALTER TABLE ONLY validations ALTER COLUMN id SET DEFAULT nextval('validations_id_seq'::regclass); -- -- Name: bags_of_words_pkey; Type: CONSTRAINT; Schema: public; Owner: the_owner; Tablespace: -- ALTER TABLE ONLY bags_of_words ADD CONSTRAINT bags_of_words_pkey PRIMARY KEY (id); -- -- Name: identity_pkey; Type: CONSTRAINT; Schema: public; Owner: the_owner; Tablespace: -- ALTER TABLE ONLY identities ADD CONSTRAINT identity_pkey PRIMARY KEY (id); -- -- Name: responses_id_pkey; Type: CONSTRAINT; Schema: public; Owner: the_owner; Tablespace: -- ALTER TABLE ONLY responses ADD CONSTRAINT responses_id_pkey PRIMARY KEY (id); -- -- Name: unique_url_sha; Type: CONSTRAINT; Schema: public; Owner: the_owner; Tablespace: -- ALTER TABLE ONLY responses ADD CONSTRAINT unique_url_sha UNIQUE (source_url_sha); -- -- Name: validations_pkey; Type: CONSTRAINT; Schema: public; Owner: the_owner; Tablespace: -- ALTER TABLE ONLY validations ADD CONSTRAINT validations_pkey PRIMARY KEY (id); -- -- Name: response_bags_of_words_fkey; Type: FK CONSTRAINT; Schema: public; Owner: the_owner -- ALTER TABLE ONLY bags_of_words ADD CONSTRAINT response_bags_of_words_fkey FOREIGN KEY (response_id) REFERENCES responses(id); -- -- Name: response_identity_fkey; Type: FK CONSTRAINT; Schema: public; Owner: the_owner -- ALTER TABLE ONLY identities ADD CONSTRAINT response_identity_fkey FOREIGN KEY (response_id) REFERENCES responses(id); -- -- Name: response_validation_fkey; Type: FK CONSTRAINT; Schema: public; Owner: the_owner -- ALTER TABLE ONLY validations ADD CONSTRAINT response_validation_fkey FOREIGN KEY (response_id) REFERENCES responses(id); -- -- Name: public; Type: ACL; Schema: -; Owner: the_owner -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM the_owner; GRANT ALL ON SCHEMA public TO the_owner; -- -- Name: bags_of_words; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON TABLE bags_of_words FROM PUBLIC; REVOKE ALL ON TABLE bags_of_words FROM the_owner; GRANT ALL ON TABLE bags_of_words TO the_owner; GRANT SELECT,INSERT,UPDATE ON TABLE bags_of_words TO the_user; -- -- Name: bags_of_words_id_seq; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON SEQUENCE bags_of_words_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bags_of_words_id_seq FROM the_owner; GRANT ALL ON SEQUENCE bags_of_words_id_seq TO the_owner; GRANT SELECT,USAGE ON SEQUENCE bags_of_words_id_seq TO the_user; -- -- Name: identities; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON TABLE identities FROM PUBLIC; REVOKE ALL ON TABLE identities FROM the_owner; GRANT ALL ON TABLE identities TO the_owner; GRANT SELECT,INSERT,UPDATE ON TABLE identities TO the_user; -- -- Name: identities_id_seq; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON SEQUENCE identities_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE identities_id_seq FROM the_owner; GRANT ALL ON SEQUENCE identities_id_seq TO the_owner; GRANT SELECT,USAGE ON SEQUENCE identities_id_seq TO the_user; -- -- Name: responses; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON TABLE responses FROM PUBLIC; REVOKE ALL ON TABLE responses FROM the_owner; GRANT ALL ON TABLE responses TO the_owner; GRANT SELECT,INSERT,UPDATE ON TABLE responses TO the_user; -- -- Name: responses_id_seq; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON SEQUENCE responses_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE responses_id_seq FROM the_owner; GRANT ALL ON SEQUENCE responses_id_seq TO the_owner; GRANT SELECT,USAGE ON SEQUENCE responses_id_seq TO the_user; -- -- Name: validations; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON TABLE validations FROM PUBLIC; REVOKE ALL ON TABLE validations FROM the_owner; GRANT ALL ON TABLE validations TO the_owner; GRANT SELECT,INSERT,UPDATE ON TABLE validations TO the_user; -- -- Name: validations_id_seq; Type: ACL; Schema: public; Owner: the_owner -- REVOKE ALL ON SEQUENCE validations_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE validations_id_seq FROM the_owner; GRANT ALL ON SEQUENCE validations_id_seq TO the_owner; GRANT SELECT,USAGE ON SEQUENCE validations_id_seq TO the_user; -- -- PostgreSQL database dump complete --
--Check if DB exists, drop and create USE master IF EXISTS (select * from master.sys.databases where name ='AccessTracker') BEGIN ALTER DATABASE AccessTracker SET SINGLE_USER WITH ROLLBACK IMMEDIATE DROP DATABASE IF EXISTS AccessTracker END CREATE DATABASE AccessTracker USE AccessTracker --Create table for current active workers-parsed from WFHUB CREATE TABLE dbo.tblActiveWorkers ( WorkerID int NOT NULL, WorkerFullName nvarchar(50), WorkerFirstName nvarchar(50), WorkerLastName nvarchar(50), ManagerFullName nvarchar(50), WorkerCity nvarchar(50), WorkerState nvarchar(50), VendorName nvarchar(max) CONSTRAINT PK_tblActiveWorkers PRIMARY KEY (WorkerID) ) --Create table for current access records-parsed from NCIDM CREATE TABLE dbo.tblAccess ( WorkerID int NOT NULL, WorkerLastName nvarchar(50), WorkerFirstName nvarchar(50), WorkerFullName nvarchar(50), BusinessRole nvarchar(100), CompanyName nvarchar(50), ManagerFullName nvarchar(50), WorkerCompanyType nvarchar(50), WorkerAccessType nvarchar(50), WorkerRegion nvarchar(8), WorkerCity nvarchar (25), WorkerState nvarchar (8) ) ALTER TABLE dbo.tblAccess WITH CHECK ADD CONSTRAINT FK_TO_tblActiveWorkers_PK FOREIGN KEY(WorkerID) REFERENCES dbo.tblActiveWorkers(WorkerID) ALTER TABLE dbo.tblAccess CHECK CONSTRAINT FK_TO_tblActiveWorkers_PK --Create table for current training records-parsed from NCIDM CREATE TABLE dbo.tblTraining ( WorkerID int NOT NULL, TrainingExpirationDate datetime, WorkerFullName nvarchar(50), ManagerFullName nvarchar(50), WorkerDepartment nvarchar(50), TrainingClass nvarchar(50), BusinessRole nvarchar(max), ComplianceMonitor nvarchar(max) ) ALTER TABLE dbo.tblTraining WITH NOCHECK ADD CONSTRAINT FK_tblTraining_tblActiveWorkers FOREIGN KEY(WorkerID) REFERENCES dbo.tblActiveWorkers (WorkerID) NOT FOR REPLICATION ALTER TABLE dbo.tblTraining NOCHECK CONSTRAINT FK_tblTraining_tblActiveWorkers --Create table for current worker records based on worker city (Duke only) CREATE TABLE dbo.tblCityRegion ( City nvarchar (max), Region nvarchar (max) ) INSERT INTO dbo.tblCityRegion (City, Region) VALUES ('Plainfield', 'MW'), ('Cincinnati', 'MW'), ('Milford', 'MW'), ('Charlotte', 'CW'), ('Vincennes', 'MW'), ('MONROE', 'CW'), ('RALEIGH', 'CE'), ('KERNERSVILLE', 'CW'), ('ST. PETERSBURG', 'FL'), ('SHELBYVILLE', 'MW'), ('TERRE HAUTE', 'MW'), ('KOKOMO', 'MW'), ('COLUMBUS', 'MW') --Create table for current worker region based on worker city (non-Duke) CREATE TABLE dbo.tblMgrRegion ( MgrName nvarchar (max), Region nvarchar (max) ) INSERT INTO dbo.tblMgrRegion (MgrName, Region) VALUES ('Bunnell, Kimberly Jean', 'CE'), ('Cecil, Jane S', 'CW'), ('Gaddy, Rodney E', 'CW'), ('Gilb, Christopher L', 'MW'), ('Hilburn, Robin CW', 'CW'), ('Ingle, Darrel R', 'MW'), ('Lanham, Misty Varner', 'CW'), ('Ledford, Burt', 'MW'), ('Pratt, Shannon Rhoda', 'CW'), ('Rathburn, Eric Daniel', 'FL'), ('Rodgers, Andy', 'CW'), ('Saboorian, K Calvin', 'CW'), ('Stenzler, Keith Alan', 'CW'), ('Thigpen, David J', 'CW'), ('Veit, Robert S', 'CE'), ('Waldrop, Dawn M', 'CW') --Change owner/access ALTER DATABASE AccessTracker set TRUSTWORTHY ON; EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false --Run SPs to show advanced options, enable clr and reconfigure EXEC sp_configure 'show advanced options', 1; RECONFIGURE EXEC sp_configure 'clr enabled', 1; RECONFIGURE --Set DB as read/write USE master ALTER DATABASE AccessTracker SET READ_WRITE
-- RedefineTables PRAGMA foreign_keys=OFF; CREATE TABLE "new_Review" ( "id" TEXT NOT NULL PRIMARY KEY, "rating" INTEGER NOT NULL, "comment" TEXT NOT NULL DEFAULT '', "productId" TEXT NOT NULL, CONSTRAINT "Review_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); INSERT INTO "new_Review" ("id", "productId", "rating") SELECT "id", "productId", "rating" FROM "Review"; DROP TABLE "Review"; ALTER TABLE "new_Review" RENAME TO "Review"; PRAGMA foreign_key_check; PRAGMA foreign_keys=ON;
/* Copyright 2021 Snowplow Analytics Ltd. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -- Use variable to set scan limits DECLARE LOWER_LIMIT, UPPER_LIMIT TIMESTAMP; {{if eq .model "mobile"}} -- Session and mobile context schema evolved with time. Finding all versions of column. DECLARE SESSION_ID, SESSION_CONTEXT_COLUMNS, MOBILE_CONTEXT_COLUMNS, MOBILE_EVENTS_QUERY STRING; CALL {{.output_schema}}.mobile_session_context_fields(SESSION_ID, SESSION_CONTEXT_COLUMNS); CALL {{.output_schema}}.mobile_mobile_context_fields({{.mobile_context}}, MOBILE_CONTEXT_COLUMNS); {{end}} SET (LOWER_LIMIT, UPPER_LIMIT) = (SELECT AS STRUCT lower_limit, upper_limit FROM {{.scratch_schema}}.{{.model}}_base_run_limits{{.entropy}}); {{if eq .model "web"}} CREATE OR REPLACE TABLE {{.scratch_schema}}.{{.model}}_events_this_run{{.entropy}} AS( -- Without downstream joins, it's safe to dedupe by picking the first event_id found. SELECT ARRAY_AGG(e ORDER BY e.collector_tstamp LIMIT 1)[OFFSET(0)].* FROM ( SELECT a.contexts_com_snowplowanalytics_snowplow_web_page_1_0_0[SAFE_OFFSET(0)].id AS page_view_id, a.* EXCEPT(contexts_com_snowplowanalytics_snowplow_web_page_1_0_0) FROM {{.input_schema}}.events a INNER JOIN {{.scratch_schema}}.{{.model}}_base_sessions_to_include{{.entropy}} b ON a.domain_sessionid = b.session_id WHERE a.collector_tstamp >= LOWER_LIMIT AND a.collector_tstamp <= UPPER_LIMIT AND a.platform IN ( {{range $i, $platform := .platform_filters}} {{if $i}}, {{end}} '{{$platform}}' {{else}} 'web' {{end}} ) {{if .app_id_filters}} -- Filter by app_id. Ignore if not specified. AND a.app_id IN ( {{range $i, $app_id := .app_id_filters}} {{if $i}}, {{end}} '{{$app_id}}' {{end}} ) {{end}} {{if eq (or .derived_tstamp_partitioned false) true}} AND a.derived_tstamp >= LOWER_LIMIT AND a.derived_tstamp <= UPPER_LIMIT {{end}} ) e GROUP BY e.event_id ); {{end}} {{if eq .model "mobile"}} SET MOBILE_EVENTS_QUERY = format(""" CREATE OR REPLACE TABLE {{.scratch_schema}}.{{.model}}_events_this_run{{.entropy}} PARTITION BY DATE(collector_tstamp) AS( WITH events AS ( SELECT -- Screen view event a.unstruct_event_com_snowplowanalytics_mobile_screen_view_1_0_0.id AS screen_view_id, a.unstruct_event_com_snowplowanalytics_mobile_screen_view_1_0_0.name AS screen_view_name, a.unstruct_event_com_snowplowanalytics_mobile_screen_view_1_0_0.previous_id AS screen_view_previous_id, a.unstruct_event_com_snowplowanalytics_mobile_screen_view_1_0_0.previous_name AS screen_view_previous_name, a.unstruct_event_com_snowplowanalytics_mobile_screen_view_1_0_0.previous_type AS screen_view_previous_type, a.unstruct_event_com_snowplowanalytics_mobile_screen_view_1_0_0.transition_type AS screen_view_transition_type, a.unstruct_event_com_snowplowanalytics_mobile_screen_view_1_0_0.type AS screen_view_type, -- Session context %s, -- Mobile context %s, -- Geo context {{if eq .geolocation_context true}} a.contexts_com_snowplowanalytics_snowplow_geolocation_context_1_1_0[SAFE_OFFSET(0)].latitude AS device_latitude, a.contexts_com_snowplowanalytics_snowplow_geolocation_context_1_1_0[SAFE_OFFSET(0)].longitude AS device_longitude, a.contexts_com_snowplowanalytics_snowplow_geolocation_context_1_1_0[SAFE_OFFSET(0)].latitude_longitude_accuracy AS device_latitude_longitude_accuracy, a.contexts_com_snowplowanalytics_snowplow_geolocation_context_1_1_0[SAFE_OFFSET(0)].altitude AS device_altitude, a.contexts_com_snowplowanalytics_snowplow_geolocation_context_1_1_0[SAFE_OFFSET(0)].altitude_accuracy AS device_altitude_accuracy, a.contexts_com_snowplowanalytics_snowplow_geolocation_context_1_1_0[SAFE_OFFSET(0)].bearing AS device_bearing, a.contexts_com_snowplowanalytics_snowplow_geolocation_context_1_1_0[SAFE_OFFSET(0)].speed AS device_speed, {{else}} CAST(NULL AS FLOAT64) AS device_latitude, CAST(NULL AS FLOAT64) AS device_longitude, CAST(NULL AS FLOAT64) AS device_latitude_longitude_accuracy, CAST(NULL AS FLOAT64) AS device_altitude, CAST(NULL AS FLOAT64) AS device_altitude_accuracy, CAST(NULL AS FLOAT64) AS device_bearing, CAST(NULL AS FLOAT64) AS device_speed, {{end}} -- App context {{if eq .application_context true}} a.contexts_com_snowplowanalytics_mobile_application_1_0_0[SAFE_OFFSET(0)].build, a.contexts_com_snowplowanalytics_mobile_application_1_0_0[SAFE_OFFSET(0)].version, {{else}} CAST(NULL AS STRING) AS build, CAST(NULL AS STRING) AS version, {{end}} -- Screen context {{if eq .screen_context true}} a.contexts_com_snowplowanalytics_mobile_screen_1_0_0[SAFE_OFFSET(0)].id AS screen_id, a.contexts_com_snowplowanalytics_mobile_screen_1_0_0[SAFE_OFFSET(0)].name AS screen_name, a.contexts_com_snowplowanalytics_mobile_screen_1_0_0[SAFE_OFFSET(0)].activity AS screen_activity, a.contexts_com_snowplowanalytics_mobile_screen_1_0_0[SAFE_OFFSET(0)].fragment AS screen_fragment, a.contexts_com_snowplowanalytics_mobile_screen_1_0_0[SAFE_OFFSET(0)].top_view_controller AS screen_top_view_controller, a.contexts_com_snowplowanalytics_mobile_screen_1_0_0[SAFE_OFFSET(0)].type AS screen_type, a.contexts_com_snowplowanalytics_mobile_screen_1_0_0[SAFE_OFFSET(0)].view_controller AS screen_view_controller, {{else}} CAST(NULL AS STRING) AS screen_id, CAST(NULL AS STRING) AS screen_name, CAST(NULL AS STRING) AS screen_activity, CAST(NULL AS STRING) AS screen_fragment, CAST(NULL AS STRING) AS screen_top_view_controller, CAST(NULL AS STRING) AS screen_type, CAST(NULL AS STRING) AS screen_view_controller, {{end}} -- select a.* after contexts to allow for future additional columns to be added to events_staged during UDF commit_table migratation step. -- leaving original context arrays in staged table. Future schema versions may contain fields that are interesting to customers but not the standard model. a.* FROM {{.input_schema}}.events a INNER JOIN {{.scratch_schema}}.{{.model}}_base_sessions_to_include{{.entropy}} b ON %s = b.session_id WHERE a.collector_tstamp >= @lowerLimit AND a.collector_tstamp <= @upperLimit AND a.platform IN ( {{range $i, $platform := .platform_filters}} {{if $i}}, {{end}} '{{$platform}}' {{else}} 'mob' {{end}} ) {{if .app_id_filters}} -- Filter by app_id. Ignore if not specified. AND a.app_id IN ( {{range $i, $app_id := .app_id_filters}} {{if $i}}, {{end}} '{{$app_id}}' {{end}} ) {{end}} {{if eq (or .derived_tstamp_partitioned false) true}} AND a.derived_tstamp >= @lowerLimit AND a.derived_tstamp <= @upperLimit {{end}} ) , deduped_events AS ( -- Without downstream joins, it's safe to dedupe by picking the first event_id found. SELECT ARRAY_AGG(e ORDER BY e.collector_tstamp LIMIT 1)[OFFSET(0)].* FROM events AS e GROUP BY e.event_id ) SELECT *, ROW_NUMBER() OVER(PARTITION BY d.session_id ORDER BY d.derived_tstamp) AS event_index_in_session FROM deduped_events AS d );""", SESSION_CONTEXT_COLUMNS, MOBILE_CONTEXT_COLUMNS, SESSION_ID); EXECUTE IMMEDIATE MOBILE_EVENTS_QUERY USING LOWER_LIMIT AS lowerLimit, UPPER_LIMIT AS upperLimit; {{end}}
-- phpMyAdmin SQL Dump -- version 4.8.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jul 26, 2018 at 11:44 AM -- Server version: 10.1.31-MariaDB -- PHP Version: 7.2.4 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `shoplienquan` -- -- -------------------------------------------------------- -- -- Table structure for table `donhang` -- CREATE TABLE `donhang` ( `IdOrder` int(10) NOT NULL, `IdUser` int(10) NOT NULL, `UserAcc` varchar(30) NOT NULL, `UserPass` varchar(30) NOT NULL, `rank1` varchar(50) NOT NULL, `rank2` varchar(50) NOT NULL, `price` double(10,0) NOT NULL, `NgayThue` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `TinhTrang` int(1) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `donhang` -- INSERT INTO `donhang` (`IdOrder`, `IdUser`, `UserAcc`, `UserPass`, `rank1`, `rank2`, `price`, `NgayThue`, `TinhTrang`) VALUES (22, 16, 'useracc1', 'passacc1', 'Đồng', 'Bạch Kim IV', 270000, '2018-07-26 08:56:14', 0), (23, 16, 'ádfdasf', 'adsfadfs', 'Đồng', 'Vàng II', 120000, '2018-07-26 08:57:22', 0); -- -------------------------------------------------------- -- -- Table structure for table `napthe` -- CREATE TABLE `napthe` ( `IdNap` int(10) NOT NULL, `IdUser` int(10) NOT NULL, `LoaiThe` varchar(15) NOT NULL, `MenhGia` int(10) NOT NULL, `MaThe` varchar(20) NOT NULL, `Seri` varchar(20) NOT NULL, `TinhTrang` int(1) NOT NULL DEFAULT '0', `NgayNap` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `napthe` -- INSERT INTO `napthe` (`IdNap`, `IdUser`, `LoaiThe`, `MenhGia`, `MaThe`, `Seri`, `TinhTrang`, `NgayNap`) VALUES (63, 16, 'viettel', 100000, '123456879', '123456789', 1, '2018-07-26 08:44:52'), (64, 16, 'viettel', 20000, '10000', '10000', 2, '2018-07-26 08:45:58'), (65, 16, 'viettel', 10000, 'sdfsdfsadf', 'sdafsdaf', 2, '2018-07-26 08:46:12'), (66, 16, 'viettel', 50000, '234423', '23424', 1, '2018-07-26 08:48:10'), (67, 16, 'viettel', 500000, 'dsfasdf', 'sdafsdafsdf', 1, '2018-07-26 08:48:45'), (68, 16, 'viettel', 10000, '13215456', '6564564', 2, '2018-07-26 08:56:37'), (69, 16, 'viettel', 500000, '546545', '65454', 0, '2018-07-26 08:57:30'); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `IdUser` int(10) NOT NULL, `phone` varchar(15) NOT NULL, `password` mediumtext NOT NULL, `name` varchar(30) NOT NULL, `avt` mediumtext, `permission` int(1) NOT NULL DEFAULT '0', `credit` int(10) DEFAULT NULL, `credit_pending` int(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `user` -- INSERT INTO `user` (`IdUser`, `phone`, `password`, `name`, `avt`, `permission`, `credit`, `credit_pending`) VALUES (16, '123', '202cb962ac59075b964b07152d234b70', 'Phạm Tuấn Anh', '07-26-2018_10-58-28.jpg', 1, 260000, 500000); -- -- Indexes for dumped tables -- -- -- Indexes for table `donhang` -- ALTER TABLE `donhang` ADD PRIMARY KEY (`IdOrder`); -- -- Indexes for table `napthe` -- ALTER TABLE `napthe` ADD PRIMARY KEY (`IdNap`), ADD UNIQUE KEY `MaThe` (`MaThe`), ADD UNIQUE KEY `Seri` (`Seri`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`IdUser`), ADD UNIQUE KEY `sdt` (`phone`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `donhang` -- ALTER TABLE `donhang` MODIFY `IdOrder` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24; -- -- AUTO_INCREMENT for table `napthe` -- ALTER TABLE `napthe` MODIFY `IdNap` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=70; -- -- AUTO_INCREMENT for table `user` -- ALTER TABLE `user` MODIFY `IdUser` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18; 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 */;
UPDATE `settings` SET `value` = "0.8" WHERE `key` = "version";
user 123: 3be373e2-b828-11e9-a2a3-2a2ae2dbcce4 resource user 123: 3be35c7c-b828-11e9-a2a3-2a2ae2dbcce4 resource user owner 654: 49a873c6-b853-11e9-a2a3-2a2ae2dbcce4 user owner 654: 3be36528-b828-11e9-a2a3-2a2ae2dbcce4 spouse role uuid (123 to 654): 35f92df8-b825-11e9-a2a3-2a2ae2dbcce4 family member role uuid (123 to 654): 35f92cc2-b825-11e9-a2a3-2a2ae2dbcce4 "AllMedicationListData" resource type uuid: 3be3a11e-b828-11e9-a2a3-2a2ae2dbcce4
SELECT TOP (5) e.EmployeeID, e.FirstName, e.Salary, d.Name AS [DepartmentName] FROM Employees AS e JOIN Departments As d ON e.DepartmentID = d.DepartmentID AND e.Salary > 15000 -- WHERE e.Salary > 15000 ORDER BY e.DepartmentID
-- CreateTable CREATE TABLE "User" ( "id" SERIAL NOT NULL, "email" TEXT NOT NULL, "username" TEXT NOT NULL, "full_name" TEXT NOT NULL, "password" TEXT NOT NULL, "email_verified" BOOLEAN NOT NULL DEFAULT false, "hashActivation" TEXT NOT NULL, "active" BOOLEAN NOT NULL DEFAULT true, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "confirmed_at" TIMESTAMP(3), PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Role" ( "id" SERIAL NOT NULL, "name" TEXT NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "UserRole" ( "id" SERIAL NOT NULL, "user_id" INTEGER NOT NULL, "role_id" INTEGER NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Book" ( "id" SERIAL NOT NULL, "name" TEXT NOT NULL, "authors" TEXT[], "editorial" TEXT NOT NULL, "price" DOUBLE PRECISION NOT NULL, "stock" INTEGER NOT NULL, "disabled" BOOLEAN NOT NULL DEFAULT false, "favourites" INTEGER[], "category_id" INTEGER NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Category" ( "id" SERIAL NOT NULL, "name" TEXT NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Cart" ( "id" SERIAL NOT NULL, "user_id" INTEGER NOT NULL, "book_id" INTEGER NOT NULL, "quantity" INTEGER NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Sale" ( "id" SERIAL NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "saleStatus" TEXT NOT NULL, "user_id" INTEGER NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "BookSale" ( "id" SERIAL NOT NULL, "sale_id" INTEGER NOT NULL, "book_id" INTEGER NOT NULL, "quantity" INTEGER NOT NULL, "price_total" DOUBLE PRECISION NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "Attachment" ( "id" SERIAL NOT NULL, "bookId" INTEGER NOT NULL, "key" TEXT NOT NULL, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "contentType" TEXT NOT NULL, "ext" TEXT NOT NULL, PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "_AttachmentToBook" ( "A" INTEGER NOT NULL, "B" INTEGER NOT NULL ); -- CreateIndex CREATE UNIQUE INDEX "User.email_unique" ON "User"("email"); -- CreateIndex CREATE UNIQUE INDEX "User.username_unique" ON "User"("username"); -- CreateIndex CREATE UNIQUE INDEX "Role.name_unique" ON "Role"("name"); -- CreateIndex CREATE UNIQUE INDEX "Category.name_unique" ON "Category"("name"); -- CreateIndex CREATE UNIQUE INDEX "_AttachmentToBook_AB_unique" ON "_AttachmentToBook"("A", "B"); -- CreateIndex CREATE INDEX "_AttachmentToBook_B_index" ON "_AttachmentToBook"("B"); -- AddForeignKey ALTER TABLE "UserRole" ADD FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "UserRole" ADD FOREIGN KEY ("role_id") REFERENCES "Role"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Book" ADD FOREIGN KEY ("category_id") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Cart" ADD FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Cart" ADD FOREIGN KEY ("book_id") REFERENCES "Book"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Sale" ADD FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "BookSale" ADD FOREIGN KEY ("sale_id") REFERENCES "Sale"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "BookSale" ADD FOREIGN KEY ("book_id") REFERENCES "Book"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Attachment" ADD FOREIGN KEY ("bookId") REFERENCES "Book"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "_AttachmentToBook" ADD FOREIGN KEY ("A") REFERENCES "Attachment"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "_AttachmentToBook" ADD FOREIGN KEY ("B") REFERENCES "Book"("id") ON DELETE CASCADE ON UPDATE CASCADE;
# Write your MySQL query statement below # Report the IDs of the employees whose salary is strictly less than $30000 and whose manager left the company. SELECT employee_id FROM Employees WHERE salary < 30000 AND manager_id NOT IN (SELECT employee_id FROM Employees) ORDER BY employee_id
--//The JOIN operation --#Modify it to show the matchid and player name for all goals scored by Germany. To identify German players, check for: teamid = 'GER' SELECT matchid ,player FROM goal WHERE teamid = 'GER' --#Show id, stadium, team1, team2 for just game 1012 SELECT id,stadium,team1,team2 FROM game WHERE id = 1012 --#Modify it to show the player, teamid, stadium and mdate for every German goal. SELECT player , teamid , stadium , mdate FROM game JOIN goal ON (id=matchid) WHERE teamid = 'GER' --#Show the team1, team2 and player for every goal scored by a player called Mario player LIKE 'Mario%' SELECT team1 , team2 , player FROM game JOIN goal ON (id=matchid) WHERE player LIKE 'Mario%' --#Show player, teamid, coach, gtime for all goals scored in the first 10 minutes gtime<=10 SELECT player, teamid, coach, gtime FROM goal JOIN eteam ON (teamid=id) WHERE gtime<=10 --#List the the dates of the matches and the name of the team in which 'Fernando Santos' was the team1 coach. SELECT mdate, teamname FROM game JOIN eteam ON (team1=eteam.id) WHERE coach = 'Fernando Santos' --#List the player for every goal scored in a game where the stadium was 'National Stadium, Warsaw' SELECT player FROM goal JOIN game ON (matchid=id) WHERE stadium = 'National Stadium, Warsaw'
--插入管理员 insert into manager(managerLoginname,managerPassword,managerName,managerEmail) values('zhangsan','670b14728ad9902aecba32e22fa4f6bd','张三','zhangsan@163.com');
select s.id from mtsh_product_spu s where s.id =196324; select t.* from om_orders_details t where t.product_spu_id not in( select s.id from mtsh_product_spu s); select t.orders_id from om_orders_details t where t.product_spu_id not in( select s.id from mtsh_product_spu s); select t.* from om_orders_details t;
ALTER TABLE monitoring_system ADD COLUMN weatherData TEXT AFTER description;
#This is a sample school system database created from scratch with guidance. The first section of this SQL script includes the creation of the database. A table for students, classes, absences, and 8 test results for a total of 8 students. The second section includes example queries and statements that could be used within the database to explore and narrow down specific data points. Examples of possible real world examples of how we could use this specific database would be modifying test scores due to absences, the input of a new student coming in, or to look up the average of all sums of a specific test score to verify the average score for the whole class. Section 1 --------------------------------------------------------------------- CREATE DATABASE test2; USE test2; SELECT DATABASE(); DROP DATABASE IF EXISTS test2; CREATE TABLE student( first_name VARCHAR(30) NOT NULL, last_name VARCHAR(30) NOT NULL, email VARCHAR(60) NULL, street VARCHAR(50) NOT NULL, city VARCHAR(40) NOT NULL, state CHAR(2) NOT NULL DEFAULT "PA", zip MEDIUMINT UNSIGNED NOT NULL, phone VARCHAR(20) NOT NULL, birth_date DATE NOT NULL, sex ENUM('M', 'F') NOT NULL, date_entered TIMESTAMP, lunch_cost FLOAT NULL, student_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ); DESCRIBE student; INSERT INTO student VALUES('Dale', 'Cooper', 'dcooper@aol.com', '123 Main St', 'Yakima', 'WA', 98901, '792-223-8901', "1959-2-22", 'M', NOW(), 3.50, NULL); INSERT INTO student VALUES('Shelly', 'Johnson', 'sjohnson@aol.com', '9 Pond Rd', 'Sparks', 'NV', 89431, '792-223-6734', "1970-12-12", 'F', NOW(), 3.50, NULL); INSERT INTO student VALUES('Bobby', 'Briggs', 'bbriggs@aol.com', '14 12th St', 'San Diego', 'CA', 92101, '792-223-6178', "1967-5-24", 'M', NOW(), 3.50, NULL)< INSERT INTO student VALUES('Donna', 'Hayward', 'dhayward@aol.com', '120 16th St', 'Davenport', 'IA', 52801, '792-223-2001', "1970-3-24", 'F', NOW(), 3.50, NULL); INSERT INTO student VALUES('Audrey', 'Horne', 'ahorne@aol.com', '342 19th St', 'Detroit', 'MI', 48222, '792-223-2001', "1965-2-1", 'F', NOW(), 3.50, NULL); INSERT INTO student VALUES('James', 'Hurley', 'jhurley@aol.com', '2578 Cliff St', 'Queens', 'NY', 11427, '792-223-1890', "1967-1-2", 'M', NOW(), 3.50, NULL); INSERT INTO student VALUES('Lucy', 'Moran', 'lmoran@aol.com', '178 Dover St', 'Hollywood', 'CA', 90078, '792-223-9678', "1954-11-27", 'F', NOW(), 3.50, NULL); INSERT INTO student VALUES('Tommy', 'Hill', 'thill@aol.com', '672 High Plains', 'Tucson', 'AZ', 85701, '792-223-1115', "1951-12-21", 'M', NOW(), 3.50, NULL); INSERT INTO student VALUES('Andy', 'Brennan', 'abrennan@aol.com', '281 4th St', 'Jacksonville', 'NC', 28540, '792-223-8902', "1960-12-27", 'M', NOW(), 3.50, NULL); SELECT * FROM student; CREATE TABLE class( name VARCHAR(30) NOT NULL, class_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); show tables; INSERT INTO class VALUES ('English', NULL), ('Speech', NULL), ('Literature', NULL), ('Algebra', NULL), ('Geometry', NULL), ('Trigonometry', NULL), ('Calculus', NULL), ('Earth Science', NULL), ('Biology', NULL), ('Chemistry', NULL), ('Physics', NULL), ('History', NULL), ('Art', NULL), ('Gym', NULL); 15. CREATE TABLE test( date DATE NOT NULL, type ENUM('T', 'Q') NOT NULL, class_id INT UNSIGNED NOT NULL, test_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY); CREATE TABLE score( student_id INT UNSIGNED NOT NULL, event_id INT UNSIGNED NOT NULL, score INT NOT NULL, PRIMARY KEY(event_id, student_id)); CREATE TABLE absence( student_id INT UNSIGNED NOT NULL, date DATE NOT NULL, PRIMARY KEY(student_id, date)); ALTER TABLE test ADD maxscore INT NOT NULL AFTER type; DESCRIBE test; INSERT INTO test VALUES ('2014-8-25', 'Q', 15, 1, NULL), ('2014-8-27', 'Q', 15, 1, NULL), ('2014-8-29', 'T', 30, 1, NULL), ('2014-8-29', 'T', 30, 2, NULL), ('2014-8-27', 'Q', 15, 4, NULL), ('2014-8-29', 'T', 30, 4, NULL); select * FROM test; ALTER TABLE score CHANGE event_id test_id INT UNSIGNED NOT NULL; DESCRIBE score; INSERT INTO score VALUES (1, 1, 15), (1, 2, 14), (1, 3, 28), (1, 4, 29), (1, 5, 15), (1, 6, 27), (2, 1, 15), (2, 2, 14), (2, 3, 26), (2, 4, 28), (2, 5, 14), (2, 6, 26), (3, 1, 14), (3, 2, 14), (3, 3, 26), (3, 4, 26), (3, 5, 13), (3, 6, 26), (4, 1, 15), (4, 2, 14), (4, 3, 27), (4, 4, 27), (4, 5, 15), (4, 6, 27), (5, 1, 14), (5, 2, 13), (5, 3, 26), (5, 4, 27), (5, 5, 13), (5, 6, 27), (6, 1, 13), (6, 2, 13), # Missed this day (6, 3, 24), (6, 4, 26), (6, 5, 13), (6, 6, 26), (7, 1, 13), (7, 2, 13), (7, 3, 25), (7, 4, 27), (7, 5, 13), # Missed this day (7, 6, 27), (8, 1, 14), # Missed this day (8, 2, 13), (8, 3, 26), (8, 4, 23), (8, 5, 12), (8, 6, 24), (9, 1, 15), (9, 2, 13), (9, 3, 28), (9, 4, 27), (9, 5, 14), (9, 6, 27), (10, 1, 15), (10, 2, 13), (10, 3, 26), (10, 4, 27), (10, 5, 12), (10, 6, 22); Fill in the absences INSERT INTO absence VALUES (6, '2014-08-29'), (7, '2014-08-29'), (8, '2014-08-27'); --------------------------------------------------------------------------- SECTION 2 SELECT FIRST_NAME, last_name FROM student; RENAME TABLE absence to absences, class to classes, score to scores, student to students, test to tests; SELECT first_name, last_name, state FROM students WHERE state="WA"; SELECT first_name, last_name, birth_date FROM students WHERE YEAR(birth_date) >= 1965; SELECT first_name, last_name, birth_date FROM students WHERE MONTH(birth_date) = 2 OR state="CA"; SELECT last_name, state, birth_date FROM students WHERE DAY(birth_date) >= 12 && (state="CA" || state="NV"); SELECT last_name FROM students WHERE last_name IS NULL; SELECT last_name FROM students WHERE last_name IS NOT NULL; SELECT first_name, last_name FROM students ORDER BY last_name; ORDER BY col_name DESC; SELECT first_name, last_name, state FROM students ORDER BY state DESC, last_name ASC; SELECT first_name, last_name FROM students LIMIT 5; SELECT first_name, last_name FROM students LIMIT 5, 10; SELECT CONCAT(first_name, " ", last_name) AS 'Name', CONCAT(city, ", ", state) AS 'Hometown' FROM students; SELECT last_name, first_name FROM students WHERE first_name LIKE 'D%' OR last_name LIKE '%n'; SELECT last_name, first_name FROM students WHERE first_name LIKE '___y'; SELECT DISTINCT state FROM students ORDER BY state; SELECT COUNT(DISTINCT state) FROM students; SELECT COUNT(*) FROM students; SELECT COUNT(*) FROM students WHERE sex='M'; SELECT sex, COUNT(*) FROM students GROUP BY sex; SELECT MONTH(birth_date) AS 'Month', COUNT(*) FROM students GROUP BY Month ORDER BY Month; SELECT state, COUNT(state) AS 'Amount' FROM students GROUP BY state HAVING Amount > 1; SELECT test_id AS 'Test', MIN(score) AS min, MAX(score) AS max, MAX(score)-MIN(score) AS 'range', SUM(score) AS total, AVG(score) AS average FROM scores GROUP BY test_id; SELECT * FROM absences; DESCRIBE scores; SELECT student_id, test_id FROM scores WHERE student_id = 6; INSERT INTO scores VALUES (6, 3, 24); DELETE FROM absences WHERE student_id = 6; Look up students that missed a test Look up the specific test missed by student 6 Insert the make up test result Delete the record in absences ALTER TABLE absences ADD COLUMN test_taken CHAR(1) NOT NULL DEFAULT 'F' AFTER student_id; ALTER TABLE absences MODIFY COLUMN test_taken ENUM('T','F') NOT NULL DEFAULT 'F'; ALTER TABLE absences DROP COLUMN test_taken; ALTER TABLE absences CHANGE student_id student_id INT UNSIGNED NOT NULL; SELECT * FROM scores UPDATE scores SET score=25 WHERE student_id=4 AND test_id=3; SELECT first_name, last_name, birth_date FROM students WHERE birth_date BETWEEN '1960-1-1' AND '1970-1-1'; SELECT first_name, last_name FROM students WHERE first_name IN ('Bobby', 'Lucy', 'Andy'); SELECT student_id, date, score, maxscore FROM tests, scores WHERE date = '2014-08-25' AND tests.test_id = scores.test_id; SELECT scores.student_id, tests.date, scores.score, tests.maxscore FROM tests, scores WHERE date = '2014-08-25' AND tests.test_id = scores.test_id; SELECT CONCAT(students.first_name, " ", students.last_name) AS Name, tests.date, scores.score, tests.maxscore FROM tests, scores, students WHERE date = '2014-08-25' AND tests.test_id = scores.test_id AND scores.student_id = students.student_id; SELECT students.student_id, CONCAT(students.first_name, " ", students.last_name) AS Name, COUNT(absences.date) AS Absences FROM students, absences WHERE students.student_id = absences.student_id GROUP BY students.student_id; SELECT students.student_id, CONCAT(students.first_name, " ", students.last_name) AS Name, COUNT(absences.date) AS Absences FROM students LEFT JOIN absences ON students.student_id = absences.student_id GROUP BY students.student_id; SELECT students.first_name, students.last_name, scores.test_id, scores.score FROM students INNER JOIN scores ON students.student_id=scores.student_id WHERE scores.score <= 15 ORDER BY scores.test_id; #This section explores different sample queries used on a the SAKILA DB. -------------------------------------------------------------------------- SELECT * FROM actor WHERE first_name = 'Scarlett'; SELECT * FROM actor WHERE last_name = 'Johansson'; SELECT COUNT(DISTINCT last_name) FROM actor SELECT * FROM FROM actor GROUP BY last_name HAVING COUNT(*) >1 SELECT actor_id FROM film_actor ORDER BY COUNT(actor_id) SELECT actor.first_name, actor.last_name, actor.actor_id, COUNT(actor_id) AS Film_Count FROM actor JOIN film_actor USING (actor_id) GROUP BY actor_id ORDER BY Film_Count DESC LIMIT 1
-- DB: module -- DT: -3M DELETE FROM `a_master_user` WHERE (`state` = 0 AND `mtime` < '{{t}}');
-- 1. widok kategorii z obliczaniem ceny brutto create or replace view vKategorie as select id, kategoria_id, nazwa, cast((cena_netto*(1+stawka_vat/100)) as decimal(7,2)) as cena_brutto from Produkty where ukryty=0; -- 2. widok produktów opisanych create or replace view vProduktyOpisane as SELECT produkt_id FROM Siedzenia UNION ALL SELECT produkt_id FROM Stoly; -- 3. widok produktów nieopisanych create or replace view vProduktyProste as SELECT P.id, P.nazwa, P.kategoria_id FROM Produkty AS P LEFT JOIN vProduktyOpisane AS S ON P.id=S.produkt_id WHERE S.produkt_id IS NULL AND P.ukryty=0; -- 4. widok połączonych produkty-siedzenia create or replace view vSiedzenia as SELECT id, nazwa, opis, wysokosc, szerokosc, dlugosc, waga, cena_netto, stawka_vat, material, przeznaczenie FROM Siedzenia, Produkty WHERE produkt_id = id; -- 5. widok połączonych produkty-stoly create or replace view vStoly as SELECT id, nazwa, opis, wysokosc, szerokosc, dlugosc, waga, cena_netto, stawka_vat, material, przeznaczenie, rodzaj_blatu, ilosc_nog FROM Stoly, Produkty WHERE produkt_id = id; -- 6. widok połączonych produkty-szafy_komody create or replace view vSzafy_komody as SELECT id, nazwa, opis, wysokosc, szerokosc, dlugosc, waga, cena_netto, stawka_vat, material, przeznaczenie, rodzaj_drzwi, ilosc_drzwi, ilosc_szuflad FROM Szafy_komody, Produkty WHERE produkt_id = id; -- 7. widok osob polaczonych z loginami create or replace view vKonta as SELECT id,imie,nazwisko,login,haslo FROM Logowanie,Osoby WHERE Osoby.id = Logowanie.osoba_id; -- 8. panel - widok połączonych produktów nie ukrytych i kategorii sortowanych po kategorii create or replace view vZmien_opis as --vUsun_produkt SELECT P.id, K.nazwa AS kat, P.nazwa AS prod FROM Kategorie AS K,Produkty AS P WHERE K.id=P.kategoria_id AND P.ukryty=0 ORDER BY kategoria_id; -- 9. widok losowych produktów create or replace view vPolecane as SELECT * FROM vKategorie WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM vKategorie ) ORDER BY nazwa LIMIT 5; -- 10. widok zamowień z kolumną określającą ile dni upłynęło od złożenia create or replace view vZamowienia_wiek AS select id, data, (to_days(now()) - to_days(`Zamowienia`.`data`)) AS roznica_dat FROM Zamowienia -- 11. widok szczegółowy zamówienia create or replace view vZamowienia_szczegoly AS SELECT * FROM Zamowienia AS Z INNER JOIN Osoby AS O INNER JOIN Adresy AS A INNER JOIN Dostawcy AS D WHERE Z.dostawca_id=D.id AND Z.osoba_id=O.id AND A.id=Z.adres_id
CREATE TABLE `patient_details` ( `P_ID` varchar(45) NOT NULL, `P_Name` varchar(45) NOT NULL, `P_Age` int(11) NOT NULL, `P_PNo` double DEFAULT NULL, `P_Add` varchar(45) DEFAULT NULL, `P_Email` varchar(20) DEFAULT NULL, PRIMARY KEY (`P_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; INSERT INTO `db`.`patient_details` (`P_Age`, `P_ID`, `P_Name`, `P_PNo`, `P_Add`) VALUES #( (19,'P_101','Abhishek',1234567890,'ABC'), (20,'P_102','Anuj',1234567890,'ABC'), (17,'P_103','Bhavam',1234567890,'ABC'), (16,'P_104','Hrithik',1234567890,'ABC'), (20,'P_105','Manas',1234567890,'ABC'), (25,'P_106','Prabhat',1234567890,'ABC'), (23,'P_107','Sahil',1234567890,'ABC'), (20,'P_108','Sudhir',1234567890,'ABC'), (24,'P_109','Adwit',1234567890,'ABC'), (24,'P_110','Harman',1234567890,'ABC'); #)
ALTER TABLE moeiwast_eiwatest_DB01.test01_sasada MODIFY STAFF_NO VARCHAR(11); ALTER TABLE moeiwast_eiwatest_DB01.test01_sasada MODIFY STAFF_NAME VARCHAR(50); ALTER TABLE moeiwast_eiwatest_DB01.test01_sasada MODIFY WORK_TIME DOUBLE(5,2);
INSERT INTO burgers(burger_name,consumed) VALUES ("Double Cheeseburger",false), ("Bleu Cheese Bacon Burger",false), ("Spicy Black Bean Burger",false), ("Hamburger",false);
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET NAMES UTF8; CREATE TABLE IF NOT EXISTS `users` ( `usercode` varchar(100) NOT NULL, `username` varchar(100) NOT NULL, `password` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ------------------------------------------------------------------ -- Script that creates the sample database ParkingDB. -- -- This script is based on MySQL 5.7.23 -- -- Last updated: 20181119 (YYYYMMDD) -- -- Diegoalru -- ------------------------------------------------------------------ -- ------------------------------------------------------------------ -- Drop database -- ------------------------------------------------------------------ DROP DATABASE IF EXISTS parkingdb; -- ------------------------------------------------------------------ -- Create empty database ParkingDB -- ------------------------------------------------------------------ CREATE SCHEMA IF NOT EXISTS parkingdb DEFAULT CHARACTER SET utf8; -- ------------------------------------------------------------------ -- Erase default user is exist -- ------------------------------------------------------------------ DROP USER IF EXISTS 'ParkingAdmin'@'%'; -- ------------------------------------------------------------------ -- Create default user -- ------------------------------------------------------------------ CREATE USER IF NOT EXISTS 'ParkingAdmin'@'%' IDENTIFIED BY 'ParkingAdmin'; GRANT ALL PRIVILEGES ON *.* TO 'ParkingAdmin'@'%'; GRANT ALL PRIVILEGES ON `parkingdb`.* TO 'ParkingAdmin'@'%' WITH GRANT OPTION; -- ------------------------------------------------------------------ -- Use ParkingDB -- ------------------------------------------------------------------ USE parkingdb; -- ------------------------------------------------------------------- -- Drop tables -- ------------------------------------------------------------------- DROP TABLE IF EXISTS Admins; DROP TABLE IF EXISTS Vehicules; DROP TABLE IF EXISTS Clients; DROP TABLE IF EXISTS TypeOfVehicules; DROP TABLE IF EXISTS Parking; DROP TABLE IF EXISTS Spot_type; DROP TABLE IF EXISTS Spot; DROP TABLE IF EXISTS Bill; -- ------------------------------------------------------------------ -- Drop Routines -- ------------------------------------------------------------------ DROP procedure IF EXISTS GetAdmins; DROP procedure IF EXISTS GetVehicules; DROP procedure IF EXISTS GetClients; DROP procedure IF EXISTS GetBills; DROP procedure IF EXISTS AdminChecker; DROP procedure IF EXISTS ReturnCodeClient; DROP procedure IF EXISTS InsertVehicule; DROP procedure IF EXISTS GetVehiculeTime; DROP procedure IF EXISTS DeleteVehicule; DROP procedure IF EXISTS GetTypes; DROP procedure IF EXISTS CreateBill; -- DROP procedure IF EXISTS test; -- ------------------------------------------------------------------ -- Create Tables -- ------------------------------------------------------------------ CREATE TABLE Admins ( code INT(4) NOT NULL AUTO_INCREMENT, password NVARCHAR(20) NOT NULL, name NVARCHAR(20) NOT NULL, flastname NVARCHAR(20) NOT NULL, slastname NVARCHAR(20) NOT NULL, id INT(9) NOT NULL, phone INT(8) NOT NULL, mail NVARCHAR(20) NOT NULL, CONSTRAINT PK_Admin_code PRIMARY KEY (code), CONSTRAINT UQ_Admin_id UNIQUE (id), CONSTRAINT UQ_Admin_phone UNIQUE (phone) )ENGINE = INNODB; CREATE TABLE Clients ( code INT(8) NOT NULL AUTO_INCREMENT, id INT(9) NOT NULL, name NVARCHAR(20) NOT NULL, company NVARCHAR(20) NOT NULL, CONSTRAINT PK_Client_code PRIMARY KEY (code), CONSTRAINT UQ_Client_id UNIQUE (id) )ENGINE = INNODB; CREATE TABLE Parking ( code INT(8) NOT NULL AUTO_INCREMENT, -- number INT(3) NOT NULL, name NVARCHAR(30) NOT NULL, CONSTRAINT PK_Parking_Code PRIMARY KEY(code) )ENGINE = INNODB; CREATE TABLE TypeOfVehicules ( code INT(1) NOT NULL, description varchar(20) NOT NULL, fare decimal NOT NULL, CONSTRAINT PK_Type_code PRIMARY KEY (code) )ENGINE = INNODB; CREATE TABLE Vehicules ( code INT(8) NOT NULL AUTO_INCREMENT, licensePlate VARCHAR(6) NOT NULL, codeCLient INT(8) NOT NULL, colour NVARCHAR(20), model NVARCHAR(20), type INT(1) NOT NULL, InHour DATETIME DEFAULT CURRENT_TIMESTAMP, OutHour DATETIME NULL, description VARCHAR(250), CONSTRAINT PK_Vehicules_code PRIMARY KEY (code), CONSTRAINT UQ_Vehicules_licensePlate UNIQUE(licensePlate), CONSTRAINT FK_Client_vehicule FOREIGN KEY (codeCLient) REFERENCES Clients (code), CONSTRAINT FK_Vehicules_type FOREIGN KEY (type) REFERENCES TypeOfVehicules (code) )ENGINE = INNODB; CREATE TABLE Spot_type ( code INT(1) NOT NULL, name NVARCHAR(20) NOT NULL, CONSTRAINT PK_SpotType_code PRIMARY KEY(code) )ENGINE = INNODB; CREATE TABLE Spot ( code INT(5) NOT NULL, number INT(3) NOT NULL, type INT(1) NOT NULL, licensePlate VARCHAR(6) NOT NULL, CONSTRAINT PK_Spot_code PRIMARY KEY(code), CONSTRAINT FK_Spot_type FOREIGN KEY (type) REFERENCES Spot_type(code), CONSTRAINT FK_Spot_licensePlate FOREIGN KEY (licensePlate) REFERENCES Vehicules(licensePlate) )ENGINE = INNODB; CREATE TABLE Bill ( code INT(7) NOT NULL AUTO_INCREMENT, parkingname NVARCHAR(30) NOT NULL, -- parking licensePlate VARCHAR(6) NOT NULL, -- vehicule type INT(1) NOT NULL, -- vehicule InHour DATETIME NOT NULL, -- vehicule OutHour DATETIME NOT NULL, -- vehicule idClient INT(9) NOT NULL, -- client name NVARCHAR(20) NOT NULL, -- client company NVARCHAR(20) NOT NULL, -- client adm_name NVARCHAR(20) NOT NULL, -- admin adm_mail NVARCHAR(20) NOT NULL, -- admin CONSTRAINT PK_Bill_code PRIMARY KEY(code), CONSTRAINT FK_Bill_license FOREIGN KEY(licensePlate) REFERENCES Vehicules(licensePlate), CONSTRAINT FK_Bill_id FOREIGN KEY(idClient) REFERENCES Clients(id) )ENGINE=INNODB; -- ------------------------------------------------------------------ -- Create Routines -- ------------------------------------------------------------------ -- This method is for return all the data from Admins. DELIMITER $$ CREATE PROCEDURE GetAdmins () BEGIN SELECT code ,password ,name ,flastname ,slastname ,id ,phone ,mail FROM Admins; END$$ DELIMITER ; -- This method is for return all the data from Vehicules. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE GetVehicules () BEGIN SELECT licensePlate ,codeClient ,colour ,model ,type ,InHour ,OutHour ,description FROM Vehicules; END$$ DELIMITER ; -- This method is for return all the data from Clients. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE GetClients () BEGIN SELECT code ,id ,name ,company FROM Clients; END$$ DELIMITER ; -- This method is for return all the types of vehicules and thier fare. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE GetTypes() BEGIN SELECT code ,description ,fare FROM TypeOfVehicules; END$$ DELIMITER ; -- With this method, you can check if the admin that we are looking for exists. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE AdminChecker (AdminCode INT(4), AdminPassword NVARCHAR(20)) BEGIN SELECT code ,mail ,password FROM Admins WHERE code = AdminCode AND password = AdminPassword; END$$ -- This method retunrs the code of a client, with it's ID. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE ReturnCodeClient(idCLient INT(9)) BEGIN SELECT code FROM Clients WHERE id = idCLient; END$$ -- With this method we establish the time of departure. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE SetVehiculeTime(plate VARCHAR(6), salida DATETIME) BEGIN -- Firts we set the time of the vehicule. UPDATE Vehicules SET OutHour = CURRENT_TIMESTAMP WHERE licensePlate = plate; -- We get the time that the car spend on the parking lot. SELECT TIMEDIFF(InHour,OutHour) Tiempo_En_Parqueo FROM Vehicules WHERE licensePlate = plate; END$$ -- With this method we delete from the database the vehicule. **** DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE DeleteVehicule(plate VARCHAR(6)) BEGIN DELETE FROM Vehicules WHERE licensePlate = plate; END$$ -- This help us to insert clients to the database. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE InsertClient(idCLient INT(9), _name NVARCHAR(20), _company NVARCHAR(20)) BEGIN INSERT INTO Clients (id, name, company) VALUES ( idCLient, _name, _company); END$$ -- This help us to insert vehicules to the database. DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE InsertVehicule(_licensePlate VARCHAR(6), idCLient INT(9), _colour NVARCHAR(20), _model NVARCHAR(20), _type INT(1), _description VARCHAR(250)) BEGIN INSERT INTO Vehicules (licensePlate, codeCLient, colour, model, type, description) VALUES (_licensePlate, (SELECT code FROM Clients WHERE id = idCLient),_colour, _model, _type, _description); END$$ -- With this method we can create bills DELIMITER $$ USE parkingdb$$ CREATE PROCEDURE CreateBill(_licensePlate VARCHAR(6), _idClient INT(9), _idAdmin INT(4) ) BEGIN /* Structure: parkingname NVARCHAR(30) NOT NULL, -- parking licensePlate VARCHAR(6) NOT NULL, -- vehicule type INT(1) NOT NULL, -- vehicule InHour DATETIME NOT NULL, -- vehicule OutHour DATETIME NOT NULL, -- vehicule idClient INT(9) NOT NULL, -- client name NVARCHAR(20) NOT NULL, -- client company NVARCHAR(20) NOT NULL, -- client adm_name NVARCHAR(20) NOT NULL, -- admin adm_mail NVARCHAR(20) NOT NULL, -- admin */ -- INSERT INTO BILL ( END $$ -- ------------------------------------------------------------------ -- Inserts -- ------------------------------------------------------------------ INSERT INTO Admins (password, name, flastname, slastname, id, phone, mail) VALUES(N'qwerty', N'Diego', N'Rubí', N'Salas', 117250628, 87108548, N'diegoalru@gmail.com'); INSERT INTO Admins (password, name, flastname, slastname, id, phone, mail) VALUES(N'qwerty', N'Admin', N'lastName', N'lastName', 117250629, 87108549, N'diegoalru@gmail.com'); INSERT INTO TypeOfVehicules (code, description, fare) VALUES (1, 'Tarifa para MOTOS', 400); INSERT INTO TypeOfVehicules (code, description, fare) VALUES (2, 'Tarifa para AUTOS', 600); CALL InsertClient (117250628, N'Diego', N'UNKNOWN'); CALL InsertClient (333999333, N'ABC', N'UNKNOWN'); CALL InsertClient (111111111, N'ABC', N'UNKNOWN'); CALL InsertClient (999333999, N'XYZ', N'UNKNOWN'); CALL InsertVehicule('BCC997', 117250628, 'RED', 'RAV4', 2, 'Carro en perfectas condiciones'); CALL InsertVehicule('BCC111', 333999333, 'RED', 'RAV4', 1, 'Moto en perfectas condiciones'); CALL InsertVehicule('ABC123', 111111111, 'RED', 'RAV4', 1, 'Moto en perfectas condiciones'); CALL InsertVehicule('XYZ999', 999333999, 'RED', 'RAV4', 2, 'Carro en perfectas condiciones'); -- ------------------------------------------------------------------ -- Execute routines -- ------------------------------------------------------------------ /* JUST FOR TEST */ /* JUST FOR TEST */ /* JUST FOR TEST */ /* JUST FOR TEST */ CALL GetAdmins(); CALL GetClients(); CALL GetTypes(); -- CALL AdminChecker(1, N'qwerty'); -- CALL InsertVehicule('BCC996', 117250628, 'RED', 'RAV4', '2', 'Vehiculo en perfectas condiciones'); -- CALL SetVehiculeTime('BCC997', CURRENT_TIMESTAMP); CALL GetVehicules(); -- CALL DeleteVehicule('BCC997');
CREATE DATABASE IF NOT EXISTS `gimnasio` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; USE `gimnasio`; -- MySQL dump 10.13 Distrib 8.0.22, for Win64 (x86_64) -- -- Host: localhost Database: gimnasio -- ------------------------------------------------------ -- Server version 8.0.22 /*!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 */; /*!50503 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 `usuarios` -- DROP TABLE IF EXISTS `usuarios`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `usuarios` ( `id` bigint NOT NULL AUTO_INCREMENT, `apellido` varchar(255) DEFAULT NULL, `email` varchar(255) DEFAULT NULL, `nombre` varchar(255) DEFAULT NULL, `password` varchar(255) DEFAULT NULL, `username` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `usuarios` -- LOCK TABLES `usuarios` WRITE; /*!40000 ALTER TABLE `usuarios` DISABLE KEYS */; INSERT INTO `usuarios` VALUES (1,'Pascual','rodrigopascual1@hotmail.com','rebo','$2a$10$BhRb.o6hY0TJVSDsOmGUdehWYW/ScmFQWjPNYSR0qjpPvIswAiuGK','admin'),(2,'porro','pedroporro@porro.es','pedro','$2a$10$1iQ6VmkrUgywQ4Ho3ciGIOF1GhK.Jm231Y12fp2aqZ1n/YMFa7QAy','pedropo'),(3,'Pascual','rodrigopascual2@hotmail.com','Rodrigo','$2a$10$zCjWk4XKbqHh1CqladyfFeQkKoJFZvLrEIZM6/xG/GaQSTpZyseT2','Rodri'),(4,'Rebollo','mariorebo@hotmail.com','Mario','$2a$10$B3pdSxd/Z1Khgf4dUKCKlutyaBhtfIIOZ8qXVqW34swgzHmZGoDm2','Rebo'),(5,'Montero','joseal@hotmail.com','Joseal','$2a$10$8HUXGDCrdoM4HQxam6X/CO.nsFZo9ATDgOtdBAStQBKMmRTBvFnP.','Unreal'); /*!40000 ALTER TABLE `usuarios` 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 2021-06-17 14:20:34
CREATE DEFINER=`root`@`%` TRIGGER `actualizar_bitacora_inventarioproductos` AFTER UPDATE ON `inventarioproductos` FOR EACH ROW CALL BitacoraInventarioProductos ( "Actualizar", New.InvPrdId, New.InvPrdCodInterno, New.InvPrdFchCaducidad, New.InvPrdEstado, New.InvPrdPadre, New.InvPrdFactor, New.InvPrdExtraible, New.UndId, Old.InvPrdId, Old.InvPrdCodInterno, Old.InvPrdFchCaducidad, Old.InvPrdEstado, Old.InvPrdPadre, Old.InvPrdFactor, Old.InvPrdExtraible, Old.UndId )
/* ------------------- TABLE STRUCTURES ------------------------- mysql> select * from Catalog; +------+------+------+ | sid | pid | cost | +------+------+------+ | 1 | 1 | 340 | | 1 | 2 | 612 | | 1 | 3 | 110 | | 1 | 4 | 763 | | 2 | 4 | 710 | | 2 | 5 | 110 | | 2 | 8 | 731 | | 2 | 9 | 234 | | 3 | 10 | 13 | | 3 | 1 | 123 | | 3 | 6 | 562 | | 3 | 7 | 52 | | 3 | 11 | 652 | | 3 | 12 | 444 | | 4 | 4 | 562 | | 4 | 7 | 562 | | 4 | 9 | 42 | | 4 | 10 | 428 | | 4 | 11 | 668 | | 4 | 2 | 778 | +------+------+------+ 20 rows in set (0.00 sec) mysql> select * from Parts; +-----+-------+--------+ | pid | pname | color | +-----+-------+--------+ | 1 | P1 | Red | | 2 | P2 | Green | | 3 | P3 | Red | | 4 | P4 | Green | | 5 | P5 | Red | | 6 | P6 | Red | | 7 | P7 | Red | | 8 | P8 | Green | | 9 | P9 | Yellow | | 10 | P10 | Blue | | 11 | P11 | Black | | 12 | P12 | Green | +-----+-------+--------+ 12 rows in set (0.03 sec) mysql> select * from Supplier; +-----+--------+----------------------+ | sid | sname | address | +-----+--------+----------------------+ | 1 | Rakesh | 221 Packer Street | | 2 | Rohan | 321 Huston Street | | 3 | Suraj | 110 Armstrong Street | | 4 | Vishnu | 23 Collins Street | +-----+--------+----------------------+ 4 rows in set (0.00 sec)*/ /*========================================================================*/ /* Find the names of suppliers who supply some red part.*/ /*========================================================================*/ select sname from Supplier where sid in (select distinct sid from Catalog join Parts on Catalog.pid=Parts.pid where color = 'red'); /* OUTPUT +--------+ | sname | +--------+ | Rakesh | | Rohan | | Suraj | | Vishnu | +--------+ 4 rows in set (0.00 sec) */ /*========================================================================*/ /*========================================================================*/ /* Find the sids of suppliers who supply some red or green part.*/ /*========================================================================*/ select distinct sid from Catalog join Parts on Catalog.pid=Parts.pid where color in ('red','green'); /* OUTPUT +------+ | sid | +------+ | 1 | | 3 | | 4 | | 2 | +------+ 4 rows in set (0.00 sec) */ /*========================================================================*/ /* Find the sids of suppliers who supply some red part or are at 221 Packer Street.*/ /*========================================================================*/ select distinct Catalog.sid from Catalog join Parts on Catalog.pid=Parts.pid join Supplier on Catalog.sid = Supplier.sid where color = 'red' and address='221 Packer Street'; /* OUTPUT +------+ | sid | +------+ | 1 | +------+ 1 row in set (0.00 sec) */ /*========================================================================*/ /* Find the sids of suppliers who supply some red part and some green part.*/ /*========================================================================*/ select distinct sid from Catalog join Parts on Catalog.pid=Parts.pid where color='red' and color='green'; /* OUTPUT Empty set (0.00 sec) */ /*========================================================================*/ /* Find the sids of suppliers who supply every part.*/ /*========================================================================*/ select distinct sid from Catalog join Parts on Catalog.pid=Parts.pid where Catalog.pid = all(select pid from Parts); /* OUTPUT Empty set (0.00 sec) */ /*========================================================================*/ /* Find the sids of suppliers who supply every red part.*/ /*========================================================================*/ select distinct sid from Catalog join Parts on Catalog.pid=Parts.pid where Catalog.pid = all(select pid from Parts where color = 'red'); /* OUTPUT Empty set (0.00 sec) */ /*========================================================================*/ /* Find the sids of suppliers who supply every red or green part.*/ /*========================================================================*/ select distinct sid from Catalog join Parts on Catalog.pid=Parts.pid where Catalog.pid = all(select pid from Parts where color in ('red','green')); /* OUTPUT Empty set (0.00 sec) */ /*========================================================================*/ /* Find the sids of suppliers who supply every red part or supply every green part.*/ /*========================================================================*/ select distinct sid from Catalog join Parts on Catalog.pid=Parts.pid where Catalog.pid = all(select pid from Parts where color='red') or Catalog.pid = all(select pid from Parts where color='green'); /* OUTPUT Empty set (0.00 sec) */ /*========================================================================*/ /* Find pairs of sids such that the supplier with the first sid charges more for some part than the supplier with the second sid.*/ /*========================================================================*/ select a.sid,b.sid,a.cost,b.cost from Catalog as a , Catalog b where a.sid <> b.sid and a.pid = b.pid and a.cost > b.cost; /* OUTPUT +------+------+------+------+ | sid | sid | cost | cost | +------+------+------+------+ | 1 | 3 | 340 | 123 | | 1 | 2 | 763 | 710 | | 1 | 4 | 763 | 562 | | 2 | 4 | 710 | 562 | | 2 | 4 | 234 | 42 | | 4 | 3 | 562 | 52 | | 4 | 3 | 428 | 13 | | 4 | 3 | 668 | 652 | | 4 | 1 | 778 | 612 | +------+------+------+------+ 9 rows in set (0.00 sec)*/ /*========================================================================*/ /* Find the pids of parts supplied by at least two different suppliers.*/ /*========================================================================*/ select pid,count(sid) from Catalog group by pid having count(*) > 1; /* OUTPUT +------+------------+ | pid | count(sid) | +------+------------+ | 1 | 2 | | 2 | 2 | | 4 | 3 | | 7 | 2 | | 9 | 2 | | 10 | 2 | | 11 | 2 | +------+------------+ 7 rows in set (0.00 sec) */ /*========================================================================*/ /* Find the pids of the most expensive parts supplied by suppliers named Rakesh */ /*========================================================================*/ select pid from Catalog where cost in (select max(cost) from Catalog c join Supplier s on c.sid = s.sid where sname = 'Rakesh' group by c.sid); /* OUTPUT +------+ | pid | +------+ | 4 | +------+ 1 row in set (0.00 sec) */ /*========================================================================*/ /* Find the pids of parts supplied by every supplier at less than $200 */ /*========================================================================*/ select pid,sid from Catalog where cost < 200; /* OUTPUT +------+------+ | pid | sid | +------+------+ | 3 | 1 | | 5 | 2 | | 10 | 3 | | 1 | 3 | | 7 | 3 | | 9 | 4 | +------+------+ 6 rows in set (0.00 sec)
-- PostGIS SQL queries for NYC Crash Mapper -- code credit: Akil Harris: https://github.com/akilism -- NOTE: values that are prepended with a colon are template values and should be replaced, eg `:identifier` -- CARTO queries do not require a semicolon unless multiple queries are executed one after another -- `table_20k_crashes` refers a sample of NYC Open Data Portal's NYPD Motor Vehicle Collisions data ----------------------- --- Boundary Tables --- ----------------------- -- name: distinct-borough -- Selects distinct boroughs SELECT DISTINCT borough, identifier, cartodb_id, the_geom_webmercator FROM nyc_borough ORDER BY identifier -- name: distinct-city-council -- Selects distinct city council districts SELECT DISTINCT identifier, cartodb_id, the_geom_webmercator FROM nyc_city_council ORDER BY identifier -- name: distinct-community-board -- Selects distinct community boards SELECT DISTINCT identifier, cartodb_id, the_geom_webmercator FROM nyc_community_board ORDER BY identifier -- name: distinct-neighborhood -- Selects distinct neighborhoods SELECT DISTINCT borough, identifier, cartodb_id, the_geom_webmercator FROM nyc_neighborhood ORDER BY borough, identifier -- name: distinct-precinct -- Selects distinct nypd precincts SELECT DISTINCT borough, identifier, cartodb_id, the_geom_webmercator FROM nyc_nypd_precinct ORDER BY borough, identifier -- name: distinct-zip-code -- Selects distinct zip codes SELECT DISTINCT borough, identifier, cartodb_id, the_geom_webmercator FROM nyc_zip_codes ORDER BY borough, identifier --name: date-bounds -- Selects max and min date from all crashes SELECT MAX(date) as max_date, MIN(date) as min_date FROM table_20k_crashes --------------------- --- Download Data --- --------------------- -- basic select query, used by download data SELECT c.on_street_name, c.cross_street_name, c.cartodb_id, c.unique_key, c.date_val as date, c.latitude, c.longitude, c.borough, c.zip_code, c.number_of_cyclist_injured, c.number_of_cyclist_killed, c.number_of_motorist_injured, c.number_of_motorist_killed, c.number_of_pedestrian_injured, c.number_of_pedestrian_killed, c.number_of_persons_injured, c.number_of_persons_killed, c.contributing_factor_vehicle_1, c.contributing_factor_vehicle_2, c.contributing_factor_vehicle_3, c.contributing_factor_vehicle_4, c.contributing_factor_vehicle_5, c.vehicle_type_code_1, c.vehicle_type_code_2, c.vehicle_type_code_3, c.vehicle_type_code_4, c.vehicle_type_code_5 FROM table_20k_crashes c -------------- --- Stats ---- -------------- -- name: stats-date -- Counts all death / injury stats for a given date range SELECT COUNT(c.cartodb_id) as total_crashes, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') --name: stats-date-by-area -- Counts all death / injury stats for a given date range filtered by some geometry table SELECT COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c JOIN :geo-table a ON ST_Within(c.the_geom, a.the_geom) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (a.identifier = :identifier) -- name: stats-date-by-custom-area -- Counts all death / injury stats for a given date range filtered by a custom shape. SELECT COUNT(c.cartodb_id) as total_crashes, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (ST_Contains(:shape, c.the_geom)) -- name: stats-date-filtered -- Counts all death / injury stats for a given date range SELECT COUNT(c.cartodb_id) as total_crashes, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) --name: stats-date-by-area-filtered -- Counts all death / injury stats for a given date range filtered by some geometry table SELECT COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c JOIN :geo-table a ON ST_Within(c.the_geom, a.the_geom) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (a.identifier = :identifier) AND (:filter-col > 0) -- name: stats-date-by-custom-area-filtered -- Counts all death / injury stats for a given date range SELECT COUNT(c.cartodb_id) as total_crashes, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, c.the_geom)) ----------------------- --- Crashes For Map --- ----------------------- --name: crashes-by-date -- Selects crashes for map by date. SELECT c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND c.the_geom IS NOT NULL GROUP BY c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name --name: crashes-by-date-custom-area -- Selects crashes for map by date filtered by a custom area. SELECT c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (ST_Contains(:shape, c.the_geom)) GROUP BY c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name --name: crashes-by-date-area -- Selects crashes for map by area and date. SELECT c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c JOIN :geo-table a ON ST_Within(c.the_geom, a.the_geom) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (a.identifier = :identifier) GROUP BY c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name --name: crashes-by-date-filtered -- Selects crashes for map by date. SELECT c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND c.the_geom IS NOT NULL GROUP BY c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name --name: crashes-by-date-custom-area-filtered -- Selects crashes for map by date. SELECT c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, c.the_geom)) GROUP BY c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name --name: crashes-by-date-area-filtered -- Selects crashes for map by area and date. SELECT c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c JOIN :geo-table a ON ST_Within(c.the_geom, a.the_geom) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (a.identifier = :identifier) GROUP BY c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name -------------------- --- All Factors ---- -------------------- -- name: all-factors-date-by-area-filtered -- Counts all factors for a given date range filtered by some geometry table. WITH all_factors as ( SELECT c.contributing_factor_vehicle_1 as factor FROM table_20k_crashes c JOIN :geo-table a ON (ST_Within(c.the_geom, a.the_geom) AND (a.identifier = :identifier)) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) UNION ALL SELECT c.contributing_factor_vehicle_2 as factor FROM table_20k_crashes c JOIN :geo-table a ON (ST_Within(c.the_geom, a.the_geom) AND (a.identifier = :identifier)) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) UNION ALL SELECT c.contributing_factor_vehicle_3 as factor FROM table_20k_crashes c JOIN :geo-table a ON (ST_Within(c.the_geom, a.the_geom) AND (a.identifier = :identifier)) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) UNION ALL SELECT c.contributing_factor_vehicle_4 as factor FROM table_20k_crashes c JOIN :geo-table a ON (ST_Within(c.the_geom, a.the_geom) AND (a.identifier = :identifier)) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) UNION ALL SELECT c.contributing_factor_vehicle_5 as factor FROM table_20k_crashes c JOIN :geo-table a ON (ST_Within(c.the_geom, a.the_geom) AND (a.identifier = :identifier)) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) ) SELECT COUNT(af.factor) as count_factor, af.factor FROM all_factors af GROUP BY af.factor ORDER BY count_factor desc -- name: all-factors-date-by-custom-area-filtered -- Counts all factors for a given date range. WITH all_factors as ( SELECT contributing_factor_vehicle_1 as factor FROM table_20k_crashes WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, the_geom)) UNION ALL SELECT contributing_factor_vehicle_2 as factor FROM table_20k_crashes WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, the_geom)) UNION ALL SELECT contributing_factor_vehicle_3 as factor FROM table_20k_crashes WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, the_geom)) UNION ALL SELECT contributing_factor_vehicle_4 as factor FROM table_20k_crashes WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, the_geom)) UNION ALL SELECT contributing_factor_vehicle_5 as factor FROM table_20k_crashes WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, the_geom)) ) SELECT COUNT(af.factor) as count_factor, af.factor FROM all_factors af GROUP BY af.factor ORDER BY count_factor desc ---------------------- --- Intersections ---- ---------------------- --name: intersections-by-date-with-order --Select all intersections filtered by date and order by a col SELECT concat_ws(',', c.latitude, c.longitude) as pos, concat_ws(',', c.on_street_name, c.cross_street_name) as streets, c.the_geom, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, ((SUM(c.number_of_persons_killed) * 2.75) + (SUM(c.number_of_persons_injured) * 1.5) + (COUNT(c.cartodb_id) * 0.75)) as dval, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') GROUP BY c.the_geom, c.latitude, c.longitude, c.on_street_name, c.cross_street_name ORDER BY :order-col :order-dir LIMIT 100 --name: intersections-by-date-with-order-filtered --Select all intersections filtered by date and order by a col SELECT concat_ws(',', c.latitude, c.longitude) as pos, concat_ws(',', c.on_street_name, c.cross_street_name) as streets, c.the_geom, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, ((SUM(c.number_of_persons_killed) * 2.75) + (SUM(c.number_of_persons_injured) * 1.5) + (COUNT(c.cartodb_id) * 0.75)) as dval, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) GROUP BY c.the_geom, c.latitude, c.longitude, c.on_street_name, c.cross_street_name ORDER BY :order-col :order-dir LIMIT 100 --name: intersections-by-date-area-with-order --Select all intersections filtered by area and date and order by a col SELECT concat_ws(',', c.latitude, c.longitude) as pos, concat_ws(',', c.on_street_name, c.cross_street_name) as streets, c.the_geom, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, ((SUM(c.number_of_persons_killed) * 2.75) + (SUM(c.number_of_persons_injured) * 1.5) + (COUNT(c.cartodb_id) * 0.75)) as dval, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c JOIN :geo-table a ON ST_Within(c.the_geom, a.the_geom) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (a.identifier = :identifier) GROUP BY c.the_geom, c.latitude, c.longitude, c.on_street_name, c.cross_street_name ORDER BY :order-col :order-dir LIMIT 100 --name: intersections-by-date-area-with-order-filtered --Select all intersections filtered by area and date and order by a col SELECT concat_ws(',', c.latitude, c.longitude) as pos, concat_ws(',', c.on_street_name, c.cross_street_name) as streets, c.the_geom, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, ((SUM(c.number_of_persons_killed) * 2.75) + (SUM(c.number_of_persons_injured) * 1.5) + (COUNT(c.cartodb_id) * 0.75)) as dval, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c JOIN :geo-table a ON ST_Within(c.the_geom, a.the_geom) WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (a.identifier = :identifier) GROUP BY c.the_geom, c.latitude, c.longitude, c.on_street_name, c.cross_street_name ORDER BY :order-col :order-dir LIMIT 100 --name: intersections-by-date-custom-area-with-order --Select all intersections filtered by date and order by a col SELECT concat_ws(',', c.latitude, c.longitude) as pos, concat_ws(',', c.on_street_name, c.cross_street_name) as streets, c.the_geom, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, ((SUM(c.number_of_persons_killed) * 2.75) + (SUM(c.number_of_persons_injured) * 1.5) + (COUNT(c.cartodb_id) * 0.75)) as dval, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (ST_Contains(:shape, c.the_geom)) GROUP BY c.the_geom, c.latitude, c.longitude, c.on_street_name, c.cross_street_name ORDER BY :order-col :order-dir LIMIT 100 --name: intersections-by-date-custom-area-with-order-filtered --Select all intersections filtered by date and order by a col SELECT concat_ws(',', c.latitude, c.longitude) as pos, concat_ws(',', c.on_street_name, c.cross_street_name) as streets, c.the_geom, COUNT(c.cartodb_id) as total_crashes, SUM(c.number_of_cyclist_injured) as cyclist_injured, SUM(c.number_of_cyclist_killed) as cyclist_killed, SUM(c.number_of_motorist_injured) as motorist_injured, SUM(c.number_of_motorist_killed) as motorist_killed, SUM(c.number_of_pedestrians_injured) as pedestrians_injured, SUM(c.number_of_pedestrians_killed) as pedestrians_killed, SUM(c.number_of_persons_injured) as persons_injured, SUM(c.number_of_persons_killed) as persons_killed, ((SUM(c.number_of_persons_killed) * 2.75) + (SUM(c.number_of_persons_injured) * 1.5) + (COUNT(c.cartodb_id) * 0.75)) as dval, SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death FROM table_20k_crashes c WHERE (date <= date ':end-date') AND (date >= date ':start-date') AND (:filter-col > 0) AND (ST_Contains(:shape, c.the_geom)) GROUP BY c.the_geom, c.latitude, c.longitude, c.on_street_name, c.cross_street_name ORDER BY :order-col :order-dir LIMIT 100
CREATE TABLE IF NOT EXISTS TEST ( id UUID NOT NULL PRIMARY KEY, email VARCHAR(200) not null UNIQUE );
DROP TABLE IF EXISTS BAJAJ_DM.D_productflag_daily; CREATE TABLE BAJAJ_DM.`D_productflag_daily` ( id TINYINT NOT NULL, `name` varchar(20) NOT NULL )ENGINE=MDB DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `BAJAJ_DM`.`temporary_table`; CREATE TABLE `BAJAJ_DM`.`temporary_table` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(20) NOT NULL, primary key (id), unique index name_unq_idx (name)) ENGINE = INNODB; ALTER TABLE BAJAJ_DM.temporary_table AUTO_INCREMENT = 1; insert into BAJAJ_DM.temporary_table (name) select distinct PRODUCTFLAG from bajaj_orig.factdaily; insert into BAJAJ_DM.D_productflag_daily (id, name) select id, name from BAJAJ_DM.temporary_table; DROP TABLE IF EXISTS `BAJAJ_DM`.`temporary_table`;
-- ?? select * from KRMS_FUNC_T; select * from KRMS_FUNC_PARM_T; select * from KRMS_TERM_T where desc_txt like '%Oppor%'; -- Lookup the Term Name that you see in the drop down in Rule Edit in KC (found in Agenda) select * from krms_TERM_SPEC_T where term_spec_id like 'KC1008'; select * from krms_term_rslvr_t; where nm like '%progr%'; -- Use the TERM_SPEC_ID from last query to find the term resolver select * from krms_term_rslvr_t where nm like '%GG%'; -- use the typ_id to find the code which will resolve this term -- NOTE : SRVC_NM column tells you the service name bean which leads to the code to be called. Grep for that service name -- This example ./src/main/resources/org/kuali/kra/CoreSpringBeans.xml: <bean id="javaFunctionTermResolverTypeService" class="org.kuali.kra.krms.service.impl.JavaFunctionTermResolverTypeServiceImpl" select * from krms_typ_t where typ_id = 'KC1001'; -- Use the Output term speck id to find the term resolver parm name and grep for the spring bean with this name select * from krms_term_rslvr_parm_spec_t where term_rslvr_id = 'KC2000';
PRAGMA TEMP_STORE = 2; PRAGMA JOURNAL_MODE = OFF; PRAGMA SYNCHRONOUS = 0; PRAGMA LOCKING_MODE = EXCLUSIVE; with recursive -- configure the limit here max_limit(max_nr) as ( select 1000000 ), naturals(n) -- init of the narural numbers 2,3,5,7,... as ( select 2 union all select n+1 from naturals where n=2 union all select n+2 from naturals where n>2 and n+2<=(select max_nr from max_limit) ), -- -- in the recursive call below we are calculating everything that can not be prime product (num,not_prime) as ( select n, n*n as sqr from naturals where sqr <= (select max(n) from naturals) and n !=2 -- this filters out all the recursive calls for evennumbers! union all -- all because we know there is no overlap between the two sets, is a bit faster than just union select num, -- because recursive does not allow to reuse n not_prime+2*num as prod --2*num because we know that every other number must be even from product where prod <= (select max(n) from naturals) ) select 'fvbakel_sqlite1' as sol_name, (select max_nr from max_limit) as max_nr, count(*) as nr_of_primes, 'algorithm=other,faithful=no,bits=8' from ( select n, case when not_prime is null then 1 else 0 end as isPrime from naturals left join (select distinct not_prime from product) unique_list on ( naturals.n = unique_list.not_prime ) ) sieve where sieve.isPrime = 1 ;
CREATE PROC [ERP].[Usp_Sel_CajaChica_By_ID] @ID INT AS BEGIN SELECT MCC.ID ,MCC.IdEmpresa ,MCC.Orden ,MCC.TipoCambio ,MCC.IdCuenta ,C.Nombre NombreCuenta ,MCC.FechaEmision ,MCC.FechaCierre ,MCC.SaldoInicial ,MCC.SaldoFinal ,MCC.TotalGastado ,MCC.IdEmpresa ,MCC.FechaRegistro ,MCC.FechaModificado ,MCC.UsuarioModifico ,MCC.UsuarioRegistro ,MCC.Flag ,MCC.FlagBorrador ,MCC.FlagCierre ,[ERP].[ObtenerNombreBancoMonedaTipo_By_IdCuenta](MCC.IdCuenta) AS NombreCuentaBancoMoneda ,C.IdMoneda ,MCC.Documento ,MCC.Observacion FROM ERP.MovimientoCajaChica MCC INNER JOIN ERP.Cuenta C ON C.ID = MCC.IdCuenta WHERE MCC.ID = @ID END
insert into employee (employeeSeq, lastName, firstName) values (1, 'Amy', 'Chan'); insert into employee (employeeSeq, lastName, firstName) values (2, 'Betty', 'Kwan'); insert into employee (employeeSeq, lastName, firstName) values (3, 'Cathy', 'Cheng'); insert into employeeView (employeeViewSeq, viewName) values (1, 'All Employee'); insert into location values ('Oakland'); insert into location values ('Union City'); insert into role values ('Manager'); insert into role values ('HR Manager'); insert into role values ('User'); insert into type values ('TS'); insert into user (userId, password, role, employeeViewSeq) values ('steve', 'steve', 'Manager', 1); insert into user (userId, password, role, employeeViewSeq) values ('jeff', 'jeff', 'HR Manager', 1); insert into viewMapping (employeeViewSeq, employeeSeq, location) values (1, 1, 'Oakland'); insert into viewMapping (employeeViewSeq, employeeSeq, location) values (1, 1, 'Union City'); insert into viewMapping (employeeViewSeq, employeeSeq, location) values (1, 2, 'Oakland'); insert into viewMapping (employeeViewSeq, employeeSeq, location) values (1, 2, 'Union City'); insert into viewMapping (employeeViewSeq, employeeSeq, location) values (1, 3, 'Oakland'); insert into viewMapping (employeeViewSeq, employeeSeq, location) values (1, 3, 'Union City'); insert into timesheet (employeeSeq, location, date, type, worked, overtime, vacation, sick, floating, holiday, other, comments, createdBy) values (1, 'Union City', '2009-1-1', 'TS', 8, 2, 0, 0, 0, 0, 0, 'Testing', 'steve'); insert into timesheet (employeeSeq, location, date, type, worked, overtime, vacation, sick, floating, holiday, other, comments, createdBy) values (2, 'Oakland', '2009-2-1', 'TS', 8, 2, 0, 0, 0, 0, 0, 'Testing2', 'steve'); insert into timesheet (employeeSeq, location, date, type, worked, overtime, vacation, sick, floating, holiday, other, comments, createdBy) values (2, 'Oakland', '2009-2-16', 'TS', 0, 0, 0, 0, 0, 0, 0, 'Testing3', 'jeff');
-- phpMyAdmin SQL Dump -- version 4.1.12 -- http://www.phpmyadmin.net -- -- Client : localhost -- Généré le : Jeu 05 Septembre 2019 à 10:37 -- Version du serveur : 5.5.59-0+deb7u1 -- Version 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 données : `se3wpkg` -- -- -- Contenu de la table `depot` -- INSERT INTO `depot` (`id_depot`, `url_depot`, `nom_depot`, `depot_actif`, `depot_principal`, `hash_xml`) VALUES (1, 'http://deb.sambaedu.org/wpkg/xml/packages.xml', 'SambaEdu Officiel', 1, 1, ''), (2, 'http://deb.sambaedu.org/wpkg/xml/packages_dev.xml', 'SambaEdu Dev', 0, 0, ''); /*!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 */;
-- -- MySQL week 1 Coding Assignment -- Backend Coding Bootcamp -- Promineo Tech -- SELECT * FROM employees LIMIT 10; SELECT count(*) FROM employees; -- Requirement #1 -- Show all employees who were born before 1965-01-01 SELECT * FROM employees WHERE birth_date < '1965-01-01'; -- Requirement #2 -- Show all employees who are female and were hired after 1990 SELECT * FROM employees WHERE gender = 'f' AND hire_date > '1990-12-31'; -- Requirement #3 -- Show the first and last name of the first 50 employees whose last name starts with F SELECT first_name, last_name FROM employees WHERE last_name LIKE 'f%' LIMIT 50; -- Requirement #4 -- Insert 3 new employees in the employees table. -- Their emp_nos should be 100, 101, and 102. -- Choose the rest of the data! -- (I added emp_no 103, Can't hire Mickey without Minnie!) INSERT INTO employees (emp_no, birth_date, first_name, last_name, gender, hire_date) VALUES (100, '1950-01-01', 'Mickey', 'Mouse', 'M', '1969-01-01'), (101, '1951-02-03', 'Daisy', 'Duck', 'F', '1970-02-02'), (102, '1949-03-03', 'Donald', 'Duck', 'M', '1970-03-03'), (103, '1951-04-04', 'Minnie', 'Mouse', 'F', '1969-02-02'); -- Confirm INSERT worked! SELECT * FROM employees LIMIT 10; -- Requirement #5 -- Check that the WHERE clause is correct before updating data SELECT * FROM employees WHERE emp_no = 10023; -- Change the employee's first name to Bob for the employee with the emp_no of 10023 UPDATE employees SET first_name = 'Bob' WHERE emp_no = 10023; -- Confirm that UPDATE worked! SELECT * FROM employees WHERE emp_no = 10023; -- Requirement #6 -- Check that the WHERE clause is correct before updating data SELECT count(*) FROM employees WHERE first_name LIKE 'P%' || last_name LIKE 'P%'; SELECT * FROM employees WHERE first_name LIKE 'P%' || last_name LIKE 'P%'; -- Change all employees hire dates to 2002-01-01 whose first or last names start with P UPDATE employees SET hire_date = '2002-01-01' WHERE first_name LIKE 'P%' || last_name LIKE 'P%'; -- Confirm that UPDATE worked! SELECT * FROM employees WHERE first_name LIKE 'P%' || last_name LIKE 'P%' LIMIT 10; -- Requirement #7 -- Check that the WHERE clause is correct before updating data SELECT * FROM employees WHERE emp_no < 10000; -- Delete all employees who have an emp_no less than 10000; DELETE FROM employees WHERE emp_no < 10000; -- Confirm that DELETE worked! SELECT * FROM employees WHERE emp_no < 10000; -- Requirement #8 -- Check that the WHERE clause is correct before updating data SELECT * FROM employees WHERE emp_no IN (10048, 10099, 10234, 20089); -- Delete all employees who have an emp_no of 10048, 10099, 10234 and 20089 DELETE FROM employees WHERE emp_no IN (10048, 10099, 10234, 20089); -- Confirm that DELETE worked! SELECT * FROM employees WHERE emp_no IN (10048, 10099, 10234, 20089); -- -- End of MySQL Week 1 Coding Assignment --
-- MySQL Script generated by MySQL Workbench -- Mon Dec 2 23:57:36 2019 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; -- ----------------------------------------------------- -- Schema dbcaxtop -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema dbcaxtop -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `dbcaxtop` DEFAULT CHARACTER SET utf8 ; USE `dbcaxtop` ; -- ----------------------------------------------------- -- Table `dbcaxtop`.`entrada` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `dbcaxtop`.`entrada` ( `documento` INT NOT NULL AUTO_INCREMENT, `descricao` VARCHAR(45) NULL, `dataInclusao` DATE NULL, `valor` FLOAT NULL, PRIMARY KEY (`documento`)) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; ------------------------------------------------------------------------------------------------ -- MySQL Script generated by MySQL Workbench -- Mon Dec 2 23:57:36 2019 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; -- ----------------------------------------------------- -- Schema dbcaxtop -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema dbcaxtop -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `dbcaxtop` DEFAULT CHARACTER SET utf8 ; USE `dbcaxtop` ; -- ----------------------------------------------------- -- Table `dbcaxtop`.`entrada` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `dbcaxtop`.`saida` ( `documento` INT NOT NULL AUTO_INCREMENT, `descricao` VARCHAR(45) NULL, `dataInclusao` DATE NULL, `valor` FLOAT NULL, PRIMARY KEY (`documento`)) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
-- -------------------------------------------------------- -- Host: 127.0.0.1 -- Server version: 10.4.11-MariaDB - mariadb.org binary distribution -- Server OS: Win64 -- HeidiSQL Version: 10.3.0.5771 -- -------------------------------------------------------- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET NAMES utf8 */; /*!50503 SET NAMES utf8mb4 */; /*!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' */; -- Dumping database structure for store4db CREATE DATABASE IF NOT EXISTS `store4db` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; USE `store4db`; -- Dumping structure for table store4db.category CREATE TABLE IF NOT EXISTS `category` ( `id` int(11) NOT NULL, `categoryName` varchar(255) DEFAULT NULL, `categoryDescription` text DEFAULT NULL, `categoryStatus` text DEFAULT NULL, `country_code` int(11) DEFAULT NULL, `parent_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.category: ~0 rows (approximately) /*!40000 ALTER TABLE `category` DISABLE KEYS */; /*!40000 ALTER TABLE `category` ENABLE KEYS */; -- Dumping structure for table store4db.countries CREATE TABLE IF NOT EXISTS `countries` ( `code` int(11) NOT NULL, `name` varchar(255) DEFAULT NULL, `continent_name` varchar(255) DEFAULT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.countries: ~0 rows (approximately) /*!40000 ALTER TABLE `countries` DISABLE KEYS */; /*!40000 ALTER TABLE `countries` ENABLE KEYS */; -- Dumping structure for table store4db.merchants CREATE TABLE IF NOT EXISTS `merchants` ( `id` int(11) NOT NULL, `merchant_name` varchar(255) DEFAULT NULL, `country_code` int(11) DEFAULT NULL, `created at` varchar(255) DEFAULT NULL, `admin_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.merchants: ~0 rows (approximately) /*!40000 ALTER TABLE `merchants` DISABLE KEYS */; /*!40000 ALTER TABLE `merchants` ENABLE KEYS */; -- Dumping structure for table store4db.offer CREATE TABLE IF NOT EXISTS `offer` ( `calculateOfferPrice` float DEFAULT NULL, `applyDiscountPrice` int(11) DEFAULT NULL, `ApplyTimeBasedDiscountPrice()` datetime DEFAULT NULL, `offerStatus` text DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.offer: ~0 rows (approximately) /*!40000 ALTER TABLE `offer` DISABLE KEYS */; /*!40000 ALTER TABLE `offer` ENABLE KEYS */; -- Dumping structure for table store4db.orders CREATE TABLE IF NOT EXISTS `orders` ( `id` int(11) NOT NULL, `user_id` int(11) DEFAULT NULL, `orderStatus` text DEFAULT NULL, `payment` text DEFAULT NULL, `created_at` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.orders: ~0 rows (approximately) /*!40000 ALTER TABLE `orders` DISABLE KEYS */; /*!40000 ALTER TABLE `orders` ENABLE KEYS */; -- Dumping structure for table store4db.order_items CREATE TABLE IF NOT EXISTS `order_items` ( `order_id` int(11) DEFAULT NULL, `product_id` int(11) DEFAULT NULL, `quantity` int(11) DEFAULT 1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.order_items: ~0 rows (approximately) /*!40000 ALTER TABLE `order_items` DISABLE KEYS */; /*!40000 ALTER TABLE `order_items` ENABLE KEYS */; -- Dumping structure for table store4db.product CREATE TABLE IF NOT EXISTS `product` ( `id` int(11) NOT NULL, `productName` text DEFAULT NULL, `productDescription` text DEFAULT NULL, `productPrice` float DEFAULT NULL, `discountPrice` int(11) DEFAULT NULL, `country_code` int(11) DEFAULT NULL, `category_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.product: ~0 rows (approximately) /*!40000 ALTER TABLE `product` DISABLE KEYS */; /*!40000 ALTER TABLE `product` ENABLE KEYS */; -- Dumping structure for table store4db.products CREATE TABLE IF NOT EXISTS `products` ( `id` int(11) NOT NULL, `name` varchar(255) DEFAULT NULL, `merchant_id` int(11) NOT NULL, `price` int(11) DEFAULT NULL, `status` enum('out_of_stock','in_stock','running_low') DEFAULT NULL, `created_at` datetime DEFAULT current_timestamp(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.products: ~0 rows (approximately) /*!40000 ALTER TABLE `products` DISABLE KEYS */; /*!40000 ALTER TABLE `products` ENABLE KEYS */; -- Dumping structure for table store4db.users CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `full_name` text DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `phone` text DEFAULT NULL, `role` text DEFAULT NULL, `status` text DEFAULT NULL, `countryCode` int(11) DEFAULT NULL, `images` text DEFAULT NULL, `email` text DEFAULT NULL, `password` text DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8mb4; -- Dumping data for table store4db.users: ~26 rows (approximately) /*!40000 ALTER TABLE `users` DISABLE KEYS */; INSERT INTO `users` (`id`, `full_name`, `created_at`, `phone`, `role`, `status`, `countryCode`, `images`, `email`, `password`) VALUES (1, 'Almira Smallpeace', '0000-00-00 00:00:00', '264-542-1244', NULL, NULL, 0, NULL, NULL, '602-10-2070'), (2, 'Bevvy Groger', '0000-00-00 00:00:00', '591-427-9616', NULL, NULL, 0, NULL, NULL, '147-01-7231'), (3, 'Alys Tarply', '0000-00-00 00:00:00', '923-448-2681', NULL, NULL, 0, NULL, NULL, '602-59-3625'), (4, 'Hart Markey', '0000-00-00 00:00:00', '204-519-1984', NULL, NULL, 0, NULL, NULL, '120-61-1251'), (5, 'Tallia Zukerman', '0000-00-00 00:00:00', '712-958-6887', NULL, NULL, 0, NULL, NULL, '798-23-5418'), (6, 'Mohandis Larrad', '0000-00-00 00:00:00', '590-316-3050', NULL, NULL, 0, NULL, NULL, '864-32-1776'), (7, 'Theo Flicker', '0000-00-00 00:00:00', '927-802-8259', NULL, NULL, 0, NULL, NULL, '353-71-6575'), (8, 'Jenna Gilkison', '0000-00-00 00:00:00', '954-721-3914', NULL, NULL, 0, NULL, NULL, '396-91-2687'), (9, 'Byrann Fitzgerald', '0000-00-00 00:00:00', '859-107-4721', NULL, NULL, 0, NULL, NULL, '521-90-9562'), (10, 'Giovanni Cathcart', '0000-00-00 00:00:00', '281-499-8921', NULL, NULL, 0, NULL, NULL, '544-07-7324'), (11, 'Haleigh Reisen', '0000-00-00 00:00:00', '320-355-8161', NULL, NULL, 0, NULL, NULL, '574-76-6994'), (12, 'Wendeline Padilla', '0000-00-00 00:00:00', '208-942-1413', NULL, NULL, 0, NULL, NULL, '536-31-6831'), (13, 'Hedwiga Peto', '0000-00-00 00:00:00', '802-186-6283', NULL, NULL, 0, NULL, NULL, '660-40-6412'), (14, 'Justine Taggerty', '0000-00-00 00:00:00', '880-492-5454', NULL, NULL, 0, NULL, NULL, '487-46-4698'), (15, 'Shaun Simoneton', '0000-00-00 00:00:00', '899-872-5539', NULL, NULL, 0, NULL, NULL, '568-94-6706'), (16, 'Lyssa Gilluley', '0000-00-00 00:00:00', '651-221-8518', NULL, NULL, 0, NULL, NULL, '773-41-4204'), (17, 'Alonzo Pimlott', '0000-00-00 00:00:00', '710-523-0606', NULL, NULL, 0, NULL, NULL, '616-06-5669'), (18, 'Rodi McCaskell', '0000-00-00 00:00:00', '781-174-4486', NULL, NULL, 0, NULL, NULL, '824-79-7386'), (19, 'Donni Ainge', '0000-00-00 00:00:00', '564-814-1330', NULL, NULL, 0, NULL, NULL, '758-71-4167'), (20, 'Urbanus Mayor', '0000-00-00 00:00:00', '150-747-4280', NULL, NULL, 0, NULL, NULL, '676-51-0925'), (21, 'Stephie Cruttenden', '0000-00-00 00:00:00', '441-110-4907', NULL, NULL, 0, NULL, NULL, '506-03-2167'), (22, 'Denni Bumpas', '0000-00-00 00:00:00', '332-859-4484', NULL, NULL, 0, NULL, NULL, '478-87-2611'), (23, 'Nola Garroway', '0000-00-00 00:00:00', '424-824-5834', NULL, NULL, 0, NULL, NULL, '890-25-2194'), (24, 'Kelsey Riatt', '0000-00-00 00:00:00', '392-705-8417', NULL, NULL, 0, NULL, NULL, '644-41-4245'), (25, 'Ivette Gomme', '0000-00-00 00:00:00', '752-766-8508', NULL, NULL, 0, NULL, NULL, '817-66-0090'), (26, 'Mireielle Pace', '0000-00-00 00:00:00', '166-196-1718', NULL, NULL, 0, NULL, NULL, '127-08-2615'); /*!40000 ALTER TABLE `users` ENABLE KEYS */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
select (a + b) - c, (a - b) + c, -- verify associativity at top a + (b - c), a - (b + c), -- ditto ((a + b) - c) + d, ((a - b) + c) + d, -- veriffy associativity in sub-expr (a + (b - c)) + d, (a - (b + c)) + d, -- ditto ((a + b) - c) - d, ((a - b) + c) - d, -- ditto (a + (b - c)) - d, (a - (b + c)) - d, -- ditto d + ((a + b) - c), d + ((a - b) + c), -- ditto d + (a + (b - c)), d + (a - (b + c)), -- ditto d - ((a + b) - c), d - ((a - b) + c), -- ditto d - (a + (b - c)), d - (a - (b + c)), -- ditto ((a1/a2)/(b/c))/((d/e)/f), -- ditto (a+b)*(c*d), -- mixed precedence a+(b*c), (a+b)*c -- ditto
-- phpMyAdmin SQL Dump -- version 4.7.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jul 26, 2017 at 04:52 PM -- Server version: 10.1.22-MariaDB -- PHP Version: 7.1.4 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `questionery` -- -- -------------------------------------------------------- -- -- Table structure for table `answer_tbl` -- CREATE TABLE `answer_tbl` ( `answer_id` int(6) NOT NULL, `answer_desc` varchar(200) NOT NULL, `ans_image` varchar(150) NOT NULL, `fk_question_id` int(6) NOT NULL, `fk_email_id` varchar(50) NOT NULL, `date` varchar(50) NOT NULL, `answer_like` varchar(50) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `answer_tbl` -- INSERT INTO `answer_tbl` (`answer_id`, `answer_desc`, `ans_image`, `fk_question_id`, `fk_email_id`, `date`, `answer_like`) VALUES (1, ' helow', '', 22, 'jilayshah123@gmail.com', '21/07/17', '21'), (24, ' using of data type ', '', 23, 'jilayshah123@gmail.com', '21/07/17', '12'), (25, '4 types', '', 22, 'rajpatel@gmail..com', '21/07/17', '4'), (26, ' basic 4 types', '', 22, 'krisha123@gmail.com', '21/07/17', '12'), (27, 'jilay jack ', '', 26, 'rajpatel@gmail..com', '25/07/17', '4'); -- -------------------------------------------------------- -- -- Table structure for table `question_tbl` -- CREATE TABLE `question_tbl` ( `question_id` int(6) NOT NULL, `question_title` varchar(100) NOT NULL, `question_desc` varchar(250) NOT NULL, `image` varchar(50) NOT NULL, `fk_email_id` varchar(50) NOT NULL, `fk_sub_id` int(6) NOT NULL, `date` varchar(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `question_tbl` -- INSERT INTO `question_tbl` (`question_id`, `question_title`, `question_desc`, `image`, `fk_email_id`, `fk_sub_id`, `date`) VALUES (22, 'data types', 'how many datatypes in c++ ', '', 'jilayshah123@gmail.com', 1, '21/07/17'), (23, 'declare veriable', 'how to declare veriable in c++ ', '', 'jilayshah123@gmail.com', 1, '21/07/17'), (24, 'data types', 'how many datatypes in java ', '', 'jilayshah123@gmail.com', 2, '21/07/17'), (26, 'php', 'if it is good language ', '', 'rajpatel@gmail..com', 4, '21/07/17'); -- -------------------------------------------------------- -- -- Table structure for table `subject_tbl` -- CREATE TABLE `subject_tbl` ( `subject_id` int(11) NOT NULL, `subject_name` varchar(100) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `subject_tbl` -- INSERT INTO `subject_tbl` (`subject_id`, `subject_name`) VALUES (1, 'C++'), (2, 'JAVA'), (3, 'C'), (4, 'PHP'), (5, '.net'); -- -------------------------------------------------------- -- -- Table structure for table `user_tbl` -- CREATE TABLE `user_tbl` ( `email_id` varchar(50) NOT NULL, `password` varchar(100) NOT NULL, `name` varchar(100) NOT NULL, `mobile_no` varchar(10) NOT NULL, `gender` varchar(10) NOT NULL, `user_image` varchar(50) NOT NULL, `token` varchar(10) NOT NULL, `flag` varchar(10) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `user_tbl` -- INSERT INTO `user_tbl` (`email_id`, `password`, `name`, `mobile_no`, `gender`, `user_image`, `token`, `flag`) VALUES ('jilayshah123@gmail.com', 'jack', 'JILAY JACK', '1212', 'male', 'IMG_420100.jpg', '404f39a2dc', 'no'), ('fenalishahpura@gmail.com', 'fenali', 'fenali', '8989898989', 'female', 'avatar-5.jpg', 'a8a8c437ef', 'no'), ('rajpatel@gmail..com', 'raj', 'Raj Patel', '89898989', 'male', 'IMG_4327.jpg', '3462193619', 'no'), ('krisha123@gmail.com', 'krisha', 'krisha', '56525315', 'female', 'avatar-3.jpg', 'e336356897', 'no'); -- -- Indexes for dumped tables -- -- -- Indexes for table `answer_tbl` -- ALTER TABLE `answer_tbl` ADD PRIMARY KEY (`answer_id`); -- -- Indexes for table `question_tbl` -- ALTER TABLE `question_tbl` ADD PRIMARY KEY (`question_id`); -- -- Indexes for table `subject_tbl` -- ALTER TABLE `subject_tbl` ADD PRIMARY KEY (`subject_id`); -- -- Indexes for table `user_tbl` -- ALTER TABLE `user_tbl` ADD PRIMARY KEY (`email_id`), ADD UNIQUE KEY `mobile_no` (`mobile_no`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `answer_tbl` -- ALTER TABLE `answer_tbl` MODIFY `answer_id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28; -- -- AUTO_INCREMENT for table `question_tbl` -- ALTER TABLE `question_tbl` MODIFY `question_id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27; -- -- AUTO_INCREMENT for table `subject_tbl` -- ALTER TABLE `subject_tbl` MODIFY `subject_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;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 */;
SELECT IEAN AS EAN,ICOD AS MODELO,IDESCR AS DESCRIPCION,FAM2.FAMDESCR AS DEPARTAMENTO, AICANTF AS VENTA_EN_UNIDADES,ILISTA5 AS COSTO,ILISTA5 * AICANTF AS COSTO_TOTAL, AIPRECIO AS PRECIO,AIPRECIO * AICANTF AS PRECIO_TOTAL,FAM1.FAMDESCR AS PROVEEDOR, FAM3.FAMDESCR AS TIPO,FAM4.FAMDESCR AS SUBTIPO,FAM5.FAMDESCR AS PERSONAJE, FAM6.FAMDESCR AS TRIMESTRE,FAM7.FAMDESCR AS DISEÑADOR,FAM8.FAMDESCR AS LICENCIA, FAM9.FAMDESCR AS TIPO_DE_LICENCIA,CATDESCR AS TIENDA, DFECHA AS FECHA, IF(DALMACEN < 12, "BOUTIQUES", IF(DALMACEN <303,"MAYOREO" ,IF(DALMACEN <503,"FRANQUICIAS", "BODEGAS"))) AS CLASIFICA_ALMACEN,SUBSTRING(ICOD,1,9)AS MODELO_PADRE FROM FAXINV LEFT JOIN FDOC ON FDOC.DSEQ=FAXINV.DSEQ LEFT JOIN FINV ON FINV.ISEQ=FAXINV.ISEQ LEFT JOIN FCLI ON FCLI.CLISEQ=FDOC.CLISEQ LEFT JOIN FUNIDAD ON FUNIDAD.UCOD=FINV.IUM LEFT JOIN FALMCAT ON FALMCAT.CATALM = FDOC.DALMACEN LEFT JOIN FAG ON FAG.AGTNUM = FDOC.DPAR1 LEFT JOIN FFAM AS FAM1 ON FAM1.FAMTNUM=FINV.IFAM1 LEFT JOIN FFAM AS FAM2 ON FAM2.FAMTNUM=FINV.IFAM2 LEFT JOIN FFAM AS FAM3 ON FAM3.FAMTNUM=FINV.IFAM3 LEFT JOIN FFAM AS FAM4 ON FAM4.FAMTNUM=FINV.IFAM4 LEFT JOIN FFAM AS FAM5 ON FAM5.FAMTNUM=FINV.IFAM5 LEFT JOIN FFAM AS FAM6 ON FAM6.FAMTNUM=FINV.IFAM6 LEFT JOIN FFAM AS FAM7 ON FAM7.FAMTNUM=FINV.IFAM7 LEFT JOIN FFAM AS FAM8 ON FAM8.FAMTNUM=FINV.IFAM8 LEFT JOIN FFAM AS FAM9 ON FAM9.FAMTNUM=FINV.IFAM9 LEFT JOIN FFAM AS FAMA ON FAMA.FAMTNUM=FINV.IFAMA WHERE DITIPMV='T' AND (FAM1.FAMDESCR= 'FONT SILVER' or FAM1.FAMDESCR= 'MOGOBIKES MEXICO' or FAM1.FAMDESCR= 'COMER.ORC, S.A') ORDER BY DALMACEN
SELECT T1.sid,T2.numberofCourse*5*3000 - T3.totalpayoffofEmployment- T1.financialaid+ housing_cost + i3.after_discount(0.95) as TuitionDue,ss3.housing, i3.Company_name as InsuCompany,i3.plan_type FROM (Select s.sid,s.firstname,s.lastname,f.financial_aid as financialaid FROM student s, Financial_service f Where s.sid=f.sid) T1, (SELECT s.sid,count(*) as numberofCourse FROM course c, student s, register r Where c.cid=r.cid AND s.sid=r.sid Group by s.sid)T2, (Select s.sid,totalhours*payrate as totalpayoffofEmployment From student s, employment e, work_as w Where s.sid=w.sid AND e.ssn=w.ssn)T3,Receive r3, Student_Service ss3,purchase_insurance pi3,insurance_obj_table i3,Financial_service fs3 Where T1.sid=T2.sid AND T3.sid=T2.sid AND r3.Student_No=ss3.Student_No AND r3.sid=T1.sid AND pi3.pid=fs3.pid AND fs3.sid=T1.sid AND pi3.iid=i3.iid;
/** * SQL for searching kaisha information * @author HaiTTH * @version $Id: KaishaSearchService_getKaishaList_Sel_01.sql 27987 2014-09-23 02:43:33Z p_chan_hai $ */ SELECT TEMP.KAISHA_CD, TEMP.KAISHA_NAME, TEMP.KAISHA_JUDGE_KBN, TEMP.KAISHA_LAST_UPDATE_DATE, TEMP.KAISHA_LAST_KEISAI_DATE, TEMP.WARN_FLG, TEMP.BATCH_WARN_FLG, TEMP.CAUTION_FLG, TEMP.KAISHA_KEISAI_REFLECT_KBN, COUNT(TEMP.SHISETSU_KEISAI_OK) AS SHISETSU_KEISAI_OK FROM ( SELECT KS.KAISHA_CD, KS.KAISHA_NAME, KS.KAISHA_JUDGE_KBN, KS.KAISHA_LAST_UPDATE_DATE, KS.KAISHA_LAST_KEISAI_DATE, ER.WARN_FLG, ER.BATCH_WARN_FLG, ER.CAUTION_FLG, KS.KAISHA_KEISAI_REFLECT_KBN, CASE SST.SHISETSU_KEISAI_STS_KBN WHEN null THEN 'NG' WHEN '2' THEN 'NG' END AS SHISETSU_KEISAI_NG, CASE SST.SHISETSU_KEISAI_STS_KBN WHEN '1' THEN 'OK' END AS SHISETSU_KEISAI_OK FROM BY_KAISHA_KIHON KS LEFT JOIN BY_KAISHA_NYUKO_ERROR ER ON KS.KAISHA_CD = ER.KAISHA_CD LEFT JOIN BY_SHISETSU_KIHON SST ON (KS.KAISHA_CD = SST.KAISHA_CD AND SST.DELETE_FLG = '0') WHERE KS.DELETE_FLG = '0' /*IF kaishaCd != null && kaishaCd != ""*/ AND TO_SINGLE_BYTE(UPPER(KS.KAISHA_CD)) = TO_SINGLE_BYTE(UPPER(/*kaishaCd*/'000001')) /*END*/ /*IF kaishaName != null && kaishaName != ""*/ AND TO_SINGLE_BYTE(UPPER(KS.KAISHA_NAME)) LIKE TO_SINGLE_BYTE(UPPER(/*kaishaName*/'%kaishaName%')) escape /*escChar*/'$' /*END*/ /*IF kaishaNameKana != null && kaishaNameKana != ""*/ AND TO_SINGLE_BYTE(UPPER(KS.KAISHA_NAME_KANA)) LIKE TO_SINGLE_BYTE(UPPER(/*kaishaNameKana*/'%kaishaNameKana%')) escape /*escChar*/'$' /*END*/ /*IF kaishaJudgeKbn != null*/ AND KS.KAISHA_JUDGE_KBN IN /*kaishaJudgeKbn*/('A') /*END*/ /*IF inputCheckErrorType != null*/ AND ( /*BEGIN*/ /*IF warningAndCaution != null && warningAndCaution !=""*/ (( ER.WARN_FLG = /*warningAndCaution*/'1' OR ER.BATCH_WARN_FLG = /*warningAndCaution*/'1' ) AND ER.CAUTION_FLG = /*warningAndCaution*/'1' ) /*END*/ /*IF warning != null && warning !=""*/ OR ( (ER.WARN_FLG = /*warning*/'1' OR ER.BATCH_WARN_FLG = /*warning*/'1' ) AND ER.CAUTION_FLG = '0') /*END*/ /*IF caution != null && caution != ""*/ OR ( ER.CAUTION_FLG = /*caution*/'1' AND ER.WARN_FLG = '0' AND ER.BATCH_WARN_FLG = '0') /*END*/ /*IF noError != null && noError != ""*/ OR ( ( ER.WARN_FLG = /*noError*/'0' OR ER.WARN_FLG is null) AND ( ER.BATCH_WARN_FLG = /*noError*/'0' OR ER.BATCH_WARN_FLG is null) AND ( ER.CAUTION_FLG = /*noError*/'0' OR ER.CAUTION_FLG is null)) /*END*/ /*END*/ ) /*END*/ ) TEMP GROUP BY TEMP.KAISHA_CD, TEMP.KAISHA_NAME, TEMP.KAISHA_JUDGE_KBN, TEMP.KAISHA_LAST_UPDATE_DATE, TEMP.KAISHA_LAST_KEISAI_DATE, TEMP.WARN_FLG, TEMP.BATCH_WARN_FLG, TEMP.CAUTION_FLG, TEMP.KAISHA_KEISAI_REFLECT_KBN /*IF kaishaKeisaiStsKbn != null*/ HAVING /*BEGIN*/ /*IF kaishaKeisaiNow == "1" && shisetsuKeisaiNow == "1"*/ (TEMP.KAISHA_KEISAI_REFLECT_KBN = /*kaishaKeisaiNow*/'1' AND COUNT(TEMP.SHISETSU_KEISAI_OK) > 0) /*END*/ /*IF kaishaKeisaiStsKbnOn == "1" && shisetsuKeisaiStsKbnOff == "2"*/ OR (TEMP.KAISHA_KEISAI_REFLECT_KBN = /*kaishaKeisaiStsKbnOn*/'1' AND COUNT(TEMP.SHISETSU_KEISAI_OK) = 0) /*END*/ /*IF notKeisaiAndReflect != null && notKeisaiAndReflect != ""*/ OR TEMP.KAISHA_KEISAI_REFLECT_KBN = /*notKeisaiAndReflect*/'2' /*END*/ /*END*/ /*END*/ ORDER BY TEMP.KAISHA_CD ASC
# Write your MySQL query statement below select user_id, sum(quantity*P.price) as spending from Sales S left join Product P using (product_id) group by 1 order by 2 desc, 1 asc
-- MySQL Script generated by MySQL Workbench -- Sun Aug 6 07:41:00 2017 -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Schema fcc_booking -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema fcc_booking -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `fcc_booking` DEFAULT CHARACTER SET utf8 ; USE `fcc_booking` ; -- ----------------------------------------------------- -- Table `fcc_booking`.`staffs` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`staffs` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `firstname` VARCHAR(255) NOT NULL, `lastname` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NOT NULL, `account_name` VARCHAR(255) NOT NULL, `password` VARCHAR(255) NOT NULL, `phone_number` VARCHAR(20) NULL, `role` ENUM('Admin', 'Staff', 'Waiter') NOT NULL COMMENT '0:admin, 1: staff, 2: Waiter', `profile_image` VARCHAR(255) NULL, `table_color` VARCHAR(255) NULL COMMENT '#FFEEBB', `token` VARCHAR(255) NULL, `reset_pwd_token` VARCHAR(255) NULL, `reset_pwd_issued_time` DATETIME NULL, `reset_pwd_limit` INT NULL, `is_enabled` TINYINT NULL DEFAULT 0 COMMENT '1: enable, 0: disable', `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `account_name_UNIQUE` (`account_name` ASC)); -- ----------------------------------------------------- -- Table `fcc_booking`.`floor_packages` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`floor_packages` ( `id` INT(11) NOT NULL, `name` VARCHAR(255) NOT NULL, `is_publish` TINYINT NOT NULL DEFAULT 0 COMMENT '1:publish, 0:draft', `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`shift_packages` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`shift_packages` ( `id` INT(11) NOT NULL, `package_name` VARCHAR(255) NOT NULL, `is_publish` TINYINT NOT NULL DEFAULT 0 COMMENT '1: publish, 0: draft', `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`bookings` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`bookings` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `booking_number` VARCHAR(255) NOT NULL COMMENT '000001', `date` DATE NOT NULL, `time` TIME NOT NULL, `hours` INT NOT NULL, `number_of_people` INT NOT NULL, `status` ENUM('Booked', 'Confirmed', 'PartiallySeated', 'Seated', 'NotArrivedYet', 'WaitingInBar', 'GotTheCheck') CHARACTER SET 'big5' NOT NULL COMMENT 'Booked\nConfirmed\nPartially seated\nSeated\nNot arrived yet\nWaiting in bar\nGot the check\nCompleted\nNo show\nCancel\nCancel & Refund', `guest_id` INT NULL DEFAULT 0 COMMENT '0: Walk-in guest', `shift_package_id` INT(11) NOT NULL, `shift_id` INT(11) NOT NULL, `floor_package_id` INT(11) NOT NULL, `assigned_tables` VARCHAR(255) NULL, `notes_by_guest` VARCHAR(1024) NULL, `notes_by_staff` VARCHAR(1024) NULL, `expense` VARCHAR(255) NULL, `referenced_by` VARCHAR(225) NULL, `deposit_amount` FLOAT NULL, `deposit_method` ENUM('wxpay', 'alipay') NULL, `deposit_transaction_id` VARCHAR(255) NULL, `refund_error` VARCHAR(255) NULL, `refund_at` TIMESTAMP NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_bookings_floor_packages1_idx` (`floor_package_id` ASC), INDEX `fk_bookings_shift_packages1_idx` (`shift_package_id` ASC), CONSTRAINT `fk_bookings_floor_packages1` FOREIGN KEY (`floor_package_id`) REFERENCES `fcc_booking`.`floor_packages` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_bookings_shift_packages1` FOREIGN KEY (`shift_package_id`) REFERENCES `fcc_booking`.`shift_packages` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`floors` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`floors` ( `id` INT(11) NOT NULL, `number` INT NOT NULL, `name` VARCHAR(255) NOT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `number_UNIQUE` (`number` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`tables` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`tables` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `table_number` INT NOT NULL, `table_name` VARCHAR(255) NULL, `seats` INT NOT NULL, `seat_from` INT NOT NULL, `seat_to` INT NOT NULL, `style` INT NOT NULL COMMENT '0:Rectangle\n1:Circle', `floor_id` INT(11) NOT NULL, `floor_package_id` INT(11) NOT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `non_reservable` TINYINT(1) NOT NULL DEFAULT 0, `table_layout` TEXT NULL COMMENT 'json string', PRIMARY KEY (`id`), INDEX `fk_tables_floors1_idx` (`floor_id` ASC), INDEX `fk_tables_floor_packages1_idx` (`floor_package_id` ASC), CONSTRAINT `fk_tables_floors1` FOREIGN KEY (`floor_id`) REFERENCES `fcc_booking`.`floors` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_tables_floor_packages1` FOREIGN KEY (`floor_package_id`) REFERENCES `fcc_booking`.`floor_packages` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`shifts` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`shifts` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `time_slots` TEXT NOT NULL COMMENT 'JSON data({from:to},{from:to}...)', `floor_package_id` INT(11) NOT NULL DEFAULT 0 COMMENT '0: default package', `shift_package_id` INT(11) NOT NULL, `shfit_atb` INT NOT NULL DEFAULT 1 COMMENT 'hours(unit)', `deposit_amount` FLOAT NULL, `is_enabled` TINYINT NOT NULL DEFAULT 1 COMMENT '1: enable, 0: disable', `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_shift_floor_packages1_idx` (`floor_package_id` ASC), INDEX `fk_shifts_shift_packages1_idx` (`shift_package_id` ASC), CONSTRAINT `fk_shift_floor_packages1` FOREIGN KEY (`floor_package_id`) REFERENCES `fcc_booking`.`floor_packages` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_shifts_shift_packages1` FOREIGN KEY (`shift_package_id`) REFERENCES `fcc_booking`.`shift_packages` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`rules` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`rules` ( `id` INT(11) NOT NULL, `name` VARCHAR(255) NOT NULL, `start_date` DATETIME NOT NULL, `end_date` DATETIME NOT NULL, `repeat` INT NULL COMMENT '0: Every day\n1: Every week\n2: Every month\n3: Every Year', `repeat_end` DATETIME NULL, `shift_package_id` INT(11) NOT NULL DEFAULT 0 COMMENT '0: closed date', `color` VARCHAR(255) NULL COMMENT '#FFEEBB', `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_rule_shift_packages1_idx` (`shift_package_id` ASC), CONSTRAINT `fk_rule_shift_packages1` FOREIGN KEY (`shift_package_id`) REFERENCES `fcc_booking`.`shift_packages` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`guests` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`guests` ( `id` INT(11) NOT NULL, `name` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NOT NULL, `phone` VARCHAR(255) NOT NULL, `wechat_account` VARCHAR(255) NULL, `alipay_accoun_id` VARCHAR(255) NULL, `alipay_account_name` VARCHAR(255) NULL, `company_name` VARCHAR(255) NULL, `is_del` TINYINT NOT NULL DEFAULT 0 COMMENT '1: deleted', `is_block` TINYINT NOT NULL DEFAULT 0 COMMENT '1: blocked', `is_vip` TINYINT NOT NULL DEFAULT 0 COMMENT '1: vip', `sms_code` VARCHAR(255) NULL, `sms_send_time` DATETIME NULL, `sms_validation_time_limit` INT NULL, `sms_validation_count_limit` INT NULL, `token` VARCHAR(255) NULL, `token_issued_at` VARCHAR(255) NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`staff_tables` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`staff_tables` ( `staff_id` INT(11) NOT NULL, `table_id` INT(11) NOT NULL, `apply_date` DATETIME NOT NULL, `shift_id` INT(11) NOT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`staff_id`, `table_id`), INDEX `fk_staff_table_tables1_idx` (`table_id` ASC), INDEX `fk_staff_tables_shifts1_idx` (`shift_id` ASC), CONSTRAINT `fk_staff_table_staff1` FOREIGN KEY (`staff_id`) REFERENCES `fcc_booking`.`staffs` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_staff_table_tables1` FOREIGN KEY (`table_id`) REFERENCES `fcc_booking`.`tables` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_staff_tables_shifts1` FOREIGN KEY (`shift_id`) REFERENCES `fcc_booking`.`shifts` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`settings` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`settings` ( `id` INT(11) NOT NULL, `key` VARCHAR(255) NOT NULL COMMENT ' DEF_SHIFT_PKG_ID, DEF_FLOOR_PKG_ID, BOOKING_APP_TIMER...', `value` VARCHAR(255) NOT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`notifications` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`notifications` ( `id` INT(11) NOT NULL, `type` ENUM('BookingCreated', 'BookingChanged', 'BookingDeleted', 'GuestCreated', 'GuestChanged', 'GuestDeleted', 'StaffCreated', 'StaffChanged', 'StaffDeleted') NOT NULL, `staff_id` INT(11) NOT NULL, `key_info1` VARCHAR(255) NULL COMMENT 'if type = \'booking create\', booking_id\nif tyep = \'staff create\' ,staff_id\n', `key_info2` VARCHAR(255) NULL COMMENT 'if type = \'booking create\', booking_date\nif tyep = \'staff create\' registered_date&time', `key_info3` VARCHAR(255) NULL COMMENT 'guest_id', `key_info4` VARCHAR(255) NULL, `key_info5` VARCHAR(255) NULL, `is_read` TINYINT NOT NULL DEFAULT 0, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`permissions` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`permissions` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`staff_permissions` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`staff_permissions` ( `id` INT(11) NOT NULL, `staff_id` INT(11) NOT NULL, `permission_id` INT(11) NOT NULL, `is_write` TINYINT NULL, `is_readonly` TINYINT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_staff_staff_permissions_staffs1_idx` (`staff_id` ASC), INDEX `fk_staff_staff_permissions_staff_permissions1_idx` (`permission_id` ASC), CONSTRAINT `fk_staff_staff_permissions_staffs1` FOREIGN KEY (`staff_id`) REFERENCES `fcc_booking`.`staffs` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_staff_staff_permissions_staff_permissions1` FOREIGN KEY (`permission_id`) REFERENCES `fcc_booking`.`permissions` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`tags` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`tags` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `icon_image` VARCHAR(255) NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `name_UNIQUE` (`name` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`guest_tags` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`guest_tags` ( `id` INT(11) NOT NULL, `guest_id` INT(11) NOT NULL, `tag_name` VARCHAR(255) NOT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `tag_name_UNIQUE` (`tag_name` ASC), UNIQUE INDEX `guest_id_UNIQUE` (`guest_id` ASC), CONSTRAINT `fk_guest_tags_guests1` FOREIGN KEY (`guest_id`) REFERENCES `fcc_booking`.`guests` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_guest_tags_tags1` FOREIGN KEY (`tag_name`) REFERENCES `fcc_booking`.`tags` (`name`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`block_tables` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`block_tables` ( `id` INT NOT NULL AUTO_INCREMENT, `table_id` INT NOT NULL, `block_date` DATETIME NOT NULL, `is_allday` TINYINT NOT NULL DEFAULT 0 COMMENT '1: all day, 0: time range', `time_range_from` TIME NULL, `time_range_to` TIME NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_block_tables_tables1_idx` (`table_id` ASC), CONSTRAINT `fk_block_tables_tables1` FOREIGN KEY (`table_id`) REFERENCES `fcc_booking`.`tables` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `fcc_booking`.`assigned_tables` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `fcc_booking`.`assigned_tables` ( `table_id` INT(11) NOT NULL, `booking_id` INT(11) NOT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`table_id`, `booking_id`), CONSTRAINT `fk_assigned_tables_tables1` FOREIGN KEY (`table_id`) REFERENCES `fcc_booking`.`tables` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_assigned_tables_bookings2` FOREIGN KEY (`booking_id`) REFERENCES `fcc_booking`.`bookings` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
DROP TABLE IF EXISTS ports; CREATE TABLE ports ( locode char(5) NOT NULL PRIMARY KEY, country char(2) NOT NULL, port_code char(3) NOT NULL, name varchar (255) NOT NULL, UNIQUE KEY (country, port_code) ); DROP TABLE IF EXISTS countries; CREATE TABLE countries ( alpha2 char(2) NOT NULL PRIMARY KEY, name varchar (255) NOT NULL, UNIQUE KEY (name) ); DROP TABLE IF EXISTS rates; CREATE TABLE rates ( id int NOT NULL AUTO_INCREMENT PRIMARY KEY, port_from char(5) NOT NULL, port_to char (5) NOT NULL, container_type varchar(25) NOT NULL, rate decimal (10, 2) NOT NULL, currency char(3) NOT NULL DEFAULT 'USD', UNIQUE KEY (port_from, port_to, container_type) ); CREATE INDEX rates_ports USING BTREE ON rates (port_from, port_to); CREATE INDEX rates_container ON rates (container_type);
SELECT a.Title, c.Name AS CategoryName, t.Name AS TownName, s.Status FROM Ads a LEFT JOIN Categories c ON c.Id = a.CategoryId LEFT JOIN Towns t ON t.Id = a.TownId LEFT JOIN AdStatuses s ON s.Id = a.StatusId
/* Navicat MySQL Data Transfer Source Server : localhost Source Server Version : 50720 Source Host : localhost:3306 Source Database : gper_mall Target Server Type : MYSQL Target Server Version : 50720 File Encoding : 65001 Date: 2020-08-02 19:29:43 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for tb_member -- ---------------------------- DROP TABLE IF EXISTS `tb_member`; CREATE TABLE `tb_member` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL COMMENT '用户名', `password` varchar(32) NOT NULL COMMENT '密码,加密存储', `phone` varchar(20) DEFAULT NULL COMMENT '注册手机号', `email` varchar(50) DEFAULT NULL COMMENT '注册邮箱', `created` datetime NOT NULL, `updated` datetime NOT NULL, `sex` varchar(2) DEFAULT '', `address` varchar(255) DEFAULT NULL, `state` int(1) DEFAULT '0', `file` varchar(255) DEFAULT NULL COMMENT '头像', `description` varchar(500) DEFAULT NULL, `points` int(11) DEFAULT '0' COMMENT '积分', `balance` decimal(10,2) DEFAULT '0.00' COMMENT '余额', `isverified` varchar(26) DEFAULT 'N', PRIMARY KEY (`id`), UNIQUE KEY `username` (`username`) USING BTREE, UNIQUE KEY `phone` (`phone`) USING BTREE, UNIQUE KEY `email` (`email`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8 COMMENT='用户表'; -- ---------------------------- -- Records of tb_member -- ---------------------------- INSERT INTO `tb_member` VALUES ('62', 'test', 'e10adc3949ba59abbe56e057f20f883e', '16607491862', null, '2017-09-05 21:27:54', '2017-10-08 18:13:51', null, null, '1', 'https://gper.club/server-img/avatars/000/00/00/user_origin_30.jpg?time1565591384242', null, null, null, 'Y'); INSERT INTO `tb_member` VALUES ('66', 'mic', 'e10adc3949ba59abbe56e057f20f883e', '16607491863', null, '2019-08-06 00:15:48', '2019-08-06 00:15:48', null, null, '1', 'https://gper.club/server-img/avatars/000/00/00/user_origin_30.jpg?time1565591384242', null, null, null, 'Y');
-- MySQL dump 10.13 Distrib 5.5.54, for debian-linux-gnu (x86_64) -- -- Host: localhost Database: pyairmonitor -- ------------------------------------------------------ -- Server version 5.5.54-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 `airdata` -- DROP TABLE IF EXISTS `airdata`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `airdata` ( `id` bigint(64) unsigned NOT NULL AUTO_INCREMENT, `u_d` bigint(64) unsigned NOT NULL COMMENT 'user_id << 32 + device_id', `timestamp` char(10) NOT NULL, `data` text NOT NULL COMMENT 'air data for whole hour, raw text format, one line for each minute', PRIMARY KEY (`id`), KEY `u_d` (`u_d`) USING BTREE, KEY `timestamp` (`timestamp`) USING BTREE, KEY `u_d_timestamp` (`u_d`,`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `airdata` -- LOCK TABLES `airdata` WRITE; /*!40000 ALTER TABLE `airdata` DISABLE KEYS */; /*!40000 ALTER TABLE `airdata` ENABLE KEYS */; UNLOCK TABLES; -- -- Table structure for table `device` -- DROP TABLE IF EXISTS `device`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `device` ( `id` int(32) unsigned NOT NULL AUTO_INCREMENT, `sn` varchar(32) NOT NULL COMMENT 'device serial number', `ver` int(32) unsigned NOT NULL COMMENT 'device version number', `mac` varchar(32) NOT NULL COMMENT 'MAC address of the device', `delay_post` int(32) unsigned NOT NULL COMMENT 'delay <delay_post> seconds to post air data, this setting is used to avoid huge connection and data in the same time from all the devices', PRIMARY KEY (`id`,`sn`,`mac`), UNIQUE KEY `id` (`id`) USING BTREE, UNIQUE KEY `mac` (`mac`) USING HASH, UNIQUE KEY `sn` (`sn`) USING HASH ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `device` -- LOCK TABLES `device` WRITE; /*!40000 ALTER TABLE `device` DISABLE KEYS */; /*!40000 ALTER TABLE `device` 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` int(32) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(64) NOT NULL, `lastname` varchar(32) NOT NULL, `firstname` varchar(32) NOT NULL, `email` varchar(64) NOT NULL, `sex` enum('male','female') NOT NULL, `cellphone` varchar(16) NOT NULL, `password` varchar(64) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`,`username`,`email`,`cellphone`), UNIQUE KEY `id` (`id`) USING BTREE, UNIQUE KEY `username` (`username`) USING HASH, UNIQUE KEY `email` (`email`) USING HASH, UNIQUE KEY `cellphone` (`cellphone`) USING HASH ) 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; -- -- Table structure for table `user_device` -- DROP TABLE IF EXISTS `user_device`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `user_device` ( `id` int(32) unsigned NOT NULL AUTO_INCREMENT, `u_d` bigint(64) unsigned NOT NULL COMMENT 'user_id << 32 + device_id', `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `token` varchar(64) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `u_d` (`u_d`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `user_device` -- LOCK TABLES `user_device` WRITE; /*!40000 ALTER TABLE `user_device` DISABLE KEYS */; /*!40000 ALTER TABLE `user_device` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2017-02-25 3:09:07
----Details of each employee: employee number, last name, first name, gender, and salary SELECT e.emp_no, e.last_name, e.first_name, e.gender, s.salaries from employees as e inner join salaries as s on e.emp_no = s.emp_no; ----employees who were hired in 1986 SELECT * from employees where hire_date like '1986%'; ----manager of each department with the following information: department number, department name, the manager's employee number, last name, first name, and start and end employment dates SELECT d.dept_no, d.dept_name, dm.emp_no,e.last_name, e.first_name, dm.from_date, dm.to_date from departments as d join dept_manager as dm on d.dept_no = dm.dept_no join employees as e on e.emp_no = dm.emp_no; ----department of each employee with the following information: employee number, last name, first name, and department name SELECT e.emp_no, e.last_name, e.first_name, dm.dept_name from employees as e join dept_emp as d on e.emp_no = d.emp_no join departments as dm on dm.dept_no = d.dept_no; ---- employees whose first name is "Hercules" and last names begin with "B. SELECT * from employees WHERE first_name = 'Hercules' and last_name like 'B%'; ----employees in the Sales department, including their employee number, last name, first name, and department name SELECT e.emp_no, e.last_name, e.first_name, dm.dept_name from employees as e join dept_emp as d on e.emp_no = d.emp_no join departments as dm on d.dept_no = dm.dept_no WHERE dm.dept_name = 'Sales'; ---- employees in the Sales and Development departments, including their employee number, last name, first name, and department name SELECT e.emp_no, e.last_name, e.first_name, dm.dept_name from employees as e join dept_emp as d on e.emp_no = d.emp_no join departments as dm on d.dept_no = dm.dept_no WHERE dm.dept_name = 'Sales' or dm.dept_name = 'Development'; ----In descending order, list the frequency count of employee last names, i.e., how many employees share each last name select last_name, count(last_name) from employees group by last_name order by count desc;
DROP TABLE IF EXISTS `xbk`.`xbk_domain`; CREATE TABLE `xbk`.`xbk_domain` ( `id` int(11) NOT NULL auto_increment, `domain_name` varchar(25) collate utf8_unicode_ci NOT NULL default '' COMMENT '网站名称', `domain_url` varchar(75) collate utf8_unicode_ci NOT NULL default '' COMMENT '网站域名', `user_id` int(11) NOT NULL default '0' COMMENT '用户编号', `star_id` int(11) NOT NULL default '0' COMMENT '星编号', `status` varchar(12) collate utf8_unicode_ci NOT NULL default '待审' COMMENT '域名状态', `cat` tinyint(1) unsigned NOT NULL default '0' COMMENT '分类', `apply_time` datetime NOT NULL default '0000-00-00 00:00:00' COMMENT '申请时间', `verify_time` datetime NOT NULL default '0000-00-00 00:00:00' COMMENT '审核时间', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE PROC [ERP].[Usp_Sel_DocumentoPagarDetalle_Export] @ListaProveedor VARCHAR(MAX), @ListaTipoComprobante VARCHAR(MAX), @Fecha DATETIME, @IdEmpresa INT, @TipoFecha INT AS BEGIN SELECT CP.ID, CP.Serie, CASE WHEN CP.IdMoneda = 1 THEN CP.Total * IIF(CP.IdDebeHaber = 1, -1, 1) ELSE 0 END TotalSoles, CASE WHEN CP.IdMoneda = 2 THEN CP.Total * IIF(CP.IdDebeHaber = 1, -1, 1) ELSE 0 END TotalDolares, CASE WHEN CP.IdMoneda = 1 THEN (CP.Total - ISNULL(TD.TotalPago, 0)) * IIF(CP.IdDebeHaber = 1, -1, 1) ELSE 0 END SaldoSoles, CASE WHEN CP.IdMoneda = 2 THEN (CP.Total - ISNULL(TD.TotalPago, 0)) * IIF(CP.IdDebeHaber = 1, -1, 1) ELSE 0 END SaldoDolares, --CASE -- WHEN CP.IdMoneda = 1 THEN (CP.Total - ISNULL(TD.TotalPago, 0)) * IIF(CP.IdDebeHaber = 1, -1, 1) -- ELSE ((CP.Total - ISNULL(TD.TotalPago, 0)) * CP.TipoCambio) * IIF(CP.IdDebeHaber = 1, -1, 1) END SaldoSoles, --CASE -- WHEN CP.IdMoneda = 2 THEN (CP.Total - ISNULL(TD.TotalPago, 0)) * IIF(CP.IdDebeHaber = 1, -1, 1) -- ELSE ((CP.Total - ISNULL(TD.TotalPago, 0)) / CP.TipoCambio) * IIF(CP.IdDebeHaber = 1, -1, 1) END SaldoDolares, CP.Numero, ENT.Nombre, CP.Fecha FechaEmision, CP.FechaVencimiento FechaVencimiento, MO.CodigoSunat, CP.Total, TC.Nombre TipoComprobante, CP.TipoCambio, T2.Abreviatura TipoDocumentoIdentidad, ETD.NumeroDocumento Ruc FROM ERP.CuentaPagar CP LEFT JOIN ERP.FN_TotalPagosCuentaPagar_Empresa(@IdEmpresa, @Fecha) TD ON CP.ID = TD.IdCuentaPagar INNER JOIN Maestro.Moneda MO ON MO.ID = CP.IdMoneda INNER JOIN PLE.T10TipoComprobante TC ON TC.ID = CP.IdTipoComprobante INNER JOIN ERP.Entidad ENT ON ENT.ID = CP.IdEntidad INNER JOIN ERP.EntidadTipoDocumento ETD ON ETD.IdEntidad = ENT.ID INNER JOIN PLE.T2TipoDocumento T2 ON T2.ID = ETD.IdTipoDocumento INNER JOIN ERP.Proveedor PRO ON PRO.IdEntidad = ENT.ID WHERE CP.Flag = 1 AND CP.IdEmpresa = @IdEmpresa AND PRO.ID IN (SELECT DATA FROM [ERP].[Fn_SplitContenido] (@ListaProveedor,',')) AND CP.IdTipoComprobante IN (SELECT DATA FROM [ERP].[Fn_SplitContenido] (@ListaTipoComprobante,',')) AND ( (@TipoFecha = 1 AND CAST(CP.Fecha AS DATE) <= CAST(@Fecha AS DATE)) OR (@TipoFecha = 2 AND CAST(CP.FechaVencimiento AS DATE) <= CAST(@Fecha AS DATE)) ) AND CP.Total - ISNULL(TD.TotalPago, 0) <> 0 END
/* Navicat Premium Data Transfer Source Server : MARIADB Source Server Type : MariaDB Source Server Version : 100137 Source Host : localhost:3306 Source Schema : web_base_codeigniter Target Server Type : MariaDB Target Server Version : 100137 File Encoding : 65001 Date: 11/02/2019 00:41:16 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for app_config -- ---------------------------- DROP TABLE IF EXISTS `app_config`; CREATE TABLE `app_config` ( `configuration_id` int(11) NOT NULL AUTO_INCREMENT, `configuration` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `description` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, `created_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `created_date` date NULL DEFAULT NULL, `modified_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `modified_date` date NULL DEFAULT NULL, PRIMARY KEY (`configuration_id`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of app_config -- ---------------------------- INSERT INTO `app_config` VALUES (1, 'APP.TEMPLATE.NAV.MENU.SIDEBAR', '1', 'nav menu sidebar behavior default', NULL, NULL, NULL, NULL); -- ---------------------------- -- Table structure for app_constant -- ---------------------------- DROP TABLE IF EXISTS `app_constant`; CREATE TABLE `app_constant` ( `app_variable_id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`app_variable_id`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for app_menu -- ---------------------------- DROP TABLE IF EXISTS `app_menu`; CREATE TABLE `app_menu` ( `menu_id` int(12) NOT NULL AUTO_INCREMENT, `menu_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `menu_icon` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `module_name` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, `type_menu` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `seq_number` int(10) NULL DEFAULT NULL, `parent_id` int(10) NULL DEFAULT NULL, `status` enum('RA','RD') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `created_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `created_date` datetime(0) NULL DEFAULT NULL, `modified_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `modified_date` datetime(0) NULL DEFAULT NULL, PRIMARY KEY (`menu_id`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 115 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of app_menu -- ---------------------------- INSERT INTO `app_menu` VALUES (5, 'Configuration', 'fa-gear', 'app_config', '', 0, 97, NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_menu` VALUES (6, 'Menu', '', 'app_menu', '', 1, 97, NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_menu` VALUES (7, 'Role', '', 'app_role', '', 1, 97, NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_menu` VALUES (9, 'Role Menu', '', 'app_role_menu', '', 1, 97, NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_menu` VALUES (36, 'Table Sequence', '', 'app_table_sequence', '', 1, 97, NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_menu` VALUES (96, 'User Access', '', 'app_resource', NULL, 6, 97, NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_menu` VALUES (97, 'Control Panel', '', '#', '', 2, 0, NULL, NULL, NULL, NULL, NULL); -- ---------------------------- -- Table structure for app_resource -- ---------------------------- DROP TABLE IF EXISTS `app_resource`; CREATE TABLE `app_resource` ( `resource_id` int(11) NOT NULL AUTO_INCREMENT, `role_id` int(11) NULL DEFAULT NULL, `nip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `type` enum('INTERNAL','VENDOR') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `status` enum('RA','RD') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'RA', `created_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `created_date` date NULL DEFAULT NULL, `modified_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `modified_date` date NULL DEFAULT NULL, PRIMARY KEY (`resource_id`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '--------------------------------------------------------------------------------------------------------------------------------------------\r\nSTATUS TABLE SYSTEM column status\r\n--------------------------------------------------------------------------------------------------------------------------------------------\r\nRA = Active Record\r\nRD = Deteled Record' ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of app_resource -- ---------------------------- INSERT INTO `app_resource` VALUES (1, 1, '000001', NULL, 'Admin A', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'RA', NULL, NULL, NULL, NULL); INSERT INTO `app_resource` VALUES (2, 2, '000002', '', 'Admin B', 'authorize', '21232f297a57a5a743894a0e4a801fc3', 'RA', NULL, NULL, NULL, NULL); -- ---------------------------- -- Table structure for app_role -- ---------------------------- DROP TABLE IF EXISTS `app_role`; CREATE TABLE `app_role` ( `role_id` int(10) NOT NULL AUTO_INCREMENT, `role_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `status` enum('RA','RD') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'RA', `created_by` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `created_date` date NULL DEFAULT NULL, `modified_by` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `modified_date` date NULL DEFAULT NULL, PRIMARY KEY (`role_id`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of app_role -- ---------------------------- INSERT INTO `app_role` VALUES (1, 'Super Admin', 'RA', NULL, '2017-04-29', NULL, NULL); INSERT INTO `app_role` VALUES (2, 'SPV', 'RA', NULL, NULL, NULL, NULL); INSERT INTO `app_role` VALUES (3, 'Guest', 'RA', NULL, NULL, NULL, NULL); -- ---------------------------- -- Table structure for app_role_menu -- ---------------------------- DROP TABLE IF EXISTS `app_role_menu`; CREATE TABLE `app_role_menu` ( `role_menu_id` int(12) NOT NULL AUTO_INCREMENT, `role_id` int(11) NULL DEFAULT NULL, `menu_id` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `status` enum('RA','RD') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `created_by` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `created_date` datetime(0) NULL DEFAULT NULL, `modified_by` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `modified_date` datetime(0) NULL DEFAULT NULL, PRIMARY KEY (`role_menu_id`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 249 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of app_role_menu -- ---------------------------- INSERT INTO `app_role_menu` VALUES (14, 1, '6', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (15, 1, '7', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (17, 1, '9', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (177, 1, '36', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (185, 1, '5', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (212, 1, '96', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (231, 1, '97', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (241, 2, '5', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (242, 2, '6', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (243, 2, '7', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (244, 2, '9', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (245, 2, '36', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (246, 2, '96', NULL, NULL, NULL, NULL, NULL); INSERT INTO `app_role_menu` VALUES (248, 2, '97', NULL, NULL, NULL, NULL, NULL); -- ---------------------------- -- Table structure for app_table_sequence -- ---------------------------- DROP TABLE IF EXISTS `app_table_sequence`; CREATE TABLE `app_table_sequence` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'table name or class name', `prefix` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `increment` int(1) NOT NULL DEFAULT 1, `pad` int(11) NOT NULL DEFAULT 8, `row` double NOT NULL DEFAULT 0, `used` double(5, 0) NOT NULL DEFAULT 0, `last_insert_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of app_table_sequence -- ---------------------------- INSERT INTO `app_table_sequence` VALUES (1, 'sln_pesan', 'MSG', 1, 27, 176, 0, 'MSG000000000000000000000000176'); INSERT INTO `app_table_sequence` VALUES (2, 'sln_pesan_session', 'SPS', 1, 27, 43, 0, 'SPS000000000000000000000000043'); INSERT INTO `app_table_sequence` VALUES (3, 'sln_partisipan', 'SPN', 1, 27, 75, 0, 'SPN000000000000000000000000075'); INSERT INTO `app_table_sequence` VALUES (4, 'Sln_sample_generator', 'SSG', 1, 8, 0, 0, ''); -- ---------------------------- -- Table structure for test_sample_generator -- ---------------------------- DROP TABLE IF EXISTS `test_sample_generator`; CREATE TABLE `test_sample_generator` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL, `address` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL, `telp` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of test_sample_generator -- ---------------------------- INSERT INTO `test_sample_generator` VALUES (1, 'Zuliadin', 'Tangerang', '081284190270'); SET FOREIGN_KEY_CHECKS = 1;
--liquibase formatted sql --changeset tomas:update_person_balance_view_table splitStatements:false CREATE OR REPLACE VIEW public.person_balance AS SELECT debt_calculation.person_id, debt_calculation.debt_total, credit_calculation.credit_total FROM ( SELECT per.id AS person_id, sum((p.unit_price - p.unit_price * sl.discount / 100)::double precision * sl.quantity) AS debt_total FROM sale s, saleline sl, batch b, product p, person per WHERE s.paied_out = false AND b.product = p.id AND per.id = s.person AND sl.sale_id = s.id AND b.id = sl.batch GROUP BY per.id) debt_calculation LEFT JOIN ( SELECT per.id AS person_id, sum(settl.amount) AS credit_total FROM settlement settl, person per WHERE settl.discounted = false AND per.id = settl.person GROUP BY per.id) credit_calculation ON credit_calculation.person_id = debt_calculation.person_id;
-- **************************************************** -- ** 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_CWH', @scm, 'CM_Org_CWH', 'Chelsea & Westminster', 'Chelsea and Westminster Hospital, London'), (1, 'CM_Sys_Cerner', @scm, 'CM_Sys_Cerner', 'Cerner Millennium', 'Cerner Millennium system'), (1, 'CWHCerner', @scm, 'CWHCerner', 'Chelsea & Westminster Local Codes', 'Chelsea & Westminster Cerner local code scheme'), (1, 'DM_patientFIN', @scm, 'DM_patientFIN', 'Patient FIN', 'Patient FIN'), (1, 'CM_GPPractitionerId', @scm, 'CM_GPPractitionerId', 'GP Practitioner Id', 'GP Practitioner Id'); INSERT IGNORE INTO concept_property_data (`dbid`, `group`, `property`, `value`) SELECT c.dbid, 0 AS `group`, p.dbid AS `property`, 'CWH_' AS `value` FROM concept c JOIN concept p ON p.id = 'code_prefix' WHERE c.id = 'CWHCerner'; -- ******************** Religion ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'religion', '/CWH/CRNR/RLGN'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/CWH/CRNR/RLGN', 'DM_religion'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/CWH/CRNR/RLGN', 'HINDU', 'CWHCerner', 'CM_ReligionD1'), ('/CWH/CRNR/RLGN', 'OTHER', 'CWHCerner', 'CM_ReligionK20'), ('/CWH/CRNR/RLGN', 'SIKH', 'CWHCerner', 'CM_ReligionI1'), ('/CWH/CRNR/RLGN', 'A', 'CWHCerner', 'CM_ReligionA1'), ('/CWH/CRNR/RLGN', 'BUDDHISM', 'CWHCerner', 'CM_ReligionB1'), ('/CWH/CRNR/RLGN', 'CHRISTIAN', 'CWHCerner', 'CM_ReligionC1'), ('/CWH/CRNR/RLGN', 'M', 'CWHCerner', 'CM_ReligionM1'), ('/CWH/CRNR/RLGN', 'E', 'CWHCerner', 'CM_ReligionE1'), ('/CWH/CRNR/RLGN', 'JUDAISM', 'CWHCerner', 'CM_ReligionF1'), ('/CWH/CRNR/RLGN', 'G', 'CWHCerner', 'CM_ReligionG1'), ('/CWH/CRNR/RLGN', 'L', 'CWHCerner', 'CM_ReligionL2'), ('/CWH/CRNR/RLGN', 'H', 'CWHCerner', 'CM_ReligionH1'), ('/CWH/CRNR/RLGN', 'N', 'CWHCerner', 'CM_ReligionN1'), ('/CWH/CRNR/RLGN', 'J', 'CWHCerner', 'CM_ReligionJ1'), ('/CWH/CRNR/RLGN', 'GREEKORTH', 'CWHCerner', 'CM_ReligionC41'), ('/CWH/CRNR/RLGN', 'RCATHOLIC', 'CWHCerner', 'CM_ReligionC67'); -- ******************** Language ******************** -- Concepts SELECT @scm := dbid FROM concept WHERE id = 'CWHCerner'; INSERT IGNORE INTO concept (document, id, scheme, code, name, description) VALUES (1, 'CWH_Lang_8', @scm, 'CWH_Lang_8', 'Cantonese', 'Cantonese'), (1, 'CWH_Lang_10', @scm, 'CWH_Lang_10', 'Creole', 'Creole'), (1, 'CWH_Lang_13', @scm, 'CWH_Lang_13', 'Ethiopian', 'Ethiopian'), (1, 'CWH_Lang_18', @scm, 'CWH_Lang_18', 'French Creole', 'French Creole'), (1, 'CWH_Lang_23', @scm, 'CWH_Lang_23', 'Hakka', 'Hakka'), (1, 'CWH_Lang_33', @scm, 'CWH_Lang_33', 'Luganda', 'Luganda'), (1, 'CWH_Lang_36', @scm, 'CWH_Lang_36', 'Mandarin', 'Mandarin'), (1, 'CWH_Lang_200', @scm, 'CWH_Lang_200', 'Other', 'Other'), (1, 'CWH_Lang_39', @scm, 'CWH_Lang_39', 'Patois', 'Patois'), (1, 'CWH_Lang_44', @scm, 'CWH_Lang_44', 'Serbo-Croat', 'Serbo-Croat'), (1, 'CWH_Lang_51', @scm, 'CWH_Lang_51', 'Sylheti', 'Sylheti'); -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'language', '/CWH/CRNR/LNGG'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/CWH/CRNR/LNGG', 'DM_language'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/CWH/CRNR/LNGG', '1', 'CWHCerner', 'FHIR_LANG_ak'), ('/CWH/CRNR/LNGG', '3', 'CWHCerner', 'FHIR_LANG_am'), ('/CWH/CRNR/LNGG', '4', 'CWHCerner', 'FHIR_LANG_ar'), ('/CWH/CRNR/LNGG', '5', 'CWHCerner', 'FHIR_LANG_bn'), ('/CWH/CRNR/LNGG', '59', 'CWHCerner', 'FHIR_LANG_cy'), ('/CWH/CRNR/LNGG', '20', 'CWHCerner', 'FHIR_LANG_de'), ('/CWH/CRNR/LNGG', '21', 'CWHCerner', 'FHIR_LANG_el'), ('/CWH/CRNR/LNGG', '12', 'CWHCerner', 'FHIR_LANG_en'), ('/CWH/CRNR/LNGG', '48', 'CWHCerner', 'FHIR_LANG_es'), ('/CWH/CRNR/LNGG', '14', 'CWHCerner', 'FHIR_LANG_fa'), ('/CWH/CRNR/LNGG', '15', 'CWHCerner', 'FHIR_LANG_fi'), ('/CWH/CRNR/LNGG', '17', 'CWHCerner', 'FHIR_LANG_fr'), ('/CWH/CRNR/LNGG', '19', 'CWHCerner', 'FHIR_LANG_gd'), ('/CWH/CRNR/LNGG', '22', 'CWHCerner', 'FHIR_LANG_gu'), ('/CWH/CRNR/LNGG', '24', 'CWHCerner', 'FHIR_LANG_ha'), ('/CWH/CRNR/LNGG', '25', 'CWHCerner', 'FHIR_LANG_he'), ('/CWH/CRNR/LNGG', '26', 'CWHCerner', 'FHIR_LANG_hi'), ('/CWH/CRNR/LNGG', '27', 'CWHCerner', 'FHIR_LANG_ig'), ('/CWH/CRNR/LNGG', '28', 'CWHCerner', 'FHIR_LANG_it'), ('/CWH/CRNR/LNGG', '29', 'CWHCerner', 'FHIR_LANG_ja'), ('/CWH/CRNR/LNGG', '30', 'CWHCerner', 'FHIR_LANG_ko'), ('/CWH/CRNR/LNGG', '31', 'CWHCerner', 'FHIR_LANG_ku'), ('/CWH/CRNR/LNGG', '32', 'CWHCerner', 'FHIR_LANG_ln'), ('/CWH/CRNR/LNGG', '35', 'CWHCerner', 'FHIR_LANG_ml'), ('/CWH/CRNR/LNGG', '11', 'CWHCerner', 'FHIR_LANG_nl'), ('/CWH/CRNR/LNGG', '16', 'CWHCerner', 'FHIR_LANG_nl'), ('/CWH/CRNR/LNGG', '37', 'CWHCerner', 'FHIR_LANG_no'), ('/CWH/CRNR/LNGG', '42', 'CWHCerner', 'FHIR_LANG_pa'), ('/CWH/CRNR/LNGG', '40', 'CWHCerner', 'FHIR_LANG_pl'), ('/CWH/CRNR/LNGG', '38', 'CWHCerner', 'FHIR_LANG_ps'), ('/CWH/CRNR/LNGG', '41', 'CWHCerner', 'FHIR_LANG_pt'), ('/CWH/CRNR/LNGG', '43', 'CWHCerner', 'FHIR_LANG_ru'), ('/CWH/CRNR/LNGG', '45', 'CWHCerner', 'FHIR_LANG_si'), ('/CWH/CRNR/LNGG', '6', 'CWHCerner', 'FHIR_LANG_so'), ('/CWH/CRNR/LNGG', '46', 'CWHCerner', 'FHIR_LANG_so'), ('/CWH/CRNR/LNGG', '2', 'CWHCerner', 'FHIR_LANG_sq'), ('/CWH/CRNR/LNGG', '50', 'CWHCerner', 'FHIR_LANG_sv'), ('/CWH/CRNR/LNGG', '49', 'CWHCerner', 'FHIR_LANG_sw'), ('/CWH/CRNR/LNGG', '53', 'CWHCerner', 'FHIR_LANG_ta'), ('/CWH/CRNR/LNGG', '54', 'CWHCerner', 'FHIR_LANG_th'), ('/CWH/CRNR/LNGG', '55', 'CWHCerner', 'FHIR_LANG_ti'), ('/CWH/CRNR/LNGG', '52', 'CWHCerner', 'FHIR_LANG_tl'), ('/CWH/CRNR/LNGG', '56', 'CWHCerner', 'FHIR_LANG_tr'), ('/CWH/CRNR/LNGG', '57', 'CWHCerner', 'FHIR_LANG_ur'), ('/CWH/CRNR/LNGG', '9', 'CWHCerner', 'FHIR_LANG_vi'), ('/CWH/CRNR/LNGG', '58', 'CWHCerner', 'FHIR_LANG_vi'), ('/CWH/CRNR/LNGG', '60', 'CWHCerner', 'FHIR_LANG_yo'), ('/CWH/CRNR/LNGG', '7', 'CWHCerner', 'FHIR_LANG_q4'), ('/CWH/CRNR/LNGG', '34', 'CWHCerner', 'FHIR_LANG_q5'), -- Local ('/CWH/CRNR/LNGG', '8', 'CWHCerner', 'CWH_Lang_8'), ('/CWH/CRNR/LNGG', '10', 'CWHCerner', 'CWH_Lang_10'), ('/CWH/CRNR/LNGG', '13', 'CWHCerner', 'CWH_Lang_13'), ('/CWH/CRNR/LNGG', '18', 'CWHCerner', 'CWH_Lang_18'), ('/CWH/CRNR/LNGG', '23', 'CWHCerner', 'CWH_Lang_23'), ('/CWH/CRNR/LNGG', '33', 'CWHCerner', 'CWH_Lang_33'), ('/CWH/CRNR/LNGG', '36', 'CWHCerner', 'CWH_Lang_36'), ('/CWH/CRNR/LNGG', '200', 'CWHCerner', 'CWH_Lang_200'), ('/CWH/CRNR/LNGG', '39', 'CWHCerner', 'CWH_Lang_39'), ('/CWH/CRNR/LNGG', '44', 'CWHCerner', 'CWH_Lang_44'), ('/CWH/CRNR/LNGG', '51', 'CWHCerner', 'CWH_Lang_51'); -- ******************** FIN Number ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'fin_number', '/CWH/CRNR/FN_NMBR'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/CWH/CRNR/FN_NMBR', 'DM_patientFIN'); -- ******************** Encounter ******************** -- Concepts SELECT @scm := dbid FROM concept WHERE id = 'CWHCerner'; INSERT IGNORE INTO concept (document, id, scheme, code, name, description) VALUES (1, 'CWH_Enc_DayCase', @scm, 'CWH_Enc_DayCase', 'Day case', 'Day case'), (1, 'CWH_Enc_Inpatient', @scm, 'CWH_Enc_Inpatient', 'Inpatient', 'Inpatient'), (1, 'CWH_Enc_Maternity', @scm, 'CWH_Enc_Maternity', 'Maternity', 'Maternity'), (1, 'CWH_Enc_Newborn', @scm, 'CWH_Enc_Newborn', 'Newborn', 'Newborn'), (1, 'CWH_Enc_RegRDayAdm', @scm, 'CWH_Enc_RegRDayAdm', 'Regular day admission', 'Regular day admission'), (1, 'CWH_Enc_RegNghtAdm', @scm, 'CWH_Enc_RegNghtAdm', 'Regular night admission', 'Regular night admission'), (1, 'CWH_Enc_DirectRef', @scm, 'CWH_Enc_DirectRef', 'Direct referral', 'Direct referral'), (1, 'CWH_Enc_Emergency', @scm, 'CWH_Enc_Emergency', 'Emergency department', 'Emergency department'), (1, 'CWH_Enc_Outpatient', @scm, 'CWH_Enc_Outpatient', 'Outpatient', 'Outpatient'), (1, 'CWH_Enc_DCWL', @scm, 'CWH_Enc_DCWL', 'Day case waiting list', 'Day case waiting list'), (1, 'CWH_Enc_PreReg', @scm, 'CWH_Enc_PreReg', 'Preregistration', 'Preregistration'), (1, 'CWH_Enc_IPWL', @scm, 'CWH_Enc_IPWL', 'Inpatient waiting list', 'Inpatient waiting list'), (1, 'CWH_Enc_PreAdmit', @scm, 'CWH_Enc_PreAdmit', 'Outpatient registration', 'Outpatient registration'), (1, 'CWH_Enc_OPReferral', @scm, 'CWH_Enc_OPReferral', 'Outpatient referral', 'Outpatient referral'); -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'encounter_type', '/CWH/CRNR/ENCNTR_TYP'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/CWH/CRNR/ENCNTR_TYP', 'DM_admissionPatientClassification'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/CWH/CRNR/ENCNTR_TYP', 'DAYCASE', 'CWHCerner', 'CWH_Enc_DayCase'), ('/CWH/CRNR/ENCNTR_TYP', 'INPATIENT', 'CWHCerner', 'CWH_Enc_Inpatient'), ('/CWH/CRNR/ENCNTR_TYP', 'MATERNITY', 'CWHCerner', 'CWH_Enc_Maternity'), ('/CWH/CRNR/ENCNTR_TYP', 'NEWBORN', 'CWHCerner', 'CWH_Enc_Newborn'), ('/CWH/CRNR/ENCNTR_TYP', 'REGRDAYADM', 'CWHCerner', 'CWH_Enc_RegRDayAdm'), ('/CWH/CRNR/ENCNTR_TYP', 'REGNGHTADM', 'CWHCerner', 'CWH_Enc_RegNghtAdm'), ('/CWH/CRNR/ENCNTR_TYP', 'DIRECTREF', 'CWHCerner', 'CWH_Enc_DirectRef'), ('/CWH/CRNR/ENCNTR_TYP', 'EMERGENCY', 'CWHCerner', 'CWH_Enc_Emergency'), ('/CWH/CRNR/ENCNTR_TYP', 'OUTPATIENT', 'CWHCerner', 'CWH_Enc_Outpatient'), ('/CWH/CRNR/ENCNTR_TYP', 'DCWL', 'CWHCerner', 'CWH_Enc_DCWL'), ('/CWH/CRNR/ENCNTR_TYP', 'PREREG', 'CWHCerner', 'CWH_Enc_PreReg'), ('/CWH/CRNR/ENCNTR_TYP', 'IPWL', 'CWHCerner', 'CWH_Enc_IPWL'), ('/CWH/CRNR/ENCNTR_TYP', 'PREADMIT', 'CWHCerner', 'CWH_Enc_PreAdmit'), ('/CWH/CRNR/ENCNTR_TYP', 'OPREFERRAL', 'CWHCerner', 'CWH_Enc_OPReferral'); -- ******************** Treatment Function ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'treatment_function_code', '/CWH/CRNR/TRTMNT_FNCTN'); -- Local -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/CWH/CRNR/TRTMNT_FNCTN', 'DM_treatmentFunctionAdmit'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/CWH/CRNR/TRTMNT_FNCTN', '100', 'CWHCerner', 'CM_TrtmntFnc100'), ('/CWH/CRNR/TRTMNT_FNCTN', '101', 'CWHCerner', 'CM_TrtmntFnc101'), ('/CWH/CRNR/TRTMNT_FNCTN', '102', 'CWHCerner', 'CM_TrtmntFnc102'), ('/CWH/CRNR/TRTMNT_FNCTN', '103', 'CWHCerner', 'CM_TrtmntFnc103'), ('/CWH/CRNR/TRTMNT_FNCTN', '104', 'CWHCerner', 'CM_TrtmntFnc104'), ('/CWH/CRNR/TRTMNT_FNCTN', '105', 'CWHCerner', 'CM_TrtmntFnc105'), ('/CWH/CRNR/TRTMNT_FNCTN', '106', 'CWHCerner', 'CM_TrtmntFnc106'), ('/CWH/CRNR/TRTMNT_FNCTN', '107', 'CWHCerner', 'CM_TrtmntFnc107'), ('/CWH/CRNR/TRTMNT_FNCTN', '108', 'CWHCerner', 'CM_TrtmntFnc108'), ('/CWH/CRNR/TRTMNT_FNCTN', '110', 'CWHCerner', 'CM_TrtmntFnc110'), ('/CWH/CRNR/TRTMNT_FNCTN', '120', 'CWHCerner', 'CM_TrtmntFnc120'), ('/CWH/CRNR/TRTMNT_FNCTN', '130', 'CWHCerner', 'CM_TrtmntFnc130'), ('/CWH/CRNR/TRTMNT_FNCTN', '140', 'CWHCerner', 'CM_TrtmntFnc140'), ('/CWH/CRNR/TRTMNT_FNCTN', '141', 'CWHCerner', 'CM_TrtmntFnc141'), ('/CWH/CRNR/TRTMNT_FNCTN', '142', 'CWHCerner', 'CM_TrtmntFnc142'), ('/CWH/CRNR/TRTMNT_FNCTN', '143', 'CWHCerner', 'CM_TrtmntFnc143'), ('/CWH/CRNR/TRTMNT_FNCTN', '144', 'CWHCerner', 'CM_TrtmntFnc144'), ('/CWH/CRNR/TRTMNT_FNCTN', '150', 'CWHCerner', 'CM_TrtmntFnc150'), ('/CWH/CRNR/TRTMNT_FNCTN', '160', 'CWHCerner', 'CM_TrtmntFnc160'), ('/CWH/CRNR/TRTMNT_FNCTN', '161', 'CWHCerner', 'CM_TrtmntFnc161'), ('/CWH/CRNR/TRTMNT_FNCTN', '170', 'CWHCerner', 'CM_TrtmntFnc170'), ('/CWH/CRNR/TRTMNT_FNCTN', '171', 'CWHCerner', 'CM_TrtmntFnc171'), ('/CWH/CRNR/TRTMNT_FNCTN', '172', 'CWHCerner', 'CM_TrtmntFnc172'), ('/CWH/CRNR/TRTMNT_FNCTN', '173', 'CWHCerner', 'CM_TrtmntFnc173'), ('/CWH/CRNR/TRTMNT_FNCTN', '174', 'CWHCerner', 'CM_TrtmntFnc174'), ('/CWH/CRNR/TRTMNT_FNCTN', '180', 'CWHCerner', 'CM_TrtmntFnc180'), ('/CWH/CRNR/TRTMNT_FNCTN', '190', 'CWHCerner', 'CM_TrtmntFnc190'), ('/CWH/CRNR/TRTMNT_FNCTN', '191', 'CWHCerner', 'CM_TrtmntFnc191'), ('/CWH/CRNR/TRTMNT_FNCTN', '192', 'CWHCerner', 'CM_TrtmntFnc192'), ('/CWH/CRNR/TRTMNT_FNCTN', '211', 'CWHCerner', 'CM_TrtmntFnc211'), ('/CWH/CRNR/TRTMNT_FNCTN', '212', 'CWHCerner', 'CM_TrtmntFnc212'), ('/CWH/CRNR/TRTMNT_FNCTN', '213', 'CWHCerner', 'CM_TrtmntFnc213'), ('/CWH/CRNR/TRTMNT_FNCTN', '214', 'CWHCerner', 'CM_TrtmntFnc214'), ('/CWH/CRNR/TRTMNT_FNCTN', '215', 'CWHCerner', 'CM_TrtmntFnc215'), ('/CWH/CRNR/TRTMNT_FNCTN', '216', 'CWHCerner', 'CM_TrtmntFnc216'), ('/CWH/CRNR/TRTMNT_FNCTN', '217', 'CWHCerner', 'CM_TrtmntFnc217'), ('/CWH/CRNR/TRTMNT_FNCTN', '218', 'CWHCerner', 'CM_TrtmntFnc218'), ('/CWH/CRNR/TRTMNT_FNCTN', '219', 'CWHCerner', 'CM_TrtmntFnc219'), ('/CWH/CRNR/TRTMNT_FNCTN', '220', 'CWHCerner', 'CM_TrtmntFnc220'), ('/CWH/CRNR/TRTMNT_FNCTN', '221', 'CWHCerner', 'CM_TrtmntFnc221'), ('/CWH/CRNR/TRTMNT_FNCTN', '222', 'CWHCerner', 'CM_TrtmntFnc222'), ('/CWH/CRNR/TRTMNT_FNCTN', '223', 'CWHCerner', 'CM_TrtmntFnc223'), ('/CWH/CRNR/TRTMNT_FNCTN', '241', 'CWHCerner', 'CM_TrtmntFnc241'), ('/CWH/CRNR/TRTMNT_FNCTN', '242', 'CWHCerner', 'CM_TrtmntFnc242'), ('/CWH/CRNR/TRTMNT_FNCTN', '251', 'CWHCerner', 'CM_TrtmntFnc251'), ('/CWH/CRNR/TRTMNT_FNCTN', '252', 'CWHCerner', 'CM_TrtmntFnc252'), ('/CWH/CRNR/TRTMNT_FNCTN', '253', 'CWHCerner', 'CM_TrtmntFnc253'), ('/CWH/CRNR/TRTMNT_FNCTN', '254', 'CWHCerner', 'CM_TrtmntFnc254'), ('/CWH/CRNR/TRTMNT_FNCTN', '255', 'CWHCerner', 'CM_TrtmntFnc255'), ('/CWH/CRNR/TRTMNT_FNCTN', '256', 'CWHCerner', 'CM_TrtmntFnc256'), ('/CWH/CRNR/TRTMNT_FNCTN', '257', 'CWHCerner', 'CM_TrtmntFnc257'), ('/CWH/CRNR/TRTMNT_FNCTN', '258', 'CWHCerner', 'CM_TrtmntFnc258'), ('/CWH/CRNR/TRTMNT_FNCTN', '259', 'CWHCerner', 'CM_TrtmntFnc259'), ('/CWH/CRNR/TRTMNT_FNCTN', '260', 'CWHCerner', 'CM_TrtmntFnc260'), ('/CWH/CRNR/TRTMNT_FNCTN', '261', 'CWHCerner', 'CM_TrtmntFnc261'), ('/CWH/CRNR/TRTMNT_FNCTN', '262', 'CWHCerner', 'CM_TrtmntFnc262'), ('/CWH/CRNR/TRTMNT_FNCTN', '263', 'CWHCerner', 'CM_TrtmntFnc263'), ('/CWH/CRNR/TRTMNT_FNCTN', '264', 'CWHCerner', 'CM_TrtmntFnc264'), ('/CWH/CRNR/TRTMNT_FNCTN', '280', 'CWHCerner', 'CM_TrtmntFnc280'), ('/CWH/CRNR/TRTMNT_FNCTN', '290', 'CWHCerner', 'CM_TrtmntFnc290'), ('/CWH/CRNR/TRTMNT_FNCTN', '291', 'CWHCerner', 'CM_TrtmntFnc291'), ('/CWH/CRNR/TRTMNT_FNCTN', '300', 'CWHCerner', 'CM_TrtmntFnc300'), ('/CWH/CRNR/TRTMNT_FNCTN', '301', 'CWHCerner', 'CM_TrtmntFnc301'), ('/CWH/CRNR/TRTMNT_FNCTN', '302', 'CWHCerner', 'CM_TrtmntFnc302'), ('/CWH/CRNR/TRTMNT_FNCTN', '303', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '304', 'CWHCerner', 'CM_TrtmntFnc304'), ('/CWH/CRNR/TRTMNT_FNCTN', '305', 'CWHCerner', 'CM_TrtmntFnc305'), ('/CWH/CRNR/TRTMNT_FNCTN', '306', 'CWHCerner', 'CM_TrtmntFnc306'), ('/CWH/CRNR/TRTMNT_FNCTN', '307', 'CWHCerner', 'CM_TrtmntFnc307'), ('/CWH/CRNR/TRTMNT_FNCTN', '308', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '309', 'CWHCerner', 'CM_TrtmntFnc309'), ('/CWH/CRNR/TRTMNT_FNCTN', '310', 'CWHCerner', 'CM_TrtmntFnc310'), ('/CWH/CRNR/TRTMNT_FNCTN', '311', 'CWHCerner', 'CM_TrtmntFnc311'), ('/CWH/CRNR/TRTMNT_FNCTN', '313', 'CWHCerner', 'CM_TrtmntFnc313'), ('/CWH/CRNR/TRTMNT_FNCTN', '314', 'CWHCerner', 'CM_TrtmntFnc314'), ('/CWH/CRNR/TRTMNT_FNCTN', '315', 'CWHCerner', 'CM_TrtmntFnc315'), ('/CWH/CRNR/TRTMNT_FNCTN', '316', 'CWHCerner', 'CM_TrtmntFnc316'), ('/CWH/CRNR/TRTMNT_FNCTN', '317', 'CWHCerner', 'CM_TrtmntFnc317'), ('/CWH/CRNR/TRTMNT_FNCTN', '318', 'CWHCerner', 'CM_TrtmntFnc318'), ('/CWH/CRNR/TRTMNT_FNCTN', '319', 'CWHCerner', 'CM_TrtmntFnc319'), ('/CWH/CRNR/TRTMNT_FNCTN', '320', 'CWHCerner', 'CM_TrtmntFnc320'), ('/CWH/CRNR/TRTMNT_FNCTN', '321', 'CWHCerner', 'CM_TrtmntFnc321'), ('/CWH/CRNR/TRTMNT_FNCTN', '322', 'CWHCerner', 'CM_TrtmntFnc322'), ('/CWH/CRNR/TRTMNT_FNCTN', '323', 'CWHCerner', 'CM_TrtmntFnc323'), ('/CWH/CRNR/TRTMNT_FNCTN', '324', 'CWHCerner', 'CM_TrtmntFnc324'), ('/CWH/CRNR/TRTMNT_FNCTN', '325', 'CWHCerner', 'CM_TrtmntFnc325'), ('/CWH/CRNR/TRTMNT_FNCTN', '327', 'CWHCerner', 'CM_TrtmntFnc327'), ('/CWH/CRNR/TRTMNT_FNCTN', '328', 'CWHCerner', 'CM_TrtmntFnc328'), ('/CWH/CRNR/TRTMNT_FNCTN', '329', 'CWHCerner', 'CM_TrtmntFnc329'), ('/CWH/CRNR/TRTMNT_FNCTN', '330', 'CWHCerner', 'CM_TrtmntFnc330'), ('/CWH/CRNR/TRTMNT_FNCTN', '331', 'CWHCerner', 'CM_TrtmntFnc331'), ('/CWH/CRNR/TRTMNT_FNCTN', '340', 'CWHCerner', 'CM_TrtmntFnc340'), ('/CWH/CRNR/TRTMNT_FNCTN', '341', 'CWHCerner', 'CM_TrtmntFnc341'), ('/CWH/CRNR/TRTMNT_FNCTN', '342', 'CWHCerner', 'CM_TrtmntFnc342'), ('/CWH/CRNR/TRTMNT_FNCTN', '343', 'CWHCerner', 'CM_TrtmntFnc343'), ('/CWH/CRNR/TRTMNT_FNCTN', '344', 'CWHCerner', 'CM_TrtmntFnc344'), ('/CWH/CRNR/TRTMNT_FNCTN', '346', 'CWHCerner', 'CM_TrtmntFnc346'), ('/CWH/CRNR/TRTMNT_FNCTN', '350', 'CWHCerner', 'CM_TrtmntFnc350'), ('/CWH/CRNR/TRTMNT_FNCTN', '352', 'CWHCerner', 'CM_TrtmntFnc352'), ('/CWH/CRNR/TRTMNT_FNCTN', '360', 'CWHCerner', 'CM_TrtmntFnc360'), ('/CWH/CRNR/TRTMNT_FNCTN', '361', 'CWHCerner', 'CM_TrtmntFnc361'), ('/CWH/CRNR/TRTMNT_FNCTN', '370', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '371', 'CWHCerner', 'CM_TrtmntFnc371'), ('/CWH/CRNR/TRTMNT_FNCTN', '400', 'CWHCerner', 'CM_TrtmntFnc400'), ('/CWH/CRNR/TRTMNT_FNCTN', '410', 'CWHCerner', 'CM_TrtmntFnc410'), ('/CWH/CRNR/TRTMNT_FNCTN', '420', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '421', 'CWHCerner', 'CM_TrtmntFnc421'), ('/CWH/CRNR/TRTMNT_FNCTN', '422', 'CWHCerner', 'CM_TrtmntFnc422'), ('/CWH/CRNR/TRTMNT_FNCTN', '424', 'CWHCerner', 'CM_TrtmntFnc424'), ('/CWH/CRNR/TRTMNT_FNCTN', '430', 'CWHCerner', 'CM_TrtmntFnc430'), ('/CWH/CRNR/TRTMNT_FNCTN', '450', 'CWHCerner', 'CM_TrtmntFnc450'), ('/CWH/CRNR/TRTMNT_FNCTN', '460', 'CWHCerner', 'CM_TrtmntFnc460'), ('/CWH/CRNR/TRTMNT_FNCTN', '501', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '502', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '503', 'CWHCerner', 'CM_TrtmntFnc503'), ('/CWH/CRNR/TRTMNT_FNCTN', '560', 'CWHCerner', 'CM_TrtmntFnc560'), ('/CWH/CRNR/TRTMNT_FNCTN', '650', 'CWHCerner', 'CM_TrtmntFnc650'), ('/CWH/CRNR/TRTMNT_FNCTN', '651', 'CWHCerner', 'CM_TrtmntFnc651'), ('/CWH/CRNR/TRTMNT_FNCTN', '652', 'CWHCerner', 'CM_TrtmntFnc652'), ('/CWH/CRNR/TRTMNT_FNCTN', '653', 'CWHCerner', 'CM_TrtmntFnc653'), ('/CWH/CRNR/TRTMNT_FNCTN', '654', 'CWHCerner', 'CM_TrtmntFnc654'), ('/CWH/CRNR/TRTMNT_FNCTN', '655', 'CWHCerner', 'CM_TrtmntFnc655'), ('/CWH/CRNR/TRTMNT_FNCTN', '656', 'CWHCerner', 'CM_TrtmntFnc656'), ('/CWH/CRNR/TRTMNT_FNCTN', '657', 'CWHCerner', 'CM_TrtmntFnc657'), ('/CWH/CRNR/TRTMNT_FNCTN', '658', 'CWHCerner', 'CM_TrtmntFnc658'), ('/CWH/CRNR/TRTMNT_FNCTN', '659', 'CWHCerner', 'CM_TrtmntFnc659'), ('/CWH/CRNR/TRTMNT_FNCTN', '660', 'CWHCerner', 'CM_TrtmntFnc660'), ('/CWH/CRNR/TRTMNT_FNCTN', '661', 'CWHCerner', 'CM_TrtmntFnc661'), ('/CWH/CRNR/TRTMNT_FNCTN', '662', 'CWHCerner', 'CM_TrtmntFnc662'), ('/CWH/CRNR/TRTMNT_FNCTN', '663', 'CWHCerner', 'CM_TrtmntFnc663'), ('/CWH/CRNR/TRTMNT_FNCTN', '700', 'CWHCerner', 'CM_TrtmntFnc700'), ('/CWH/CRNR/TRTMNT_FNCTN', '710', 'CWHCerner', 'CM_TrtmntFnc710'), ('/CWH/CRNR/TRTMNT_FNCTN', '711', 'CWHCerner', 'CM_TrtmntFnc711'), ('/CWH/CRNR/TRTMNT_FNCTN', '712', 'CWHCerner', 'CM_TrtmntFnc712'), ('/CWH/CRNR/TRTMNT_FNCTN', '713', 'CWHCerner', 'CM_TrtmntFnc713'), ('/CWH/CRNR/TRTMNT_FNCTN', '715', 'CWHCerner', 'CM_TrtmntFnc715'), ('/CWH/CRNR/TRTMNT_FNCTN', '720', 'CWHCerner', 'CM_TrtmntFnc720'), ('/CWH/CRNR/TRTMNT_FNCTN', '721', 'CWHCerner', 'CM_TrtmntFnc721'), ('/CWH/CRNR/TRTMNT_FNCTN', '722', 'CWHCerner', 'CM_TrtmntFnc722'), ('/CWH/CRNR/TRTMNT_FNCTN', '723', 'CWHCerner', 'CM_TrtmntFnc723'), ('/CWH/CRNR/TRTMNT_FNCTN', '724', 'CWHCerner', 'CM_TrtmntFnc724'), ('/CWH/CRNR/TRTMNT_FNCTN', '725', 'CWHCerner', 'CM_TrtmntFnc725'), ('/CWH/CRNR/TRTMNT_FNCTN', '726', 'CWHCerner', 'CM_TrtmntFnc726'), ('/CWH/CRNR/TRTMNT_FNCTN', '727', 'CWHCerner', 'CM_TrtmntFnc727'), ('/CWH/CRNR/TRTMNT_FNCTN', '800', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '811', 'CWHCerner', 'CM_TrtmntFnc811'), ('/CWH/CRNR/TRTMNT_FNCTN', '812', 'CWHCerner', 'CM_TrtmntFnc812'), ('/CWH/CRNR/TRTMNT_FNCTN', '822', 'CWHCerner', 'CM_TrtmntFnc822'), ('/CWH/CRNR/TRTMNT_FNCTN', '834', 'CWHCerner', 'CM_TrtmntFnc834'), ('/CWH/CRNR/TRTMNT_FNCTN', '840', 'CWHCerner', 'CM_TrtmntFnc840'), ('/CWH/CRNR/TRTMNT_FNCTN', '920', 'CWHCerner', 'CM_TrtmntFnc920'), ('/CWH/CRNR/TRTMNT_FNCTN', '10001', 'CWHCerner', 'CM_TrtmntFnc100'), ('/CWH/CRNR/TRTMNT_FNCTN', '10002', 'CWHCerner', 'CM_TrtmntFnc100'), ('/CWH/CRNR/TRTMNT_FNCTN', '10099', 'CWHCerner', 'CM_TrtmntFnc100'), ('/CWH/CRNR/TRTMNT_FNCTN', '10101', 'CWHCerner', 'CM_TrtmntFnc101'), ('/CWH/CRNR/TRTMNT_FNCTN', '10102', 'CWHCerner', 'CM_TrtmntFnc101'), ('/CWH/CRNR/TRTMNT_FNCTN', '10130', 'CWHCerner', 'CM_TrtmntFnc101'), ('/CWH/CRNR/TRTMNT_FNCTN', '10199', 'CWHCerner', 'CM_TrtmntFnc101'), ('/CWH/CRNR/TRTMNT_FNCTN', '10240', 'CWHCerner', 'CM_TrtmntFnc102'), ('/CWH/CRNR/TRTMNT_FNCTN', '10246', 'CWHCerner', 'CM_TrtmntFnc102'), ('/CWH/CRNR/TRTMNT_FNCTN', '10299', 'CWHCerner', 'CM_TrtmntFnc102'), ('/CWH/CRNR/TRTMNT_FNCTN', '10399', 'CWHCerner', 'CM_TrtmntFnc103'), ('/CWH/CRNR/TRTMNT_FNCTN', '10499', 'CWHCerner', 'CM_TrtmntFnc104'), ('/CWH/CRNR/TRTMNT_FNCTN', '10539', 'CWHCerner', 'CM_TrtmntFnc105'), ('/CWH/CRNR/TRTMNT_FNCTN', '10599', 'CWHCerner', 'CM_TrtmntFnc105'), ('/CWH/CRNR/TRTMNT_FNCTN', '10699', 'CWHCerner', 'CM_TrtmntFnc106'), ('/CWH/CRNR/TRTMNT_FNCTN', '10701', 'CWHCerner', 'CM_TrtmntFnc107'), ('/CWH/CRNR/TRTMNT_FNCTN', '10799', 'CWHCerner', 'CM_TrtmntFnc107'), ('/CWH/CRNR/TRTMNT_FNCTN', '11001', 'CWHCerner', 'CM_TrtmntFnc110'), ('/CWH/CRNR/TRTMNT_FNCTN', '11002', 'CWHCerner', 'CM_TrtmntFnc110'), ('/CWH/CRNR/TRTMNT_FNCTN', '11003', 'CWHCerner', 'CM_TrtmntFnc110'), ('/CWH/CRNR/TRTMNT_FNCTN', '11004', 'CWHCerner', 'CM_TrtmntFnc110'), ('/CWH/CRNR/TRTMNT_FNCTN', '11005', 'CWHCerner', 'CM_TrtmntFnc110'), ('/CWH/CRNR/TRTMNT_FNCTN', '11099', 'CWHCerner', 'CM_TrtmntFnc110'), ('/CWH/CRNR/TRTMNT_FNCTN', '12033', 'CWHCerner', 'CM_TrtmntFnc120'), ('/CWH/CRNR/TRTMNT_FNCTN', '12099', 'CWHCerner', 'CM_TrtmntFnc120'), ('/CWH/CRNR/TRTMNT_FNCTN', '13014', 'CWHCerner', 'CM_TrtmntFnc130'), ('/CWH/CRNR/TRTMNT_FNCTN', '13020', 'CWHCerner', 'CM_TrtmntFnc130'), ('/CWH/CRNR/TRTMNT_FNCTN', '13044', 'CWHCerner', 'CM_TrtmntFnc130'), ('/CWH/CRNR/TRTMNT_FNCTN', '13099', 'CWHCerner', 'CM_TrtmntFnc130'), ('/CWH/CRNR/TRTMNT_FNCTN', '14099', 'CWHCerner', 'CM_TrtmntFnc140'), ('/CWH/CRNR/TRTMNT_FNCTN', '14499', 'CWHCerner', 'CM_TrtmntFnc144'), ('/CWH/CRNR/TRTMNT_FNCTN', '15099', 'CWHCerner', 'CM_TrtmntFnc150'), ('/CWH/CRNR/TRTMNT_FNCTN', '16001', 'CWHCerner', 'CM_TrtmntFnc160'), ('/CWH/CRNR/TRTMNT_FNCTN', '16002', 'CWHCerner', 'CM_TrtmntFnc160'), ('/CWH/CRNR/TRTMNT_FNCTN', '16099', 'CWHCerner', 'CM_TrtmntFnc160'), ('/CWH/CRNR/TRTMNT_FNCTN', '16199', 'CWHCerner', 'CM_TrtmntFnc161'), ('/CWH/CRNR/TRTMNT_FNCTN', '17111', 'CWHCerner', 'CM_TrtmntFnc171'), ('/CWH/CRNR/TRTMNT_FNCTN', '17299', 'CWHCerner', 'CM_TrtmntFnc172'), ('/CWH/CRNR/TRTMNT_FNCTN', '17399', 'CWHCerner', 'CM_TrtmntFnc173'), ('/CWH/CRNR/TRTMNT_FNCTN', '19029', 'CWHCerner', 'CM_TrtmntFnc190'), ('/CWH/CRNR/TRTMNT_FNCTN', '19199', 'CWHCerner', 'CM_TrtmntFnc191'), ('/CWH/CRNR/TRTMNT_FNCTN', '21499', 'CWHCerner', 'CM_TrtmntFnc214'), ('/CWH/CRNR/TRTMNT_FNCTN', '25399', 'CWHCerner', 'CM_TrtmntFnc253'), ('/CWH/CRNR/TRTMNT_FNCTN', '25501', 'CWHCerner', 'CM_TrtmntFnc255'), ('/CWH/CRNR/TRTMNT_FNCTN', '25801', 'CWHCerner', 'CM_TrtmntFnc258'), ('/CWH/CRNR/TRTMNT_FNCTN', '25945', 'CWHCerner', 'CM_TrtmntFnc259'), ('/CWH/CRNR/TRTMNT_FNCTN', '30001', 'CWHCerner', 'CM_TrtmntFnc300'), ('/CWH/CRNR/TRTMNT_FNCTN', '30002', 'CWHCerner', 'CM_TrtmntFnc300'), ('/CWH/CRNR/TRTMNT_FNCTN', '30043', 'CWHCerner', 'CM_TrtmntFnc300'), ('/CWH/CRNR/TRTMNT_FNCTN', '30099', 'CWHCerner', 'CM_TrtmntFnc300'), ('/CWH/CRNR/TRTMNT_FNCTN', '30101', 'CWHCerner', 'CM_TrtmntFnc301'), ('/CWH/CRNR/TRTMNT_FNCTN', '30102', 'CWHCerner', 'CM_TrtmntFnc301'), ('/CWH/CRNR/TRTMNT_FNCTN', '30103', 'CWHCerner', 'CM_TrtmntFnc301'), ('/CWH/CRNR/TRTMNT_FNCTN', '30199', 'CWHCerner', 'CM_TrtmntFnc301'), ('/CWH/CRNR/TRTMNT_FNCTN', '30201', 'CWHCerner', 'CM_TrtmntFnc302'), ('/CWH/CRNR/TRTMNT_FNCTN', '30299', 'CWHCerner', 'CM_TrtmntFnc302'), ('/CWH/CRNR/TRTMNT_FNCTN', '30301', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30303', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30304', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30307', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30335', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30337', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30341', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30399', 'CWHCerner', 'CM_TrtmntFnc303'), ('/CWH/CRNR/TRTMNT_FNCTN', '30627', 'CWHCerner', 'CM_TrtmntFnc306'), ('/CWH/CRNR/TRTMNT_FNCTN', '30699', 'CWHCerner', 'CM_TrtmntFnc306'), ('/CWH/CRNR/TRTMNT_FNCTN', '30717', 'CWHCerner', 'CM_TrtmntFnc307'), ('/CWH/CRNR/TRTMNT_FNCTN', '30799', 'CWHCerner', 'CM_TrtmntFnc307'), ('/CWH/CRNR/TRTMNT_FNCTN', '30801', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30802', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30803', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30804', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30805', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30806', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30807', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30808', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30809', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30810', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30811', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30899', 'CWHCerner', 'CM_TrtmntFnc308'), ('/CWH/CRNR/TRTMNT_FNCTN', '30999', 'CWHCerner', 'CM_TrtmntFnc309'), ('/CWH/CRNR/TRTMNT_FNCTN', '31099', 'CWHCerner', 'CM_TrtmntFnc310'), ('/CWH/CRNR/TRTMNT_FNCTN', '31101', 'CWHCerner', 'CM_TrtmntFnc311'), ('/CWH/CRNR/TRTMNT_FNCTN', '31399', 'CWHCerner', 'CM_TrtmntFnc313'), ('/CWH/CRNR/TRTMNT_FNCTN', '31699', 'CWHCerner', 'CM_TrtmntFnc316'), ('/CWH/CRNR/TRTMNT_FNCTN', '31799', 'CWHCerner', 'CM_TrtmntFnc317'), ('/CWH/CRNR/TRTMNT_FNCTN', '31899', 'CWHCerner', 'CM_TrtmntFnc318'), ('/CWH/CRNR/TRTMNT_FNCTN', '31999', 'CWHCerner', 'CM_TrtmntFnc319'), ('/CWH/CRNR/TRTMNT_FNCTN', '32002', 'CWHCerner', 'CM_TrtmntFnc320'), ('/CWH/CRNR/TRTMNT_FNCTN', '32005', 'CWHCerner', 'CM_TrtmntFnc320'), ('/CWH/CRNR/TRTMNT_FNCTN', '32006', 'CWHCerner', 'CM_TrtmntFnc320'), ('/CWH/CRNR/TRTMNT_FNCTN', '32099', 'CWHCerner', 'CM_TrtmntFnc320'), ('/CWH/CRNR/TRTMNT_FNCTN', '32299', 'CWHCerner', 'CM_TrtmntFnc322'), ('/CWH/CRNR/TRTMNT_FNCTN', '32399', 'CWHCerner', 'CM_TrtmntFnc323'), ('/CWH/CRNR/TRTMNT_FNCTN', '32499', 'CWHCerner', 'CM_TrtmntFnc324'), ('/CWH/CRNR/TRTMNT_FNCTN', '33001', 'CWHCerner', 'CM_TrtmntFnc330'), ('/CWH/CRNR/TRTMNT_FNCTN', '33099', 'CWHCerner', 'CM_TrtmntFnc330'), ('/CWH/CRNR/TRTMNT_FNCTN', '34001', 'CWHCerner', 'CM_TrtmntFnc340'), ('/CWH/CRNR/TRTMNT_FNCTN', '34021', 'CWHCerner', 'CM_TrtmntFnc340'), ('/CWH/CRNR/TRTMNT_FNCTN', '34023', 'CWHCerner', 'CM_TrtmntFnc340'), ('/CWH/CRNR/TRTMNT_FNCTN', '34099', 'CWHCerner', 'CM_TrtmntFnc340'), ('/CWH/CRNR/TRTMNT_FNCTN', '34199', 'CWHCerner', 'CM_TrtmntFnc341'), ('/CWH/CRNR/TRTMNT_FNCTN', '35008', 'CWHCerner', 'CM_TrtmntFnc350'), ('/CWH/CRNR/TRTMNT_FNCTN', '35099', 'CWHCerner', 'CM_TrtmntFnc350'), ('/CWH/CRNR/TRTMNT_FNCTN', '36001', 'CWHCerner', 'CM_TrtmntFnc360'), ('/CWH/CRNR/TRTMNT_FNCTN', '36002', 'CWHCerner', 'CM_TrtmntFnc360'), ('/CWH/CRNR/TRTMNT_FNCTN', '36003', 'CWHCerner', 'CM_TrtmntFnc360'), ('/CWH/CRNR/TRTMNT_FNCTN', '36004', 'CWHCerner', 'CM_TrtmntFnc360'), ('/CWH/CRNR/TRTMNT_FNCTN', '36099', 'CWHCerner', 'CM_TrtmntFnc360'), ('/CWH/CRNR/TRTMNT_FNCTN', '36102', 'CWHCerner', 'CM_TrtmntFnc361'), ('/CWH/CRNR/TRTMNT_FNCTN', '36103', 'CWHCerner', 'CM_TrtmntFnc361'), ('/CWH/CRNR/TRTMNT_FNCTN', '36104', 'CWHCerner', 'CM_TrtmntFnc361'), ('/CWH/CRNR/TRTMNT_FNCTN', '36120', 'CWHCerner', 'CM_TrtmntFnc361'), ('/CWH/CRNR/TRTMNT_FNCTN', '36199', 'CWHCerner', 'CM_TrtmntFnc361'), ('/CWH/CRNR/TRTMNT_FNCTN', '37001', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37002', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37003', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37004', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37005', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37006', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37007', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37008', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37009', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37010', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37011', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37012', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37015', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '37099', 'CWHCerner', 'CM_TrtmntFnc370'), ('/CWH/CRNR/TRTMNT_FNCTN', '40001', 'CWHCerner', 'CM_TrtmntFnc400'), ('/CWH/CRNR/TRTMNT_FNCTN', '40002', 'CWHCerner', 'CM_TrtmntFnc400'), ('/CWH/CRNR/TRTMNT_FNCTN', '40003', 'CWHCerner', 'CM_TrtmntFnc400'), ('/CWH/CRNR/TRTMNT_FNCTN', '40018', 'CWHCerner', 'CM_TrtmntFnc400'), ('/CWH/CRNR/TRTMNT_FNCTN', '40099', 'CWHCerner', 'CM_TrtmntFnc400'), ('/CWH/CRNR/TRTMNT_FNCTN', '41028', 'CWHCerner', 'CM_TrtmntFnc410'), ('/CWH/CRNR/TRTMNT_FNCTN', '41099', 'CWHCerner', 'CM_TrtmntFnc410'), ('/CWH/CRNR/TRTMNT_FNCTN', '42001', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42002', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42003', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42004', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42005', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42007', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42008', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42099', 'CWHCerner', 'CM_TrtmntFnc420'), ('/CWH/CRNR/TRTMNT_FNCTN', '42201', 'CWHCerner', 'CM_TrtmntFnc422'), ('/CWH/CRNR/TRTMNT_FNCTN', '42202', 'CWHCerner', 'CM_TrtmntFnc422'), ('/CWH/CRNR/TRTMNT_FNCTN', '42209', 'CWHCerner', 'CM_TrtmntFnc422'), ('/CWH/CRNR/TRTMNT_FNCTN', '42210', 'CWHCerner', 'CM_TrtmntFnc422'), ('/CWH/CRNR/TRTMNT_FNCTN', '42221', 'CWHCerner', 'CM_TrtmntFnc422'), ('/CWH/CRNR/TRTMNT_FNCTN', '42299', 'CWHCerner', 'CM_TrtmntFnc422'), ('/CWH/CRNR/TRTMNT_FNCTN', '42499', 'CWHCerner', 'CM_TrtmntFnc424'), ('/CWH/CRNR/TRTMNT_FNCTN', '43005', 'CWHCerner', 'CM_TrtmntFnc430'), ('/CWH/CRNR/TRTMNT_FNCTN', '43010', 'CWHCerner', 'CM_TrtmntFnc430'), ('/CWH/CRNR/TRTMNT_FNCTN', '43011', 'CWHCerner', 'CM_TrtmntFnc430'), ('/CWH/CRNR/TRTMNT_FNCTN', '43099', 'CWHCerner', 'CM_TrtmntFnc430'), ('/CWH/CRNR/TRTMNT_FNCTN', '50101', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '50102', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '50103', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '50104', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '50105', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '50112', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '50113', 'CWHCerner', 'CM_TrtmntFnc501'), ('/CWH/CRNR/TRTMNT_FNCTN', '50201', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50202', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50203', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50204', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50205', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50206', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50207', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50208', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50209', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50210', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50211', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50212', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50232', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50236', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50238', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50242', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50247', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50288', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50292', 'CWHCerner', 'CM_TrtmntFnc502'), ('/CWH/CRNR/TRTMNT_FNCTN', '50301', 'CWHCerner', 'CM_TrtmntFnc503'), ('/CWH/CRNR/TRTMNT_FNCTN', '50302', 'CWHCerner', 'CM_TrtmntFnc503'), ('/CWH/CRNR/TRTMNT_FNCTN', '56099', 'CWHCerner', 'CM_TrtmntFnc560'), ('/CWH/CRNR/TRTMNT_FNCTN', '65001', 'CWHCerner', 'CM_TrtmntFnc650'), ('/CWH/CRNR/TRTMNT_FNCTN', '65002', 'CWHCerner', 'CM_TrtmntFnc650'), ('/CWH/CRNR/TRTMNT_FNCTN', '65003', 'CWHCerner', 'CM_TrtmntFnc650'), ('/CWH/CRNR/TRTMNT_FNCTN', '65004', 'CWHCerner', 'CM_TrtmntFnc650'), ('/CWH/CRNR/TRTMNT_FNCTN', '65099', 'CWHCerner', 'CM_TrtmntFnc650'), ('/CWH/CRNR/TRTMNT_FNCTN', '65101', 'CWHCerner', 'CM_TrtmntFnc651'), ('/CWH/CRNR/TRTMNT_FNCTN', '65102', 'CWHCerner', 'CM_TrtmntFnc651'), ('/CWH/CRNR/TRTMNT_FNCTN', '65199', 'CWHCerner', 'CM_TrtmntFnc651'), ('/CWH/CRNR/TRTMNT_FNCTN', '65299', 'CWHCerner', 'CM_TrtmntFnc652'), ('/CWH/CRNR/TRTMNT_FNCTN', '65399', 'CWHCerner', 'CM_TrtmntFnc653'), ('/CWH/CRNR/TRTMNT_FNCTN', '65401', 'CWHCerner', 'CM_TrtmntFnc654'), ('/CWH/CRNR/TRTMNT_FNCTN', '65402', 'CWHCerner', 'CM_TrtmntFnc654'), ('/CWH/CRNR/TRTMNT_FNCTN', '65403', 'CWHCerner', 'CM_TrtmntFnc654'), ('/CWH/CRNR/TRTMNT_FNCTN', '65499', 'CWHCerner', 'CM_TrtmntFnc654'), ('/CWH/CRNR/TRTMNT_FNCTN', '65599', 'CWHCerner', 'CM_TrtmntFnc655'), ('/CWH/CRNR/TRTMNT_FNCTN', '65699', 'CWHCerner', 'CM_TrtmntFnc656'), ('/CWH/CRNR/TRTMNT_FNCTN', '80001', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80002', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80003', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80004', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80005', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80019', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80022', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80024', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '80099', 'CWHCerner', 'CM_TrtmntFnc800'), ('/CWH/CRNR/TRTMNT_FNCTN', '81199', 'CWHCerner', 'CM_TrtmntFnc811'), -- Missing from NHS-DD ('/CWH/CRNR/TRTMNT_FNCTN', '147L', 'CWHCerner', 'CM_TrtmntFnc147'), ('/CWH/CRNR/TRTMNT_FNCTN', '820L', 'CWHCerner', 'CM_TrtmntFnc820'), ('/CWH/CRNR/TRTMNT_FNCTN', '823L', 'CWHCerner', 'CM_TrtmntFnc823'), ('/CWH/CRNR/TRTMNT_FNCTN', '824L', 'CWHCerner', 'CM_TrtmntFnc824'), ('/CWH/CRNR/TRTMNT_FNCTN', '831L', 'CWHCerner', 'CM_TrtmntFnc831'), ('/CWH/CRNR/TRTMNT_FNCTN', '900L', 'CWHCerner', 'CM_TrtmntFnc900'), ('/CWH/CRNR/TRTMNT_FNCTN', '901L', 'CWHCerner', 'CM_TrtmntFnc901'), ('/CWH/CRNR/TRTMNT_FNCTN', '903L', 'CWHCerner', 'CM_TrtmntFnc903'), ('/CWH/CRNR/TRTMNT_FNCTN', '950L', 'CWHCerner', 'CM_TrtmntFnc950'), -- New codes from 18-June-2021 ('/CWH/CRNR/TRTMNT_FNCTN', '145', 'CWHCerner', 'CM_TrtmntFnc145'), ('/CWH/CRNR/TRTMNT_FNCTN', '830', 'CWHCerner', 'CM_TrtmntFnc830') ; -- ******************** Admission Source ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'admission_source_code', '/CWH/CRNR/ADMSSN_SRC'); -- Property INSERT INTO map_node_meta (node, concept) VALUES ('/CWH/CRNR/ADMSSN_SRC', 'DM_sourceOfAdmission'); -- Value maps INSERT INTO map_node_value_meta (node, value, scheme, concept) VALUES ('/CWH/CRNR/ADMSSN_SRC', '19', 'CWHCerner', 'CM_SrcAdmUsual'), ('/CWH/CRNR/ADMSSN_SRC', '29', 'CWHCerner', 'CM_SrcAdmTempR'), ('/CWH/CRNR/ADMSSN_SRC', '39', 'CWHCerner', 'CM_SrcAdmPePoCo'), ('/CWH/CRNR/ADMSSN_SRC', '39a', 'CWHCerner', 'CM_SrcAdmPePoCo'), -- Custom local ('/CWH/CRNR/ADMSSN_SRC', '40', 'CWHCerner', 'CM_SrcAdmPe'), ('/CWH/CRNR/ADMSSN_SRC', '41', 'CWHCerner', 'CM_SrcAdmCo'), ('/CWH/CRNR/ADMSSN_SRC', '42', 'CWHCerner', 'CM_SrcAdmPo'), ('/CWH/CRNR/ADMSSN_SRC', '49', 'CWHCerner', 'CM_SrcAdmPSyHosp'), ('/CWH/CRNR/ADMSSN_SRC', '51', 'CWHCerner', 'CM_SrcAdmA1'), ('/CWH/CRNR/ADMSSN_SRC', '52', 'CWHCerner', 'CM_SrcAdmA2'), ('/CWH/CRNR/ADMSSN_SRC', '53', 'CWHCerner', 'CM_SrcAdmA3'), ('/CWH/CRNR/ADMSSN_SRC', '54', 'CWHCerner', 'CM_SrcAdmA4'), ('/CWH/CRNR/ADMSSN_SRC', '65', 'CWHCerner', 'CM_SrcAdmA5'), ('/CWH/CRNR/ADMSSN_SRC', '66', 'CWHCerner', 'CM_SrcAdmA6'), ('/CWH/CRNR/ADMSSN_SRC', '79', 'CWHCerner', 'CM_SrcAdmA7'), ('/CWH/CRNR/ADMSSN_SRC', '85', 'CWHCerner', 'CM_SrcAdmA8'), ('/CWH/CRNR/ADMSSN_SRC', '87', 'CWHCerner', 'CM_SrcAdmA9'), ('/CWH/CRNR/ADMSSN_SRC', '88', 'CWHCerner', 'CM_SrcAsmA10'); -- ******************** Admission Method ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'admission_method_code', '/CDS/INPTNT/ADMSSN_MTHD'); -- ******************** Discharge Method ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', 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_CWH', 'CM_Sys_Cerner', null, null, 'discharge_destination_code', '/CDS/INPTNT/DSCHRG_DSTNTN'); -- ******************** Ethnicity ******************** -- Context INSERT INTO map_context_meta (provider, `system`, `schema`, `table`, `column`, node) VALUES ('CM_Org_CWH', 'CM_Sys_Cerner', null, null, 'ethnicity', '/CDS/PTNT/ETHNC_CTGRY');
-- Eliminar el modelo orientado a objetos DROP FUNCTION mantenimiento_total;
-- phpMyAdmin SQL Dump -- version 4.8.3 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jan 11, 2020 at 06:24 AM -- Server version: 10.1.37-MariaDB -- PHP Version: 7.2.12 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `absensi_pkl` -- -- -------------------------------------------------------- -- -- Table structure for table `bulan` -- CREATE TABLE `bulan` ( `id_bln` int(10) NOT NULL, `nama_bln` varchar(25) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `bulan` -- INSERT INTO `bulan` (`id_bln`, `nama_bln`) VALUES (1, 'Januari'), (2, 'Februari'), (3, 'Maret'), (4, 'April'), (5, 'Mei'), (6, 'Juni'), (7, 'Juli'), (8, 'Agustus'), (9, 'September'), (10, 'Oktober'), (11, 'November'), (12, 'Desember'); -- -------------------------------------------------------- -- -- Table structure for table `catatan` -- CREATE TABLE `catatan` ( `id_cat` int(10) NOT NULL, `id_user` int(10) NOT NULL, `id_bln` int(10) NOT NULL, `id_hri` int(10) NOT NULL, `id_tgl` int(10) NOT NULL, `isi_cat` longtext NOT NULL, `status_cat` enum('Menunggu','Dikonfirmasi','Ditolak') NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `catatan` -- INSERT INTO `catatan` (`id_cat`, `id_user`, `id_bln`, `id_hri`, `id_tgl`, `isi_cat`, `status_cat`) VALUES (31, 2, 1, 4, 14, 'Fixed : Navbar link, bug absen pulang, empty input data', 'Dikonfirmasi'), (32, 4, 1, 4, 14, 'Tes fixes bug empty note', 'Dikonfirmasi'), (33, 4, 1, 4, 14, 'Tidak ada kegiatan, rencannya mau beresin kabel tapi wktunya ngga memungkinkan jadi di tunda.dikasih minum es kelapa muda. :D', 'Dikonfirmasi'), (34, 4, 1, 5, 15, 'Identifikasi pc yg tidak bisa masuk bios, ternyata masalah di power supplynya. Setelah di ganti power supplynya baru bisa masuk bios kemudian di install ulang paki windows 7', 'Dikonfirmasi'), (35, 4, 1, 5, 15, 'Identifikasi pc yg tidak bisa masuk bios, ternyata masalah di power supplynya. Setelah di ganti power supplynya baru bisa masuk bios kemudian di install ulang paki windows 7', 'Dikonfirmasi'), (44, 3, 1, 7, 17, 'Semoga lebih baik :D', 'Dikonfirmasi'), (43, 2, 1, 7, 17, 'Tes ya', 'Menunggu'), (39, 4, 1, 7, 17, 'Mysqli fix bug real escape string', 'Dikonfirmasi'), (40, 4, 1, 7, 17, 'Testing 2nd Migration to MySQLi', 'Dikonfirmasi'), (41, 2, 1, 7, 17, 'Testing 2nd Migrations To MySQLi', 'Menunggu'), (45, 4, 1, 2, 19, 'Senin bersihin Ram trus install ulang', ''), (46, 5, 2, 5, 19, 'Hemmm tes aja deh :D Hahaha :*', 'Dikonfirmasi'), (47, 3, 2, 5, 19, 'Terimakasih Untuk hari ini :D\\r\\nTerimakasih atas semua kebaikan ini :D', 'Dikonfirmasi'), (48, 3, 2, 5, 19, 'Tes fix Bug :D\r\nSemangaaatt :D \'\'\" <- tesss', 'Dikonfirmasi'), (49, 9, 12, 2, 3, 'Beli laset cd r', 'Dikonfirmasi'), (50, 9, 12, 2, 3, 'Hel ', ''), (51, 9, 12, 2, 3, 'Keluar yah', ''); -- -------------------------------------------------------- -- -- Table structure for table `data_absen` -- CREATE TABLE `data_absen` ( `id_absen` int(11) NOT NULL, `id_user` varchar(100) NOT NULL, `id_bln` int(10) NOT NULL, `id_hri` int(10) NOT NULL, `id_tgl` int(10) NOT NULL, `jam_msk` varchar(50) NOT NULL, `st_jam_msk` enum('Menunggu','Dikonfirmasi','Ditolak') NOT NULL, `jam_klr` varchar(50) NOT NULL, `st_jam_klr` enum('Belum Absen','Menunggu','Dikonfirmasi','Ditolak') NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `data_absen` -- INSERT INTO `data_absen` (`id_absen`, `id_user`, `id_bln`, `id_hri`, `id_tgl`, `jam_msk`, `st_jam_msk`, `jam_klr`, `st_jam_klr`) VALUES (48, '4', 1, 5, 15, '12.58 WIB', 'Dikonfirmasi', '16.25 WIB', 'Dikonfirmasi'), (49, '4', 1, 6, 16, '09.37 WIB', 'Dikonfirmasi', '', 'Belum Absen'), (50, '2', 1, 6, 16, '15.41 WIB', 'Dikonfirmasi', '', 'Belum Absen'), (51, '3', 1, 7, 17, '06.43 WIB', 'Ditolak', '', 'Belum Absen'), (53, '4', 1, 7, 17, '18.00 WIB', 'Ditolak', '18.01 WIB', 'Ditolak'), (54, '2', 1, 7, 17, '18.09 WIB', 'Ditolak', '18.09 WIB', 'Dikonfirmasi'), (56, '4', 1, 1, 18, '07.16 WIB', 'Ditolak', '12.46 WIB', 'Dikonfirmasi'), (58, '4', 1, 3, 20, '07.20 WIB', 'Ditolak', '07.20 WIB', 'Dikonfirmasi'), (59, '4', 1, 4, 21, '07.14 WIB', 'Dikonfirmasi', '', 'Belum Absen'), (60, '2', 1, 2, 26, '10.01 WIB', 'Dikonfirmasi', '10.01 WIB', 'Ditolak'), (61, '2', 2, 3, 10, '16.58 WIB', 'Dikonfirmasi', '16.59 WIB', 'Menunggu'), (66, '2', 12, 1, 2, '04.36 WIB', 'Menunggu', '', 'Belum Absen'), (67, '9', 12, 2, 3, '14.16 WIB', 'Dikonfirmasi', '14.19 WIB', 'Dikonfirmasi'), (68, '8', 12, 2, 3, '14.18 WIB', 'Dikonfirmasi', '14.18 WIB', 'Dikonfirmasi'), (69, '8', 12, 6, 7, '07.34 WIB', 'Menunggu', '', 'Belum Absen'), (70, '8', 12, 5, 13, '14.19 WIB', 'Menunggu', '14.19 WIB', 'Menunggu'); -- -------------------------------------------------------- -- -- Table structure for table `detail_pb` -- CREATE TABLE `detail_pb` ( `id_user` int(10) NOT NULL, `name_user` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `detail_pb` -- INSERT INTO `detail_pb` (`id_user`, `name_user`) VALUES (3, 'Irfan'), (8, 'Helmi'), (1, 'Admin'), (7, 'Admin123'); -- -------------------------------------------------------- -- -- Table structure for table `detail_user` -- CREATE TABLE `detail_user` ( `id_user` int(10) NOT NULL, `nis_user` int(25) NOT NULL, `name_user` varchar(255) NOT NULL, `sklh_user` varchar(255) NOT NULL, `jk_user` varchar(5) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `detail_user` -- INSERT INTO `detail_user` (`id_user`, `nis_user`, `name_user`, `sklh_user`, `jk_user`) VALUES (9, 1234, 'Arif', 'Smk Al Irsyad', 'L'), (8, 123, 'Sahal', 'Smk Al Irsyad', 'L'); -- -------------------------------------------------------- -- -- Table structure for table `hari` -- CREATE TABLE `hari` ( `id_hri` int(10) NOT NULL, `nama_hri` varchar(50) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `hari` -- INSERT INTO `hari` (`id_hri`, `nama_hri`) VALUES (1, 'Senin'), (2, 'Selasa'), (3, 'Rabu'), (4, 'Kamis'), (5, 'Jum\'at'), (6, 'Sabtu'), (7, 'Minggu'); -- -------------------------------------------------------- -- -- Table structure for table `tanggal` -- CREATE TABLE `tanggal` ( `id_tgl` int(10) NOT NULL, `nama_tgl` varchar(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `tanggal` -- INSERT INTO `tanggal` (`id_tgl`, `nama_tgl`) VALUES (1, '01'), (2, '02'), (3, '03'), (4, '04'), (5, '05'), (6, '06'), (7, '07'), (8, '08'), (9, '09'), (10, '10'), (11, '11'), (12, '12'), (13, '13'), (14, '14'), (15, '15'), (16, '16'), (17, '17'), (18, '18'), (19, '19'), (20, '20'), (21, '21'), (22, '22'), (23, '23'), (24, '24'), (25, '25'), (26, '26'), (27, '27'), (28, '28'), (29, '29'), (30, '30'), (31, '31'); -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE `user` ( `id_user` int(10) NOT NULL, `email_user` varchar(255) NOT NULL, `pwd_user` varchar(255) NOT NULL, `level_user` enum('sw','pb') NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id_user`, `email_user`, `pwd_user`, `level_user`) VALUES (1, 'admin@localhost.com', 'd033e22ae348aeb5660fc2140aec35850c4da997', 'pb'), (9, 'arif@localhost.com', '14382b5500e8c77f42fce98ff52ab1b7a12d6537', 'sw'), (7, 'admin123@localhost.com', 'f865b53623b121fd34ee5426c792e5c33af8c227', 'pb'), (8, 'sahal@localhost.com', '6de62a1b444168e91cb73a7bad8513f27ddd8a94', 'sw'); -- -- Indexes for dumped tables -- -- -- Indexes for table `bulan` -- ALTER TABLE `bulan` ADD PRIMARY KEY (`id_bln`); -- -- Indexes for table `catatan` -- ALTER TABLE `catatan` ADD PRIMARY KEY (`id_cat`); -- -- Indexes for table `data_absen` -- ALTER TABLE `data_absen` ADD PRIMARY KEY (`id_absen`); -- -- Indexes for table `detail_pb` -- ALTER TABLE `detail_pb` ADD PRIMARY KEY (`id_user`); -- -- Indexes for table `detail_user` -- ALTER TABLE `detail_user` ADD PRIMARY KEY (`id_user`,`nis_user`); -- -- Indexes for table `hari` -- ALTER TABLE `hari` ADD PRIMARY KEY (`id_hri`); -- -- Indexes for table `tanggal` -- ALTER TABLE `tanggal` ADD PRIMARY KEY (`id_tgl`); -- -- Indexes for table `user` -- ALTER TABLE `user` ADD PRIMARY KEY (`id_user`,`email_user`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `bulan` -- ALTER TABLE `bulan` MODIFY `id_bln` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; -- -- AUTO_INCREMENT for table `catatan` -- ALTER TABLE `catatan` MODIFY `id_cat` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=52; -- -- AUTO_INCREMENT for table `data_absen` -- ALTER TABLE `data_absen` MODIFY `id_absen` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=71; -- -- AUTO_INCREMENT for table `hari` -- ALTER TABLE `hari` MODIFY `id_hri` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `tanggal` -- ALTER TABLE `tanggal` MODIFY `id_tgl` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32; 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 */;
drop table if exists configuration; create table configuration ( plugin text not null constraint configuration_pkey primary key, url text not null ); create index index_configuration_plugin on configuration (plugin);
grant AQ_USER_ROLE to teqdemo; grant select_catalog_role to teqdemo; grant AQ_ADMINISTRATOR_ROLE to teqdemo; grant execute on sys.dbms_aq to teqdemo; grant execute on sys.dbms_aqin to teqdemo; grant execute on sys.dbms_aqjms to teqdemo; alter user teqdemo quota unlimited on users; begin dbms_aqadm.grant_system_privilege(privilege => 'DEQUEUE_ANY', grantee => 'TEQDEMO', admin_option => TRUE); end; begin sys.dbms_aqadm.create_sharded_queue(queue_name=>'TEQ', multiple_consumers => TRUE); sys.dbms_aqadm.set_queue_parameter('TEQ', 'SHARD_NUM', 1); sys.dbms_aqadm.set_queue_parameter('TEQ', 'STICKY_DEQUEUE', 1); sys.dbms_aqadm.set_queue_parameter('TEQ', 'KEY_BASED_ENQUEUE', 1); sys.dbms_aqadm.start_queue('TEQ'); end; begin sys.dbms_aqadm.stop_queue('TEQ'); sys.dbms_aqadm.drop_sharded_queue(queue_name=>'TEQ'); end; select owner, object_name from dba_objects where object_name like 'MESSAGE_TYPE'; show parameter streams show parameter local alter system set LOCAL_LISTENER='(ADDRESS=(PROTOCOL=TCP)(HOST=db21c )(PORT=1521))' alter system set streams_pool_size=64M scope=spfile; begin sys.dbms_aqadm.create_sharded_queue(queue_name=>'TEQ', multiple_consumers => TRUE); sys.dbms_aqadm.set_queue_parameter('TEQ', 'SHARD_NUM', 1); sys.dbms_aqadm.set_queue_parameter('TEQ', 'STICKY_DEQUEUE', 1); sys.dbms_aqadm.set_queue_parameter('TEQ', 'KEY_BASED_ENQUEUE', 0); begin sys.dbms_aqadm.start_queue('TEQ'); end; declare pval number; begin dbms_aqadm.get_queue_parameter('TEQ', 'AQ$GET_KEY_SHARD=100', pval); dbms_output.put_line('The key 100 is mapped to shard id ' || pval); END; DECLARE text varchar2(32767); bytes RAW(32767); body BLOB; position INT; --agent sys.aq$_agent := sys.aq$_agent('consumers', null, 0); message sys.aq$_jms_bytes_message; enqueue_options dbms_aq.enqueue_options_t; message_properties dbms_aq.message_properties_t; msgid raw(16); BEGIN message := sys.aq$_jms_bytes_message.construct; message_properties.correlation := '100'; --message.set_replyto(agent); --message.set_type('tkaqpet2'); message.set_userid('teqdemo'); message.set_appid('okafka'); message.set_groupid('producer'); message.set_groupseq(1); message.set_string_property('topic','TEQ'); message.set_string_property('AQINTERNAL_PARTITION','0'); FOR i IN 1..500 LOOP text := CONCAT (text, '1234567890'); END LOOP; --message.set_text(text); bytes := HEXTORAW(text); dbms_lob.createtemporary(lob_loc => body, cache => TRUE); dbms_lob.open (body, DBMS_LOB.LOB_READWRITE); position := 1 ; FOR i IN 1..10 LOOP dbms_lob.write ( lob_loc => body, amount => FLOOR((LENGTH(bytes)+1)/2), offset => position, buffer => bytes); position := position + FLOOR((LENGTH(bytes)+1)/2) ; END LOOP; message.set_bytes(body); dbms_aq.enqueue(queue_name => 'TEQ', enqueue_options => enqueue_options, message_properties => message_properties, payload => message, msgid => msgid); dbms_lob.freetemporary(lob_loc => body); END; DECLARE id pls_integer; blob_data blob; clob_data clob; blob_len pls_integer; message sys.aq$_jms_bytes_message; agent sys.aq$_agent; dequeue_options dbms_aq.dequeue_options_t; message_properties dbms_aq.message_properties_t; msgid raw(16); gdata sys.aq$_jms_value; java_exp exception; pragma EXCEPTION_INIT(java_exp, -24197); BEGIN DBMS_OUTPUT.ENABLE (20000); -- Dequeue this message from AQ queue using DBMS_AQ package dbms_aq.dequeue(queue_name => 'TEQ', dequeue_options => dequeue_options, message_properties => message_properties, payload => message, msgid => msgid); -- Retrieve the header agent := message.get_replyto; dbms_output.put_line('Type: ' || message.get_type || ' UserId: ' || message.get_userid || ' AppId: ' || message.get_appid || ' GroupId: ' || message.get_groupid || ' GroupSeq: ' || message.get_groupseq); -- Retrieve the user properties dbms_output.put_line('price: ' || message.get_float_property('price')); dbms_output.put_line('color: ' || message.get_string_property('color')); IF message.get_boolean_property('import') = TRUE THEN dbms_output.put_line('import: Yes' ); ELSIF message.get_boolean_property('import') = FALSE THEN dbms_output.put_line('import: No' ); END IF; dbms_output.put_line('year: ' || message.get_int_property('year')); dbms_output.put_line('mileage: ' || message.get_long_property('mileage')); dbms_output.put_line('password: ' || message.get_byte_property('password')); -- Shows how to retrieve the message payload of aq$_jms_bytes_message -- Prepare call, send the content in the PL/SQL aq$_jms_bytes_message object to -- Java stored procedure(Jserv) in the form of a byte array. -- Passing -1 reserves a new slot in msg store of sys.aq$_jms_bytes_message. -- Max number of sys.aq$_jms_bytes_message type of messges to be operated at -- the same time in a session is 20. Call clean_body fn. with parameter -1 -- might result in ORA-24199 error if messages operated on are already 20. -- You must call clean or clean_all function to clean up message store. id := message.prepare(-1); -- Read data from BytesMessage paylaod. These fns. are analogy of JMS Java -- API's. See the JMS Types chapter for detail. dbms_output.put_line('Payload:'); -- read a byte from the BytesMessage payload dbms_output.put_line('read_byte:' || message.read_byte(id)); -- read a byte array into a blob object from the BytesMessage payload dbms_output.put_line('read_bytes:'); blob_len := message.read_bytes(id, blob_data, 272); display_blob(blob_data); -- read a char from the BytesMessage payload dbms_output.put_line('read_char:'|| message.read_char(id)); -- read a double from the BytesMessage payload dbms_output.put_line('read_double:'|| message.read_double(id)); -- read a float from the BytesMessage payload dbms_output.put_line('read_float:'|| message.read_float(id)); -- read a int from the BytesMessage payload dbms_output.put_line('read_int:'|| message.read_int(id)); -- read a long from the BytesMessage payload dbms_output.put_line('read_long:'|| message.read_long(id)); -- read a short from the BytesMessage payload dbms_output.put_line('read_short:'|| message.read_short(id)); -- read a String from the BytesMessage payload. -- the String is in UTF8 encoding in the message payload dbms_output.put_line('read_utf:'); message.read_utf(id, clob_data); display_clob(clob_data); -- Use either clean_all or clean to clean up the message store when the user -- do not plan to do paylaod retrieving on this message anymore message.clean(id); -- sys.aq$_jms_bytes_message.clean_all(); EXCEPTION WHEN java_exp THEN dbms_output.put_line('exception information:'); display_exp(sys.aq$_jms_bytes_message.get_exception()); END;
CREATE TABLE baseline ( version VARCHAR(10) NULL, last_updated_date DATETIME NULL, comments VARCHAR(255) NULL ); CREATE TABLE symbol ( exchange_id INT NULL, exchange VARCHAR(10) NULL, ticker VARCHAR(32) NULL, instrument VARCHAR(64) NULL, name VARCHAR(255) NULL, sector VARCHAR(255) NULL, industry VARCHAR(255) NULL, ipo DATETIME NULL, currency VARCHAR(32) NULL, created_date DATETIME NULL, last_updated_date DATETIME NULL ); CREATE TABLE indices ( index_id int NULL, short_name VARCHAR(50) NULL, full_name VARCHAR(100) NULL, geog VARCHAR(100) NULL, data_source VARCHAR(250) NULL ); CREATE TABLE index_data ( index_id int NULL, short_name VARCHAR(50) NULL, update_date datetime NULL, ticker varchar NULL, data_date datetime NULL, weight numeric NULL ); CREATE TABLE exchange ( abbrev VARCHAR(32) NULL, name VARCHAR(255) NULL, city VARCHAR(255) NULL, country VARCHAR(255) NULL, currency VARCHAR(64) NULL, timezone_offset time NULL, created_date DATETIME NULL, last_updated_date DATETIME NULL ); CREATE TABLE daily_price ( data_vendor_id INT NULL, data_vendor VARCHAR(50) NULL, exchange_id INT NULL, exchange VARCHAR(10) NULL, symbol_id INT NULL, ticker VARCHAR(32), price_date DATETIME NULL, created_date DATETIME NULL, last_updated_date DATETIME NULL, open_price DECIMAL(19, 4) NULL, high_price DECIMAL(19, 4) NULL, low_price DECIMAL(19, 4) NULL, close_price DECIMAL(19, 4) NULL, volume BIGINT NULL, ex_dividend DECIMAL(19, 4) NULL, split_ratio DECIMAL(19, 4) NULL, adj_close_price DECIMAL(19, 4) NULL, adj_open_price DECIMAL(19, 4) NULL, adj_high_price DECIMAL(19, 4) NULL, adj_low_price DECIMAL(19, 4) NULL, adj_volume DECIMAL(19, 4) NULL ); CREATE INDEX daily_price_ticker_idx ON daily_price(ticker); CREATE INDEX daily_price_date_idx ON daily_price(price_date); CREATE TABLE dividends ( data_vendor_id INT NULL, data_vendor VARCHAR(50) NULL, exchange_id INT NULL, exchange VARCHAR(10) NULL, symbol_id INT NULL, ticker VARCHAR(32), date DATETIME NULL, dividend DECIMAL(19, 4) NULL, created_date DATETIME NULL, last_updated_date DATETIME NULL ); CREATE INDEX dividends_ticker_idx ON dividends(ticker); CREATE INDEX dividends_date_idx ON dividends(date); CREATE TABLE data_vendor ( name VARCHAR(64) NULL, data_vendor_id INT NULL, website_url VARCHAR(255) NULL, support_email VARCHAR(255) NULL, created_date DATETIME NULL, last_updated_date DATETIME NULL ); CREATE TABLE fundamentals ( data_vendor_id INT NULL, symbol_id INT NULL, ticker VARCHAR(32), date DATE NULL, data_type VARCHAR(32) NULL, data_name VARCHAR(32) NULL, data_frequency VARCHAR(32) NULL, data DECIMAL(19,4) NULL, created_date DATETIME NULL, last_updated_date DATETIME NULL, backtest_date DATETIME NULL ); CREATE INDEX fundamentals_ticker_idx ON fundamentals(ticker); CREATE TABLE cansim_tables ( tbl_id VARCHAR(10) NULL, short_desc VARCHAR(100) NULL, freq VARCHAR(32) NULL, update_freq VARCHAR(10) NULL, units VARCHAR(32) NULL, long_desc VARCHAR(256) NULL, coord_desc_1 VARCHAR(100) NULL, coord_desc_2 VARCHAR(100) NULL, coord_desc_3 VARCHAR(100) NULL, coord_desc_4 VARCHAR(100) NULL, coord_desc_5 VARCHAR(100) NULL, update_date DATETIME NULL ); CREATE INDEX cansim_tables_tbl_id_idx ON cansim_tables(tbl_id); CREATE TABLE cansim_vectors ( tbl_id VARCHAR(10) NULL, vector VARCHAR(50) NULL, coordinate VARCHAR(50) NULL, coord_val_1 VARCHAR(200) NULL, coord_val_2 VARCHAR(200) NULL, coord_val_3 VARCHAR(200) NULL, coord_val_4 VARCHAR(200) NULL, coord_val_5 VARCHAR(200) NULL, update_date DATETIME NULL ); CREATE INDEX cansim_vectors_tbl_id_idx ON cansim_vectors(tbl_id); CREATE INDEX cansim_vectors_vector_idx ON cansim_vectors(vector); CREATE INDEX cansim_vectors_coordinate_idx ON cansim_vectors(coordinate); CREATE TABLE cansim_data ( tbl_id VARCHAR(10) NULL, vector VARCHAR(10) NULL, coordinate VARCHAR(10) NULL, ref_date VARCHAR(50) NULL, value VARCHAR(200) NULL, update_date DATETIME NULL ); CREATE INDEX cansim_data_tbl_id_idx ON cansim_data(tbl_id); CREATE INDEX cansim_data_vector_idx ON cansim_data(vector); CREATE INDEX cansim_data_coordinate_idx ON cansim_data(coordinate);
{% macro extract_email_domain(email) -%} SUBSTRING(email, STRPOS(email, '@') + 1) {%- endmacro %}
/* Navicat MySQL Data Transfer Source Server : datebase Source Server Version : 50532 Source Host : localhost:3306 Source Database : ltx Target Server Type : MYSQL Target Server Version : 50532 File Encoding : 65001 Date: 2014-12-02 18:54:46 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for `accessory` -- ---------------------------- DROP TABLE IF EXISTS `accessory`; CREATE TABLE `accessory` ( `id` int(11) NOT NULL AUTO_INCREMENT, `accName` varchar(255) NOT NULL DEFAULT '' COMMENT '文件在服务器上的储存位置', `articleId` int(11) DEFAULT NULL, `fileName` varchar(255) NOT NULL DEFAULT '' COMMENT '上传文件原文件名称', `upLoadTime` date NOT NULL DEFAULT '0000-00-00' COMMENT '文件上传时间', PRIMARY KEY (`id`), KEY `articleId` (`articleId`), CONSTRAINT `accessory_ibfk_1` FOREIGN KEY (`articleId`) REFERENCES `article` (`articleId`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of accessory -- ---------------------------- -- ---------------------------- -- Table structure for `article` -- ---------------------------- DROP TABLE IF EXISTS `article`; CREATE TABLE `article` ( `articleId` int(11) NOT NULL AUTO_INCREMENT, `articleTitle` varchar(255) NOT NULL, `articleType` varchar(255) NOT NULL, `articleContext` text NOT NULL, `articleAuthor` varchar(255) NOT NULL, `uploadTime` date DEFAULT NULL, `createTIme` date DEFAULT NULL, PRIMARY KEY (`articleId`), KEY `articleType` (`articleType`), CONSTRAINT `article_ibfk_1` FOREIGN KEY (`articleType`) REFERENCES `articletype` (`articleType`) ) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of article -- ---------------------------- INSERT INTO `article` VALUES ('1', 'test1', '1', 'this is text', 'none', '2014-11-15', null); INSERT INTO `article` VALUES ('2', 'test2', '15', 'this is text2', 'none', '2014-11-04', null); INSERT INTO `article` VALUES ('3', 'text3', '16', 'this is text3', 'none', '2014-11-05', null); INSERT INTO `article` VALUES ('4', 'text4', '17', 'this is text4', 'none', '2014-11-14', null); INSERT INTO `article` VALUES ('5', 'text5', '18', 'this is text5', 'none', '2014-11-22', null); INSERT INTO `article` VALUES ('6', 'text6', '19', 'this is text6', 'dhy', '2014-10-16', null); INSERT INTO `article` VALUES ('7', 'article1', '20', 'test123kjsadfjkdafhjksdafhdahfkdsaf', 'aa', '2014-10-15', null); INSERT INTO `article` VALUES ('8', 'atricle2', '20', 'articleType is 20', 'author20', '2014-11-12', null); INSERT INTO `article` VALUES ('9', 'atricle3', '20', 'articleType is 20', 'author20', '2014-07-31', null); INSERT INTO `article` VALUES ('10', 'atricle4', '20', 'articleType is 20', 'author20', '2014-09-11', null); INSERT INTO `article` VALUES ('11', 'atricle5', '20', 'articleType is 20', 'author20', '2014-02-23', null); INSERT INTO `article` VALUES ('12', 'atricle6', '20', 'articleType is 20', 'author20', '2014-05-16', null); INSERT INTO `article` VALUES ('13', 'article7', '21', 'articleType is 21', 'author21', '2014-09-12', null); INSERT INTO `article` VALUES ('14', 'article8', '21', 'articleType is 21', 'author21', '2014-08-31', null); INSERT INTO `article` VALUES ('15', 'article9', '21', 'articleType is 21', 'author21', '2014-10-11', null); INSERT INTO `article` VALUES ('16', 'article10', '21', 'articleType is 21', 'author21', '2014-03-23', null); INSERT INTO `article` VALUES ('17', 'article11', '21', 'articleType is 21', 'author21', '2014-04-16', null); INSERT INTO `article` VALUES ('18', 'article12', '22', 'articleType is 22', 'author22', '2014-02-12', null); INSERT INTO `article` VALUES ('19', 'article13', '22', 'articleType is 22', 'author22', '2014-01-31', null); INSERT INTO `article` VALUES ('20', 'article14', '22', 'articleType is 22', 'author22', '2014-11-11', null); INSERT INTO `article` VALUES ('22', 'article15', '22', 'articleType is 22', 'author22', '2014-06-23', null); INSERT INTO `article` VALUES ('23', 'article16', '22', 'articleType is 22', 'author22', '2014-03-16', null); INSERT INTO `article` VALUES ('24', 'article17', '23', 'articleType is 23', 'author23', '2014-12-12', null); INSERT INTO `article` VALUES ('25', 'article18', '23', 'articleType is 23', 'author23', '2014-05-31', null); INSERT INTO `article` VALUES ('26', 'article19', '23', 'articleType is 23', 'author23', '2014-12-11', null); INSERT INTO `article` VALUES ('27', 'article20', '23', 'articleType is 23', 'author23', '2014-09-23', null); INSERT INTO `article` VALUES ('28', 'article21', '23', 'articleType is 23', 'author23', '2014-07-16', null); INSERT INTO `article` VALUES ('29', 'article17', '24', 'articleType is 24', 'author24', '2014-12-12', null); INSERT INTO `article` VALUES ('30', 'article18', '24', 'articleType is 24', 'author24', '2014-09-28', null); INSERT INTO `article` VALUES ('31', 'article19', '24', 'articleType is 24', 'author24', '2014-12-11', null); INSERT INTO `article` VALUES ('32', 'article20', '24', 'articleType is 24', 'author24', '2014-02-24', null); INSERT INTO `article` VALUES ('33', 'article21', '24', 'articleType is 24', 'author24', '2014-10-16', null); INSERT INTO `article` VALUES ('34', '红红火火', '25', 'articleType is 25', 'author25', '2014-10-12', null); INSERT INTO `article` VALUES ('35', 'name1', '25', 'articleType is 25dafdsf', 'author25', '2014-06-28', null); INSERT INTO `article` VALUES ('36', 'name2', '25', 'articleType is 25arwqrqwerq', 'author25', '2014-12-11', null); INSERT INTO `article` VALUES ('37', '恍恍惚惚', '25', 'articleType is 25dfad', 'author25', '2014-02-25', null); INSERT INTO `article` VALUES ('38', '呵呵呵呵', '25', 'articleType is 25fghdfhgfasd', 'author25', '2014-10-16', null); INSERT INTO `article` VALUES ('39', '39', '20', '123123123', '123', '2014-11-25', null); INSERT INTO `article` VALUES ('40', '40', '10', '123', '123', '2014-11-06', null); INSERT INTO `article` VALUES ('41', '41', '10', '123', '123', '2014-11-07', null); INSERT INTO `article` VALUES ('42', '42', '10', '123', '123', '2014-11-15', null); INSERT INTO `article` VALUES ('43', '42', '10', '123', '123', '2014-11-27', null); INSERT INTO `article` VALUES ('44', '44', '11', '123', '123', '2014-11-26', null); INSERT INTO `article` VALUES ('45', '45', '11', '123', '123', '2014-11-26', null); INSERT INTO `article` VALUES ('46', '46', '11', '123', '123', '2014-11-20', null); INSERT INTO `article` VALUES ('47', '47', '11', '123', '123', '2014-11-28', null); INSERT INTO `article` VALUES ('48', '48', '11', '123', '10', '2014-11-16', null); INSERT INTO `article` VALUES ('49', '49', '11', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('50', '51', '12', '123', '10', '2014-11-30', null); INSERT INTO `article` VALUES ('51', '52', '12', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('52', '53', '12', '123', '10', '2014-11-18', null); INSERT INTO `article` VALUES ('53', '54', '12', '123', '10', '2014-11-17', null); INSERT INTO `article` VALUES ('54', '55', '12', '123', '10', '2014-10-31', null); INSERT INTO `article` VALUES ('55', '65', '12', '123', '10', '2014-11-19', null); INSERT INTO `article` VALUES ('56', '76', '13', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('57', '77', '13', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('58', '88', '13', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('59', '333', '13', '123', '10', '2014-11-11', null); INSERT INTO `article` VALUES ('60', '234', '13', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('61', '23432', '13', '123', '10', '2014-11-04', null); INSERT INTO `article` VALUES ('62', '234234', '14', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('63', '1231232', '14', '123', '10', '2014-11-08', null); INSERT INTO `article` VALUES ('64', '21141', '14', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('65', '1431', '14', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('66', '343', '14', '123', '10', '2014-11-22', null); INSERT INTO `article` VALUES ('67', '12343', '14', '123', '10', '2014-11-18', null); INSERT INTO `article` VALUES ('68', '1232', '14', '123', '10', '2014-11-15', null); INSERT INTO `article` VALUES ('69', '4343', '12', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('70', '4323', '12', '123', '10', '2014-10-22', null); INSERT INTO `article` VALUES ('71', '234532', '13', '123', '10', '2014-11-26', null); INSERT INTO `article` VALUES ('72', '3242345', '14', '123', '10', '2014-11-16', null); -- ---------------------------- -- Table structure for `articletype` -- ---------------------------- DROP TABLE IF EXISTS `articletype`; CREATE TABLE `articletype` ( `typeId` int(11) NOT NULL AUTO_INCREMENT, `articleType` varchar(255) NOT NULL, `TypeName` varchar(255) NOT NULL, `parentType` int(11) DEFAULT NULL, PRIMARY KEY (`typeId`), KEY `articleType` (`articleType`) ) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of articletype -- ---------------------------- INSERT INTO `articletype` VALUES ('1', '1', '政策法规', null); INSERT INTO `articletype` VALUES ('5', '2', '动态新闻', null); INSERT INTO `articletype` VALUES ('6', '3', '党政工作', null); INSERT INTO `articletype` VALUES ('7', '4', '关工委', null); INSERT INTO `articletype` VALUES ('8', '5', '文体娱乐', null); INSERT INTO `articletype` VALUES ('9', '6', '百家讲坛', null); INSERT INTO `articletype` VALUES ('10', '7', '办事指南', null); INSERT INTO `articletype` VALUES ('11', '8', '下载中心', null); INSERT INTO `articletype` VALUES ('12', '9', '部门概况', null); INSERT INTO `articletype` VALUES ('25', '10', '国家有关文件', '1'); INSERT INTO `articletype` VALUES ('26', '11', '重庆市有关文件', '1'); INSERT INTO `articletype` VALUES ('27', '12', '学校有关规定', '1'); INSERT INTO `articletype` VALUES ('28', '13', '工作计划', '2'); INSERT INTO `articletype` VALUES ('29', '14', '通知公告', '2'); INSERT INTO `articletype` VALUES ('30', '15', '专题报告', '2'); INSERT INTO `articletype` VALUES ('31', '16', '追忆堂', '2'); INSERT INTO `articletype` VALUES ('32', '17', '组织机构', '3'); INSERT INTO `articletype` VALUES ('33', '18', '党建动态', '3'); INSERT INTO `articletype` VALUES ('34', '19', '理论中心组', '3'); INSERT INTO `articletype` VALUES ('35', '20', '组织机构', '4'); INSERT INTO `articletype` VALUES ('36', '21', '文件汇编', '4'); INSERT INTO `articletype` VALUES ('37', '22', '工作动态', '4'); INSERT INTO `articletype` VALUES ('38', '23', '组织设置', '5'); INSERT INTO `articletype` VALUES ('39', '24', '工作动态', '5'); INSERT INTO `articletype` VALUES ('40', '25', '老年风采', '5'); -- ---------------------------- -- Table structure for `image` -- ---------------------------- DROP TABLE IF EXISTS `image`; CREATE TABLE `image` ( `imgId` int(11) NOT NULL AUTO_INCREMENT, `imgUrl` varchar(255) DEFAULT NULL, `articleId` int(11) DEFAULT NULL, PRIMARY KEY (`imgId`), KEY `articleId` (`articleId`), CONSTRAINT `image_ibfk_1` FOREIGN KEY (`articleId`) REFERENCES `article` (`articleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of image -- ---------------------------- -- ---------------------------- -- Table structure for `user` -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL DEFAULT '' COMMENT '用户名', `password` varchar(255) NOT NULL DEFAULT '' COMMENT '用户密码', PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of user -- ---------------------------- INSERT INTO `user` VALUES ('1', 'admin', '111'); INSERT INTO `user` VALUES ('11', 'name', '123'); INSERT INTO `user` VALUES ('19', 'name2', '123'); INSERT INTO `user` VALUES ('28', 'qwe啊', 'qwe');
CREATE OR REPLACE PACKAGE BODY USER1.UNIVERSITY AS PROCEDURE new_student(NS_ID IN student.S_ID%type , NS_FNAME IN student.S_FNAME%type, NS_LNAME IN student.S_LNAME%type, NS_AGE IN STUDENT.S_AGE%type, NS_ADRESS IN STUDENT.S_ADDRESS%type) is Begin INSERT INTO student(S_ID,S_FNAME,S_LNAME,S_AGE,S_ADDRESS) VALUES(NS_ID,NS_FNAME,NS_LNAME,NS_AGE,NS_ADRESS); COMMIT ; END new_student; PROCEDURE Delete_student (stid student.s_id%type) IS BEGIN Delete from Student where s_id = stid; END Delete_student ; PROCEDURE course_student (NCRS_ID IN enrollment.CRS_ID%type,NS_ID IN student.S_ID%type, NT_ID IN TEACHER.T_ID%type, NGRADE IN enrollment.GRADE%type,NYEAR IN enrollment.YEAR%type) IS highgrade exception; alreadyregistered exception; n number; Begin select count(*) into n from enrollment where s_id=NS_ID and crs_id=ncrs_id; if (NGRADE>100) then raise highgrade; elsif(n>=1) then raise alreadyregistered; else INSERT INTO enrollment (CRS_ID,S_ID,T_ID,GRADE,YEAR) VALUES(NCRS_ID,NS_ID,NT_ID,NGRADE,NYEAR) ; COMMIT WORK; end if; exception when highgrade then raise_application_error(-20005,'Grade cannot be higher than 100'); when alreadyregistered then raise_application_error(-20004,'Course already registered'); END course_student; FUNCTION GPA(student_id student.s_id%type) return number is gpa number; sumcredits number; avggrade number; cursor grades is select enrollment.grade,course.crs_credits from enrollment,course where enrollment.CRS_ID=course.CRS_ID and enrollment.S_ID=student_id ; inexistantstudent exception; begin avggrade:=0; sumcredits:=0; gpa:=0; for i in grades loop if(i.grade<60) then avggrade:=0*i.crs_credits+avggrade; elsif(i.grade> 60 and i.grade<= 65) then avggrade:=1*i.crs_credits+avggrade; elsif (i.grade > 65 and i.grade<=67) then avggrade:=1.3*i.crs_credits+avggrade; elsif (i.grade > 67 and i.grade<=70) then avggrade:=1.7*i.crs_credits+avggrade; elsif (i.grade > 70 and i.grade<=76) then avggrade:=2*i.crs_credits+avggrade; elsif (i.grade > 77 and i.grade<=73) then avggrade:=2.3*i.crs_credits+avggrade; elsif (i.grade > 73 and i.grade<=77) then avggrade:=2.7*i.crs_credits+avggrade; elsif (i.grade > 80 and i.grade<=83) then avggrade:=3*i.crs_credits+avggrade; elsif (i.grade > 83 and i.grade<=87) then avggrade:=3.3*i.crs_credits+avggrade; elsif (i.grade > 87 and i.grade<=90) then avggrade:=3.7*i.crs_credits+avggrade; elsif (i.grade >=90) then avggrade:=4*i.crs_credits+avggrade; end if; sumcredits:=sumcredits+i.crs_credits; end loop; gpa:=avggrade/sumcredits; return round(gpa,2); exception when ZERO_DIVIDE then return 0; end GPA; PROCEDURE honor_students is cursor st is select * from student ; begin dbms_output.put_line('Honor Students'); for i in st loop if university.GPA(i.S_ID)>3.6 then dbms_output.put_line(i.s_fname||' '||i.s_lname||'GPA:'||UNIVERSITY.GPA(i.S_ID)); end if; end loop; end; PROCEDURE Student_club_leaders (clubname clubs.cl_name%type) IS fname2 student.s_fname%type; lname2 student.s_lname%type; BEGIN SELECT s_fname, s_lname INTO fname2,lname2 from Student, clubs WHERE student.s_id = clubs.president_id AND clubs.cl_name=clubname; dbms_output.put_line ('The president of :' || clubname || 'is : '|| fname2||' '|| lname2); END Student_club_leaders; FUNCTION courses_per_teacher (teacher_id teacher.t_id%type) return number IS n number; begin SELECT count(crs_id) INTO n FROM teacher_course GROUP BY t_id ; RETURN n ; END; PROCEDURE Teacher_by_course (coursename Course.crs_name%type) IS cursor t is SELECT t_fname, t_lname FROM teacher, course,teacher_course WHERE teacher_course.t_id = teacher.t_id and course.crs_id=teacher_course.crs_id AND coursename=course.crs_name; begin dbms_output.put_line(coursename||' Teachers:' ); for i in t loop dbms_output.put_line(i.t_fname||' '||i.t_lname); end loop; END teacher_by_course; PROCEDURE student_info(id in STUDENT.S_ID%type) is s student%rowtype; n int; cursor grades is select grade,crs_name from enrollment,course where enrollment.CRS_ID=course.CRS_ID and enrollment.S_ID=id; begin n:=0; select * into s from student where s_id=id; dbms_output.put_line(s.s_fname||' '||s.s_lname); dbms_output.put_line('Address'||s.s_address); for i in grades loop dbms_output.put_line(i.crs_name||' '||i.grade); n:=n+1; end loop; if n=0 then dbms_output.put_line('No courses registered'); else dbms_output.put_line('GPA:'||UNIVERSITY.GPA(id)); end if; end student_info; end university;
SELECT messages.text, messages.date, users.name FROM chat.users AS users INNER JOIN messages ON users.id=messages.user_id WHERE text LIKE "%2%";
set feedback off set define off prompt Dropping T_TST_ROWTOCOL... drop table T_TST_ROWTOCOL cascade constraints; prompt Creating T_TST_ROWTOCOL... CREATE TABLE t_tst_rowtocol ( ID VARCHAR2(2), val NUMBER(10) ) ; prompt Loading T_TST_ROWTOCOL... insert into T_TST_ROWTOCOL (val, ID) values (1, '1'); insert into T_TST_ROWTOCOL (val, ID) values (2, '2'); insert into T_TST_ROWTOCOL (val, ID) values (3, '3'); insert into T_TST_ROWTOCOL (val, ID) values (4, '4'); insert into T_TST_ROWTOCOL (val, ID) values (5, '5'); insert into T_TST_ROWTOCOL (val, ID) values (6, '6'); insert into T_TST_ROWTOCOL (val, ID) values (7, '7'); commit; prompt 7 records loaded set feedback on set define on prompt Done. -- Solution SELECT SUM(DECODE(T.ID, 1, T.VAL, 0)) AS JAN, SUM(DECODE(T.ID, 2, T.VAL, 0)) AS FEB, SUM(DECODE(T.ID, 3, T.VAL, 0)) AS MAR, SUM(DECODE(T.ID, 4, T.VAL, 0)) AS APR, SUM(DECODE(T.ID, 5, T.VAL, 0)) AS MAY, SUM(DECODE(T.ID, 6, T.VAL, 0)) AS JUN, SUM(DECODE(T.ID, 7, T.VAL, 0)) AS JUL, SUM(DECODE(T.ID, 8, T.VAL, 0)) AS AUG, SUM(DECODE(T.ID, 9, T.VAL, 0)) AS SEP, SUM(DECODE(T.ID, 10, T.VAL, 0)) AS OCT, SUM(DECODE(T.ID, 11, T.VAL, 0)) AS NOV, SUM(DECODE(T.ID, 12, T.VAL, 0)) AS DEC FROM T_TST_ROWTOCOL T; -- Another solution SELECT SUM(CASE WHEN T.ID = 1 THEN T.VAL ELSE 0 END) AS JAN, SUM(CASE WHEN T.ID = 2 THEN T.VAL ELSE 0 END) AS FEB, SUM(CASE WHEN T.ID = 3 THEN T.VAL ELSE 0 END) AS MAR, SUM(CASE WHEN T.ID = 4 THEN T.VAL ELSE 0 END) AS APR, SUM(CASE WHEN T.ID = 5 THEN T.VAL ELSE 0 END) AS MAY, SUM(CASE WHEN T.ID = 6 THEN T.VAL ELSE 0 END) AS JUN, SUM(CASE WHEN T.ID = 7 THEN T.VAL ELSE 0 END) AS JUL, SUM(CASE WHEN T.ID = 8 THEN T.VAL ELSE 0 END) AS AUG, SUM(CASE WHEN T.ID = 9 THEN T.VAL ELSE 0 END) AS SEP, SUM(CASE WHEN T.ID = 10 THEN T.VAL ELSE 0 END) AS OCT, SUM(CASE WHEN T.ID = 11 THEN T.VAL ELSE 0 END) AS NOV, SUM(CASE WHEN T.ID = 12 THEN T.VAL ELSE 0 END) AS DEC FROM T_TST_ROWToCOL T;
-- PRIMERA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status is null; -- SEGUNDA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status ='Shipped'; -- CREAMOS UN INDICE CON LA CLUMNA STATUS DE LA TABLA ORDERS CREATE INDEX index_status on orders(status); -- VOLVEMOS A EJECUTRA LAS MISMAS SENTENCIAS EXPLAIN QUE HEMOS REALIZADO ANTES -- PRIMERA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status is null; -- SEGUNDA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status ='Shipped'; -- EJECUTAMOS AHORA LA SENTENCIA ANALYZE EN LA TABLA ORDERS ANALYZE orders; -- VOLVEMOS A EJECUTAR LAS MISMAS SENTENCIAS DEL PRIMER APRATADO -- PRIMERA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status is null; -- SEGUNDA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status ='Shipped'; -- EJECUTAMOS LA SENTENCIA EXPLAIN CON LAS OTRAS DOS CONSULTAS DEL APENDICE 2 -- TERCERA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status ='Paid'; -- CUARTA CONSULTA DEL APENDICE 2 EXPLAIN SELECT count(*) FROM orders WHERE status ='Processed';
drop table CONTENU_ETAT; drop table IST_XMLDATA; drop table USER_XMLDATA; drop table PROFIL_XMLDATA; drop table Menu_xmldata;
DROP TABLE IF EXISTS board; CREATE TABLE board( id INT AUTO_INCREMENT PRIMARY KEY, userUID VARCHAR(200), boardData VARCHAR(1000), nextPlayer VARCHAR(1) ); DROP TABLE IF EXISTS sys_param; CREATE TABLE sys_param( id INT AUTO_INCREMENT PRIMARY KEY, code VARCHAR(200), value VARCHAR(200) ); DROP TABLE IF EXISTS scores; CREATE TABLE scores( id INT AUTO_INCREMENT PRIMARY KEY, playerName VARCHAR(200), opponentName VARCHAR(200), playerScore SMALLINT, opponentScore SMALLINT, draw SMALLINT ); INSERT INTO sys_param VALUES(1, 'healthcheck', 'OK');
use schoolschedulingdb; select studentID, StudFirstName, StudLastName, count(*) from students natural join student_schedules natural join classes natural join subjects natural join categories natural join departments where deptname='Information Technology' group by studentID;
 DO $$ BEGIN IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20190926135525_v1.33') THEN CREATE TABLE result_input_controls ( id uuid NOT NULL, record_state integer NOT NULL, caption character varying(128) NULL, modified_by uuid NOT NULL, modified_on timestamp without time zone NULL, created_by uuid NOT NULL, created_on timestamp without time zone NOT NULL, state text NULL, teritorial_service text NULL, license_id uuid NOT NULL, lims_rpid uuid NOT NULL, register_number text NULL, end_date timestamp without time zone NULL, drug_name text NULL, drug_form text NULL, producer_name text NULL, producer_country text NULL, medicine_series text NULL, medicine_expiration_date timestamp without time zone NULL, size_of_series text NULL, unit_of_measurement text NULL, amount_of_imported_medicine text NULL, win_number text NULL, date_win timestamp without time zone NULL, input_control_result text NULL, name_of_mismatch text NULL, comment text NULL, CONSTRAINT pk_result_input_controls PRIMARY KEY (id), CONSTRAINT fk_result_input_controls_iml_licenses_license_id FOREIGN KEY (license_id) REFERENCES iml_licenses (id) ON DELETE CASCADE, CONSTRAINT fk_result_input_controls_lims_rp_lims_rpid FOREIGN KEY (lims_rpid) REFERENCES lims_rp (id) ON DELETE CASCADE ); END IF; END $$; DO $$ BEGIN IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20190926135525_v1.33') THEN CREATE INDEX ix_result_input_controls_license_id ON result_input_controls (license_id); END IF; END $$; DO $$ BEGIN IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20190926135525_v1.33') THEN CREATE INDEX ix_result_input_controls_lims_rpid ON result_input_controls (lims_rpid); END IF; END $$; DO $$ BEGIN IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20190926135525_v1.33') THEN INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") VALUES ('20190926135525_v1.33', '2.2.2-servicing-10034'); END IF; END $$;
use ResumeInfo; Drop table if exists Duty; Drop table if exists Skill; Drop table if exists Schooling; Drop table if exists Employment; Drop table if exists Person; Create table Person( persID int not null auto_increment, persName varchar(40), email varchar(40), primary key(persID) ); Create table Schooling ( degID int not null auto_increment, persID int, degType varchar(20), degMajor varchar(20), college varchar(40), yearGrad int, primary key(degID, persID), foreign key(persID) references Person(persID) ); Create table Employment ( empID int not null auto_increment, persID int, title varchar(25), startDate varchar(20), endDate varchar(20), company varchar(40), primary key(empID, persID), foreign key(persID) references Person(persID) ); Create table Duty ( dutyID int not null auto_increment, empID int, dutyDesc varchar(50), primary key(dutyID, empID), foreign key(empID) references Employment(empID) ); Create table Skill ( skillID int not null auto_increment, persID int, skillName varchar(20), skillRating varchar(20), primary key(skillID,persID), foreign key(persID) references Person(persID) );
alter table public.applications rename column description to display_name; alter table public.event_type rename column description to display_name;
CREATE TABLE CUSTOMERS( CUSTOMER_ID NUMBER, CONSTRAINT CUSTOMERS_PK PRIMARY KEY (CUSTOMER_ID), COMPANY_NAME NVARCHAR2(50), CONTACT_NAME NVARCHAR2(30), CONTACT_TITLE NVARCHAR2(20), ADDRESS NVARCHAR2(100), CITY NVARCHAR2(20), REGION NUMBER, POSTAL_CODE NUMBER, COUNTRY NVARCHAR2(20), PHONE NVARCHAR2(20), FAX NVARCHAR2(20) );
/** * Insert data nearest station * @author TuanNA14 * @version $Id: ShisetsuNearbyStationCreateService_insertShisetsu_Ins_01.sql 8784 2014-06-26 10:37:34Z p_guen_toan $ */ INSERT INTO FR_SHISETSU_NEARBY_STATION FSNS ( FSNS.SHISETSU_CD ,FSNS.NEARBY_STATION_NO ,FSNS.NAVITIME_STATION_ID ,FSNS.NAVITIME_STATION_NAME ,FSNS.NEARBY_STATION_WALK_MINUTE ,FSNS.CREATE_DATE ,FSNS.CREATE_USER_ID ,FSNS.CREATE_MODULE_ID ,FSNS.UPDATE_DATE ,FSNS.UPDATE_USER_ID ,FSNS.UPDATE_MODULE_ID ) VALUES ( /*shisetsuCd*/'000000001' ,/*nearbyStationNo*/'1' ,/*navitimeStationId*/'0000000002' ,/*navitimeStationName*/'BTC0000000002' ,/*nearbyStationWalkMinute*/'11' ,/*createDate*/SYSDATE ,/*createUserId*/'SUKBATCH' ,/*createModuleId*/'BATCH' ,/*updateDate*/SYSDATE ,/*updateUserId*/'SUKBATCH' ,/*updateModuleId*/'BATCH' )
1. Получить репорт по department_id с минимальной и максимальной зарплатой, с самой ранней и самой поздней датой прихода на работу и с количеством сотрудников. Сортировать по количеству сотрудников (по убыванию). select department_id, min(salary), max(salary), min(hire_date), max(hire_date), count(*) from employees group by department_id order by count(*) desc; 2. Выведите информацию о первой букве имени сотрудника и количество имён, которые начинаются с этой буквы. Выводить строки для букв, где количество имён, начинающихся с неё больше 1. Сортировать по количеству. select substr(first_name, 1, 1), count(*) from employees group by substr(first_name, 1, 1) having count(*) > 1 order by count(*) desc; 3. Выведите id департамента, з/п и количество сотрудников, которые работают в одном и том же департаменте и получают одинаковую зарплату. select department_id, salary, count(*) from employees group by department_id, salary; 4. Выведите день недели и количество сотрудников, которых приняли на работу в этот день. select to_char(hire_date, 'day'), count(*) from employees group by to_char(hire_date, 'day') order by to_char(hire_date, 'day'); 5. Выведите id департаментов, в которых работает больше 30 сотрудников и сумма их з/п-т больше 300000. select department_id, sum(salary), count(*) from employees group by department_id having count(*) > 30 and sum(salary) > 300000; 6. Из таблицы countries вывести все region_id, для которых сумма всех букв их стран больше 50ти. select region_id, count(*), sum(length(country_name)) from countries group by region_id having sum(length(country_name)) > 50; 7. Выведите информацию о job_id и округленную среднюю зарплату работников для каждого job_id. select job_id, round(avg(salary)) from employees group by job_id order by job_id; 8. Получить список id департаментов, в которых работают сотрудники нескольких (>1) job_id. select department_id, count(distinct job_id) from employees group by department_id having count(distinct job_id) > 1; 9. Выведите информацию о department, job_id, максимальную и минимальную з/п для всех сочетаний department_id - job_id, где средняя з/п больше 10000. select department_id, job_id, min(salary), max(salary) from employees group by department_id, job_id having avg(salary) > 10000 order by department_id; 10.Получить список manager_id, у которых средняя зарплата всех его подчиненных, не имеющих комиссионные, находится в промежутке от 6000 до 9000. select * from employees; select manager_id, round(avg(salary)) from employees where commission_pct is null group by manager_id having avg(salary) between 6000 and 9000; 11.Выведите округлённую до тысяч (не тысячных) максимальную зарплату среди всех средних зарплат по департаментам. select round(max(avg(salary)),-3) from employees group by department_id;
select f.ID, f.Name, e.name, f.BitMask, f.Active from Enrich_DC3_FL_Polk.dbo.GradeLevel f left join Enrich_DC3_FL_Polk_empty.dbo.GradeLevel e on e.ID = f.ID order by f.BitMask select f.ID, f.Name, e.Name, f.DeletedDate, f.ProgramID from Enrich_DC3_FL_Polk.dbo.IepDisability f left join Enrich_DC3_FL_Polk_empty.dbo.IepDisability e on e.ID = f.ID order by f.Name, f.StateCode select f.ID, f.Text, e.Text, f.DeletedDate from Enrich_DC3_FL_Polk.dbo.IepPlacementOption f left join Enrich_DC3_FL_Polk_empty.dbo.IepPlacementOption e on e.ID = f.ID order by f.TypeID, f.Sequence select f.ID, f.Name, e.name, f.DeletedDate from Enrich_DC3_FL_Polk.dbo.IepServiceCategory f left join Enrich_DC3_FL_Polk_empty.dbo.IepServiceCategory e on e.ID = f.ID where f.DeletedDate is null order by f.Sequence select f.ID, f.Name, e.name, f.DeletedDate from Enrich_DC3_FL_Polk.dbo.PrgStatus f left join Enrich_DC3_FL_Polk_empty.dbo.PrgStatus e on e.ID = f.ID where f.ProgramID = 'F98A8EF2-98E2-4CAC-95AF-D7D89EF7F80C' and f.IsExit = 1 order by f.Sequence select f.ID, f.Name, e.name, f.DeletedDate from Enrich_DC3_FL_Polk.dbo.PrgLocation f left join Enrich_DC3_FL_Polk_empty.dbo.PrgLocation e on e.ID = f.ID order by f.Name select f.ID, f.Name, e.name, f.DeletedDate from Enrich_DC3_FL_Polk.dbo.ServiceDef f left join Enrich_DC3_FL_Polk_empty.dbo.ServiceDef e on e.ID = f.ID order by f.Name select * from Enrich_DC3_FL_Polk_empty.dbo.IepDisability select Type = 'Disab', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from IepDisability x where x.DeletedDate is null union all select Type = 'Gender', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = DisplayValue from EnumValue where Type = (select ID from EnumType where Type = 'GEN' and IsActive = 1) union all select Type = 'Race', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = DisplayValue from EnumValue where Type = (select ID from EnumType where Type = 'ETH' and IsActive = 1) union all select Type = 'Grade', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from GradeLevel union all select Type = 'GoalArea', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from IepGoalAreaDef where DeletedDate is null union all select Type = 'LRE', SubType = case pt.Name when 'Ages 3-5' then 'PK' when 'Ages 6-21' then 'K12' else pt.Name end, EnrichID = po.ID, StateCode = isnull(po.StateCode,''), LegacySpedCode = '', EnrichLabel = po.Text from IepPlacementOption po join IepPlacementType pt on po.TypeID = pt.ID where po.DeletedDate is null union all select Type = 'PostSchArea', SubType = '', EnrichID = ID, StateCode = '', LegacySpedCode = '', EnrichLabel = Name from IepPostSchoolAreaDef x union all select Type = 'ServLoc', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from PrgLocation where DeletedDate is null union all select Type = 'Exit', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from PrgStatus where ProgramID = 'F98A8EF2-98E2-4CAC-95AF-D7D89EF7F80C' and DeletedDate is null union all --select Type = 'Service', SubType = 'SpecialEd', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from ServiceDef where DeletedDate is null select Type = 'Service', SubType = case isc.Name when 'Special Education' then 'SpecialEd' else isc.Name end, EnrichID = sd.ID, StateCode = isnull(sd.StateCode,''), LegacySpedCode = '', EnrichLabel = sd.Name from ServiceDef sd join IepServiceDef isd on sd.ID = isd.ID join IepServiceCategory isc on isd.CategoryID = isc.ID where sd.DeletedDate is null union all select Type = 'ServFreq', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from ServiceFrequency where DeletedDate is null union all select Type = 'ServProv', SubType = '', EnrichID = ID, StateCode = isnull(StateCode,''), LegacySpedCode = '', EnrichLabel = Name from ServiceProviderTitle where DeletedDate is null order by Type, SubType, EnrichLabel select * from Program select Type = 'Service', SubType = case isc.Name when 'Special Education' then 'SpecialEd' else isc.Name end, EnrichID = sd.ID, StateCode = isnull(sd.StateCode,''), LegacySpedCode = '', EnrichLabel = sd.Name, sd.UserDefined from ServiceDef sd join IepServiceDef isd on sd.ID = isd.ID join IepServiceCategory isc on isd.CategoryID = isc.ID where sd.DeletedDate is null and sd.name like 'Transp%'
SELECT --申請物件元本構成情報.支払種類コード B.PAY_TYPE_DETAIL, --SUM(申請物件元本構成情報.税込金額 * 換算レート(从原通貨换算成取引通货) / 換算レート(从取引通貨换算成原通货)) SUM(B.PRICE_INCLUDING_TAX * PAY_CURRENCY_EXCHANGE_RATE / KEY_CURRENCY_EXCHANGE_RATE) AS PRICE_INCLUDING_TAX --【LAMP_STEP2 向け仕様追加・変更対応】 huxia modify 2013/05/20 start --SUM(元本構成要否) ,SUM(CONVERT(int,B.PRINCIPAL_IS_COMPOSITION)) AS PRINCIPAL_IS_COMPOSITION_SUM --【LAMP_STEP2 向け仕様追加・変更対応】 huxia modify 2013/05/20 end --申請物件情報テプール FROM APPLY_SUPPLIES_INFO AS A --申請物件元本構成情報 LEFT JOIN APPLY_PRINCIPAL_COMPOSITION_INFO B --申請物件情報.申請番号=申請物件元本構成情報.申請番号 ON A.APPLY_NO = B.APPLY_NO --申請物件情報.物件番号=申請物件元本構成情報.物件番号 AND A.SUPPLIES_NO = B.SUPPLIES_NO WHERE A.APPLY_NO = /*applyNo*/ --申請物件元本構成情報.支払種類コード GROUP BY B.PAY_TYPE_DETAIL ORDER BY B.PAY_TYPE_DETAIL ASC
IF NOT EXISTS ( SELECT [name] FROM sys.tables WHERE [name] = 'users' ) BEGIN CREATE TABLE users ( id INT IDENTITY(1,1) PRIMARY KEY, alias VARCHAR(255) NOT NULL, first_name VARCHAR(255), last_name VARCHAR(255), email VARCHAR(255), registration_date DATETIME NOT NULL, last_active DATETIME ); END;
SELECT name FROM MOVIESTAR WHERE gender="M" OR address LIKE "%Prefect Rd%"
-- phpMyAdmin SQL Dump -- version 4.6.5.2 -- https://www.phpmyadmin.net/ -- -- Хост: 127.0.0.1:3306 -- Время создания: Июн 06 2017 г., 20:54 -- Версия сервера: 10.0.28-MariaDB -- Версия PHP: 5.6.29 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 */; -- -- База данных: `DVD` -- -- -------------------------------------------------------- -- -- Структура таблицы `abonements` -- CREATE TABLE `abonements` ( `id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `deleted_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Структура таблицы `countries` -- CREATE TABLE `countries` ( `id` int(11) NOT NULL, `sortname` varchar(3) NOT NULL, `name` varchar(150) NOT NULL, `phonecode` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `countries` -- INSERT INTO `countries` (`id`, `sortname`, `name`, `phonecode`) VALUES (1, 'AF', 'Afghanistan', 93), (2, 'AL', 'Albania', 355), (3, 'DZ', 'Algeria', 213), (4, 'AS', 'American Samoa', 1684), (5, 'AD', 'Andorra', 376), (6, 'AO', 'Angola', 244), (7, 'AI', 'Anguilla', 1264), (8, 'AQ', 'Antarctica', 0), (9, 'AG', 'Antigua And Barbuda', 1268), (10, 'AR', 'Argentina', 54), (11, 'AM', 'Armenia', 374), (12, 'AW', 'Aruba', 297), (13, 'AU', 'Australia', 61), (14, 'AT', 'Austria', 43), (15, 'AZ', 'Azerbaijan', 994), (16, 'BS', 'Bahamas The', 1242), (17, 'BH', 'Bahrain', 973), (18, 'BD', 'Bangladesh', 880), (19, 'BB', 'Barbados', 1246), (20, 'BY', 'Belarus', 375), (21, 'BE', 'Belgium', 32), (22, 'BZ', 'Belize', 501), (23, 'BJ', 'Benin', 229), (24, 'BM', 'Bermuda', 1441), (25, 'BT', 'Bhutan', 975), (26, 'BO', 'Bolivia', 591), (27, 'BA', 'Bosnia and Herzegovina', 387), (28, 'BW', 'Botswana', 267), (29, 'BV', 'Bouvet Island', 0), (30, 'BR', 'Brazil', 55), (31, 'IO', 'British Indian Ocean Territory', 246), (32, 'BN', 'Brunei', 673), (33, 'BG', 'Bulgaria', 359), (34, 'BF', 'Burkina Faso', 226), (35, 'BI', 'Burundi', 257), (36, 'KH', 'Cambodia', 855), (37, 'CM', 'Cameroon', 237), (38, 'CA', 'Canada', 1), (39, 'CV', 'Cape Verde', 238), (40, 'KY', 'Cayman Islands', 1345), (41, 'CF', 'Central African Republic', 236), (42, 'TD', 'Chad', 235), (43, 'CL', 'Chile', 56), (44, 'CN', 'China', 86), (45, 'CX', 'Christmas Island', 61), (46, 'CC', 'Cocos (Keeling) Islands', 672), (47, 'CO', 'Colombia', 57), (48, 'KM', 'Comoros', 269), (49, 'CG', 'Congo', 242), (50, 'CD', 'Congo The Democratic Republic Of The', 242), (51, 'CK', 'Cook Islands', 682), (52, 'CR', 'Costa Rica', 506), (53, 'CI', 'Cote D\'Ivoire (Ivory Coast)', 225), (54, 'HR', 'Croatia (Hrvatska)', 385), (55, 'CU', 'Cuba', 53), (56, 'CY', 'Cyprus', 357), (57, 'CZ', 'Czech Republic', 420), (58, 'DK', 'Denmark', 45), (59, 'DJ', 'Djibouti', 253), (60, 'DM', 'Dominica', 1767), (61, 'DO', 'Dominican Republic', 1809), (62, 'TP', 'East Timor', 670), (63, 'EC', 'Ecuador', 593), (64, 'EG', 'Egypt', 20), (65, 'SV', 'El Salvador', 503), (66, 'GQ', 'Equatorial Guinea', 240), (67, 'ER', 'Eritrea', 291), (68, 'EE', 'Estonia', 372), (69, 'ET', 'Ethiopia', 251), (70, 'XA', 'External Territories of Australia', 61), (71, 'FK', 'Falkland Islands', 500), (72, 'FO', 'Faroe Islands', 298), (73, 'FJ', 'Fiji Islands', 679), (74, 'FI', 'Finland', 358), (75, 'FR', 'France', 33), (76, 'GF', 'French Guiana', 594), (77, 'PF', 'French Polynesia', 689), (78, 'TF', 'French Southern Territories', 0), (79, 'GA', 'Gabon', 241), (80, 'GM', 'Gambia The', 220), (81, 'GE', 'Georgia', 995), (82, 'DE', 'Germany', 49), (83, 'GH', 'Ghana', 233), (84, 'GI', 'Gibraltar', 350), (85, 'GR', 'Greece', 30), (86, 'GL', 'Greenland', 299), (87, 'GD', 'Grenada', 1473), (88, 'GP', 'Guadeloupe', 590), (89, 'GU', 'Guam', 1671), (90, 'GT', 'Guatemala', 502), (91, 'XU', 'Guernsey and Alderney', 44), (92, 'GN', 'Guinea', 224), (93, 'GW', 'Guinea-Bissau', 245), (94, 'GY', 'Guyana', 592), (95, 'HT', 'Haiti', 509), (96, 'HM', 'Heard and McDonald Islands', 0), (97, 'HN', 'Honduras', 504), (98, 'HK', 'Hong Kong S.A.R.', 852), (99, 'HU', 'Hungary', 36), (100, 'IS', 'Iceland', 354), (101, 'IN', 'India', 91), (102, 'ID', 'Indonesia', 62), (103, 'IR', 'Iran', 98), (104, 'IQ', 'Iraq', 964), (105, 'IE', 'Ireland', 353), (106, 'IL', 'Israel', 972), (107, 'IT', 'Italy', 39), (108, 'JM', 'Jamaica', 1876), (109, 'JP', 'Japan', 81), (110, 'XJ', 'Jersey', 44), (111, 'JO', 'Jordan', 962), (112, 'KZ', 'Kazakhstan', 7), (113, 'KE', 'Kenya', 254), (114, 'KI', 'Kiribati', 686), (115, 'KP', 'Korea North', 850), (116, 'KR', 'Korea South', 82), (117, 'KW', 'Kuwait', 965), (118, 'KG', 'Kyrgyzstan', 996), (119, 'LA', 'Laos', 856), (120, 'LV', 'Latvia', 371), (121, 'LB', 'Lebanon', 961), (122, 'LS', 'Lesotho', 266), (123, 'LR', 'Liberia', 231), (124, 'LY', 'Libya', 218), (125, 'LI', 'Liechtenstein', 423), (126, 'LT', 'Lithuania', 370), (127, 'LU', 'Luxembourg', 352), (128, 'MO', 'Macau S.A.R.', 853), (129, 'MK', 'Macedonia', 389), (130, 'MG', 'Madagascar', 261), (131, 'MW', 'Malawi', 265), (132, 'MY', 'Malaysia', 60), (133, 'MV', 'Maldives', 960), (134, 'ML', 'Mali', 223), (135, 'MT', 'Malta', 356), (136, 'XM', 'Man (Isle of)', 44), (137, 'MH', 'Marshall Islands', 692), (138, 'MQ', 'Martinique', 596), (139, 'MR', 'Mauritania', 222), (140, 'MU', 'Mauritius', 230), (141, 'YT', 'Mayotte', 269), (142, 'MX', 'Mexico', 52), (143, 'FM', 'Micronesia', 691), (144, 'MD', 'Moldova', 373), (145, 'MC', 'Monaco', 377), (146, 'MN', 'Mongolia', 976), (147, 'MS', 'Montserrat', 1664), (148, 'MA', 'Morocco', 212), (149, 'MZ', 'Mozambique', 258), (150, 'MM', 'Myanmar', 95), (151, 'NA', 'Namibia', 264), (152, 'NR', 'Nauru', 674), (153, 'NP', 'Nepal', 977), (154, 'AN', 'Netherlands Antilles', 599), (155, 'NL', 'Netherlands The', 31), (156, 'NC', 'New Caledonia', 687), (157, 'NZ', 'New Zealand', 64), (158, 'NI', 'Nicaragua', 505), (159, 'NE', 'Niger', 227), (160, 'NG', 'Nigeria', 234), (161, 'NU', 'Niue', 683), (162, 'NF', 'Norfolk Island', 672), (163, 'MP', 'Northern Mariana Islands', 1670), (164, 'NO', 'Norway', 47), (165, 'OM', 'Oman', 968), (166, 'PK', 'Pakistan', 92), (167, 'PW', 'Palau', 680), (168, 'PS', 'Palestinian Territory Occupied', 970), (169, 'PA', 'Panama', 507), (170, 'PG', 'Papua new Guinea', 675), (171, 'PY', 'Paraguay', 595), (172, 'PE', 'Peru', 51), (173, 'PH', 'Philippines', 63), (174, 'PN', 'Pitcairn Island', 0), (175, 'PL', 'Poland', 48), (176, 'PT', 'Portugal', 351), (177, 'PR', 'Puerto Rico', 1787), (178, 'QA', 'Qatar', 974), (179, 'RE', 'Reunion', 262), (180, 'RO', 'Romania', 40), (181, 'RU', 'Russia', 70), (182, 'RW', 'Rwanda', 250), (183, 'SH', 'Saint Helena', 290), (184, 'KN', 'Saint Kitts And Nevis', 1869), (185, 'LC', 'Saint Lucia', 1758), (186, 'PM', 'Saint Pierre and Miquelon', 508), (187, 'VC', 'Saint Vincent And The Grenadines', 1784), (188, 'WS', 'Samoa', 684), (189, 'SM', 'San Marino', 378), (190, 'ST', 'Sao Tome and Principe', 239), (191, 'SA', 'Saudi Arabia', 966), (192, 'SN', 'Senegal', 221), (193, 'RS', 'Serbia', 381), (194, 'SC', 'Seychelles', 248), (195, 'SL', 'Sierra Leone', 232), (196, 'SG', 'Singapore', 65), (197, 'SK', 'Slovakia', 421), (198, 'SI', 'Slovenia', 386), (199, 'XG', 'Smaller Territories of the UK', 44), (200, 'SB', 'Solomon Islands', 677), (201, 'SO', 'Somalia', 252), (202, 'ZA', 'South Africa', 27), (203, 'GS', 'South Georgia', 0), (204, 'SS', 'South Sudan', 211), (205, 'ES', 'Spain', 34), (206, 'LK', 'Sri Lanka', 94), (207, 'SD', 'Sudan', 249), (208, 'SR', 'Suriname', 597), (209, 'SJ', 'Svalbard And Jan Mayen Islands', 47), (210, 'SZ', 'Swaziland', 268), (211, 'SE', 'Sweden', 46), (212, 'CH', 'Switzerland', 41), (213, 'SY', 'Syria', 963), (214, 'TW', 'Taiwan', 886), (215, 'TJ', 'Tajikistan', 992), (216, 'TZ', 'Tanzania', 255), (217, 'TH', 'Thailand', 66), (218, 'TG', 'Togo', 228), (219, 'TK', 'Tokelau', 690), (220, 'TO', 'Tonga', 676), (221, 'TT', 'Trinidad And Tobago', 1868), (222, 'TN', 'Tunisia', 216), (223, 'TR', 'Turkey', 90), (224, 'TM', 'Turkmenistan', 7370), (225, 'TC', 'Turks And Caicos Islands', 1649), (226, 'TV', 'Tuvalu', 688), (227, 'UG', 'Uganda', 256), (228, 'UA', 'Ukraine', 380), (229, 'AE', 'United Arab Emirates', 971), (230, 'GB', 'United Kingdom', 44), (231, 'US', 'United States', 1), (232, 'UM', 'United States Minor Outlying Islands', 1), (233, 'UY', 'Uruguay', 598), (234, 'UZ', 'Uzbekistan', 998), (235, 'VU', 'Vanuatu', 678), (236, 'VA', 'Vatican City State (Holy See)', 39), (237, 'VE', 'Venezuela', 58), (238, 'VN', 'Vietnam', 84), (239, 'VG', 'Virgin Islands (British)', 1284), (240, 'VI', 'Virgin Islands (US)', 1340), (241, 'WF', 'Wallis And Futuna Islands', 681), (242, 'EH', 'Western Sahara', 212), (243, 'YE', 'Yemen', 967), (244, 'YU', 'Yugoslavia', 38), (245, 'ZM', 'Zambia', 260), (246, 'ZW', 'Zimbabwe', 263); -- -------------------------------------------------------- -- -- Структура таблицы `disks` -- CREATE TABLE `disks` ( `id` int(11) NOT NULL, `title` varchar(56) NOT NULL, `about` text NOT NULL, `year` timestamp NULL DEFAULT NULL, `actors` text NOT NULL, `directed_by` varchar(256) NOT NULL, `created_at` timestamp NULL DEFAULT NULL, `deleted_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `cost` float NOT NULL, `count` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `disks` -- INSERT INTO `disks` (`id`, `title`, `about`, `year`, `actors`, `directed_by`, `created_at`, `deleted_at`, `updated_at`, `cost`, `count`) VALUES (1, 'Пираты Карибского моря: Мертвецы не рассказывают сказки', 'Исчерпавший свою удачу капитан Джек Воробей обнаруживает, что за ним охотится его старый неприятель, ужасный капитан Салазар и его призрачные пираты. Они только что сбежали из Дьявольского треугольника и намерены уничтожить всех пиратов, включая Джека. Поможет спастись лишь могущественный артефакт — трезубец Посейдона, который дарует своему обладателю полный контроль над морями.', '1994-06-14 19:00:00', 'Джонни Депп,\nХавьер Бардем,\nДжеффри Раш,\nБрентон Туэйтс,\nКая Скоделарио,\nКевин МакНэлли,\nГолшифте Фарахани,\nДэвид Уэнэм,\nСтивен Грэм,\nЭнгус Барнетт,', 'Хоаким Роннинг, Эспен Сандберг', '2017-04-30 19:00:00', NULL, '2017-05-29 06:55:37', 250, 100), (2, 'Меч короля Артура', 'Молодой Артур живёт на задворках Лондиниума вместе со своей бандой. Он и понятия не имел о своём королевском происхождении, пока однажды не взял в руки меч Эскалибур. Меч начинает менять Артура. В результате он присоединяется к сопротивлению и таинственной молодой девушке по имени Гвиневра. Ему предстоит научиться понимать магическое оружие, которым он овладел, столкнуться со своими собственными демонами и объединить народ в борьбе против диктатора Вортигерна, убившего его родителей и завладевшего короной.', '2017-05-14 19:00:00', 'Чарли Ханнэм,\r\nАстрид Берже-Фрисби,\r\nДжуд Лоу,\r\nДжимон Хонсу,\r\nЭрик Бана,\r\nЭйдан Гиллен,\r\nФредди Фокс,\r\nКрэйг МакГинли,\r\nТом Ву,\r\nКингсли Бен-Адир,', 'Гай Ричи', '2017-05-08 19:00:00', NULL, '2017-05-29 06:55:37', 230, 11), (3, 'TEST', 'TEST', '2017-05-29 18:48:30', 'TEST', 'TEST', '2017-05-29 18:48:55', NULL, '2017-05-29 18:48:55', 233.23, 34), (4, 'QWERTY', 'QWERTY', '2017-05-29 18:51:37', 'QWERTY', 'QWERTY', '2017-05-29 18:52:08', NULL, '2017-05-29 18:52:08', 34.33, 123), (5, 'SDF1', 'SDF1', '2017-05-29 18:53:16', 'SDF', 'SDF', '2017-05-29 18:53:39', NULL, '2017-05-29 18:53:39', 23.23, 23); -- -------------------------------------------------------- -- -- Структура таблицы `disks_countries` -- CREATE TABLE `disks_countries` ( `id_disk` int(11) NOT NULL, `id_country` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `disks_countries` -- INSERT INTO `disks_countries` (`id_disk`, `id_country`) VALUES (2, 3), (2, 6), (0, 4), (0, 5), (0, 8), (3, 2), (3, 5), (3, 6), (5, 9), (5, 13), (5, 16), (1, 1), (1, 2), (1, 15); -- -------------------------------------------------------- -- -- Структура таблицы `disks_genres` -- CREATE TABLE `disks_genres` ( `disk_id` int(11) NOT NULL, `genre_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `disks_genres` -- INSERT INTO `disks_genres` (`disk_id`, `genre_id`) VALUES (2, 4), (2, 5), (0, 3), (0, 6), (0, 9), (0, 15), (0, 14), (0, 11), (3, 5), (3, 8), (3, 12), (3, 11), (3, 6), (3, 14), (5, 4), (5, 6), (5, 7), (5, 11), (5, 14), (1, 1), (1, 6), (1, 5), (1, 8), (1, 14); -- -------------------------------------------------------- -- -- Структура таблицы `genres` -- CREATE TABLE `genres` ( `id` int(11) NOT NULL, `title` varchar(32) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `genres` -- INSERT INTO `genres` (`id`, `title`) VALUES (1, 'Аниме'), (2, 'Биографический'), (3, 'Боевик'), (4, 'Вестерн'), (5, 'Военный'), (6, 'Детектив'), (7, 'Детский'), (8, 'Драма'), (9, 'Документальный'), (10, 'Научный'), (11, 'Приключения'), (12, 'Комедия'), (13, 'Фантастика'), (14, 'Спорт'), (15, 'Сериал'); -- -------------------------------------------------------- -- -- Структура таблицы `orders` -- CREATE TABLE `orders` ( `id` int(11) NOT NULL, `abonement_id` int(11) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `manager_id` int(11) NOT NULL, `finished` timestamp NULL DEFAULT NULL, `expire` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `cost` float NOT NULL, `count_disks` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Структура таблицы `orders_disks` -- CREATE TABLE `orders_disks` ( `order_id` int(11) NOT NULL, `disk_id` int(11) NOT NULL, `finished` tinyint(1) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Структура таблицы `orders_returned` -- CREATE TABLE `orders_returned` ( `id` int(11) NOT NULL, `order_id` int(11) NOT NULL, `manager_id` int(11) NOT NULL, `return_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `count_disks` int(11) NOT NULL, `corrupted_disks` int(11) NOT NULL, `fine` float NOT NULL COMMENT 'Штраф', `description` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Структура таблицы `orders_trashs` -- CREATE TABLE `orders_trashs` ( `tmp_order_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `disk_id` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Структура таблицы `roles` -- CREATE TABLE `roles` ( `id` int(11) NOT NULL, `name` varchar(55) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `roles` -- INSERT INTO `roles` (`id`, `name`) VALUES (1, 'Admin'), (2, 'Manager'), (3, 'Customer'); -- -------------------------------------------------------- -- -- Структура таблицы `shift` -- CREATE TABLE `shift` ( `id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `open_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `close_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Смена'; -- -------------------------------------------------------- -- -- Структура таблицы `tokens` -- CREATE TABLE `tokens` ( `id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `token` varchar(32) NOT NULL, `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `tokens` -- INSERT INTO `tokens` (`id`, `user_id`, `token`, `expires`, `created_at`) VALUES (1, 3, '95acf64e-c386-43c5-b6c9-bfce5020', '2017-05-29 04:43:31', '2017-05-29 04:43:31'), (2, 3, '4f966489-cdec-4b06-8e30-1430cc8f', '2017-05-29 04:44:48', '2017-05-29 04:44:48'), (3, 3, 'f455b914-5048-4478-810b-7bbd1e97', '2017-05-29 04:46:06', '2017-05-29 04:46:06'), (4, 3, '79cb57fe-8ec7-426e-a10c-d4828b7a', '2017-05-29 04:46:45', '2017-05-29 04:46:45'), (5, 3, '57000108-2c98-4625-916d-de4d426e', '2017-05-29 04:47:02', '2017-05-29 04:47:02'), (6, 3, 'c8d8bea1-d5d5-4a4d-9126-7ec5c530', '2017-05-29 04:48:23', '2017-05-29 04:48:23'), (7, 3, '3190fe3f-d7e7-4ca4-94fe-e425422c', '2017-05-29 04:49:52', '2017-05-29 04:49:52'), (8, 2, '1f050530-6c82-40bf-b3a3-e9693265', '2017-05-29 04:52:36', '2017-05-29 04:52:36'), (9, 2, '9bca8fd0-eab1-42f4-b06d-33f1d2b1', '2017-05-29 04:54:20', '2017-05-29 04:54:20'), (10, 2, 'a27ceb77-47b3-42e1-9bd1-56cb82ee', '2017-05-29 04:59:43', '2017-05-29 04:59:43'), (11, 2, 'e5226e17-adb1-4083-ad3e-1fb71afc', '2017-05-29 05:00:23', '2017-05-29 05:00:23'), (12, 2, 'b755bda0-255f-4281-8d7c-bad1f2ee', '2017-05-29 05:01:46', '2017-05-29 05:01:46'), (13, 1, 'ea724952-8be1-41ab-a9d9-1581fd42', '2017-05-29 05:02:25', '2017-05-29 05:02:25'), (14, 1, '7b6a2306-d634-4b45-bba3-1a0bb259', '2017-05-29 05:15:52', '2017-05-29 05:15:52'), (15, 1, '209389a1-9e26-4731-bc7c-21609555', '2017-05-29 05:19:17', '2017-05-29 05:19:17'), (16, 1, 'e5b6a0f6-92b4-49eb-9484-717df04e', '2017-05-29 05:21:11', '2017-05-29 05:21:11'), (17, 1, '460eea70-c0a6-4812-bb70-5599fab0', '2017-05-29 05:23:10', '2017-05-29 05:23:10'), (18, 1, '6577f789-cb75-4ee4-9ee1-c0c15ab1', '2017-05-29 05:25:29', '2017-05-29 05:25:29'), (19, 1, '33026b08-e588-4a8e-b383-02f6d993', '2017-05-29 05:27:54', '2017-05-29 05:27:54'), (20, 1, 'f05b83bd-6e36-4da9-be75-2d81e65f', '2017-05-29 05:28:26', '2017-05-29 05:28:26'), (21, 1, 'dc037ad9-61f0-4085-af3e-0de27282', '2017-05-29 05:29:05', '2017-05-29 05:29:05'), (22, 1, 'ec32dc62-396f-4754-970b-d4578202', '2017-05-29 05:33:18', '2017-05-29 05:33:18'), (23, 1, '178f8d1e-ef03-401e-b859-a2047722', '2017-05-29 05:33:57', '2017-05-29 05:33:57'), (24, 1, '1067d915-c22f-4547-91b6-b43374e2', '2017-05-29 05:47:59', '2017-05-29 05:47:59'), (25, 1, 'a9c534f5-a2c7-4d54-8e8d-3d5e4f35', '2017-05-29 05:48:54', '2017-05-29 05:48:54'), (26, 1, '82e120b8-5a3c-4a31-b38c-941487d2', '2017-05-29 05:50:53', '2017-05-29 05:50:53'), (27, 1, 'db9c2f94-984b-407f-b945-b839f320', '2017-05-29 05:54:26', '2017-05-29 05:54:26'), (28, 1, '87246d7a-e289-4d89-ac8f-ee31b161', '2017-05-29 05:54:52', '2017-05-29 05:54:52'), (29, 1, '17ef1a37-c940-422b-b44d-faea32d4', '2017-05-29 05:58:13', '2017-05-29 05:58:13'), (30, 1, '6a0fe883-4ff6-4efe-8c54-7720b507', '2017-05-29 06:22:38', '2017-05-29 06:22:38'), (31, 1, '4db3f5da-7db3-4958-aa8a-d310b242', '2017-05-29 06:23:33', '2017-05-29 06:23:33'), (32, 1, '439ce029-30dd-47d4-b6c5-2c03c589', '2017-05-29 06:24:37', '2017-05-29 06:24:37'), (33, 1, '566f8913-70df-4d91-9030-39aafdf2', '2017-05-29 06:25:32', '2017-05-29 06:25:32'), (34, 1, 'ec8153eb-817a-4e85-ae03-4c599b3e', '2017-05-29 06:27:23', '2017-05-29 06:27:23'), (35, 1, '068e7bce-4641-47c4-93ab-d15c8fd2', '2017-05-29 06:35:54', '2017-05-29 06:35:54'), (36, 4, 'a7cc2bd4-9b2c-4807-bd58-fcb8c349', '2017-05-29 06:36:38', '2017-05-29 06:36:38'), (37, 1, '333786f7-4d55-4774-8f13-7de5344f', '2017-05-29 06:39:57', '2017-05-29 06:39:57'), (38, 2, '30c0d4a3-102b-4339-bf3b-b44d9731', '2017-05-29 06:40:09', '2017-05-29 06:40:09'), (39, 1, '557266f2-2a18-4cc3-8061-b059a5dd', '2017-05-29 06:40:19', '2017-05-29 06:40:19'), (40, 2, 'fed82a11-83e3-4bab-9ab5-4a945b13', '2017-05-29 06:40:39', '2017-05-29 06:40:39'), (41, 1, '2f44f552-9436-4a38-accb-e6d55c28', '2017-05-29 07:12:47', '2017-05-29 07:12:47'), (42, 1, '57a0f7cc-a3a9-4f11-8d4e-c5ef4f08', '2017-05-29 07:13:04', '2017-05-29 07:13:04'), (43, 1, 'fc8222bb-29c3-4406-bfdb-8750d1e0', '2017-05-29 07:13:43', '2017-05-29 07:13:43'), (44, 1, 'b2891a51-d29a-40a2-ba7c-64a2ef76', '2017-05-29 07:14:34', '2017-05-29 07:14:34'), (45, 1, 'd098892f-d2ac-400f-8af8-c2aabf80', '2017-05-29 07:24:24', '2017-05-29 07:24:24'), (46, 1, 'cb3323e5-29a1-4122-919c-187b0432', '2017-05-29 07:25:11', '2017-05-29 07:25:11'), (47, 1, 'd3be408e-a894-47ad-b4f6-f45d080d', '2017-05-29 07:25:23', '2017-05-29 07:25:23'), (48, 1, '52cab07d-c9a0-4d75-aca9-c4d59c7d', '2017-05-29 07:25:43', '2017-05-29 07:25:43'), (49, 1, 'debb3751-5284-4274-812b-9df505b4', '2017-05-29 07:25:59', '2017-05-29 07:25:59'), (50, 1, '491f3f06-78a7-46e9-9738-1c151e48', '2017-05-29 07:26:33', '2017-05-29 07:26:33'), (51, 1, '54dfea28-444a-4f1f-bc4d-b47d32b0', '2017-05-29 07:27:00', '2017-05-29 07:27:00'), (52, 1, 'bf122b5c-e899-497b-be72-de699a8e', '2017-05-29 07:35:35', '2017-05-29 07:35:35'), (53, 1, '64ecb5c0-1d6f-4168-b401-0971df81', '2017-05-29 07:35:58', '2017-05-29 07:35:58'), (54, 1, 'f6dde2a2-e3b8-4007-9b51-37d45bf6', '2017-05-29 07:54:18', '2017-05-29 07:54:18'), (55, 1, '4a172b2f-16d9-4be6-a007-b63197e3', '2017-05-29 07:56:07', '2017-05-29 07:56:07'), (56, 1, '4d475bc8-3dc6-4192-b68b-b9672d92', '2017-05-29 07:56:51', '2017-05-29 07:56:51'), (57, 1, '0590b61a-13ad-4f86-8959-6b76c777', '2017-05-29 07:58:40', '2017-05-29 07:58:40'), (58, 1, 'ec33c7c7-6369-4601-9c43-02825807', '2017-05-29 08:01:13', '2017-05-29 08:01:13'), (59, 1, 'd4af3d5f-930f-4aee-948d-145b919f', '2017-05-29 15:33:41', '2017-05-29 15:33:41'), (60, 1, 'ac05dcf8-5f30-4e36-a980-1de129f5', '2017-05-29 16:06:24', '2017-05-29 16:06:24'), (61, 1, '1f0ff960-58cf-4998-ac3a-a4019e8a', '2017-05-29 16:15:06', '2017-05-29 16:15:06'), (62, 1, 'b2bbd557-1590-4319-946e-755c3287', '2017-05-29 16:55:13', '2017-05-29 16:55:13'), (63, 1, 'b5283dc6-bed8-4e09-8464-efdbea0f', '2017-05-29 16:55:41', '2017-05-29 16:55:41'), (64, 1, 'd87d7895-af90-4111-8110-644f06f4', '2017-05-29 16:57:04', '2017-05-29 16:57:04'), (65, 1, '24cd0da1-9728-4450-a49d-b1069521', '2017-05-29 17:05:38', '2017-05-29 17:05:38'), (66, 1, 'b4a72d7d-d2e1-4307-a2da-04143567', '2017-05-29 17:13:46', '2017-05-29 17:13:46'), (67, 1, '8efc3b51-5f62-4375-9a11-17b5119b', '2017-05-29 17:14:32', '2017-05-29 17:14:32'), (68, 1, '6d43fbe0-9501-466d-bc7a-5747395e', '2017-05-29 17:15:24', '2017-05-29 17:15:24'), (69, 1, '94f51d10-bbe6-4f83-9dcb-daf93439', '2017-05-29 17:17:20', '2017-05-29 17:17:20'), (70, 1, '7a2b7a68-45e0-4a66-92a5-2c1a0097', '2017-05-29 17:19:22', '2017-05-29 17:19:22'), (71, 1, '3ce8d706-4084-462a-a400-8da12cda', '2017-05-29 17:20:02', '2017-05-29 17:20:02'), (72, 1, 'ae67fb69-1968-4d5f-9e51-a4059b8e', '2017-05-29 17:21:47', '2017-05-29 17:21:47'), (73, 1, '00e635f2-0997-4f00-84ab-403aed74', '2017-05-29 17:24:37', '2017-05-29 17:24:37'), (74, 1, 'cbf7bca3-f488-4186-8b0b-b30b38d0', '2017-05-29 17:25:16', '2017-05-29 17:25:16'), (75, 1, 'ac0c3af6-486f-4422-b8f2-b90e9538', '2017-05-29 17:27:09', '2017-05-29 17:27:09'), (76, 1, 'a5c96274-af4a-4fa8-8436-50af6122', '2017-05-29 17:28:01', '2017-05-29 17:28:01'), (77, 1, '19979e3b-7faa-4aa8-9375-a542d603', '2017-05-29 18:09:38', '2017-05-29 18:09:38'), (78, 1, '8e0cfbe8-fd37-4398-976f-17c213e5', '2017-05-29 18:11:09', '2017-05-29 18:11:09'), (79, 1, '368bf820-ccf4-4cc5-a9a7-fbd12b07', '2017-05-29 18:11:57', '2017-05-29 18:11:57'), (80, 1, '61b4179e-4297-4b79-a6b0-48da6af2', '2017-05-29 18:12:31', '2017-05-29 18:12:31'), (81, 1, '07da7746-a257-412f-a6e6-475506c6', '2017-05-29 18:13:42', '2017-05-29 18:13:42'), (82, 1, 'e060eac8-69c4-4a24-bd68-0400f2bc', '2017-05-29 18:15:39', '2017-05-29 18:15:39'), (83, 1, 'f7ecd4c0-a264-4fbc-9574-fa7a4b1a', '2017-05-29 18:16:13', '2017-05-29 18:16:13'), (84, 1, '3480ca05-8659-4a2a-8305-385c4b8c', '2017-05-29 18:17:23', '2017-05-29 18:17:23'), (85, 1, 'ad28a494-009c-4617-a7cd-ef868352', '2017-05-29 18:19:05', '2017-05-29 18:19:05'), (86, 1, '2e6f06e7-0739-4b61-ab72-d8178e5b', '2017-05-29 18:19:46', '2017-05-29 18:19:46'), (87, 1, '45db95b0-ddb5-41ce-ba1a-5c7e4711', '2017-05-29 18:21:29', '2017-05-29 18:21:29'), (88, 1, 'd675c5a6-fbd3-43e4-9398-8f4954ad', '2017-05-29 18:24:27', '2017-05-29 18:24:27'), (89, 1, 'a1a99cb6-6623-4098-ba58-ac39a5be', '2017-05-29 18:25:01', '2017-05-29 18:25:01'), (90, 1, 'ab1f2e2d-64a5-4300-ad30-b7172ef2', '2017-05-29 18:25:46', '2017-05-29 18:25:46'), (91, 1, 'dbdf6abd-8792-4e17-ac00-93b6e029', '2017-05-29 18:29:28', '2017-05-29 18:29:28'), (92, 1, 'cfccc966-171e-4f27-8c46-db5e0890', '2017-05-29 18:29:45', '2017-05-29 18:29:45'), (93, 1, '3989aa11-5f34-4781-90f1-ad7047a4', '2017-05-29 18:31:48', '2017-05-29 18:31:48'), (94, 1, '95ef4b98-d422-42d0-9062-950e8895', '2017-05-29 18:32:37', '2017-05-29 18:32:37'), (95, 1, '40fa97c6-6929-43af-8996-d0c75288', '2017-05-29 18:34:25', '2017-05-29 18:34:25'), (96, 1, 'ce3d4a63-1638-4d58-9a67-e23ef9a3', '2017-05-29 18:36:54', '2017-05-29 18:36:54'), (97, 1, '52cab6a7-81b3-4066-936e-21c135f5', '2017-05-29 18:40:57', '2017-05-29 18:40:57'), (98, 1, 'a4485998-10c1-40d3-a91c-36334405', '2017-05-29 18:48:27', '2017-05-29 18:48:27'), (99, 1, '1300cbd2-009d-4050-9df7-53d731ac', '2017-05-29 18:51:16', '2017-05-29 18:51:16'), (100, 1, 'bd19aacb-abc2-449d-8dab-c7197278', '2017-05-29 18:53:13', '2017-05-29 18:53:13'), (101, 1, '80482718-cf24-4581-b586-098f7336', '2017-05-29 18:54:49', '2017-05-29 18:54:49'), (102, 1, 'efb71014-2d06-4e52-b77a-53143490', '2017-05-29 18:58:05', '2017-05-29 18:58:05'), (103, 1, '02c458d9-81f8-411c-a9be-9d770261', '2017-05-29 19:00:16', '2017-05-29 19:00:16'), (104, 3, 'f611c342-876f-4597-8ea9-495e3ec4', '2017-05-30 16:50:41', '2017-05-30 16:50:41'), (105, 2, 'dd57907f-6bdf-4342-862a-9634a447', '2017-05-30 16:50:54', '2017-05-30 16:50:54'), (106, 1, '05f2e7ab-5add-4668-8335-ba9f5ac5', '2017-05-30 16:51:42', '2017-05-30 16:51:42'), (107, 3, 'e2387989-299f-4cae-a182-248c4dab', '2017-05-30 16:54:05', '2017-05-30 16:54:05'), (108, 2, '6b19f513-c904-4b6b-9968-cc8811c7', '2017-05-30 16:54:34', '2017-05-30 16:54:34'), (109, 1, '0b1b453e-8e0e-482a-883d-7e1c341b', '2017-06-01 17:13:45', '2017-06-01 17:13:45'); -- -------------------------------------------------------- -- -- Структура таблицы `users` -- CREATE TABLE `users` ( `id` bigint(20) UNSIGNED NOT NULL COMMENT 'Идентификатор пользователя', `first_name` varchar(56) NOT NULL COMMENT 'Имя', `last_name` varchar(56) NOT NULL COMMENT 'Фамилия', `patronumyc` varchar(56) NOT NULL COMMENT 'Отчество', `phones` varchar(255) NOT NULL COMMENT 'Телефонs', `birth_date` timestamp NULL DEFAULT NULL, `passport_number` int(10) NOT NULL COMMENT 'Номер паспорта', `passport_year` timestamp NULL DEFAULT NULL COMMENT 'Год выдачи', `passport_issuer` varchar(255) NOT NULL COMMENT 'Кем выдан', `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `deleted_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `login` varchar(32) NOT NULL, `password_hash` varchar(64) NOT NULL, `email` varchar(56) NOT NULL, `role` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Пользователи'; -- -- Дамп данных таблицы `users` -- INSERT INTO `users` (`id`, `first_name`, `last_name`, `patronumyc`, `phones`, `birth_date`, `passport_number`, `passport_year`, `passport_issuer`, `created_at`, `deleted_at`, `updated_at`, `login`, `password_hash`, `email`, `role`) VALUES (1, 'Масяня1', 'Иванов1', 'Олегович', '12345678,98765432,325523', '2017-04-30 19:00:00', 1234564567, '2010-01-26 19:00:00', 'ГУП', '2017-05-27 10:35:10', NULL, '2017-05-30 16:52:10', 'admin', 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'admin@admin.admin', 1), (2, 'Менеджер', 'Самый', 'Лучший', '12345678,98765432,325523', '2017-03-06 19:00:00', 1234564567, '2016-07-04 19:00:00', 'Чел', '2017-05-27 10:35:10', NULL, '2017-05-29 06:40:30', 'manager', '65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5', 'manager@manager.manager', 2), (3, 'Клиент', 'Самый', 'Лучший', '12345678,98765432,325523', '2017-03-06 19:00:00', 1234564567, '2015-09-07 19:00:00', 'МСК', '2017-05-27 10:35:10', NULL, '2017-05-29 05:58:05', 'client', '65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5', 'client@client.client', 3), (4, 'admin1', 'admin1', 'admin1', '098,765', '2004-06-17 06:35:56', 213, '2017-05-29 06:35:56', 'RTY', '2017-05-29 06:36:27', NULL, '2017-05-29 08:01:56', 'admin1', '65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5', 'admin1@admin1.admin1', 1), (5, '2@2.2', '2@2.2', '2@2.2', '222', '2017-05-29 18:35:59', 123, '2017-05-29 18:35:59', '123', '2017-05-29 18:36:27', NULL, '2017-05-29 18:36:27', '2', 'dbc6e5113e2659acbbd1dc7ff20346c2e461ff80c3bb419bee89dd44c599444c', '2@2.2', 2); -- -- Индексы сохранённых таблиц -- -- -- Индексы таблицы `abonements` -- ALTER TABLE `abonements` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `countries` -- ALTER TABLE `countries` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `disks` -- ALTER TABLE `disks` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `genres` -- ALTER TABLE `genres` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `orders` -- ALTER TABLE `orders` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `orders_returned` -- ALTER TABLE `orders_returned` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `roles` -- ALTER TABLE `roles` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `shift` -- ALTER TABLE `shift` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `tokens` -- ALTER TABLE `tokens` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT для сохранённых таблиц -- -- -- AUTO_INCREMENT для таблицы `abonements` -- ALTER TABLE `abonements` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT для таблицы `countries` -- ALTER TABLE `countries` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=247; -- -- AUTO_INCREMENT для таблицы `disks` -- ALTER TABLE `disks` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT для таблицы `genres` -- ALTER TABLE `genres` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16; -- -- AUTO_INCREMENT для таблицы `orders` -- ALTER TABLE `orders` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT для таблицы `orders_returned` -- ALTER TABLE `orders_returned` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT для таблицы `roles` -- ALTER TABLE `roles` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT для таблицы `shift` -- ALTER TABLE `shift` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT для таблицы `tokens` -- ALTER TABLE `tokens` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=110; -- -- AUTO_INCREMENT для таблицы `users` -- ALTER TABLE `users` MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Идентификатор пользователя', AUTO_INCREMENT=6; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
CREATE TABLE TB_PRODUTO( cd_produto INT NOT NULL PRIMARY KEY, descricao VARCHAR(50) NOT NULL, categoria VARCHAR(50) NOT NULL, subcategoria VARCHAR(50) NULL, valor NUMERIC(10,2) NOT NULL ) CREATE TABLE TB_VENDAS( cod_venda INT NOT NULL PRIMARY KEY, dt_venda DATETIME NOT NULL, valor_unitario NUMERIC(10,2) NOT NULL, quantidade INT NOT NULL, valor_total NUMERIC(10,2) NOT NULL, cd_produto INT NOT NULL REFERENCES TB_PRODUTO (cd_produto) ) SELECT cd_produto, descricao FROM TB_PRODUTO WHERE subcategoria IS NULL SELECT P.cd_produto, P.descricao FROM TB_PRODUTO P WHERE P.descricao LIKE '%caneta%' SELECT V.cod_venda, P.descricao, V.quantidade, V.valor_total FROM TB_VENDAS V INNER JOIN TB_PRODUTO P ON(V.cd_produto = P.cd_produto) WHERE dt_venda >= '20190101' AND dt_venda <= '20191231' select * from TB_VENDAS SELECT P.descricao, V.quantidade FROM TB_VENDAS V INNER JOIN TB_PRODUTO P ON(V.cd_produto = P.cd_produto) SELECT P.categoria, SUM(V.valor_total) FROM TB_VENDAS V INNER JOIN TB_PRODUTO P ON(V.cd_produto = P.cd_produto) GROUP BY P.categoria
USE authtion_dev; SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS authtion_consumers, authtion_countries, authtion_genders, authtion_users, authtion_authorities, authtion_consumer_authority, authtion_mailing, oauth_access_token, oauth_refresh_token; SET FOREIGN_KEY_CHECKS = 1; CREATE TABLE authtion_consumers ( id BIGINT(20) NOT NULL AUTO_INCREMENT, email VARCHAR(50) NOT NULL, email_confirmed TINYINT(1) NOT NULL DEFAULT '0', email_non_public TINYINT(1) NOT NULL DEFAULT '1', password VARCHAR(100) NOT NULL, account_non_expired TINYINT(1) NOT NULL DEFAULT '1', credentials_non_expired TINYINT(1) NOT NULL DEFAULT '1', account_non_locked TINYINT(1) NOT NULL DEFAULT '1', enabled TINYINT(1) NOT NULL DEFAULT '1', created_on DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_on DATETIME ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), UNIQUE KEY authtion_consumers_id_uindex (id), UNIQUE KEY authtion_consumers_email_uindex (email) ) ENGINE = InnoDB AUTO_INCREMENT = 1000 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; CREATE TABLE authtion_countries ( country VARCHAR(100) NOT NULL, alpha2 VARCHAR(2) NOT NULL, alpha3 VARCHAR(3) NOT NULL DEFAULT '', phone_code VARCHAR(50), PRIMARY KEY (alpha2) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; CREATE TABLE authtion_genders ( gender VARCHAR(1) NOT NULL, description VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (gender) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; CREATE TABLE authtion_users ( consumer_id BIGINT(20) NOT NULL, nick_name VARCHAR(20), nick_name_non_public TINYINT(1) NOT NULL DEFAULT '1', first_name VARCHAR(20), first_name_non_public TINYINT(1) NOT NULL DEFAULT '1', middle_name VARCHAR(20), middle_name_non_public TINYINT(1) NOT NULL DEFAULT '1', last_name VARCHAR(20), last_name_non_public TINYINT(1) NOT NULL DEFAULT '1', gender VARCHAR(1), gender_non_public TINYINT(1) NOT NULL DEFAULT '1', date_of_birth DATE, date_of_birth_non_public TINYINT(1) NOT NULL DEFAULT '1', country VARCHAR(2), country_non_public TINYINT(1) NOT NULL DEFAULT '1', city VARCHAR(100), city_non_public TINYINT(1) NOT NULL DEFAULT '1', company VARCHAR(100), company_non_public TINYINT(1) NOT NULL DEFAULT '1', updated_on DATETIME ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, KEY authtion_users_consumers_id_fk (consumer_id), CONSTRAINT authtion_users_consumers_id_fk FOREIGN KEY (consumer_id) REFERENCES authtion_consumers (id) ON DELETE CASCADE, CONSTRAINT authtion_users_genders_id_fk FOREIGN KEY (gender) REFERENCES authtion_genders (gender) ON DELETE CASCADE, CONSTRAINT authtion_users_countries_country_fk FOREIGN KEY (country) REFERENCES authtion_countries (alpha2) ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; CREATE TABLE authtion_authorities ( authority VARCHAR(20) NOT NULL, description VARCHAR(100) NOT NULL DEFAULT '', PRIMARY KEY (authority), UNIQUE KEY authtion_authorities_authority_uindex (authority) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; CREATE TABLE authtion_consumer_authority ( consumer_id BIGINT(20) NOT NULL, authority VARCHAR(20) NOT NULL, KEY authtion_consumer_authority_consumers_id_fk (consumer_id), KEY authtion_consumer_authority_authorities_authority_fk (authority), CONSTRAINT authtion_consumer_authority_consumers_id_fk FOREIGN KEY (consumer_id) REFERENCES authtion_consumers (id) ON DELETE CASCADE, CONSTRAINT authtion_consumer_authority_authorities_authority_fk FOREIGN KEY (authority) REFERENCES authtion_authorities (authority) ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; CREATE TABLE authtion_mailing ( created_on DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `type` INT NOT NULL, email VARCHAR(50) NOT NULL, sent TINYINT(1) NOT NULL, max_attempts_reached TINYINT(1) NOT NULL, data VARCHAR(1000) NOT NULL DEFAULT '', cause_of_last_failure VARCHAR(1000) NOT NULL DEFAULT '', updated_on DATETIME ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (created_on, `type`, email) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; -- -- To persist tokens between server restarts I need: -- 1) to configure a persistent token store (JdbcTokenStore for example, see config/TokenStoreConfig.java) -- 2) create SQL tables: https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/test/resources/schema.sql -- (minimum): CREATE TABLE oauth_access_token ( token_id VARCHAR(256), token BLOB, authentication_id VARCHAR(256) PRIMARY KEY, user_name VARCHAR(256), client_id VARCHAR(256), authentication BLOB, refresh_token VARCHAR(256) ); CREATE TABLE oauth_refresh_token ( token_id VARCHAR(256), token BLOB, authentication BLOB );
alter table PLACEUR_PLACE drop column PICTURE_ID cascade ;
UPDATE Users SET Password = NULL WHERE LastLoginTime < '2010-03-10 00:00:00.000'
alter table icd_annotation add index component_author (component_id, author_id);
DROP TABLE IF EXISTS FRUITS; DROP TABLE IF EXISTS CHEESES; DROP TABLE IF EXISTS SWEETS; CREATE TABLE FRUITS( ID BIGINT AUTO_INCREMENT, NAME varchar(255) ); CREATE TABLE CHEESES( ID BIGINT AUTO_INCREMENT, NAME varchar(255) ); CREATE TABLE SWEETS( ID BIGINT AUTO_INCREMENT, NAME varchar(255) );
--Problem 1. Create Database CREATE DATABASE [Minions] USE [Minions] --Problem 2. Create Tables CREATE TABLE [Minions]( [Id] INT PRIMARY KEY, [Name] NVARCHAR(50) NOT NULL, [Age] INT NOT NULL ) CREATE TABLE [Towns]( [Id] INT PRIMARY KEY, [Name] NVARCHAR(50) NOT NULL ) --Problem 3. Alter Minions Table ALTER TABLE [Minions] ADD [TownId] INT FOREIGN KEY REFERENCES [Towns](Id) SET IDENTITY_INSERT [Minions] ON SET IDENTITY_INSERT [Towns] OFF --Problem 4. Insert Records in Both Tables INSERT INTO [Towns]([Id], [Name]) VALUES (1, 'Sofia'), (2, 'Plovdiv'), (3, 'Varna') ALTER TABLE [Minions] ALTER COLUMN [Age] INT INSERT INTO [Minions]([Id], [Name], [Age], [TownId]) VALUES (1, 'Kevin', 22, 1), (2, 'Bob', 15, 3), (3, 'Steward', NULL, 2) SELECT * FROM [Minions] SELECT * FROM [Towns] --Problem 5. Truncate Table Minions TRUNCATE TABLE [Minions] -- Problem 6. Drop All Tables DROP TABLE [Minions], [Towns] --Problem 7. Create Table People CREATE TABLE [People]( [Id] INT PRIMARY KEY IDENTITY NOT NULL, [Name] NVARCHAR(200) NOT NULL, [Picture] VARBINARY(MAX), CHECK (DATALENGTH([Picture]) <= 2000000), [Height] DECIMAL(3,2), [Weight] DECIMAL(5,2), [Gender] CHAR(1) NOT NULL, CHECK ([Gender] = 'm' OR [Gender] = 'f'), [Birthdate] DATE NOT NULL, [Biography] NVARCHAR(MAX) ) INSERT INTO [People]([Name], [Height], [Weight], [Gender], [Birthdate]) VALUES ('Pesho', 1.85, 78.50, 'm', '1988-09-27'), ('Gosho', 1.75, 98.50, 'm', '1983-09-05'), ('Maria', 1.68, 48.50, 'f', '1999-12-07'), ('Ivan', 1.95, 91.05, 'm', '1986-05-15'), ('Silvia', 1.77, 55.00, 'f', '1996-11-30') SELECT * FROM [People] -- Problem 8. Create Table Users -> first variant for judge.softuni.org CREATE TABLE [Users]( [Id] BIGINT PRIMARY KEY IDENTITY NOT NULL, [Username] VARCHAR(30) NOT NULL UNIQUE, [ProfilePassword] VARCHAR(26) NOT NULL, [Picture] VARBINARY(MAX), CHECK (DATALENGTH([Picture]) <= 900000), [LastLoginTime] TIME, [IsDeleted] BIT ) INSERT INTO [Users]([Username], [ProfilePassword], [LastLoginTime], [IsDeleted]) VALUES ('Pesho', 'SADGASGSFDNJsukjh', '15:25:33', 'true'), ('Ico', 'SADGAfsahfhsukjh', '15:03:33', 'true'), ('Gosho', 'SADGAdshsNJsukjh', '12:49:58', 'false'), ('Ivan', 'SADGAdshsNJsusadkjh', '09:49:58', 'false'), ('Niki', 'SADasdGAdshsNJsukjh', '11:49:58', 'true') SELECT * FROM [Users] -- Problem 8. Create Table Users -> second variant for judge.softuni.org CREATE TABLE [Users]( [Id] BIGINT PRIMARY KEY IDENTITY NOT NULL, [Username] VARCHAR(30) NOT NULL, [ProfilePassword] VARCHAR(26) NOT NULL, [Picture] VARBINARY(MAX), CHECK (DATALENGTH([Picture]) <= 900000), [LastLoginTime] DATETIME2, [IsDeleted] BIT DEFAULT 0 ) INSERT INTO [Users]([Username], [ProfilePassword], [LastLoginTime]) VALUES ('Pesho', 'SADGASGSFDNJsukjh', (CURRENT_TIMESTAMP)), ('Ico', 'SADGAfsahfhsukjh', (CURRENT_TIMESTAMP)), ('Gosho', 'SADGAdshsNJsukjh', (CURRENT_TIMESTAMP)), ('Ivan', 'SADGAdssdahsNJsukjh', (CURRENT_TIMESTAMP)), ('Niki', 'SADGasdAdshsNJsukjh', (CURRENT_TIMESTAMP)) SELECT * FROM [Users] -- Problem 8. Create Table Users -> third variant for judge.softuni.org CREATE TABLE [Users]( [Id] BIGINT PRIMARY KEY IDENTITY NOT NULL, [Username] VARCHAR(30) NOT NULL, [ProfilePassword] VARCHAR(26) NOT NULL, [Picture] VARBINARY(MAX), CHECK (DATALENGTH([Picture]) <= 900000), [LastLoginTime] DATETIME2, [IsDeleted] BIT ) INSERT INTO [Users]([Username], [ProfilePassword], [LastLoginTime], [IsDeleted]) VALUES ('Pesho', 'SADGASGSFDNJsukjh', (CURRENT_TIMESTAMP), 1), ('Ico', 'SADGAfsahfhsukjh', (CURRENT_TIMESTAMP), 0), ('Gosho', 'SADGAdshsNJsukjh', (CURRENT_TIMESTAMP), 1), ('Ivo', 'gfahathartahah', (CURRENT_TIMESTAMP), 0), ('Ivan', 'afdasf', (CURRENT_TIMESTAMP), 1) SELECT * FROM [Users] --Problem 9. Change Primary Key ALTER TABLE [Users] DROP CONSTRAINT [PK__Users__3214EC07D3B56B0D] ALTER TABLE [Users] ADD CONSTRAINT [Pk_Users] PRIMARY KEY (Id,Username); --Problem 10. Add Check Constraint ALTER TABLE [Users] ADD CHECK (DATALENGTH([ProfilePassword]) >= 5) --Problem 11. Set Default Value of a Field ALTER TABLE [Users] ADD DEFAULT (CURRENT_TIMESTAMP) FOR [LastLoginTime] --Problem 12. Set Unique Field ALTER TABLE [Users] DROP CONSTRAINT [PK_Users] ALTER TABLE [Users] ADD CONSTRAINT [Pk_Users] PRIMARY KEY (Id); ALTER TABLE [Users] ADD UNIQUE ([Username]) --Problem 13. Movies Database CREATE TABLE [Directors]( [Id] INT PRIMARY KEY IDENTITY, [DirectorName] NVARCHAR(25) NOT NULL, [Notes] NVARCHAR(50) ) CREATE TABLE [Genres]( [Id] INT PRIMARY KEY IDENTITY, [GenreName] NVARCHAR(50) NOT NULL, [Notes] TEXT ) CREATE TABLE [Categories]( [Id] INT PRIMARY KEY IDENTITY, [CategoryName] NVARCHAR(50) NOT NULL, [Notes] TEXT ) CREATE TABLE [Movies]( [Id] INT PRIMARY KEY IDENTITY, [Title] NVARCHAR(50) NOT NULL, [DirectorId] INT FOREIGN KEY REFERENCES [Directors]([Id]), [CopyrightYear] DECIMAL(4,0), [Length] TIME, [GenreId] INT FOREIGN KEY REFERENCES [Genres]([Id]), [CategoryId] INT FOREIGN KEY REFERENCES [Categories]([Id]), [Rating] DECIMAL(2,1), [Notes] TEXT ) INSERT INTO [Directors]([DirectorName]) VALUES ('Pesho'), ('Slavi'), ('Pesho'), ('Ivan'), ('Gosho') INSERT INTO [Genres]([GenreName]) VALUES ('Horror'), ('Comedy'), ('Sci-Fi'), ('Thriller'), ('Fantasy') INSERT INTO [Categories]([CategoryName]) VALUES ('Action'), ('Drama'), ('Mystery'), ('Thriller'), ('Western') INSERT INTO [Movies]([Title], [DirectorId], [CopyrightYear], [Length], [GenreId], [CategoryId], [Rating]) VALUES ('DSFG', 3, 2021, '03:45:25', 1, 2, 9.8), ('FGA', 2, 2021, '01:45:36', 4, 2, 7.7), ('HGFDH', 1, 2021, '01:35:45', 2, 2, 3.8), ('DSGFDFG', 4, 2021, '01:15:35', 3, 2, 7.8), ('DSGFDGFG', 5, 2021, '02:45:15', 5, 2, 1.2) SELECT * FROM[Directors] SELECT * FROM [Genres] SELECT * FROM [Categories] SELECT * FROM [Movies] DROP TABLE [Categories] DROP TABLE [Customers] --Problem 14. Car Rental Database CREATE TABLE [Categories]( [Id] INT PRIMARY KEY IDENTITY, [CategoryName] NVARCHAR(50) NOT NULL, [DailyRate] DECIMAL(7,2), [WeeklyRate] DECIMAL(7,2), [MonthlyRate] DECIMAL(7,2), [WeekendRate] DECIMAL(7,2) ) CREATE TABLE [Cars]( [Id] INT PRIMARY KEY IDENTITY, [PlateNumber] NVARCHAR(20) NOT NULL, [Manufacturer] NVARCHAR(20) NOT NULL, [Model] NVARCHAR(20) NOT NULL, [CarYear] DECIMAL(4,0), [CategoryId] INT FOREIGN KEY REFERENCES [Categories]([Id]), [Doors] DECIMAL(1,0), [Picture] VARBINARY(MAX), CHECK (DATALENGTH([Picture]) <= 2000000), [Condition] NVARCHAR(15), [Available] BIT ) CREATE TABLE [Employees]( [Id] INT PRIMARY KEY IDENTITY, [FirstName] NVARCHAR(25) NOT NULL, [LastName] NVARCHAR(25) NOT NULL, [Title] NVARCHAR(10), [Notes] TEXT ) CREATE TABLE [Customers]( [Id] INT PRIMARY KEY IDENTITY, [DriverLicenceNumber] NVARCHAR(40) NOT NULL, [FullName] NVARCHAR(25) NOT NULL, [Address] TEXT, [ZIPCode] NVARCHAR(15), [Notes] TEXT ) CREATE TABLE [RentalOrders]( [Id] INT PRIMARY KEY IDENTITY, [EmployeeId] INT FOREIGN KEY REFERENCES [Employees]([Id]), [CustomerId] INT FOREIGN KEY REFERENCES [Customers]([Id]), [CarId] INT FOREIGN KEY REFERENCES [Cars]([Id]), [TankLevel] NVARCHAR(10) NOT NULL, [KilometrageStart] DECIMAL(4,1), [KilometrageEnd] DECIMAL(4,1), [TotalKilometrage] DECIMAL(10,0), [StartDate] DATE NOT NULL, [EndDate] DATE NOT NULL, [TotalDays] DECIMAL(4,0), [RateApplied] DECIMAL(7,2), [TaxRate] DECIMAL(7,2), [OrderStatus] NVARCHAR(15), [Notes] TEXT ) INSERT INTO [Categories]([CategoryName], [DailyRate], [WeeklyRate], [WeekendRate]) VALUES ('practical', 59.99, 255.28, 122.25), ('comfortable',65.89, 299.87, 165.33), ('economical', 45.77, 199.54, 135.39) INSERT INTO [Cars]([PlateNumber], [Manufacturer], [Model], [CarYear], [CategoryId], [Doors], [Available]) VALUES ('EH0212BP', 'Opel', 'Astra', 1992, 1, 4, 'true'), ('EH02da2BP', 'Oasdel', 'Astasda', 2005, 2, 4, 'true'), ('EHasd212BP', 'Opasdl', 'Astasdasa', 2022, 3, 2, 'false') INSERT INTO [Employees]([FirstName], [LastName]) VALUES ('Petar', 'Ivanov'), ('Stoyan', 'Georgiev'), ('Ivan', 'Petrov') INSERT INTO [Customers]([DriverLicenceNumber], [FullName], [ZIPCode]) VALUES ('JIGLAKFJFJHGDHASF', 'Petar Georgiev', '528000BT'), ('JIdasdFJFJHGDHASF', 'Milen Georgiev', '5246540BT'), ('JIGLAKFJFgfdgfDHASF', 'Petar Stoyanov', '5280655BT') INSERT INTO [RentalOrders]([EmployeeId], [CustomerId], [CarId], [TankLevel], [StartDate], [EndDate], [OrderStatus]) VALUES (1, 3, 2, 'FULL', '1988-09-27', '1988-10-27', 'Complete'), (2, 3, 3, 'HALF', '2022-05-27', '2022-10-15', 'Alieve'), (3, 1, 1, 'EMPTY', '1989-12-27', '1990-11-05', 'Complete') SELECT * FROM [Categories] SELECT * FROM [Cars] SELECT * FROM [Employees] SELECT * FROM [Customers] SELECT * FROM [RentalOrders] -- Problem 15. Hotel Database CREATE TABLE [Employees]( [Id] INT PRIMARY KEY IDENTITY, [FirstName] NVARCHAR(25) NOT NULL, [LastName] NVARCHAR(25) NOT NULL, [Title] NVARCHAR(10), [Notes] TEXT ) CREATE TABLE [Customers]( [Accountnumber] DECIMAL(10,0) PRIMARY KEY NOT NULL, [FirstName] NVARCHAR(15) NOT NULL, [LastName] NVARCHAR(15) NOT NULL, [PhoneNumber] DECIMAL(10,0) NOT NULL, [EmergencyName] NVARCHAR(25), [EmergencyNumber] DECIMAL(10,0), [Notes] TEXT ) CREATE TABLE [RoomStatus]( [RoomStatus] NVARCHAR(10) PRIMARY KEY NOT NULL, [Notes] TEXT ) CREATE TABLE [RoomTypes]( [RoomType] NVARCHAR(10) PRIMARY KEY NOT NULL, [Notes] TEXT ) CREATE TABLE [BedTypes]( [BedType] NVARCHAR(10) PRIMARY KEY NOT NULL, [Notes] TEXT ) CREATE TABLE [Rooms]( [RoomNumber] SMALLINT PRIMARY KEY NOT NULL, [RoomType] NVARCHAR(10) FOREIGN KEY REFERENCES [RoomTypes]([RoomType]), [BedType] NVARCHAR(10) FOREIGN KEY REFERENCES [BedTypes]([BedType]), [Rate] DECIMAL(7,2) NOT NULL, [RoomStatus] NVARCHAR(10) FOREIGN KEY REFERENCES [RoomStatus]([RoomStatus]), [Notes] TEXT ) CREATE TABLE [Payments]( [Id] INT PRIMARY KEY IDENTITY, [EmployeeId] INT FOREIGN KEY REFERENCES [Employees]([Id]), [PaymentDate] DATE, [AccountNumber] DECIMAL(10,0) FOREIGN KEY REFERENCES [Customers]([AccountNumber]), [FirstDateOccupied] DATE NOT NULL, [LastDateOccupied] DATE NOT NULL, [TotalDays] DECIMAL(4,0), [AmountCharged] DECIMAL(7,2), [TaxRate] DECIMAL(4,2), [TaxAmount] DECIMAL(7,2), [PaymentTotal] DECIMAL(7,2), [Notes] TEXT ) CREATE TABLE [Occupancies]( [Id] INT PRIMARY KEY IDENTITY, [EmployeeId] INT FOREIGN KEY REFERENCES [Employees]([Id]), [DateOccupied] DATE NOT NULL, [AccountNumber] DECIMAL(10,0) FOREIGN KEY REFERENCES [Customers]([AccountNumber]), [RoomNumber] SMALLINT FOREIGN KEY REFERENCES [Rooms]([RoomNumber]), [RateApplied] DECIMAL(5,2), [PhoneCharge] DECIMAL(5,2), [Notes] TEXT ) INSERT INTO [Employees]([FirstName], [LastName]) VALUES ('Petar', 'Ivanov'), ('Stoyan', 'Georgiev'), ('Ivan', 'Petrov') INSERT INTO [Customers]([AccountNumber], [FirstName], [LastName], [PhoneNumber]) VALUES (1234567890, 'Petar', 'Ivanov', 0886656814), (1234667890, 'Stoyan', 'Georgiev', 0685456814), (1234567990, 'Ivan', 'Petrov', 0886855681) INSERT INTO [RoomStatus]([RoomStatus]) VALUES ('Available'), ('occupated'), ('Cleening') INSERT INTO [RoomTypes]([RoomType]) VALUES ('Double'), ('Single'), ('Famaly') INSERT INTO [BedTypes]([BedType]) VALUES ('Double'), ('KingSize'), ('Single') INSERT INTO [Rooms]([RoomNumber], [RoomType], [BedType], [Rate], [RoomStatus]) VALUES (122, 'Double', 'Double', 25.50, 'Available'), (132, 'Double', 'Single', 15.50, 'occupated'), (322, 'Double', 'KingSize', 45.50, 'Cleening') INSERT INTO [Payments]([EmployeeId], [AccountNumber], [PaymentDate], [FirstDateOccupied], [LastDateOccupied]) VALUES (1, 1234567890, '2020-05-27', '2022-05-27', '2022-09-27'), (2, 1234667890, '2021-05-27', '2022-06-15', '2022-09-01'), (3, 1234567990, '2021-06-27', '2022-09-27', '2023-01-15') INSERT INTO [Occupancies]([EmployeeId], [DateOccupied], [AccountNumber], [RoomNumber]) VALUES (1, '2022-05-27', 1234567890, 122), (2, '2022-06-27', 1234667890, 132), (3, '2022-09-27', 1234567990, 322) SELECT * FROM [Employees] SELECT * FROM [Customers] SELECT * FROM [RoomStatus] SELECT * FROM [RoomTypes] SELECT * FROM [BedTypes] SELECT * FROM [Rooms] SELECT * FROM [Payments] SELECT * FROM [Occupancies] --Problem 16. Create SoftUni Database --Problem 19. Basic Select All Fields SELECT * FROM [Towns] SELECT * FROM [Departments] SELECT * FROM [Employees] --Problem 20. Basic Select All Fields and Order Them SELECT * FROM [Towns] ORDER BY [Name] ASC; SELECT * FROM [Departments] ORDER BY [Name] ASC; SELECT * FROM [Employees] ORDER BY [Salary] DESC; --Problem 21. Basic Select Some Fields SELECT [Name] FROM [Towns] ORDER BY [Name] ASC; SELECT [Name] FROM [Departments] ORDER BY [Name] ASC; SELECT [FirstName], [LastName], [JobTitle], [Salary] FROM [Employees] ORDER BY [Salary] DESC; --Problem 22. Increase Employees Salary --CREATE TABLE [Money]( -- [Id] INT PRIMARY KEY IDENTITY, -- [FirstName] NVARCHAR(25) NOT NULL, -- [LastName] NVARCHAR(25) NOT NULL, -- [Salary] DECIMAL(7, 2), -- [Notes] TEXT --) --INSERT INTO [Money]([FirstName], [LastName], [Salary]) -- VALUES --('Double', 'GFU', 25.25), --('Single', 'UGDSAF', 37.25), --('Famaly', 'JHUFALHD', 45.78) UPDATE [Employees] SET [Salary] = [Salary] + ([Salary] * 0.1) SELECT [Salary] FROM [Employees] --Problem 23. Decrease Tax Rate UPDATE [Payments] SET [TaxRate] = [TaxRate] - ([TaxRate] * 0.03) SELECT [TaxRate] FROM [Payments] --Problem 24. Delete All Records TRUNCATE TABLE [Occupancies] -- RANAMING COLUNM EXEC sp_RENAME 'Rooms.LastName', 'BedType'
/* Warnings: - You are about to drop the `_opcionValoresToproducto` table. If the table is not empty, all the data it contains will be lost. - You are about to drop the `opcionValores` table. If the table is not empty, all the data it contains will be lost. - Added the required column `idProducto` to the `productoDeVenta` table without a default value. This is not possible if the table is not empty. */ -- DropForeignKey ALTER TABLE "_opcionValoresToproducto" DROP CONSTRAINT "_opcionValoresToproducto_A_fkey"; -- DropForeignKey ALTER TABLE "_opcionValoresToproducto" DROP CONSTRAINT "_opcionValoresToproducto_B_fkey"; -- DropForeignKey ALTER TABLE "opcionCategoria" DROP CONSTRAINT "opcionCategoria_idOpcionValores_fkey"; -- AlterTable ALTER TABLE "productoDeVenta" ADD COLUMN "idProducto" BIGINT NOT NULL; -- DropTable DROP TABLE "_opcionValoresToproducto"; -- DropTable DROP TABLE "opcionValores"; -- CreateTable CREATE TABLE "opcionCatValores" ( "idOpcionCat" BIGINT NOT NULL, "idValor" BIGINT NOT NULL, "nombre" TEXT NOT NULL, PRIMARY KEY ("idOpcionCat","idValor") ); -- CreateTable CREATE TABLE "productoDeVentaOpciones" ( "id" BIGSERIAL NOT NULL, "idProductoDeVenta" BIGINT NOT NULL, "idOpcionCategoria" BIGINT NOT NULL, "idOpcionCatValor" BIGINT NOT NULL, "idValor" BIGINT NOT NULL, PRIMARY KEY ("id") ); -- AddForeignKey ALTER TABLE "opcionCatValores" ADD FOREIGN KEY ("idOpcionCat") REFERENCES "opcionCategoria"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "productoDeVentaOpciones" ADD FOREIGN KEY ("idProductoDeVenta") REFERENCES "productoDeVenta"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "productoDeVentaOpciones" ADD FOREIGN KEY ("idOpcionCategoria") REFERENCES "opcionCategoria"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "productoDeVentaOpciones" ADD FOREIGN KEY ("idOpcionCatValor", "idValor") REFERENCES "opcionCatValores"("idOpcionCat", "idValor") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "productoDeVenta" ADD FOREIGN KEY ("idProducto") REFERENCES "producto"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `collections` ADD UNIQUE KEY `name` (`name`), ADD UNIQUE KEY `description` (`description`);