text stringlengths 6 9.38M |
|---|
SELECT birth FROM PEOPLE WHERE name is 'Emma Stone'; |
CREATE TABLE tarjay_reviews (
id INT,
created_at VARCHAR(16),
author VARCHAR(256),
stars INT,
body VARCHAR,
would_recommend BOOLEAN,
title VARCHAR(256),
comfort INT,
style INT,
value INT,
sizing INT,
helpful_votes INT,
product_id INT,
PRIMARY KEY (product_id, id)
);
COPY tarjay_reviews(
id,
created_at,
author,
stars,
body,
would_recommend,
title,
comfort,
style,
value,
sizing,
helpful_votes,
product_id
)
FROM '/home/singh/hackreactor/SDC/service/target_reviews_component/newDb/newSeed.csv'
DELIMITER ','
CSV HEADER;
COPY tarjay_reviews
FROM '/home/singh/hackreactor/SDC/service/target_reviews_component/newDb/newSeed.tsv'
DELIMITER E'\t'; |
DROP TABLE customer IF EXISTS;
CREATE TABLE customer (
id BIGINT IDENTITY PRIMARY KEY,
name VARCHAR(255),
email VARCHAR(255)
);
CREATE TABLE stock (
id INT IDENTITY PRIMARY KEY,
symbol VARCHAR(10) UNIQUE,
price DECIMAL(10,2)
);
CREATE TABLE customer_stocks (
id BIGINT IDENTITY PRIMARY KEY,
customer_id BIGINT,
stock_id INT
);
ALTER TABLE customer_stocks
ADD FOREIGN KEY (customer_id) REFERENCES customer(id);
ALTER TABLE customer_stocks
ADD FOREIGN KEY (stock_id) REFERENCES stock(id);
|
\set ON_ERROR_STOP true
CREATE TYPE lift_data_template AS ENUM(
'weight/reps',
'height/reps',
'timeInSeconds',
'weight/timeInSeconds'
);
CREATE TABLE lifts(
id serial PRIMARY KEY,
name varchar(256),
workout integer NOT NULL,
data_template lift_data_template NOT NULL,
sets integer[]
);
CREATE TABLE sets(
id serial PRIMARY KEY,
data_template lift_data_template NOT NULL,
lift integer NOT NULL,
weight real,
height real,
time_in_seconds real,
reps integer
);
INSERT INTO lifts (name,workout,data_template,sets) VALUES ('turtle lift',1,'weight/reps','{1,2,3}');
INSERT INTO lifts (name,workout,data_template,sets) VALUES ('turtle press',1,'weight/reps','{4,5,6}');
INSERT INTO lifts (name,workout,data_template,sets) VALUES ('turtle push',1,'weight/reps','{7,8,9}');
INSERT INTO lifts (name,workout,data_template,sets) VALUES ('turtle press',2,'weight/reps','{10,11,12}');
INSERT INTO lifts (name,workout,data_template,sets) VALUES ('turtle cleans',2,'weight/reps','{13,14,15}');
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',1,100.0,NULL,NULL,10);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',1,110.0,NULL,NULL,10);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',1,120.0,NULL,NULL,10);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',2,155.0,NULL,NULL,8);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',2,165.0,NULL,NULL,8);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',2,175.0,NULL,NULL,8);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',3,210.5,NULL,NULL,3);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',3,215.5,NULL,NULL,3);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',3,220.5,NULL,NULL,2);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',4,165.0,NULL,NULL,8);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',4,175.0,NULL,NULL,8);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',4,185.0,NULL,NULL,8);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',5,135.0,NULL,NULL,5);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',5,155.0,NULL,NULL,5);
INSERT INTO sets(data_template,lift,weight,height,time_in_seconds,reps) VALUES ('weight/reps',5,175.0,NULL,NULL,4);
|
select trim(rat.nm_rat) as ramo_atividade,
gem.nm_gem as grupo_empresarial,
emp.nm_emp as empresa,
crt.cd_crt as cartao,
cun.nr_cpf_cnpj_cun as cpf,
to_char(crt.dt_inc_usr, 'dd/MM/yyyy') as data_inclusao_cartao,
to_char(crt.dt_pri_dps_crt, 'dd/MM/yyyy') as data_primeiro_deposito,
to_char(crt.dt_ult_dps_crt, 'dd/MM/yyyy') as data_ultimo_deposito,
case when crt.fg_atv_crt = 'S' then 'Ativo' else 'Inativo' end as status,
mes.descricao as mes,
coalesce(sc_opr.get_limite_concedido_tempo(crt.cd_crt, 1, (to_date('01/' || mes.descricao, 'dd/mm/yyyy') + interval '1 month')::date), 0) as limite_concedido_saque_extra,
coalesce(opr.valor_saque_extra, 0) as valor_faturado_saque_extra,
coalesce(opr.valor_pago_saque_extra, 0) as valor_pago_saque_extra,
coalesce(sc_opr.get_limite_concedido_tempo(crt.cd_crt, 2, (to_date('01/' || mes.descricao, 'dd/mm/yyyy') + interval '1 month')::date), lmt.vl_cnc_lmt) as limite_concedido_compra,
coalesce(opr.valor_compra, 0) as valor_faturado_compra,
coalesce(opr.valor_pago_compra, 0) as valor_pago_compra,
coalesce(dps.valor_depositado, 0) as valor_depositado,
coalesce(trf.valor_tmc, 0) as valor_tmc
from sc_opr.tbl_crt crt
left join sc_opr.tbl_lmt lmt on crt.cd_crt = lmt.cd_crt and lmt.cd_tlt = 2
inner join sc_analise.tbl_mes mes on 1 = 1 and mes.ano = 2019 and mes.mes <= 12
inner join sc_cad.tbl_fnc fnc on crt.cd_fnc = fnc.cd_fnc
inner join sc_cad.tbl_cun cun on fnc.cd_cun = cun.cd_cun
inner join sc_cad.tbl_emp emp on fnc.cd_emp = emp.cd_emp
inner join sc_cad.tbl_gem gem on emp.cd_gem = gem.cd_gem
inner join sc_cad.tbl_rat rat on emp.cd_rat = rat.cd_rat
left join (select sum(case when fcr_tlt.cd_tlt = 1 then fcr_tlt.vl_ttl_fcr_tlt else 0 end) as valor_saque_extra,
sum(case when fcr_tlt.cd_tlt = 2 then fcr_tlt.vl_ttl_fcr_tlt else 0 end) as valor_compra,
sum(case when fcr_tlt.cd_tlt = 1 then fcr_tlt.vl_ttl_fcr_tlt - fcr_tlt.vl_rst_fcr_tlt else 0 end) as valor_pago_saque_extra,
sum(case when fcr_tlt.cd_tlt = 2 then fcr_tlt.vl_ttl_fcr_tlt - fcr_tlt.vl_rst_fcr_tlt else 0 end) as valor_pago_compra,
fcr.cd_crt, to_char(fcr.dt_vnc_fcr, 'mm/yyyy') as mes
from sc_fcr.tbl_fcr fcr
inner join sc_fcr.tbl_fcr_tlt fcr_tlt on fcr.cd_fcr = fcr_tlt.cd_fcr
where fcr.dt_vnc_fcr >= '2019-01-01'
and fcr.st_fcr <> 3 --situação diferente de cancelada
group by fcr.cd_crt, to_char(fcr.dt_vnc_fcr, 'mm/yyyy')) opr on crt.cd_crt = opr.cd_crt and mes.descricao = opr.mes
left join (select sum(rdp.vl_dep_rdp) as valor_depositado,
rdp.cd_crt, to_char(hfe.dt_dps_hfe, 'mm/yyyy') as mes
from sc_adp.tbl_rdp rdp
inner join sc_adp.tbl_hfe hfe on rdp.cd_hfe = hfe.cd_hfe
where hfe.dt_dps_hfe >= '2019-01-01'
and hfe.st_hfe = 5 --situação depositado do arquivo de depósito
and rdp.st_rdp = 5 --situação depositado do registro de depósito
group by rdp.cd_crt, to_char(hfe.dt_dps_hfe, 'mm/yyyy')) dps on crt.cd_crt = dps.cd_crt and mes.descricao = dps.mes
left join (select sum(tsc.vl_tsc) as valor_tmc,
tsc.cd_crt, to_char(tsc.dt_pgto_tsc, 'mm/yyyy') as mes
from sc_srv.tbl_tsc tsc
where tsc.dt_pgto_tsc >= '2019-01-01'
and tsc.cd_srv = 12 -- tarifa de manutenção de conta
and tsc.st_tsc = 2 --situação cobrado
group by tsc.cd_crt, to_char(tsc.dt_pgto_tsc, 'mm/yyyy')) trf on crt.cd_crt = trf.cd_crt and mes.descricao = trf.mes
where crt.dt_ult_dps_crt >= '2019-01-01';
--and crt.fg_atv_crt = 'S'
--and crt.cd_crt = 60586876660144;
--separar app
select * from sc_cad.tbl_pce order by nm_pce;
select * from sc_cad.tbl_ctr where cd_emp = 29;
select * from sc_cad.tbl_fem_ctr where cd_ctr = 33;
select * from sc_cad.tbl_tlt_ctr where cd_fem_ctr = 566;
select sc_cad.get_parametro_contrato_cartao(46, 60586876660144)
vp_parametro numeric,
vp_cartao numeric,
select *--coalesce(max(cd_hlm), -1)
from sc_opr.tbl_hlm
where cd_crt = 60586876660144
and cd_tlt = 1
--and dt_inc_usr < '2019-02-02';
order by dt_inc_usr
select sc_opr.get_limite_concedido_tempo(60586876660144, 2, '2019-02-01')
--select auxiliares
select * from sc_opr.tbl_top order by nm_top
select * from sc_adp.tbl_rdp limit 10
select * from sc_fcr.tbl_fcr limit 10
select * from sc_opr.tbl_lmt limit 10
select * from sc_fcr.tbl_fcr_tlt where cd_fcr = 915473
select * from sc_cad.tbl_dmn where nm_cmp_dmn like '%TSC%'
select * from sc_adp.tbl_hfe limit 10 order by nm_top
--conferindo tarifas tmc cobradas
select sum(tsc.vl_tsc) as valor_tmc,
tsc.cd_crt, to_char(tsc.dt_pgto_tsc, 'mm/yyyy') as mes
from sc_srv.tbl_tsc tsc
where tsc.dt_pgto_tsc >= '2019-01-01'
and tsc.cd_srv = 12 -- tarifa de manutenção de conta
and tsc.st_tsc = 2 --situação cobrado
and tsc.cd_crt in (62015564162526)
group by tsc.cd_crt, to_char(tsc.dt_pgto_tsc, 'mm/yyyy') |
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
DROP TABLE `roles_privileges`;
DROP TABLE `privileges`;
DROP TABLE `userPasswordResetToken`;
DROP TABLE `userVerificationToken`;
DROP TABLE `user_roles`;
DROP TABLE `roles`;
CREATE TABLE IF NOT EXISTS `privileges` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `roles` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`dateCreated` datetime DEFAULT NULL,
`lastUpdated` datetime DEFAULT NULL,
`version` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `roles_privileges` (
`role_id` bigint(20) NOT NULL,
`privilege_id` bigint(20) NOT NULL,
KEY `FK5duhoc7rwt8h06avv41o41cfy` (`privilege_id`),
KEY `FK629oqwrudgp5u7tewl07ayugj` (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `userPasswordResetToken` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`expiryDate` datetime DEFAULT NULL,
`token` varchar(255) DEFAULT NULL,
`user_id` bigint(20) NOT NULL,
`newEncryptPassword` varchar(255) DEFAULT NULL,
`userId` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK5je774r7gry8c2maaovfivjfe` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `userVerificationToken` (
`id` bigint(20) NOT NULL,
`expiryDate` datetime DEFAULT NULL,
`token` varchar(255) DEFAULT NULL,
`user_id` bigint(20) NOT NULL,
`previousToken` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_VERIFY_USER` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `user_roles` (
`user_Id` bigint(20) NOT NULL,
`role_Id` bigint(20) NOT NULL,
PRIMARY KEY (`user_Id`),
KEY `FKh8ciramu9cc9q3qcqiv4ue8a6` (`role_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO privileges(`id`,`name`) VALUES(null,'READ_PRIVILEGE');
INSERT INTO privileges(`id`,`name`) VALUES(null,'WRITE_PRIVILEGE');
INSERT INTO roles (`id`,`name`,`dateCreated`,`lastUpdated`,`version`) VALUES (NULL,'ROLE_ADMIN',DATE( NOW( )),DATE( NOW( )),'1');
INSERT INTO roles (`id`,`name`,`dateCreated`,`lastUpdated`,`version`) VALUES (NULL,'ROLE_USER',DATE( NOW( )),DATE( NOW( )),'1');
INSERT INTO roles_privileges (`role_id`, `privilege_id`) VALUES(1,1);
INSERT INTO roles_privileges (`role_id`, `privilege_id`) VALUES(1,2);
INSERT INTO roles_privileges (`role_id`, `privilege_id`) VALUES(2,1);
INSERT INTO roles_privileges (`role_id`, `privilege_id`) VALUES(2,2); |
DROP TABLE IF EXISTS trail;
CREATE TABLE trail (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
summary VARCHAR(255),
trail_id INT,
difficulty VARCHAR(255),
stars DECIMAL(3,1),
img_small VARCHAR(255),
latitude DECIMAL (12,7),
longitude DECIMAL (12,7),
length DECIMAL(4,1),
conditionstatus TEXT,
conditiondetails TEXT
);
INSERT INTO TRAIL (name, summary, trail_id, difficulty, stars, img_small, latitude, longitude,length, conditionstatus, conditiondetails) VALUES ('Shevlin Loop Trail',
'An after work special for the Bend 9-to-5er or a tune-up time trial for the dedicated racer.',7009092,'Easy',
4.2,'https://cdn-files.apstatic.com/hike/7007179_sqsmall_1554322332.jpg',44.0818,-121.3784,4.8,'Unknown',
'null');
INSERT INTO TRAIL (name, summary, trail_id, difficulty, stars, img_small, latitude, longitude,length, conditionstatus, conditiondetails) VALUES ('Deschutes River Hiking Trail',
'Needs Summary',7073493,'Easy',
5,'https://cdn-files.apstatic.com/hike/7056730_sqsmall_1555945367.jpg',44.0221,-121.3633,14.5,'All Clear',
'Mostly Dry, Some Mud');
INSERT INTO TRAIL (name, summary, trail_id, difficulty, stars, img_small, latitude, longitude,length, conditionstatus, conditiondetails) VALUES (
'Tiddlywinks Lower',
'An easy climb connecting to other trails.',7035581,'Intermediate',
5,'https://cdn-files.apstatic.com/hike/7035792_sqsmall_1555020892.jpg',43.9783,-121.4684,4.1,'Unknown',
'null');
INSERT INTO TRAIL (name, summary, trail_id, difficulty, stars, img_small, latitude, longitude,length, conditionstatus, conditiondetails) VALUES ('Pilot Butte Trail',
'A steep, short climb with great views.',7005256,'Intermediate',
3.9,'https://cdn-files.apstatic.com/hike/7004532_sqsmall_1554245535.jpg',44.0579,-121.2786,0.9,'Unknown',
'null');
|
select promotions
, total
, cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
from (
select sum(ss_ext_sales_price) promotions
from store_sales
, store
, promotion
, date_dim
, customer
, customer_address
, item
where ss_sold_date_sk = d_date_sk
and ss_store_sk = s_store_sk
and ss_promo_sk = p_promo_sk
and ss_customer_sk= c_customer_sk
and ca_address_sk = c_current_addr_sk
and ss_item_sk = i_item_sk
and ca_gmt_offset = -7
and i_category = 'Electronics'
and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
and s_gmt_offset = -7
and d_year = 1999 and d_moy = 11
) promotional_sales, (
select sum(ss_ext_sales_price) total
from store_sales
, store
, date_dim
, customer
, customer_address
, item
where ss_sold_date_sk = d_date_sk
and ss_store_sk = s_store_sk
and ss_customer_sk = c_customer_sk
and ca_address_sk = c_current_addr_sk
and ss_item_sk = i_item_sk
and ca_gmt_offset = -7
and i_category = 'Electronics'
and s_gmt_offset = -7
and d_year = 1999
and d_moy = 11
) all_sales
order by promotions
, total
limit 100
; |
ALTER TABLE `boyo_advertisement` ADD COLUMN `title` VARCHAR(50) NOT NULL ;
CREATE TABLE IF NOT EXISTS `boyo_userCOOInfo` (
`userId` int(11) NOT NULL,
`level` int(11) NOT NULL,
`chargeGold` int(11) NOT NULL,
`lastLoginTime` int(11) NOT NULL,
`ext` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`userId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; |
# modifications to be applied to pre-57 databases to bring them to rel-57 state
## ---------------------renaming group_id into node_id in genomic_align_group table:
#
ALTER TABLE genomic_align_group DROP KEY genomic_align_id;
ALTER TABLE genomic_align_group DROP COLUMN type;
ALTER TABLE genomic_align_group CHANGE group_id node_id bigint unsigned NOT NULL AUTO_INCREMENT;
## The following two lines only "rename" a key, which is unlikely to be needed, but takes A LOT of time to complete:
#
#ALTER TABLE genomic_align_group ADD KEY node_id(node_id);
#ALTER TABLE genomic_align_group DROP KEY group_id;
ALTER TABLE genomic_align_group ADD UNIQUE KEY genomic_align_id(genomic_align_id);
## ---------------------add new keys for speeding things up:
#
ALTER TABLE genomic_align ADD KEY (method_link_species_set_id);
## --------------------making dnafrag_id bigint everywhere:
#
ALTER TABLE constrained_element MODIFY COLUMN dnafrag_id bigint(20) unsigned NOT NULL;
ALTER TABLE dnafrag MODIFY COLUMN dnafrag_id bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE dnafrag_region MODIFY COLUMN dnafrag_id bigint(20) unsigned NOT NULL DEFAULT '0';
ALTER TABLE genomic_align MODIFY COLUMN dnafrag_id bigint(20) unsigned NOT NULL DEFAULT '0';
## --------------------widening some analysis fields (Andy, you should have warned Compara and added these to the patch as well) :
#
ALTER TABLE analysis MODIFY COLUMN db_file varchar(255);
ALTER TABLE analysis MODIFY COLUMN program varchar(255);
ALTER TABLE analysis MODIFY COLUMN program_file varchar(255);
## ------------------- subset and subset_member tables are now becoming a part of the release:
#
CREATE TABLE subset (
subset_id int(10) NOT NULL auto_increment,
description varchar(255),
dump_loc varchar(255),
PRIMARY KEY (subset_id),
UNIQUE (description)
);
#
CREATE TABLE subset_member (
subset_id int(10) NOT NULL,
member_id int(10) NOT NULL,
KEY (member_id),
UNIQUE subset_member_id (subset_id, member_id)
);
## ---------------------- This table holds the sequence cds information
#
CREATE TABLE sequence_cds (
sequence_cds_id int(10) unsigned NOT NULL auto_increment, # unique internal id
member_id int(10) unsigned NOT NULL, # unique internal id
length int(10) NOT NULL,
sequence_cds longtext NOT NULL,
FOREIGN KEY (member_id) REFERENCES member(member_id),
PRIMARY KEY (sequence_cds_id),
KEY (member_id),
KEY sequence_cds (sequence_cds(64))
);
## ---------------------- Left-Right indices' offsets
#
CREATE TABLE lr_index_offset (
table_name varchar(64) NOT NULL,
lr_index int(10) unsigned NOT NULL,
PRIMARY KEY (table_name)
);
|
CREATE Procedure sp_Get_Beat_Customer @CustomerID nvarchar(30)
as
SELECT Beat.Description FROM Customer
INNER JOIN Beat_Salesman ON
Customer.CustomerID = Beat_Salesman.CustomerID
INNER JOIN Beat ON
Beat.BeatID = Beat_Salesman.BeatID
Where Customer.CustomerID = @CustomerID
|
create SCHEMA ALIENGAMESCHEMA;
drop TABLE ALIENGAMESCHEMA.RECORDS;
create TABLE ALIENGAMESCHEMA.RECORDS(name VARCHAR(20), winTime INTEGER);
insert into ALIENGAMESCHEMA.RECORDS values ('Abraham', 100000);
select * from ALIENGAMESCHEMA.RECORDS;
|
-- =============================================
-- Author: Satish Kayada
-- Create date: 01/02/2018
-- Description: Display Header on Tab of Inward outward Page only
-- =============================================
Create PROC [Stock].[usp_Appointment_Stock_Inward_To_Outward_Header_Text]
AS
BEGIN
Select Count(*) As totalparty,sum(stonecount) as totalstone
From (
SELECT Distinct Visit.PARTY_CODE,StoneId.stoneid,
1 As stonecount
FROM Stock.VISIT_STONES_FOR_NEXTCABIN StoneId
left join Stock.VISIT on Stock.VISIT.visit_id=StoneId.visit_id
) as stone
END; |
CREATE TABLE `code_attribute` (
`CODE_ATTRIBUTE_ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`MARK` varchar(255) NOT NULL COMMENT '一组信息的唯一标识,默认是表名',
`COLUMN_NAME` varchar(255) NOT NULL COMMENT '表字段名',
`ATTRIBUTE_NAME` varchar(255) DEFAULT NULL COMMENT 'java 属性名',
`DESCRIPTION` varchar(500) NOT NULL COMMENT '描述信息',
`EQUAL_SUPPORT` enum('NO','YES') NOT NULL COMMENT '是否支持equal查询',
`IN_SUPPORT` enum('NO','YES') NOT NULL COMMENT '是否支持IN查询',
`COMPARE_SUPPORT` enum('NO','YES') NOT NULL COMMENT '是否支持比较查询',
`INDISTINCT_SUPPORT` enum('NO','YES') NOT NULL COMMENT '是否支持模糊查询',
`IS_PRIMARY` enum('NO','YES') NOT NULL COMMENT '是否是主键',
`SORT_ORDER` int(20) NOT NULL COMMENT '顺序',
`INPUT_TIME` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`CODE_ATTRIBUTE_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
CREATE TABLE `page_attribute` (
`PAGE_ATTRIBUTE_ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`VIEW_MARK` varchar(255) DEFAULT NULL COMMENT '视图标识',
`ATTRIBUTE` varchar(255) DEFAULT NULL COMMENT '属性名称',
`ALIAS` varchar(255) DEFAULT NULL COMMENT '显示别名',
`TYPE` enum('text','textbox','select','date','time') DEFAULT NULL COMMENT '显示方式',
`LENGTH` int(11) DEFAULT NULL COMMENT '长度',
`QUERY_TAG` enum('YES','NO') DEFAULT NULL COMMENT '是否做为查询条件',
`LIST_TAG` enum('YES','NO') DEFAULT NULL COMMENT '是否列表展示',
`ADD_TAG` enum('YES','NO') DEFAULT NULL COMMENT '是否支持增加',
`DETAIL_TAG` enum('YES','NO') DEFAULT NULL COMMENT '是否详情页面展示',
`UPDATE_TAG` enum('NO','UPDATE','VIEW') DEFAULT NULL COMMENT '是否修改页面展示',
PRIMARY KEY (`PAGE_ATTRIBUTE_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
|
--<서브 쿼리를 이용한 테이블 생성과 컬럼 수정>
--; 테이블을 생성하는 작업은 요구 분석 -> 모델링 작업을 거치는
-- 아주 섬세하고 복잡한 과정을 통해 이루어진다.
-- 테이블 생성의 기본 이론은 데이터는 변하지만 데이터의 구조는
-- 안정적이어야 한다는 기본적인 토대 위에서 만들어진다.
-- 그러므로 테이블의 생성은 모델링시 초기에 모두 만들어지고
-- 이후 서비스 운영중에는 테이블을 만들지 않는 것을 원칙으로 한다
-- 만일 운영중에 테이블이 생성되거나 특히 운영중에 테이블의
-- 구조가 변경된다는 것은 사실상 요구분석과 모델링에 문제가
-- 있었다는 의미로 판단한다.
--
-- 하지만 현실 세계의 요구사항은 끊임없이 변경되고 있다.
-- 그러므로 모든 것을 원칙대로만 하기는 어려운 요소가 있다.
-- 그래서 드물지만 서비스 운영중에 테이블을 만들거나 테이블의
-- 구조를 수정하는 것 또한 필요한 부분이라고 할 수 있다.
--
--<컬럼 수정>
--ALTER TABLE 테이블명
--[ADD|MODIFY] 컬럼 데이터타입;
--1) 추가된 컬럼에는 NULL 값이 저장된다.
--2) CHAR 와 VARCHAR2 는 컬럼의 크기를 변경하지 않으면
-- 서로 수정 교환이 가능하다
--3) 컬럼의 크기는 늘리는 것만 가능하다
--4) 대상 컬럼에 데이터가 없을 때만 크기를 줄이거나 타입을
-- 수정하는 것이 가능하다.
--
--ALTER TABLE 테이블명
--DROP COLUMN 컬럼;
--1) 불필요한 컬럼을 삭제한다
--2) SYS 유저가 소유한 테이블의 컬럼은 DROP 할 수 없다.
--테이블 생성
CREATE TABLE test (no number);
--테이블 컬럼 추가
ALTER TABLE test ADD name CHAR(10);
--테이블 컬럼 수정
ALTER TABLE test MODIFY name VARCHAR2(10);
--테이블 컬럼 삭제
ALTER TABLE test DROP COLUMN name;
--<서브 쿼리를 이용한 테이블 생성>
--CREATE TABLE 테이블명 (컬럼, ...)
--AS (SELECT 문 : sub query 문);
--1) 서브 퀴리문의 결과를 테이블로 생성한다
--2) 데이터 타입과 길이는 서브 쿼리문에 의해 결정된다
--3) 컬럼의 리스트와 서브 쿼리의 컬럼은 반드시 1:1
-- 대응된다.
--4) 컬럼명이 없으면 서브 쿼리의 검색 결과 출력되는
-- 헤더를 컬럼명으로 사용한다.
--5) 서브 쿼리에 계산식이나 함수를 사용하는 경우 반드시
-- 'CREATE TABLE 문'에 컬럼명을 정의하거나 별명을
-- 사용한다.
--개발업무를 담당하는 사원의 근무 부서관련 정보를
--검색할 수 있는 테이블을 생성한다.
DROP TABLE e_dept;
CREATE TABLE e_dept
AS (SELECT eno, ename, job, d.dno, dname, loc
FROM dept d, emp e
WHERE d.dno = e.dno
AND job='개발');
--부서별 평균 연봉을 검색할 수 있는 테이블을 생성하라
CREATE TABLE d_sal
AS (SELECT d.dno, dname, ROUND(AVG(sal)) av_sal
FROM dept d, emp e
WHERE d.dno=e.dno
GROUP BY d.dno, dname);
--부서별로 검색된 사원의 연봉 정보를 이용하여 테이블을 생성
CREATE TABLE e_sal(dno, eno, ename, an_sal)
AS (SELECT dno, eno, ename, sal*12+NVL(comm,0)
FROM emp
ORDER BY dno);
--RDB에서는 테이블은 컬럼의 순서나 행의 순서와는 무관하다는
--원칙을 세우고 있다.
--이것은 데이터를 순서화 시켜서 테이블에 저장하는 것은
--RDB의 원칙에 위배됨으로 이를 지원하지 않는다.
--그래서 위의 서브쿼리에서는 ORDER BY 를 지원하지 않는다.
--
--하지만 테이블에 물리적으로 관련있는 데이터가 연속되어
--저장된다면 매우 유용한 것이 사실이다.
--정렬되어 저장된 데이터는 검색 작업을 수행할 때 물리적인
--I/O 양을 줄일 수 있고, 나중에 정렬할 필요가 없어서 성능을
--매우 많이 향상시켜준다.
--
--이럴 때는 아래처럼 2단계로 나눠서 작업을 한다.
--1) 먼저 빈 테이블을 생성한다
--2) 빈 테이블에 정렬된 결과를 입력한다
-- (대용량 데이터 입력시 '다이렉트 로드'를 이용하면
-- 속도가 훨씬 빨라진다)
CREATE TABLE e_sal(dno, eno, ename, an_sal)
AS (SELECT dno, eno, ename, sal*12+NVL(comm, 0)
FROM emp
WHERE 1=2);
INSERT INTO e_sal
SELECT dno, eno, ename, sal*12+NVL(comm, 0)
FROM emp
ORDER BY dno;
SELECT * FROM e_sal;
|
create table Users(
username varchar(20) not null,
password varchar(20),
primary key(username) on cascade delete
)
create table Emails(
address varchar(30) not null,
subscribed bool,
primary key(address) on cascade delete
)
create table has(
address varchar(30) not null,
username varchar(20) not null,
primary key(address, username),
foreign key(address) references Emails,
foreign key(username) references Users
)
create table friends_with(
friend varchar(30),
friended varchar(30),
primary key(friend, friended),
foreign key(fiend) references Users,
foreign key(friended) references Users
)
create table SecurityQuestions(
q_id int not null,
question varchar(30),
answer varchar(30),
primary key(q_id),
)
create table secured_with(
q_id int not null,
username varchar(20),
primary key(q_id),
foreign key(q_id) references SecurityQuestions,
foreign key(username) references Users
)
create table Events(
e_id int not null,
name varchar(20),
description varchar(100),
date datetime,
primary key(e_id)
)
create table favorited(
username varchar(20),
e_id int,
primary key(username, e_id),
foreign key(username) references Users,
foreign key(e_id) references Events
)
create table Tags(
t_id int not null,
name varhar(20),
primary key(t_id)
)
create table tagged_with(
t_id int not null,
e_id int,
primary key(t_id, e_id),
foreign key(t_id) references Tags.
foreign key(e_id) references Events
)
create table Locations(
l_id int not null,
name varchar(30),
address varchar(30),
directions varchar(30),
primary key(l_id)
)
create table located(
e_id int,
l_id int,
primary key(e_id, l_id),
foreign key(e_id) references Events,
foreign key(l_id) references Locations
)
create table Preferences(
p_id int,
primary key(p_id) on cascade delete
)
create table preferredEvents(
p_id int,
e_id int,
primary key(p_id, e_id),
foreign key(e_id) references Events,
foreign key(p_id) references Preferences
)
create table preferredLocations(
p_id int,
l_id int,
primary key(p_id, l_id),
foreign key(p_id) references Preferences,
foreign key(l_id) references Locations
)
create table hasPreferences(
username varchar(20) not null,
p_id int not null,
primary key(username, p_id),
foreign key(username) references Users,
foreign key(p_id) references Preferences
)
|
DELETE * FROM employee;
|
SELECT title
FROM Movies
a left join Rating b
on a.mID = b.mID
WHERE stars is null |
-- 计算各个部门的员工个数,表头显示为:部门、员工个数
SELECT department 部门, COUNT(id) 员工个数 FROM employee GROUP BY department; |
ALTER TABLE `users` ADD `verified` tinyint(1) NOT NULL DEFAULT '0'; |
-- phpMyAdmin SQL Dump
-- version 4.1.4
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Feb 14, 2016 at 05:47 AM
-- Server version: 5.6.15-log
-- PHP Version: 5.4.24
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `cpsdb`
--
-- --------------------------------------------------------
--
-- Table structure for table `pay_records`
--
CREATE TABLE IF NOT EXISTS `pay_records` (
`no` int(11) NOT NULL AUTO_INCREMENT,
`id` int(11) NOT NULL,
`amount` int(11) NOT NULL,
`date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`no`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `tbl_balance`
--
CREATE TABLE IF NOT EXISTS `tbl_balance` (
`no` int(11) NOT NULL AUTO_INCREMENT,
`id` int(25) NOT NULL,
`tuitionfee` int(25) NOT NULL,
`current` int(25) NOT NULL,
`discount` int(25) NOT NULL,
`level` varchar(25) NOT NULL,
`year` int(25) NOT NULL,
PRIMARY KEY (`no`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
--
-- Dumping data for table `tbl_balance`
--
INSERT INTO `tbl_balance` (`no`, `id`, `tuitionfee`, `current`, `discount`, `level`, `year`) VALUES
(3, 1, 4000, 4000, 0, 'SRHS', 2012),
(4, 2, 3000, 3000, 0, 'JRHS', 2012),
(5, 3, 2000, 2000, 0, 'PREP', 2013),
(6, 4, 2600, 2600, 0, 'JRHS', 2014),
(7, 5, 6000, 6000, 0, 'PREP', 2015),
(8, 6, 10000, 10000, 0, 'SRHS', 2015);
-- --------------------------------------------------------
--
-- Table structure for table `tbl_studreg`
--
CREATE TABLE IF NOT EXISTS `tbl_studreg` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fname` varchar(24) NOT NULL,
`mname` varchar(24) NOT NULL,
`lname` varchar(24) NOT NULL,
`gender` varchar(1) NOT NULL,
`bday` date NOT NULL,
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
--
-- Dumping data for table `tbl_studreg`
--
INSERT INTO `tbl_studreg` (`id`, `fname`, `mname`, `lname`, `gender`, `bday`, `created`) VALUES
(1, 'John', 'L', 'Smith', 'm', '0000-00-00', '2016-02-05 06:14:27'),
(2, 'Julie Ann', 'G', 'Sarmiento', 'f', '0000-00-00', '2016-02-05 06:15:01'),
(3, 'Richard', 'L', 'Torres', 'm', '0000-00-00', '2016-02-05 06:15:25'),
(4, 'Edison', 'M', 'Enchanes', 'm', '0000-00-00', '2016-02-05 06:15:52'),
(5, 'Angelica', 'B', 'Lunar', 'f', '0000-00-00', '2016-02-05 06:16:13'),
(6, 'Venus', 'P', 'Eubra', 'f', '0000-00-00', '2016-02-05 06:16:33');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_tuitionfees`
--
CREATE TABLE IF NOT EXISTS `tbl_tuitionfees` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`year` varchar(20) NOT NULL,
`PREP` int(15) NOT NULL,
`ELEM` int(15) NOT NULL,
`JRHS` int(15) NOT NULL,
`SRHS` int(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `tbl_tuitionfees`
--
INSERT INTO `tbl_tuitionfees` (`id`, `year`, `PREP`, `ELEM`, `JRHS`, `SRHS`) VALUES
(1, '2012', 1000, 2000, 3000, 4000),
(2, '2013', 2000, 2500, 3000, 4000),
(3, '2014', 2300, 2500, 2600, 2800),
(4, '2015', 6000, 8000, 9000, 10000);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
insert into burger(burger_name,devoured)values("classic cheeseburger",true);
insert into burger(burger_name,devoured)values("hamburger",true);
insert into burger(burger_name,devoured)values("bacon and bleu cheese burger",false);
insert into burger(burger_name,devoured)values("vegi burger",true);
|
/*insert into tb_member values (2,'test2','1234','Tom''s company','tom@nate.com',sysdate);
select*from tb_member;*/
delete from tb_member where id=3;
insert into tb_member values (3, 'test3', '1234', '''machine''','tom@nate.com',sysdate);
-- 디비 자체내에서 각가의 레코드를 식별하기 위한 필드가 하나 추가된다
-- rowid
select rowid, id, userid, password, username, email, regdate from tb_member;
--수정하기
update tb_member set username='장길산', password=1234 where id=1;
commit;
-- Data Dictionary(데이타 사전) : 사용자가 만드는 계정, 테이블, 시퀀스, 인덱스...
-- 모든 정보가 테이블에 저장된다
-- DBA_, All_,USER_
select*from user_tables;
-- 제약조건이 뭐뭐 있는지 확인해보자(constraint)
select*from user_constraints;
select*from user_tab_columns;
select table_name from user_tab_columns where column_name='USERID';
select*from all_users;
select*from role_sys_privs;
create table test1
(
id number,
text varchar2(20),
constraint PK_TEST1 primary key(id)
);
insert into test1 values(1,'A');
insert into test1 values(2,'B');
insert into test1 values(3,'C');
drop table test1; --테이블 삭제
create table test1
(
id number,
id2 number,
text varchar2(20),
constraint PK_TEST1 primary key(id, id2)
);
insert into test1 values(1,1,'A');
insert into test1 values(1,2,'B');
insert into test1 values(2,1,'C');
insert into test1 values(1,1,'D');
delete from test1 where id2=3;
create table test2
(
id number,
text varchar2(20)
);
-- alter table 수정할 테이블명 add 컬럼 데이타타입
alter table test2 add text2 varchar2(100);
desc test2;
--primary key 추가하기
alter table test2 add constraint PK_TEST2 primary key(id);
--컬럼 삭제
alter table test2 drop column text2;
--제약조건 삭제
alter table test2 drop constraint PK_TEST2; |
--张少举
--新增
--付款模版匹配
DECLARE
column_exist NUMBER;
BEGIN
SELECT COUNT(*) INTO column_exist FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'NIS_BILLHEAD' AND COLUMN_NAME = 'TEMPLATE_ID_1';
IF column_exist = 0 THEN
EXECUTE IMMEDIATE 'alter table NIS_BILLHEAD add TEMPLATE_ID_1 NUMBER(10)';
END IF;
END;
/
DECLARE
column_exist NUMBER;
BEGIN
SELECT COUNT(*) INTO column_exist FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'NIS_BILLHEAD' AND COLUMN_NAME = 'TEMPLATE_ID_2';
IF column_exist = 0 THEN
EXECUTE IMMEDIATE 'alter table NIS_BILLHEAD add TEMPLATE_ID_2 NUMBER(10)';
END IF;
END;
/
DECLARE
column_exist NUMBER;
BEGIN
SELECT COUNT(*) INTO column_exist FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'NIS_BILLHEAD' AND COLUMN_NAME = 'COST_CENTER_CODE';
IF column_exist = 0 THEN
EXECUTE IMMEDIATE 'alter table NIS_BILLHEAD add COST_CENTER_CODE VARCHAR2(20)';
END IF;
END;
/
/*==============================================================*/
/* 4.Table: ERP_TEMPLATE_STORE(模版主表) */
/*==============================================================*/
DECLARE
tb_exists NUMBER;
BEGIN
SELECT COUNT(*) INTO tb_exists FROM tabs t WHERE t.table_name='ERP_TEMPLATE_STORE';
IF tb_exists <>0 THEN
EXECUTE IMMEDIATE 'DROP TABLE ERP_TEMPLATE_STORE cascade constraints';
END IF;
END;
/
create table ERP_TEMPLATE_STORE (
ID NUMBER(10) not null,
CORP_CODE VARCHAR2(4),
REFER_CODE VARCHAR2(32),
VOUCHER_PRE_TEXT VARCHAR2(60),
REFER VARCHAR2(50),
PAY_TYPE VARCHAR2(4),
ITEM_CODE VARCHAR2(40),
VOUCHER_TYPE_CODE CHAR(2),
TYPE_CODE VARCHAR2(32),
TEMPLATE_NAME VARCHAR2(32),
TEMPLATE_CODE VARCHAR2(32),
ABS VARCHAR2(100),
PURPOSE VARCHAR2(100),
RMK VARCHAR2(100),
REVERSE1 VARCHAR2(100),
REVERSE2 VARCHAR2(100),
constraint PK_ERP_TEMPLATE_STORE primary key (ID)
);
comment on table ERP_TEMPLATE_STORE is '凭证模版表';
comment on column ERP_TEMPLATE_STORE.CORP_CODE is '单位编码(关联BT_CORP)';
comment on column ERP_TEMPLATE_STORE.REFER_CODE is '参考凭证编号';
comment on column ERP_TEMPLATE_STORE.VOUCHER_PRE_TEXT is '凭证抬头文本';
comment on column ERP_TEMPLATE_STORE.VOUCHER_TYPE_CODE is '凭证类别(关联ERP_VOUCHER_TYPE)';
comment on column ERP_TEMPLATE_STORE.TYPE_CODE is '模版类型编码(关联ERP_TEMPLATE_TYPE)';
comment on column ERP_TEMPLATE_STORE.TEMPLATE_NAME is '模版名称';
comment on column ERP_TEMPLATE_STORE.TEMPLATE_CODE is '模版编码';
comment on column ERP_TEMPLATE_STORE.ABS is '摘要';
comment on column ERP_TEMPLATE_STORE.PURPOSE is '用途';
comment on column ERP_TEMPLATE_STORE.RMK is '备注';
comment on column ERP_TEMPLATE_STORE.REVERSE1 is '自定义一';
comment on column ERP_TEMPLATE_STORE.REVERSE2 is '自定义二';
/*==============================================================*/
/* 5.Table: ERP_TEMPLATE_DTL_STORE(模版分录表) */
/*==============================================================*/
DECLARE
tb_exists NUMBER;
BEGIN
SELECT COUNT(*) INTO tb_exists FROM tabs t WHERE t.table_name='ERP_TEMPLATE_DTL_STORE';
IF tb_exists <>0 THEN
EXECUTE IMMEDIATE 'DROP TABLE ERP_TEMPLATE_DTL_STORE cascade constraints';
END IF;
END;
/
create table ERP_TEMPLATE_DTL_STORE (
ID NUMBER(10) not null,
TEMPLATE_ID NUMBER(10),
ENTRY_CODE VARCHAR2(32),
LOAN_DIRECTION CHAR(1),
SUBJECT_CODE VARCHAR2(60),
SUBJECT_NAME VARCHAR2(100),
SUBJECT_CLASS VARCHAR2(100),
SUBJECT_TYPE VARCHAR2(100),
COST_CENTER_CODE VARCHAR2(20),
CASH_FLOW_CODE VARCHAR2(100),
ACCOUNT_CODE VARCHAR2(50),
ACCOUNT_TYPE VARCHAR2(100),
PAYMENT_REASON_CODE VARCHAR2(50),
LEDGER_SIGN VARCHAR2(50),
TRANS_TYPE VARCHAR2(50),
ASSIGN VARCHAR2(100),
TRADE_PARTNER VARCHAR2(100),
TAX_CODE VARCHAR2(50),
DTL_ITEM_CODE VARCHAR2(50),
DTL_REVERSE1 VARCHAR2(100),
DTL_REVERSE2 VARCHAR2(100),
DTL_ABS VARCHAR2(200),
constraint PK_ERP_TEMPLATE_DTL_STORE primary key (ID)
);
comment on table ERP_TEMPLATE_DTL_STORE is '凭证模版分录表';
comment on column ERP_TEMPLATE_DTL_STORE.TEMPLATE_ID is '关联ERP_TEMPLATE';
comment on column ERP_TEMPLATE_DTL_STORE.ENTRY_CODE is '分录编码';
comment on column ERP_TEMPLATE_DTL_STORE.LOAN_DIRECTION is '借贷方向 0,借 1,贷';
comment on column ERP_TEMPLATE_DTL_STORE.SUBJECT_CODE is '科目编号';
comment on column ERP_TEMPLATE_DTL_STORE.SUBJECT_NAME is '科目名称';
comment on column ERP_TEMPLATE_DTL_STORE.SUBJECT_CLASS is '科目大类';
comment on column ERP_TEMPLATE_DTL_STORE.SUBJECT_TYPE is '科目类型';
comment on column ERP_TEMPLATE_DTL_STORE.COST_CENTER_CODE is '成本中心 取数ERP_COST_CENTER';
comment on column ERP_TEMPLATE_DTL_STORE.CASH_FLOW_CODE is '现金流量代码';
comment on column ERP_TEMPLATE_DTL_STORE.ACCOUNT_CODE is '记账代码 bt_dictionary表 class=13';
comment on column ERP_TEMPLATE_DTL_STORE.ACCOUNT_TYPE is '账户类型';
comment on column ERP_TEMPLATE_DTL_STORE.PAYMENT_REASON_CODE is '付款原因代码 bt_dictionary表 class=17';
comment on column ERP_TEMPLATE_DTL_STORE.LEDGER_SIGN is '总账标识 bt_dictionary表 class=14';
comment on column ERP_TEMPLATE_DTL_STORE.TRANS_TYPE is '事物类型 bt_dictionary表 class=15';
comment on column ERP_TEMPLATE_DTL_STORE.ASSIGN is '分配';
comment on column ERP_TEMPLATE_DTL_STORE.TRADE_PARTNER is '贸易伙伴';
comment on column ERP_TEMPLATE_DTL_STORE.TAX_CODE is '税码 bt_dictionary表 class=16';
comment on column ERP_TEMPLATE_DTL_STORE.DTL_ITEM_CODE is '预算代码 bt_dictionary表 class=12';
comment on column ERP_TEMPLATE_DTL_STORE.DTL_REVERSE1 is '自定义一';
comment on column ERP_TEMPLATE_DTL_STORE.DTL_REVERSE2 is '自定义二';
comment on column ERP_TEMPLATE_DTL_STORE.DTL_ABS is '摘要';
DECLARE
record_exists NUMBER;
BEGIN
SELECT COUNT(*) INTO record_exists FROM tb_generator t where t.gen_name='erptemplatestoreid';
IF record_exists = 0 THEN
insert into tb_generator(id,gen_name,gen_value)
values(
(select max(id)+1 from tb_generator),
'erptemplatestoreid',
'100'
);
END IF;
END;
/
DECLARE
record_exists NUMBER;
BEGIN
SELECT COUNT(*) INTO record_exists FROM tb_generator t where t.gen_name='erptemplatedetailstoreid';
IF record_exists = 0 THEN
insert into tb_generator(id,gen_name,gen_value)
values(
(select max(id)+1 from tb_generator),
'erptemplatedetailstoreid',
'100'
);
END IF;
END;
/
COMMIT;
|
CREATE TABLE usuarios(
id SERIAL PRIMARY KEY NOT NULL,
login int NOT NULL ,
senha VARCHAR (32) NOT NULL,
nome VARCHAR (50) NOT NULL
);
CREATE TABLE clientes (
id SERIAL PRIMARY KEY NOT NULL,
matricula VARCHAR(20) NOT NULL,
nome VARCHAR(50) NOT NULL,
tipo VARCHAR(10)
);
CREATE TABLE equipamentos (
id SERIAL PRIMARY KEY NOT NULL,
patrimonio int NOT NULL,
sn VARCHAR(50),
tipo VARCHAR(10),
emprestado boolean,
status text
);
CREATE TABLE emprestimos (
id SERIAL PRIMARY KEY NOT NULL,
usuario int NOT NULL,
cliente int NOT NULL,
equipamento int NOT NULL,
saida Timestamp without Time Zone NOT NULL,
devolucao Timestamp without Time Zone NOT NULL,
CONSTRAINT FK_USUARIO FOREIGN KEY(usuario) REFERENCES usuarios(id),
CONSTRAINT FK_CLIENTE FOREIGN KEY(cliente) REFERENCES clientes(id),
CONSTRAINT FK_EQUIPAMENTO FOREIGN KEY(equipamento) REFERENCES equipamentos(id)
);
CREATE TABLE emprestados (
id SERIAL PRIMARY KEY NOT NULL,
usuario int NOT NULL,
cliente int NOT NULL,
equipamento int NOT NULL,
saida Timestamp without Time Zone NOT NULL,
CONSTRAINT FK_USUARIO FOREIGN KEY(usuario) REFERENCES usuarios(id),
CONSTRAINT FK_CLIENTE FOREIGN KEY(cliente) REFERENCES clientes(id),
CONSTRAINT FK_EQUIPAMENTO FOREIGN KEY(equipamento) REFERENCES equipamentos(id)
);
insert into usuarios(login, senha, nome) values ('2981585', '12345', 'Felipe Araujo de Lima');
insert into clientes(matricula, nome, tipo) values ('20132y6-rc0189','Felipe Araujo de Lima','aluno');
insert into equipamentos(patrimonio, sn, tipo, emprestado, status) values (162254,'BRG350F2Y3','notebook', false, '');
insert into emprestimos(usuario,cliente,equipamento,saida) values (1,1,1,'2016-12-06 14:11:01');
update emprestimos set devolucao = '2016-12-06 14:16:01' where id = 1;
select * from usuarios;
select * from clientes;
select * from equipamentos;
select * from emprestimos;
drop table emprestimos; |
/*
SQL Datei
Datenbank für wsm
*/
-- Löscht die Datenbank falls Sie schon existiert --
DROP DATABASE IF EXISTS wsm;
-- Erstellt eine neua datenbank --
create database wsm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
-- script soll mit der wsm datenbank arbeiten --
use wsm;
-- Erstellt die Tabelle Produkt--
CREATE TABLE IF NOT EXISTS Produkt (
ProduktID int(11) NOT NULL AUTO_INCREMENT,
ProduktName varchar(20) NOT NULL,
ProduktBeschreibung text,
kategorieID int(11),
Bild varchar(20) DEFAULT NULL,
Preis float(6,2) DEFAULT NULL,
PRIMARY KEY (ProduktID)
)ENGINE=INNODB;
-- Fügt der Tabelle Produkt eine vielzahl von datensätzen hinzu--
INSERT INTO Produkt (ProduktName, Bild, Preis, KategorieID, ProduktBeschreibung) VALUES
('Stock', 'stick', 1, 1, 'Basiselement für alle Werkzeuge Vielseitig einsetzbar'),
('Stein Axt', 'stone_axe', 5, 1, 'Wird verwendet um Holzblöcke schneller als per Hand abzubauen'),
('Stein Hacke', 'stone_hoe', 4, 1, 'Wird verwendet, um Erd- und Grasblöckee umzugraben und sie damit fürs Bepflanzen vorzubereiten'),
('Stein Spitzhacke', 'stone_pickaxe', 5, 1, 'Wird benötigt um Stein- und Erzblöcke abzubauen'),
('Stein Schaufel', 'stone_shovel', 4, 1, 'Hiermit kannst du Erde,Gras, Sand, Kies und Schnee schneller als mit der Hand abbauen. Du brauchst eine Schaufel, um Schneebälle abzubauen'),
('Holz Schaufel', 'wood_shovel', 2, 1, 'Hiermit kannst du Erde,Gras, Sand, Kies und Schnee schneller als mit der Hand abbauen. Du brauchst eine Schaufel, um Schneebälle abzubauen'),
('Holz Spitzhacke', 'wood_pickaxe', 3, 1, 'Wird benötigt um Stein- und Erzblöcke abzubauen'),
('Holz Hacke', 'wood_hoe', 2, 1, 'Wird verwendet, um Erd- und Grasblöckee umzugraben und sie damit fürs Bepflanzen vorzubereiten'),
('Holz Axt', 'wood_axe', 3, 1, 'Wird verwendet um Holzblöcke schneller als per Hand abzubauen'),
('Diamant Axt', 'diamond_axe', 10, 1, 'Wird verwendet um Holzblöcke schneller als per Hand abzubauen'),
('Diamant Hacke', 'diamond_hoe', 8, 1,'Wird verwendet, um Erd- und Grasblöckee umzugraben und sie damit fürs Bepflanzen vorzubereiten'),
('Diamant Schaufel', 'diamond_shovel', 8, 1, 'Hiermit kannst du Erde,Gras, Sand, Kies und Schnee schneller als mit der Hand abbauen. Du brauchst eine Schaufel, um Schneebälle abzubauen'),
('Diamant Spitzhacke', 'diamond_pickaxe', 10, 1, 'Wird benötigt um Stein- und Erzblöcke abzubauen'),
('Diamant Schwert', 'diamond_sword', 15, 2, 'Wird zum kämpfen verwendet (+7 Angriffsschaden)'),
('Diamant Schuhe', 'diamond_boots', 12, 3, 'Verleiht dem Träger +3 Rüstungspunkte'),
('Diamant Brustpanzer', 'diamond_chestplate', 18, 3, 'Verleiht dem Träger 8 Rüstungspunkte'),
('Diamant Helm', 'diamond_helmet', 12, 3, 'Verleiht dem Träger +3 Rüstungspunkte'),
('Apfel', 'apple', 3, 4, 'Regeneriert 2 Leben'),
('Goldener Apfel', 'apple_golden', 6, 4, 'Regeneriert 2 Leben und regeneriert Leben für 4 Sekunden'),
('Pfeil', 'arrow', 1, 2, 'Wird als Munition für Bogen verwendet'),
('Steak', 'beef_cooked', 5, 4, 'Regeneriert 4 Leben'),
('Bogen', 'bow_standby', 10, 2, 'Erlaubt Fernangriffe mit Pfeilen'),
('Brot', 'bread', 5, 4, 'Regeneriert 2,5 Leben'),
('Keks', 'cookie', 4, 4, 'Regeneriert 1 Leben'),
('Backfisch', 'fish_cod_cooked', 5, 4, 'Regeneriert 2,5 Leben'),
('Eisenaxt', 'iron_axe', 12, 2, 'Wird verwendet um Holzblöcke schneller als per Hand abzubauen'),
('Eisenstiefel', 'iron_boots', 12, 3, 'Verleiht dem Träger 2 Rüstungspunkte'),
('Eisen Brustpanzer', 'iron_chestplate', 12, 3, 'Verleiht dem Träger 6 Rüstungspunkte'),
('Eisen Spitzhacke', 'iron_pickaxe', 12, 1, 'Wird benötigt um Stein- und Erzblöcke abzubauen'),
('Eisen Schaufel', 'iron_shovel', 12, 1, 'Hiermit kannst du Erde,Gras, Sand, Kies und Schnee schneller als mit der Hand abbauen. Du brauchst eine Schaufel, um Schneebälle abzubauen'),
('Eisen Schwert', 'iron_sword', 12, 2, 'Wird zum kämpfen verwendet (+6 Angriffsschaden)'),
('Wassermelone', 'melon', 12, 4, 'Regeneriert 1 Leben'),
('Kartoffel', 'potato_baked', 12, 4, 'Regeneriert 0,5 Leben'),
('Kürbiskuchen', 'pumpkin_pie', 12, 4, 'Regeneriert 1,5 Leben'),
('Creeper Hut', 'skull_creeper', 12, 3, 'Können als dekoration plaziert werden oder als Helm getragen werden'),
('Skelet Hut', 'skull_skeleton', 12, 3, 'Können als dekoration plaziert werden oder als Helm getragen werden'),
('Steve Hut', 'skull_steve', 12, 3, 'Können als dekoration plaziert werden oder als Helm getragen werden'),
('Wither Hut', 'skull_wither', 12, 3, 'Können als dekoration plaziert werden oder als Helm getragen werden'),
('Zombie Hut', 'skull_zombie', 12, 3, 'Können als dekoration plaziert werden oder als Helm getragen werden'),
('Diamant Hose', 'diamond_leggings', 15, 3, 'Verleiht dem Träger 6 Rüstungspunkte');
-- Erstellt die Tabelle Kategorie --
CREATE TABLE IF NOT EXISTS Kategorie(
KategorieID int(11) NOT NULL AUTO_INCREMENT,
KategorieName varchar(15) NOT NULL,
PRIMARY KEY(KategorieID)
)ENGINE=INNODB;
-- Fügt der Tabelle Kategorie, die notwendigen Kategorien hinzu --
INSERT INTO Kategorie(KategorieName) VALUES
('Werkzeug'),
('Waffe'),
('Ruestung'),
('Nahrung');
-- Legt Tabelle Kunde an --
CREATE TABLE IF NOT EXISTS Kunde(
KundeID int(11) NOT NULL AUTO_INCREMENT,
KundeNickname varchar(20) NOT NULL,
KundeName varchar(20) NOT NULL,
KundeVorname varchar(20) NOT NULL,
KundeEMAIL varchar(50) NOT NULL,
KundePasswd varchar(10) NOT NULL,
PRIMARY KEY (KundeID)
)ENGINE=INNODB;
-- Fügt Beispiel Kunden an --
INSERT INTO Kunde (KundeNickname, KundeName, KundeVorname, KundeEMAIL, KundePasswd) VALUES
('Stormy Puma', 'Stern', 'Max', 'maxStern@toast.de', '123456'),
('El Studen', 'Pfeiffer', 'Axel', 'axelPfeiffer@toast.de', '456789'),
('The Puppy', 'Schmidt', 'Astrid', 'astridSchmidt@toast.de', '147852'),
('Homeless Laser', 'Rotenbach', 'Robert', 'robertRobert@toast.de', '852369'),
('King Slayer', 'Lannister', 'Jamie', 'jamieLannister@westeros.de', '987456'),
('Rotten Pilot', 'Fischer', 'Max', 'maxFischer@toast.de', '654321'),
('Sunny Panda', 'Brinkfurt', 'Nathalie', 'nathalieBrinkfurt@toast.de', '156975');
-- Erstellt die Tabelle Bestellungen --
CREATE TABLE IF NOT EXISTS Bestellungen(
BestellID int(11) NOT NULL AUTO_INCREMENT,
KundeID int(11) NOT NULL,
Datum DATE,
PRIMARY KEY (BestellID),
FOREIGN KEY (KundeID) REFERENCES Kunde(KundeID)
)ENGINE=INNODB;
INSERT INTO Bestellungen (KundeID, Datum) VALUES
(1, '2015-03-19'),
(5, '2015-03-19'),
(5, '2015-03-20');
-- Erstellt die Tabelle Bestelldeatils --
CREATE TABLE IF NOT EXISTS Bestelldetails(
BestellID int(11) NOT NULL,
ProduktID int(11) NOT NULL,
Anzahl int(11),
PRIMARY KEY (BestellID, ProduktID),
FOREIGN KEY (BestellID) REFERENCES Bestellungen(BestellID),
FOREIGN KEY (ProduktID) REFERENCES Produkt(ProduktID)
)ENGINE=INNODB;
INSERT INTO Bestelldetails (BestellID, ProduktID, Anzahl) VALUES
(1, 16, 17),
(2, 2, 16),
(2, 23, 6),
(3, 14, 15),
(3, 19, 3);
|
# ************************************************************
# Sequel Pro SQL dump
# Version 4096
#
# http://www.sequelpro.com/
# http://code.google.com/p/sequel-pro/
#
# Host: localhost (MySQL 5.6.13)
# Database: SQLHardWay
# Generation Time: 2014-03-29 18:19:43 +0000
# ************************************************************
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
# Dump of table person
# ------------------------------------------------------------
DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`id` int(11) NOT NULL,
`first_name` text,
`last_name` text,
`age` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
LOCK TABLES `person` WRITE;
/*!40000 ALTER TABLE `person` DISABLE KEYS */;
INSERT INTO `person` (`id`, `first_name`, `last_name`, `age`)
VALUES
(0,'Zed','Shaw',37),
(1,'Bella','Lewis',48),
(2,'Jeremy','Lewis',40),
(3,'Aria','Lewis',10);
/*!40000 ALTER TABLE `person` ENABLE KEYS */;
UNLOCK TABLES;
# Dump of table person_pet
# ------------------------------------------------------------
DROP TABLE IF EXISTS `person_pet`;
CREATE TABLE `person_pet` (
`person_id` int(11) DEFAULT NULL,
`pet_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table pet
# ------------------------------------------------------------
DROP TABLE IF EXISTS `pet`;
CREATE TABLE `pet` (
`id` int(11) NOT NULL,
`name` text,
`breed` text,
`age` int(11) DEFAULT NULL,
`dead` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
LOCK TABLES `pet` WRITE;
/*!40000 ALTER TABLE `pet` DISABLE KEYS */;
INSERT INTO `pet` (`id`, `name`, `breed`, `age`, `dead`)
VALUES
(0,'Fluffy','Unicorn',1000,0),
(1,'Gignator','Robot',1,1),
(2,'Oscar','Oscar fish',6,1),
(3,'Gambit','cat',3,0),
(4,'Snailie','Golden Snail',1,1);
/*!40000 ALTER TABLE `pet` ENABLE KEYS */;
UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*
结算中心-已退税,未退税
*/
delimiter $
drop procedure if exists Proc_Settlements_SumTaxReceived $
create procedure Proc_Settlements_SumTaxReceived(sInvoiceNO varchar(255))
begin
declare fTaxReceived decimal(18,2);
set fTaxReceived=(Select Sum(ifnull(ExportRebatesValue,0)) as ExportRebatesValue From ExportRebatesDetail
Where InvoiceNO=sInvoiceNO);
Update Settlements set TaxReceived=ifnull(fTaxReceived,0),TaxRemain=(ifnull(TaxRebateReceivable,0)-ifnull(fTaxReceived,0)) Where InvoiceNO=sInvoiceNO;
end $
delimiter ; |
create or replace package github_issues_milestones
as
/** Interface to github issues milestones API
* @author Morten Egan
* @project OracleGit
* @version 0.1.0
*/
/** List milestones for a repository
* @author Morten Egan
* @param git_account The account that owns the repository
* @param repos_name The name of the repository
* @param state The state of the milestone. Either open or closed. Default: open
* @param sort What to sort results by. Either due_date or completeness. Default: due_date
* @param direction The direction of the sort. Either asc or desc. Default: asc
* @return Milestones for the repository
*/
function list_milestones (
git_account varchar2
, repos_name varchar2
, state varchar2 default 'open'
, sort varchar2 default 'due_date'
, direction varchar2 default 'asc'
)
return github.call_result;
/** Get a single milestone
* @author Morten Egan
* @param git_account The account that owns the repository
* @param repos_name The name of the repository
* @param milestone_id The id of the milestone to get
* @return The JSON object of a milestone
*/
function get_milestone (
git_account varchar2
, repos_name varchar2
, milestone_id number
)
return github.call_result;
/** Create a milestone
* @author Morten Egan
* @param git_account The account that owns the repository
* @param repos_name The name of the repository
* @param title The title of the milestone.
* @param state The state of the milestone. Either open or closed. Default: open
* @param description A description of the milestone.
* @param due_on The milestone due date. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
*/
procedure create_milestone (
git_account varchar2
, repos_name varchar2
, title varchar2
, state varchar2 default 'open'
, description varchar2 default null
, due_on varchar2 default null
);
/** Update a milestone
* @author Morten Egan
* @param git_account The account that owns the repository
* @param repos_name The name of the repository
* @param milestone_id The id of the milestone to edit
* @param title The title of the milestone.
* @param state The state of the milestone. Either open or closed. Default: open
* @param description A description of the milestone.
* @param due_on The milestone due date. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
*/
procedure update_milestone (
git_account varchar2
, repos_name varchar2
, milestone_id number
, title varchar2 default null
, state varchar2 default 'open'
, description varchar2 default null
, due_on varchar2 default null
);
/** Delete a milestone
* @author Morten Egan
* @param git_account The account that owns the repository
* @param repos_name The name of the repository
* @param milestone_id The id of the milestone to delete
*/
procedure delete_milestone (
git_account varchar2
, repos_name varchar2
, milestone_id number
);
end github_issues_milestones;
/ |
UPDATE SectionType SET Name = 'Bulletin Zone', Code = 'BULLETIN_ZONE' WHERE ID = 11 |
select * from pt999 where menuid like '2501%' for update
select * from jxjdjhb where lx = 1 and lb = 2 and de011 = 2014 and hzbz = '0'
select * from jxjdjhb where lx = 1 and lb = 2 and de011 = 2014 and hzbz = '1'
select * from jxjdjhb_mx where lx = 1 and lb = 2 and hzbs = 'Y' for update
select * from jxjdjhb_mx where lx = 1 and lb = 2 and hzbs = '1' for update
select * from jxjdjhb where id = 1192 for update
select * from jxjdjhb_mx where jhid = '1192' for update
|
CREATE INDEX idx_ratings_movie_id
ON ratings(movie_id); |
CREATE TABLE [display].[resource_plan]
(
[sys_id_display_value] NVARCHAR(MAX) NULL,
[end_date_display_value] NVARCHAR(MAX) NULL,
[short_description_display_value] NVARCHAR(4000) NULL,
[plan_type_display_value] NVARCHAR(MAX) NULL,
[role_display_value] NVARCHAR(MAX) NULL,
[notes_display_value] NVARCHAR(4000) NULL,
[request_type_display_value] NVARCHAR(MAX) NULL,
[top_task_display_value] NVARCHAR(MAX) NULL,
[sys_updated_on_display_value] DATETIME NULL,
[program_display_value] NVARCHAR(MAX) NULL,
[distribution_display_value] NVARCHAR(MAX) NULL,
[allocated_hours_display_value] NVARCHAR(MAX) NULL,
[skills_display_value] NVARCHAR(MAX) NULL,
[number_display_value] NVARCHAR(MAX) NULL,
[sys_updated_by_display_value] NVARCHAR(MAX) NULL,
[percent_allocated_display_value] NVARCHAR(MAX) NULL,
[actual_hours_display_value] NVARCHAR(MAX) NULL,
[portfolio_display_value] NVARCHAR(MAX) NULL,
[fte_display_value] NVARCHAR(MAX) NULL,
[sys_created_on_display_value] DATETIME NULL,
[sys_domain_display_value] NVARCHAR(MAX) NULL,
[members_list_display_value] NVARCHAR(MAX) NULL,
[assigned_hours_display_value] NVARCHAR(MAX) NULL,
[state_display_value] NVARCHAR(MAX) NULL,
[group_resource_display_value] NVARCHAR(MAX) NULL,
[sys_created_by_display_value] NVARCHAR(MAX) NULL,
[start_date_display_value] NVARCHAR(255) NULL,
[notes_list_display_value] NVARCHAR(4000) NULL,
[assigned_cost_display_value] NVARCHAR(MAX) NULL,
[planned_hours_display_value] NVARCHAR(MAX) NULL,
[man_days_display_value] NVARCHAR(MAX) NULL,
[resource_type_display_value] NVARCHAR(MAX) NULL,
[sys_mod_count_display_value] NVARCHAR(MAX) NULL,
[sys_tags_display_value] NVARCHAR(MAX) NULL,
[user_resource_display_value] NVARCHAR(MAX) NULL,
[allocated_cost_display_value] NVARCHAR(MAX) NULL,
[task_display_value] NVARCHAR(MAX) NULL,
[actual_cost_display_value] NVARCHAR(MAX) NULL,
[percent_capacity_display_value] NVARCHAR(MAX) NULL,
[operational_work_type_display_value] NVARCHAR(MAX) NULL,
[planned_cost_display_value] NVARCHAR(MAX) NULL,
[members_preference_display_value] NVARCHAR(MAX) NULL,
[distribution_type_display_value] NVARCHAR(MAX) NULL,
)
|
CREATE OR REPLACE VIEW History_Min_Time_View AS
SELECT
MAX(timeentered) as timeentered,
tid_id as tid_id,
interface_id as interface_id
FROM pm_history
WHERE
timeentered <= SYSDATE -1
GROUP BY tid_id, interface_id
UNION
SELECT
MIN(timeentered) as timeentered,
tid_id as tid_id,
interface_id as interface_id
FROM pm_history
GROUP BY tid_id, interface_id
;
COMMIT;
|
-- TITLE1: Apply Rules
-- TITLE2: Viewing Rules that Specify a Destination Queue on Apply
-- DESC: You can specify a destination queue for a rule using the SET_ENQUEUE_DESTINATION procedure in the DBMS_APPLY_ADM package. If an apply process has such a rule in its positive rule set, and a message satisfies the rule, then the apply process enqueues the message into the destination queue.
COLUMN RULE_OWNER HEADING 'Rule Owner' FORMAT A15
COLUMN RULE_NAME HEADING 'Rule Name' FORMAT A15
COLUMN DESTINATION_QUEUE_NAME HEADING 'Destination Queue' FORMAT A30
SELECT RULE_OWNER, RULE_NAME, DESTINATION_QUEUE_NAME
FROM DBA_APPLY_ENQUEUE;
|
-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- 主機: localhost
-- 產生時間: 2020 年 03 月 01 日 15:26
-- 伺服器版本: 5.5.64-MariaDB
-- PHP 版本: 7.3.14
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 */;
--
-- 資料庫: `s1080404`
--
-- --------------------------------------------------------
--
-- 資料表結構 `t1_admin`
--
CREATE TABLE `t1_admin` (
`id` int(10) UNSIGNED NOT NULL,
`acc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`pwd` text COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t1_admin`
--
INSERT INTO `t1_admin` (`id`, `acc`, `pwd`) VALUES
(1, 'admin', '1234');
-- --------------------------------------------------------
--
-- 資料表結構 `t2_member_account`
--
CREATE TABLE `t2_member_account` (
`id` int(10) UNSIGNED NOT NULL,
`acc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`email` text COLLATE utf8mb4_unicode_ci NOT NULL,
`pwd` text COLLATE utf8mb4_unicode_ci NOT NULL,
`re_pwd` text COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t2_member_account`
--
INSERT INTO `t2_member_account` (`id`, `acc`, `email`, `pwd`, `re_pwd`) VALUES
(1, 'admin', 'admin@admin.com', '1234', '1234'),
(2, 'test01', 'test01@test01.com', 'test01', 'test01');
-- --------------------------------------------------------
--
-- 資料表結構 `t3_member_info`
--
CREATE TABLE `t3_member_info` (
`id` int(10) UNSIGNED NOT NULL,
`id_number` text COLLATE utf8mb4_unicode_ci,
`name` text COLLATE utf8mb4_unicode_ci,
`acc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`pwd` text COLLATE utf8mb4_unicode_ci NOT NULL,
`nickname` text COLLATE utf8mb4_unicode_ci,
`sex` text COLLATE utf8mb4_unicode_ci,
`birth` text COLLATE utf8mb4_unicode_ci,
`address` text COLLATE utf8mb4_unicode_ci,
`phone` text COLLATE utf8mb4_unicode_ci,
`phonedpy` int(11) DEFAULT NULL,
`email` text COLLATE utf8mb4_unicode_ci NOT NULL,
`emaildpy` int(11) DEFAULT NULL,
`line` text COLLATE utf8mb4_unicode_ci,
`linedpy` int(11) DEFAULT NULL,
`wapp` text COLLATE utf8mb4_unicode_ci,
`wappdpy` int(11) DEFAULT NULL,
`registdate` datetime NOT NULL,
`updatetime` datetime NOT NULL,
`chk` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t3_member_info`
--
INSERT INTO `t3_member_info` (`id`, `id_number`, `name`, `acc`, `pwd`, `nickname`, `sex`, `birth`, `address`, `phone`, `phonedpy`, `email`, `emaildpy`, `line`, `linedpy`, `wapp`, `wappdpy`, `registdate`, `updatetime`, `chk`) VALUES
(1, 'IF000001', '會員1', 'user', '1234', '暱稱1', '女', '1994-10-31', '新北市泰山區貴子里', '0912-345-678', NULL, '123@gmail.com', NULL, NULL, NULL, NULL, NULL, '2020-01-06 08:50:45', '2020-01-14 22:51:28', 1),
(2, 'IF000002', '會員2', 'test02', '1234', '暱稱2', '男', '1990-02-07', '新北市泰山區貴子里', '0966-666-666', NULL, 'test02@test.com', NULL, NULL, NULL, NULL, NULL, '2020-01-06 08:49:48', '2020-01-10 16:04:25', 0),
(3, NULL, '會員3', 'test03', '3214', '暱稱3', '男', '1999-12-31', '新北市泰山區貴子里', '0987-654-321', NULL, '123@gmail.com', NULL, NULL, NULL, NULL, NULL, '2020-01-10 13:10:16', '2020-01-10 16:04:25', 0),
(4, NULL, '會員3', 'test04', '1234', '暱稱4', '男', '1999-12-31', '新北市泰山區貴子里', '0988-888-888', NULL, '123@gmail.com', NULL, NULL, NULL, NULL, NULL, '2020-01-10 13:11:25', '2020-01-10 16:04:25', 0),
(9, NULL, '會員5', 'test05', '1234', '暱稱5', '女', '1999-12-31', '新北市泰山區貴子里', '0910-111-222', NULL, '1234@gmail.com', NULL, NULL, NULL, NULL, NULL, '2020-01-15 13:03:56', '2020-01-15 13:03:56', 0),
(10, NULL, '會員6', 'test06', '1234', '暱稱6', '男', '1988-10-10', '新北市泰山區貴子里', '0966-000-888', NULL, 'abc@gmail.com', NULL, NULL, NULL, NULL, NULL, '2020-01-15 13:05:12', '2020-01-15 13:05:12', 0),
(11, NULL, '會員7', 'test07', '1234', '暱稱7', '男', '1978-02-05', '新北市泰山區貴子里', '0965-432-198', NULL, 'abcd@gmail.com', NULL, NULL, NULL, NULL, NULL, '2020-01-15 13:05:52', '2020-01-15 13:05:52', 0),
(13, NULL, NULL, '0000', '123456', NULL, NULL, NULL, NULL, NULL, NULL, 'abcjoe61115@gmail.com', NULL, NULL, NULL, NULL, NULL, '2020-01-21 14:00:49', '0000-00-00 00:00:00', 0);
-- --------------------------------------------------------
--
-- 資料表結構 `t4_profile`
--
CREATE TABLE `t4_profile` (
`id` int(10) UNSIGNED NOT NULL,
`id_number` text COLLATE utf8mb4_unicode_ci,
`acc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`nickname` text COLLATE utf8mb4_unicode_ci,
`sex` text COLLATE utf8mb4_unicode_ci,
`phonedpy` int(11) DEFAULT NULL,
`line` text COLLATE utf8mb4_unicode_ci,
`linedpy` int(11) DEFAULT NULL,
`wapp` text COLLATE utf8mb4_unicode_ci,
`wappdpy` int(11) DEFAULT NULL,
`emaildpy` text COLLATE utf8mb4_unicode_ci,
`price` int(11) DEFAULT NULL,
`freetime1` int(11) DEFAULT NULL,
`freetime2` int(11) DEFAULT NULL,
`location` text COLLATE utf8mb4_unicode_ci,
`locat` text COLLATE utf8mb4_unicode_ci NOT NULL,
`place` text COLLATE utf8mb4_unicode_ci,
`intro` text COLLATE utf8mb4_unicode_ci,
`interest` text COLLATE utf8mb4_unicode_ci,
`item` text COLLATE utf8mb4_unicode_ci,
`img` text COLLATE utf8mb4_unicode_ci,
`chk` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t4_profile`
--
INSERT INTO `t4_profile` (`id`, `id_number`, `acc`, `nickname`, `sex`, `phonedpy`, `line`, `linedpy`, `wapp`, `wappdpy`, `emaildpy`, `price`, `freetime1`, `freetime2`, `location`, `locat`, `place`, `intro`, `interest`, `item`, `img`, `chk`) VALUES
(1, 'IFtest01', 'user', '暱稱1', '女', 1, 'ifriend123', 0, '0987-654-321', 1, '1', 120, 10, 18, '新北', '北部地區', '新北、台北', '熱愛交友,喜歡運動', '籃球、爬山、美食', NULL, 'member-1.jpg', 0),
(2, NULL, 'test02', '暱稱2', '男', 0, '0', 0, '0', 0, '0', 80, 13, 19, '新北', '北部地區', NULL, '體驗數學研究所,意義是一個,相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持,評分研究什麼樣偉大大幅長大行為電視劇浙江人力讓你變化,穩定訊息地方。', '美食、電玩、藝術、運動', NULL, 'member-2.jpg', 0),
(3, NULL, 'test03', '暱稱3', '男', 0, '0', 0, '0', 0, '0', 120, 10, 15, '高雄', '南部地區', NULL, '相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持', '攝影、運動、舞蹈', NULL, 'member-3.jpg', 0),
(4, NULL, 'test04', '暱稱4', '女', 0, '0', 0, '0', 0, '0', 60, 10, 15, '台南', '南部地區', NULL, '相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持', '攝影、運動、舞蹈', NULL, 'member-4.jpg', 0),
(5, NULL, 'test05', '暱稱5', '男', 0, '0', 0, '0', 0, '0', 200, 13, 19, '新竹', '中部地區', NULL, '體驗數學研究所,意義是一個,相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持,評分研究什麼樣偉大大幅長大行為電視劇浙江人力讓你變化,穩定訊息地方。', '美食、電玩、藝術、運動', NULL, 'member-5.jpg', 0),
(6, NULL, 'test06', '暱稱6', '男', 0, '0', 0, '0', 0, '0', 150, 10, 15, '高雄', '南部地區', NULL, '相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持', '攝影、運動、舞蹈', NULL, 'member-6.jpg', 0),
(7, NULL, 'test07', '暱稱7', '女', 0, '0', 0, '0', 0, '0', 100, 9, 17, '台南', '南部地區', NULL, '關閉需要建築不需要目光表示賓館說是忘記光臨本類因素危機,背景管理會不會工業有一定電視台,結構宣佈高。', '籃球、爬山、美食、電影', NULL, 'member-7.jpg', 0),
(8, NULL, 'test08', '暱稱8', '男', 0, '0', 0, '0', 0, '0', 80, 13, 19, '新北', '北部地區', NULL, '體驗數學研究所,意義是一個,相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持,評分研究什麼樣偉大大幅長大行為電視劇浙江人力讓你變化,穩定訊息地方。', '美食、電玩、藝術、運動', NULL, 'member-8.jpg', 0),
(9, NULL, 'test09', '暱稱9', '男', 0, '0', 0, '0', 0, '0', 120, 10, 15, '高雄', '南部地區', NULL, '相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持', '攝影、運動、舞蹈', NULL, 'member-9.jpg', 0),
(10, NULL, 'test10', '暱稱10', '女', 0, '0', 0, '0', 0, '0', 60, 10, 15, '台南', '南部地區', NULL, '相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持', '攝影、運動、舞蹈', NULL, 'member-10.jpg', 0),
(11, NULL, 'test11', '暱稱11', '男', 0, '0', 0, '0', 0, '0', 200, 13, 19, '新竹', '中部地區', NULL, '體驗數學研究所,意義是一個,相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持,評分研究什麼樣偉大大幅長大行為電視劇浙江人力讓你變化,穩定訊息地方。', '美食、電玩、藝術、運動', NULL, 'member-11.jpg', 0),
(12, NULL, 'test12', '暱稱12', '男', 0, '0', 0, '0', 0, '0', 150, 10, 15, '高雄', '南部地區', NULL, '相同承擔市政府技巧論壇,還能攻擊由於近年來也不你沒有戰士最多,飯店事情權利劇情資源位元有點版權演唱主題軍事,來到第二次的說高興附近吃螺絲臨床臺中幾年提出了堅持', '攝影、運動、舞蹈', NULL, 'member-12.jpg', 0),
(13, NULL, '0000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, NULL);
-- --------------------------------------------------------
--
-- 資料表結構 `t5_event`
--
CREATE TABLE `t5_event` (
`id` int(10) UNSIGNED NOT NULL,
`acc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`eventname` text COLLATE utf8mb4_unicode_ci NOT NULL,
`organizer` text COLLATE utf8mb4_unicode_ci NOT NULL,
`locat` text COLLATE utf8mb4_unicode_ci NOT NULL,
`place` text COLLATE utf8mb4_unicode_ci NOT NULL,
`placeadd` text COLLATE utf8mb4_unicode_ci NOT NULL,
`num` int(11) NOT NULL,
`order_num` int(11) NOT NULL,
`timelength` int(11) NOT NULL,
`type` text COLLATE utf8mb4_unicode_ci NOT NULL,
`budget` int(11) NOT NULL,
`intro` text COLLATE utf8mb4_unicode_ci NOT NULL,
`memo` text COLLATE utf8mb4_unicode_ci NOT NULL,
`date` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t5_event`
--
INSERT INTO `t5_event` (`id`, `acc`, `eventname`, `organizer`, `locat`, `place`, `placeadd`, `num`, `order_num`, `timelength`, `type`, `budget`, `intro`, `memo`, `date`) VALUES
(1, 'user', '吃海鮮', '暱稱1', '北部地區', '海鮮餐廳', '新北市泰山區貴子里', 5, 3, 2, '聚餐', 300, '四個必要大約利益未知迅速重量,理論文章速度您現在,當時存在說出後來也不消失我現在請您出口破解比例形式,保證產品,那些推薦要求修改推坑王字幕有人我愛吃飯', '當時存在說出後來也不消失我現在請您出口破解比例形式,保證產品,那些推薦要求修改推坑王字幕有人我愛吃飯', '2020-02-01 12:00:00'),
(2, '', '玩桌遊', '暱稱2', '南部地區', '桌遊店', '台中市桌遊餐廳', 6, 3, 3, '室內活動', 200, '', '', '2020-01-16 14:00:00'),
(3, '', '參觀美術館', '暱稱3', '北部地區', '台北市立美術館', '台北市中山區中山北路三段181號', 1, 0, 3, '室內活動', 100, '', '', '2020-02-14 10:00:00'),
(4, '', '看夜景', '暱稱4', '北部地區', '象山', '台北市信義區五段150巷22弄(象山捷運站)', 3, 1, 4, '室外活動', 0, '', '', '2020-01-29 20:30:00'),
(5, '', '看電影+吃大餐', '暱稱5', '南部地區', '電影院、美式餐廳', '高雄大遠百威秀影城', 3, 3, 5, '室內活動', 600, '', '', '2020-02-14 10:00:00'),
(6, '', '爬山', '暱稱6', '南部地區', '阿里山', '嘉義小火車', 2, 1, 8, '室外活動', 200, '', '', '2020-02-23 07:00:00'),
(7, 'user', '打麻將', '暱稱1', '北部地區', '我家', '新北市泰山區貴子里', 3, 0, 4, '室內活動', 500, '明星一缺三 等你來挑戰', '提供酒水', '2020-01-24 18:30:00'),
(8, 'user', '吃火鍋', '暱稱1', '北部地區', '迎客門', '新北市泰山區貴子里泰山職訓場山下', 10, 0, 2, '聚餐', 140, '吃飯', '結訓前一天聚聚', '2020-01-15 17:00:00'),
(9, 'user', '周年慶購物', '暱稱1', '中部地區', 'SOGO百貨', '台中SOGO百貨公司', 2, 0, 3, '室內活動', 5000, '周年慶大搶購', '買到傾家蕩產', '2020-01-27 09:20:00'),
(10, 'test02', '測試活動', '暱稱1', '北部地區', '泰山職訓場', '新北市泰山區貴子里', 1, 0, 2, '室內活動', 100, '測試用', '測試用', '2020-01-30 09:50:00'),
(11, 'test03', '測試活動2', '暱稱1', '北部地區', '泰山職訓場', '新北市泰山區貴子里', 1, 0, 2, '室內活動', 100, '測試用2', '測試用2', '2020-01-10 09:50:00'),
(12, 'user', '測試活動3', '暱稱1', '北部地區', '泰山職訓場', '新北市泰山區貴子里', 1, 0, 2, '室內活動', 100, '測試用3', '測試用3', '2020-01-10 09:50:00'),
(13, 'admin', '測試活動', '官方', '北部地區', '泰山職訓場', '新北市泰山區貴子里', 5, 0, 2, '室內活動', 200, '測試用', '測試用', '2020-01-30 09:50:00'),
(14, 'admin', '測試活動2', '官方', '北部地區', '泰山職訓場', '新北市泰山區貴子里', 5, 0, 2, '室內活動', 200, '測試用2', '測試用2', '2020-01-10 09:50:00'),
(15, 'admin', '測試活動3', '官方', '北部地區', '泰山職訓場', '新北市泰山區貴子里', 5, 0, 2, '室內活動', 200, '測試用3', '測試用3', '2020-01-10 09:50:00'),
(16, 'admin', '測試活動4', '官方', '中部地區', '台中火車站', '台中市台中火車站', 5, 0, 2, '室外活動', 100, '測試用4', '測試用4', '2020-01-30 09:50:00'),
(17, 'admin', '測試活動5', '官方', '南部地區', '台南火車站', '台南市台南火車站', 5, 0, 2, '室外活動', 100, '測試用5', '測試用5', '2020-01-30 09:50:00'),
(18, 'admin', '測試活動6', '官方', '東部地區', '台東火車站', '台東市台東火車站', 3, 0, 2, '室外活動', 200, '測試用6', '測試用6', '2020-01-10 09:50:00'),
(19, 'admin', '測試活動7', '官方', '離島及其他地區', '朝日溫泉', '臺東縣綠島鄉公館村溫泉167號', 5, 0, 2, '室內活動', 200, '測試用7', '測試用7', '2020-01-10 09:50:00'),
(20, 'admin', '測試活動10', '官方', '北部地區', '泰山職訓場', '新北市泰山區貴子里', 10, 0, 4, '室內活動', 500, '測試用', '測試', '2020-01-27 09:20:00'),
(21, 'admin', '測試活動11', '官方', '中部地區', '台中火車站', '台中SOGO百貨公司', 10, 0, 2, '室內活動', 140, '測試用', '測試', '2020-01-30 09:50:00'),
(22, 'admin', '測試活動12', '官方', '離島及其他地區', '綠島朝日溫泉', '綠島朝日溫泉', 3, 0, 3, '室內活動', 200, '測試用', '測試', '2020-02-14 00:00:00'),
(23, 'user', '1234', '暱稱1', '東部地區', '222222', '1231313', 100, 0, 2, '遊戲', 100, '失我現在請您出口破解比例形式,保證產品,那些推薦要求修改推坑王字幕有人我愛吃飯', '當時存在說出後來也不消失我現在請您出口破解比例形式,保證產品,那些推薦', '2020-01-17 09:45:00'),
(24, 'admin', '123', '官方', '南部地區', '22222', 'xxxxxxxx', 10, 0, 2, '聚餐', 200, '123', '322321', '2020-01-30 00:00:00');
-- --------------------------------------------------------
--
-- 資料表結構 `t6_event_order`
--
CREATE TABLE `t6_event_order` (
`id` int(10) UNSIGNED NOT NULL,
`eventname` text COLLATE utf8mb4_unicode_ci NOT NULL,
`organizer` text COLLATE utf8mb4_unicode_ci NOT NULL,
`event_id` int(11) NOT NULL,
`date` datetime NOT NULL,
`organizer_acc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`user_acc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`ememo` text COLLATE utf8mb4_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t6_event_order`
--
INSERT INTO `t6_event_order` (`id`, `eventname`, `organizer`, `event_id`, `date`, `organizer_acc`, `user_acc`, `ememo`) VALUES
(1, '吃海鮮', '會員1', 1, '2020-02-01 12:00:00', 'test01', 'test01', '提早半小時離開'),
(2, '爬山', '暱稱6', 6, '2020-02-23 07:00:00', '', 'user', ''),
(3, '吃海鮮', '暱稱1', 1, '2020-02-01 12:00:00', 'user', 'user', '123');
-- --------------------------------------------------------
--
-- 資料表結構 `t7_member_order`
--
CREATE TABLE `t7_member_order` (
`id` int(10) UNSIGNED NOT NULL,
`whoacc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`useracc` text COLLATE utf8mb4_unicode_ci NOT NULL,
`date` datetime NOT NULL,
`timelength` int(11) NOT NULL,
`place` text COLLATE utf8mb4_unicode_ci NOT NULL,
`schedule` text COLLATE utf8mb4_unicode_ci NOT NULL,
`budget` int(11) NOT NULL,
`memo` text COLLATE utf8mb4_unicode_ci NOT NULL,
`updatetime` datetime NOT NULL,
`chk` int(11) NOT NULL,
`chk2` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t7_member_order`
--
INSERT INTO `t7_member_order` (`id`, `whoacc`, `useracc`, `date`, `timelength`, `place`, `schedule`, `budget`, `memo`, `updatetime`, `chk`, `chk2`) VALUES
(1, 'test12', 'user', '2020-01-28 10:45:00', 2, '新北', '看電影', 300, '絕地戰警3', '2020-01-15 10:51:11', 1, 1),
(2, 'test12', 'user', '2020-01-21 17:45:00', 4, '新北', '看電影', 220, '看變身特務', '2020-01-15 10:52:57', 1, 1),
(3, 'test12', 'user', '2020-01-16 18:40:00', 2, '迎客門', '吃晚餐', 150, '我付錢', '2020-01-15 14:37:14', 1, 0),
(4, 'test13', 'user', '2020-01-18 16:50:00', 3, '台中', '聚餐', 600, '一起吃燒烤', '2020-02-28 16:42:27', 1, 1),
(5, 'user', 'test13', '2020-03-07 16:50:00', 3, '台中', '聚餐', 800, '一起吃燒烤', '2020-02-28 16:42:27', 1, 1),
(6, 'user', 'test13', '2020-03-02 15:30:00', 2, '台北', '吃下午茶', 300, '甜點吃到飽', '2020-02-28 23:00:24', 1, 0),
(7, 'test02', 'test13', '2020-03-18 14:30:00', 2, '台北', '看電影', 250, '看小丑女', '2020-02-28 23:09:48', 0, 0),
(8, 'test13', 'user', '2020-02-18 14:30:00', 2, '新光三越', '吃下午茶', 350, '台北車站旁', '2020-02-29 15:52:20', 1, 0),
(9, 'test13', 'user', '2020-02-20 10:30:00', 3, '欣欣秀泰', '看電影', 200, '早場電影', '2020-02-29 15:53:18', 0, 0);
-- --------------------------------------------------------
--
-- 資料表結構 `t8_contact`
--
CREATE TABLE `t8_contact` (
`id` int(11) NOT NULL,
`name` text COLLATE utf8mb4_unicode_ci NOT NULL,
`email` text COLLATE utf8mb4_unicode_ci NOT NULL,
`subject` text COLLATE utf8mb4_unicode_ci NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 傾印資料表的資料 `t8_contact`
--
INSERT INTO `t8_contact` (`id`, `name`, `email`, `subject`, `content`) VALUES
(1, '123', 'lily40623@yahoo.com.tw', '111111', '56548494');
--
-- 已傾印資料表的索引
--
--
-- 資料表索引 `t1_admin`
--
ALTER TABLE `t1_admin`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `t2_member_account`
--
ALTER TABLE `t2_member_account`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `t3_member_info`
--
ALTER TABLE `t3_member_info`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `t4_profile`
--
ALTER TABLE `t4_profile`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `t5_event`
--
ALTER TABLE `t5_event`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `t6_event_order`
--
ALTER TABLE `t6_event_order`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `t7_member_order`
--
ALTER TABLE `t7_member_order`
ADD PRIMARY KEY (`id`);
--
-- 資料表索引 `t8_contact`
--
ALTER TABLE `t8_contact`
ADD PRIMARY KEY (`id`);
--
-- 在傾印的資料表使用自動遞增(AUTO_INCREMENT)
--
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t1_admin`
--
ALTER TABLE `t1_admin`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t2_member_account`
--
ALTER TABLE `t2_member_account`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t3_member_info`
--
ALTER TABLE `t3_member_info`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t4_profile`
--
ALTER TABLE `t4_profile`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t5_event`
--
ALTER TABLE `t5_event`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t6_event_order`
--
ALTER TABLE `t6_event_order`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t7_member_order`
--
ALTER TABLE `t7_member_order`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- 使用資料表自動遞增(AUTO_INCREMENT) `t8_contact`
--
ALTER TABLE `t8_contact`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
--SELECT prod_id, prod_name
--FROM Products
--WHERE prod_name LIKE 'F%y'
--SELECT prod_id, prod_name
--FROM Products
--WHERE prod_name LIKE '_ inch teddy bear';
--SELECT prod_id, prod_name
--FROM Products
--Where prod_name LIKE '%Bean bag%';
--SELECT prod_id, prod_name
--FROM Products
--WHERE prod_name COLLATE ==== makes it case sensitive
--LATIN1_General_CS_AS LIKE '%Bean bag%';
--SELECT prod_id, prod_name
--FROM Products ==== how to do range
--WHERE prod_name LIKE '%[A-D]ean bag%';
--SELECT prod_id, prod_name
--FROM Products
--WHERE prod_name COLLATE ======makes the range case sensitive
--LATIN1_General_CS_AS LIKE '%[A-D]Ean bag%';
--SELECT prod_id, prod_name
--FROM Products
--WHERE prod_name LIKE '%[^b]ean bag%';
--SELECt AVG(prod_price) AS avg_price === give me average of prod_price and call it avg_price
--FROM Products;
--GO === not neccessary here but should be used after every block of statement
--SELECT AVG(prod_price) AS avg_price
--FROM Products
--WHERE vend_id = 'DLL01';
--SELECT COUNT(*) AS num_cust
--FROM Customers;
--SELECT COUNT(cust_email) AS num_cust
--FROM Customers;
--SELECT MAX(prod_price) AS max_price
--FROM Products;
--SELECT MIN(prod_price) AS in_price
--FROM Products;
--SELECT SUM(quantity) AS items_ordered
--FROM OrderItems
--WHERE order_num = 20005;
--SELECT SUM(item_price*quantity) AS total_price
--FROM OrderItems
--WHERE order_num = 20005;
--SELECT COUNT(*) AS num_items, MIN(prod_price) AS price_min, MAX(prod_price) AS price_max, AVG(prod_price) AS price_avg
--FROM Products;
--SELECT AVG(DISTINCT prod_price) AS avg_price
--FROM Products
--WHERE vend_id = 'DLL01';
--SELECT order_num, MIN(quantity) AS min_qunatity
--FROM OrderItems;
SELECT DISTINCT order_num, item_price
FROM OrderItems;
SELECT MAX(item_price) AS max_price
FROM OrderItems
WHERE prod_id = 'BR03';
SELECT *
FROM OrderItems;
SELECT AVG(DISTINCT order_num), prod_id, quantity, item_price
FROM OrderItems;
|
DROP TABLE APPEALS;
DROP TABLE CRIME_OFFICERS;
DROP TABLE CRIME_CHARGES;
ALTER TABLE CRIMINALS
ADD CONSTRAINT criminals_criminalID_pk PRIMARY KEY(criminal_id);
ALTER TABLE CRIMINALS
ADD CONSTRAINT criminals_vstatus_ck CHECK(v_status IN ('Y','N'));
ALTER TABLE CRIMINALS
ADD CONSTRAINT criminals_pstatus_ck CHECK(p_status IN ('Y','N'));
ALTER TABLE CRIMES
ADD CONSTRAINT crimes_crimeid_pk PRIMARY KEY(crime_id);
ALTER TABLE CRIMES
ADD CONSTRAINT crimes_criminalid_fk FOREIGN KEY(criminal_id)
REFERENCES CRIMINALS (criminal_id);
ALTER TABLE CRIMES
ADD CONSTRAINT crimes_class_ck CHECK(classification IN ('F','M','O','U'));
ALTER TABLE CRIMES
ADD CONSTRAINT crimes_status_ck CHECK(status IN ('CL','CA','IA'));
ALTER TABLE ALIASES
ADD CONSTRAINT aliases_aliasid_pk PRIMARY KEY(alias_id);
ALTER TABLE ALIASES
ADD CONSTRAINT aliases_criminalid_fk FOREIGN KEY(criminal_id)
REFERENCES criminals (criminal_id);
ALTER TABLE SENTENCES
ADD CONSTRAINT sentences_sentenceid_pk PRIMARY KEY(sentence_id);
ALTER TABLE SENTENCES
ADD CONSTRAINT sentences_criminalid_fk FOREIGN KEY(criminal_id)
REFERENCES criminals (criminal_id);
ALTER TABLE SENTENCES
ADD CONSTRAINT sentences_type_ck CHECK(type IN ('J','H','P'));
ALTER TABLE PROB_OFFICERS
ADD CONSTRAINT probofficers_probid_pk PRIMARY KEY(prob_id);
ALTER TABLE PROB_OFFICERS
ADD CONSTRAINT probofficers_status_ck CHECK(status IN ('A','I'));
ALTER TABLE OFFICERS
ADD CONSTRAINT officers_officerid_pk PRIMARY KEY(officer_id);
ALTER TABLE OFFICERS
ADD CONSTRAINT officers_status_ck CHECK(status IN ('A','I'));
CREATE TABLE crime_charges
(charge_id NUMBER(10,0),
crime_id NUMBER(9,0),
crime_code NUMBER(3,0),
charge_status CHAR(2),
fine_amount NUMBER(7,2),
court_fee NUMBER(7,2),
amount_paid NUMBER(7,2),
pay_due_date DATE,
CONSTRAINT crimecharges_chargeid_pk PRIMARY KEY(charge_id),
CONSTRAINT crimecharges_crimeid_fk FOREIGN KEY(crime_id)
REFERENCES crimes (crime_id),
CONSTRAINT crimecharges_chargestatus_ck
CHECK(charge_status IN ('PD','GL','NG'))
);
CREATE TABLE crime_officers
(crime_id NUMBER(9,0),
officer_id NUMBER(8,0),
CONSTRAINT crimeofficers_crimeid_fk FOREIGN KEY(crime_id)
REFERENCES crimes (crime_id),
CONSTRAINT crimeofficers_officerid_fk FOREIGN KEY(officer_id)
REFERENCES officers (officer_id)
);
CREATE TABLE appeals
(appeal_id NUMBER(5),
crime_id NUMBER(9,0),
filing_date DATE,
hearing_date DATE,
status CHAR(1),
CONSTRAINT appeals_appealid_pk PRIMARY KEY(appeal_id),
CONSTRAINT appeals_crimeid_fk FOREIGN KEY(crime_id)
REFERENCES crimes (crime_id),
CONSTRAINT appeals_status_ck CHECK(status IN ('P','A','D'))
); |
create or replace trigger Q2_2
before insert or update of noCage on LesAnimaux
for each row
Declare
fct varchar(20);
begin
select fonction into fct from LesCages where nocage = :new.nocage;
if fct != :new.fonction_cage then raise_application_error(-20001, 'cage incompatible');
end if;
end;
|
CREATE DATABASE IF NOT EXISTS `psgris` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `psgris`;
-- MySQL dump 10.13 Distrib 5.7.29, for Linux (x86_64)
--
-- Host: localhost Database: psgris
-- ------------------------------------------------------
-- Server version 5.7.29-0ubuntu0.18.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 `candidatos`
--
DROP TABLE IF EXISTS `candidatos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `candidatos` (
`dre` int(11) NOT NULL,
`nome` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`curso` varchar(30) NOT NULL,
`area_favorita` varchar(30) DEFAULT NULL,
`presenca` char(4) NOT NULL,
PRIMARY KEY (`dre`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `candidatos`
--
LOCK TABLES `candidatos` WRITE;
/*!40000 ALTER TABLE `candidatos` DISABLE KEYS */;
INSERT INTO `candidatos` VALUES (117425689,'Fulano de Tal','fulanodetal@poli.ufrj.br','Engenharia Elétrica','Banco de Dados','100%'),(118104124,'Ciclano Silva','ciclano@poli.ufrj.br','Engenharia Civil','Criptografia','60%'),(118127894,'Felipe Barbosa','felipe-barbosa@dcc.ufrj.br','Ciência da Computação','Firewall','70%'),(118658963,'Maria Julia','maria.j@dcc.ufrj.br','Ciência da Computação','Web','90%'),(119105102,'Mariano Gomes','mariano-gomesj@dcc.ufrj.br','Ciência da Computação','Web','80%'),(119574125,'Daniel Soares','soares_daniel@poli.ufrj.br','Engenharia Nuclear','Redes','100%');
/*!40000 ALTER TABLE `candidatos` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `ouvintes`
--
DROP TABLE IF EXISTS `ouvintes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ouvintes` (
`nome` varchar(30) NOT NULL,
`vinculo_ufrj` text NOT NULL,
`identificacao(CPF/DRE)` varchar(12) NOT NULL,
`curso` varchar(30) DEFAULT NULL,
`email` varchar(30) DEFAULT NULL,
`como_conheceuGRIS` text NOT NULL,
PRIMARY KEY (`identificacao(CPF/DRE)`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `ouvintes`
--
LOCK TABLES `ouvintes` WRITE;
/*!40000 ALTER TABLE `ouvintes` DISABLE KEYS */;
INSERT INTO `ouvintes` VALUES ('Márcio Santos','Sem vínculo','04415478921','','masantos@gmail.com','Por um membro'),('Sofia Lima','Sem vínculo','05745825801','','lima_sofia@gmail.com','Pesquisa'),('Adalto Melo','Estudante','115487658','Ciência da Computação','melo-adalto@dcc.ufrj.br','Mural'),('Roberto Nunes','Estudante','117256341','Biologia','robnunes@biologia.ufrj.br','Grupo Facebook');
/*!40000 ALTER TABLE `ouvintes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `palestrantes`
--
DROP TABLE IF EXISTS `palestrantes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `palestrantes` (
`id_get` int(2) NOT NULL,
`nome` varchar(30) NOT NULL,
`descricao` text NOT NULL,
`formacao` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`gris_desde` year(4) NOT NULL,
`situacao_gris` text NOT NULL,
PRIMARY KEY (`id_get`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `palestrantes`
--
LOCK TABLES `palestrantes` WRITE;
/*!40000 ALTER TABLE `palestrantes` DISABLE KEYS */;
INSERT INTO `palestrantes` VALUES (1,'Esoj','Trabalha no CapGov','Engenharia Eletrônica','esoj@poli.ufrj.br',2018,'Membro'),(2,'Breno','Trabalha no CapGov','Engenharia Eletrônica','brenocss@poli.ufrj.br',2018,'Membro'),(3,'Sidney','Monitor de Criptografia I','Ciência da Computação','sid@dcc.ufrj.br',2019,'Membro'),(4,'Franklin','Diretor GRIS','Ciência da Computação','franklin@dcc.ufrj.br',2019,'Membro'),(5,'Manoel','Analista de Segurança - Globo','Engenharia Eletrônica','mdjunior@poli.ufrj.br',2013,'Colaborador'),(6,'Arthur','Especialista em BD','Ciência da Computação','arthur@dcc.ufrj.br',2015,'Colaborador');
/*!40000 ALTER TABLE `palestrantes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tag`
--
DROP TABLE IF EXISTS `tag`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tag` (
`id_tag` int(2) NOT NULL AUTO_INCREMENT,
`assunto` varchar(30) NOT NULL,
`descricao` text NOT NULL,
`data_entrega` varchar(10) NOT NULL,
`get_avaliador` int(2) DEFAULT NULL,
PRIMARY KEY (`id_tag`),
KEY `get_avaliador` (`get_avaliador`),
CONSTRAINT `tag_ibfk_1` FOREIGN KEY (`get_avaliador`) REFERENCES `palestrantes` (`id_get`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tag`
--
LOCK TABLES `tag` WRITE;
/*!40000 ALTER TABLE `tag` DISABLE KEYS */;
INSERT INTO `tag` VALUES (1,'Banco de Dados','Criar um Banco de Dados do Processo Seletivo GRIS','29/02/2020',6),(2,'Criptografia','Resolver 3 desafios do Cryptopals','29/02/2020',3),(3,'Perl/Go','Criar um Portscanner em Go','27/02/2020',5),(4,'Ethical Hacking','Redação sobre Ethical Hacking e Hacking Ativismo','07/03/2020',6);
/*!40000 ALTER TABLE `tag` 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 2020-02-28 15:52:09
|
/*
Navicat MySQL Data Transfer
Source Server : Tanyaconnect
Source Server Version : 50716
Source Host : localhost:3306
Source Database : javaee
Target Server Type : MYSQL
Target Server Version : 50716
File Encoding : 65001
Date: 2019-06-09 17:54:23
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for question
-- ----------------------------
DROP TABLE IF EXISTS `question`;
CREATE TABLE `question` (
`question_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '题目id',
`question_content` varchar(255) DEFAULT NULL COMMENT '题目题干',
`question_Aans` varchar(255) DEFAULT NULL COMMENT 'A答案',
`question_Bans` varchar(255) DEFAULT NULL COMMENT 'B答案',
`question_Cans` varchar(255) DEFAULT NULL COMMENT 'C答案',
`question_Dans` varchar(255) DEFAULT NULL COMMENT 'D答案',
`question_rightans` varchar(255) DEFAULT NULL COMMENT '正确答案',
`question_type` int(11) DEFAULT NULL COMMENT '题目类型',
`question_test` int(11) NOT NULL DEFAULT '0' COMMENT '对应试卷id',
PRIMARY KEY (`question_id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of question
-- ----------------------------
INSERT INTO `question` VALUES ('1', '()是构成C语言程序的基本单位。', '函数', '过程', '子程序', '子例程', '函数', '1', '3');
INSERT INTO `question` VALUES ('2', 'C语言程序从()开始执行。', '程序中第一条可执行语句', '程序中第一个函数', '程序中的main函数', '包含文件中的第一个函数', '程序中的main函数', '1', '3');
INSERT INTO `question` VALUES ('3', '以下说法中正确的是()', 'C语言程序总是从第一个定义的函数开始执行', '在C语言程序中,要调用的函数必须在main()函数中定义', 'C语言程序总是从main()函数开始执行', 'C语言程序中的main()函数必须放在程序的开始部分', 'C语言程序总是从main()函数开始执行', '1', '3');
INSERT INTO `question` VALUES ('4', '#include <stdio.h>\r\nmain()\r\n{ int a=1,b=3,c=5;\r\nif (c==a+b)\r\n printf(\"yes\\n\");\r\nelse\r\n printf(\"no\\n\");\r\n}', '', '', '', '', 'no', '3', '3');
INSERT INTO `question` VALUES ('5', '#include <stdio.h>\r\nmain()\r\n{ int a=12, b= -34, c=56, min=0;\r\nmin=a;\r\n if(min>b) \r\nmin=b;\r\n if(min>c) \r\nmin=c;\r\nprintf(\"min=%d\", min);\r\n}', null, null, null, null, 'min=34', '3', '3');
INSERT INTO `question` VALUES ('9', 'this()关键字表示当前类的对象', null, null, null, null, '对', '2', '3');
INSERT INTO `question` VALUES ('10', 'super()关键字表示父类对象', null, null, null, null, '对', '2', '3');
INSERT INTO `question` VALUES ('11', '()修饰抽象类,抽象方法', 'static', 'final', 'abstract', 'protect', 'static', '1', '3');
INSERT INTO `question` VALUES ('12', 'static修饰抽象类,抽象方法', null, null, null, null, '错', '2', '3');
INSERT INTO `question` VALUES ('13', 'jvm是虚拟机', null, null, null, null, '对', '2', '3');
-- ----------------------------
-- Table structure for questiontype
-- ----------------------------
DROP TABLE IF EXISTS `questiontype`;
CREATE TABLE `questiontype` (
`qtid` int(11) NOT NULL AUTO_INCREMENT COMMENT '试题类型id',
`qtname` varchar(50) NOT NULL COMMENT '试题类型名称',
`score` int(11) NOT NULL COMMENT '该题型分数',
PRIMARY KEY (`qtid`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of questiontype
-- ----------------------------
INSERT INTO `questiontype` VALUES ('1', '选择题', '2');
INSERT INTO `questiontype` VALUES ('2', '判断题', '1');
INSERT INTO `questiontype` VALUES ('3', '读程序题', '3');
-- ----------------------------
-- Table structure for test
-- ----------------------------
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`test_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '试卷id',
`test_name` varchar(255) DEFAULT NULL COMMENT '试卷名称',
`test_time` int(11) DEFAULT NULL COMMENT '考试时长(单位:分钟)',
PRIMARY KEY (`test_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of test
-- ----------------------------
INSERT INTO `test` VALUES ('3', '2016级一体化实践工程期末考', '90');
INSERT INTO `test` VALUES ('4', '2018年化学与社会期中考试', '60');
INSERT INTO `test` VALUES ('5', '2017级数学建模期末考试', '90');
INSERT INTO `test` VALUES ('6', '2017级化学与社会期末考试', '60');
INSERT INTO `test` VALUES ('7', '2018级高等数学考试', '90');
INSERT INTO `test` VALUES ('8', '2018年四级模拟试卷', '710');
INSERT INTO `test` VALUES ('9', '2018级英语水平测试', '120');
-- ----------------------------
-- Table structure for userinfo
-- ----------------------------
DROP TABLE IF EXISTS `userinfo`;
CREATE TABLE `userinfo` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) DEFAULT NULL,
`user_password` varchar(255) DEFAULT NULL,
`user_phone` varchar(255) DEFAULT NULL,
`user_postbox` varchar(255) DEFAULT NULL,
`user_type` int(1) NOT NULL,
`user_wish` varchar(255) DEFAULT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of userinfo
-- ----------------------------
INSERT INTO `userinfo` VALUES ('2', 'Morty', '1216', null, '5656545@qq.com', '0', '考研加油!!!');
INSERT INTO `userinfo` VALUES ('3', 'Summer', '1217', '15502664545', '16556586@qq.com', '0', '最强王者');
INSERT INTO `userinfo` VALUES ('4', 'Jerry', '1218', null, '1655165665@qq.com', '0', '新年脱单!!!');
INSERT INTO `userinfo` VALUES ('5', 'Beth', '111', null, '1656498456@qq.com', '0', 'LOL皮肤大减价');
INSERT INTO `userinfo` VALUES ('6', 'serv', '33333333', '15504475422', '26541656112@qq.com', '0', '哈哈哈啊哈哈哈哈啊哈哈');
INSERT INTO `userinfo` VALUES ('7', 'sss', 'ssss', null, '51654516@qq.com', '0', '不挂科');
INSERT INTO `userinfo` VALUES ('9', 'Dick', '123456', null, '1215456@qq.com', '0', '777777777');
INSERT INTO `userinfo` VALUES ('10', 'David', '666', null, '4549984@qq.com', '0', '略略略');
INSERT INTO `userinfo` VALUES ('13', 'Di', '156131', '15504475422', '165651652@qq.com', '0', 'hahahah');
INSERT INTO `userinfo` VALUES ('39', 'Aver', '151515', null, '154698546@qq.com', '0', '发发发!');
INSERT INTO `userinfo` VALUES ('40', 'THOR', '626262', null, '62523645@qq.com', '0', '就想上个墙');
INSERT INTO `userinfo` VALUES ('41', 'Tanya', '541619', null, '265454656@qq.com', '1', '上个墙+1');
INSERT INTO `userinfo` VALUES ('42', 'Tom', '999999', null, '999999@qq.com', '0', '赚钱赚钱赚钱');
INSERT INTO `userinfo` VALUES ('44', 'Auser', 'f379eaf3c831b04de153469d1bec345e', null, '555555@qq.com', '0', null);
INSERT INTO `userinfo` VALUES ('45', 'AbigUser', '5b1b68a9abf4d2cd155c81a9225fd158', null, '', '0', null);
INSERT INTO `userinfo` VALUES ('46', 'man', 'e10adc3949ba59abbe56e057f20f883e', null, '', '1', '777');
INSERT INTO `userinfo` VALUES ('47', 'girl', '96e79218965eb72c92a549dd5a330112', null, '', '0', '666');
INSERT INTO `userinfo` VALUES ('48', 'girl1', '96e79218965eb72c92a549dd5a330112', null, '', '0', '666');
INSERT INTO `userinfo` VALUES ('49', 'girl3', '96e79218965eb72c92a549dd5a330112', null, '', '0', '哈哈哈');
INSERT INTO `userinfo` VALUES ('50', 'girl2', '96e79218965eb72c92a549dd5a330112', null, '', '0', '哈哈哈');
INSERT INTO `userinfo` VALUES ('51', 'test', 'd41d8cd98f00b204e9800998ecf8427e', null, '', '0', null);
INSERT INTO `userinfo` VALUES ('54', 'mtest', '96e79218965eb72c92a549dd5a330112', null, '', '1', null);
INSERT INTO `userinfo` VALUES ('55', 'sad', '698d51a19d8a121ce581499d7b701668', null, '', '0', null);
INSERT INTO `userinfo` VALUES ('56', 'asdad', '698d51a19d8a121ce581499d7b701668', null, '', '0', null);
INSERT INTO `userinfo` VALUES ('57', 'test1', '96e79218965eb72c92a549dd5a330112', '15504415485', '', '0', 'test');
INSERT INTO `userinfo` VALUES ('58', 'test2', '96e79218965eb72c92a549dd5a330112', '15504475422', '', '0', 'test');
INSERT INTO `userinfo` VALUES ('59', 'test3', '96e79218965eb72c92a549dd5a330112', null, '123132165@qq.com', '1', null);
INSERT INTO `userinfo` VALUES ('60', 'ttt', 'e3ceb5881a0a1fdaad01296d7554868d', null, '12165165@qq.com', '0', '靠');
INSERT INTO `userinfo` VALUES ('61', 'lgb', '49bff6732fef7aad07d9236bfaf60d0d', '15504475422', '15613165@qq.com', '0', 'kanchunwan');
INSERT INTO `userinfo` VALUES ('62', 'user4', '1218', null, '16516132165', '0', null);
INSERT INTO `userinfo` VALUES ('63', 'user4', '1218', null, '16516132165', '0', null);
-- ----------------------------
-- Table structure for userinfo2
-- ----------------------------
DROP TABLE IF EXISTS `userinfo2`;
CREATE TABLE `userinfo2` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) DEFAULT NULL,
`user_password` varchar(255) DEFAULT NULL,
`user_type` int(11) DEFAULT NULL COMMENT '用户类型',
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of userinfo2
-- ----------------------------
INSERT INTO `userinfo2` VALUES ('3', 'l', '698d51a19d8a121ce581499d7b701668', '2');
INSERT INTO `userinfo2` VALUES ('4', 'll', 'bcbe3365e6ac95ea2c0343a2395834dd', '1');
|
INSERT INTO guestbook_entry (ID,EMAIL,CONTENT, LAST_UPDATE)
VALUES (1000, 'example@example.org', 'Inserted via ebean.ddl.seedSql property', GETDATE());
|
--Create procedure 5: pro_enroll
select * from enrolled;
create or replace procedure pro_enroll(sname_in IN varchar, cname IN varchar) as
student_num number;
begin
select s.snum into student_num from student s where s.sname = sname_in;
insert into ENROLLED values (student_num, cname);
end pro_enroll;
/
--run procedure
begin
pro_enroll('M.Lee', 'CS448');
pro_enroll('A.Smith', 'ENG320');
end;
/
select * from enrolled; |
CREATE PROCEDURE sp_get_InvoiceDetailReceived_only (@INVOICENO INT)
AS
SELECT
Items.Product_Code, Items.ProductName, NULL, Batch_Number,
InvoiceDetailReceived.Quantity, InvoiceDetailReceived.SalePrice,
InvoiceDetailReceived.TaxCode, InvoiceDetailReceived.DiscountPercentage,
InvoiceDetailReceived.DiscountValue, InvoiceDetailReceived.Amount, Null, Null, Null SCHEMEID, Null SPLCATSCHEMEID,
Null FREESERIAL, Null SPLCATSERIAL,
NULL SCHEMEDISCPERCENT, NULL SCHEMEDISCAMOUNT,
NULL SPLCATDISCPERCENT, NULL SPLCATDISCAMOUNT,
NULL SPECIALCATEGORYSCHEME, NULL SCHEME_INDICATOR, NULL SPLCATSCHEME_INDICATOR , SPBED = IsNull(InvoiceDetailReceived.SalePriceBeforeExciseAmount,0) , ExciseDuty = IsNull(InvoiceDetailReceived.ExciseDuty,0)
FROM InvoiceDetailReceived, Items
WHERE InvoiceDetailReceived.InvoiceID = @INVOICENO
AND InvoiceDetailReceived.Product_Code = Items.Product_Code and active = 1
Order by ItemOrder
|
create table if not exists categories (
id integer not null constraint categories_pkey primary key,
description varchar(255),
name varchar(255) not null,
position integer not null,
slug varchar(255) not null constraint uk_category_slug unique,
topic_count integer default 0 not null,
parent_id integer,
constraint uk_category_parent_position unique (parent_id, position)
);
create table if not exists groups (
id integer not null constraint groups_pkey primary key,
color varchar(255),
icon varchar(255),
name varchar(20) not null constraint uk_group_name unique
);
create table if not exists group_permissions (
group_id integer not null,
permissions varchar(255),
constraint uk_group_permission unique (group_id, permissions) -- manual add
);
create table if not exists remember_me_token (
series varchar(255) not null constraint remember_me_token_pkey primary key,
last_used timestamp,
token varchar(255),
username varchar(255)
);
-- manual: upper()
create index if not exists remember_me_token_username_index on remember_me_token (upper(username));
create table if not exists settings (
key varchar(255) not null constraint settings_pkey primary key,
value varchar(65535) not null
);
create table if not exists secrets (
key varchar(255) not null constraint secrets_pkey primary key,
value varchar(65535) not null
);
create table if not exists users (
id integer not null constraint users_pkey primary key,
active boolean default false not null,
avatar varchar(255),
bio varchar(255),
create_at timestamp default now() not null,
email varchar(255) not null constraint uk_user_email unique,
email_public boolean default false not null,
github varchar(255),
last_sign_in_at timestamp,
last_sign_ip varchar(255),
locked_at timestamp,
locked_until timestamp,
nickname varchar(30) not null constraint uk_user_nickname unique,
password varchar(255) not null,
post_count integer default 0 not null,
topic_count integer default 0 not null,
username varchar(30) not null,
website varchar(255),
group_id integer default 3 not null
);
-- manual: upper()
create unique index if not exists uk_user_username on users (upper(username));
create table if not exists topics (
id integer not null constraint topics_pkey primary key,
create_at timestamp default now() not null,
delete boolean default false not null,
delete_by_id integer,
feature boolean default false not null,
last_reply_at timestamp default now() not null,
locked boolean default false not null,
locked_by_id integer,
pinned boolean default false not null,
post_index integer default 0 not null,
slug varchar(255) not null,
title varchar(255) not null,
author_id integer not null,
last_reply_by_id integer
);
create index if not exists topics_author_index on topics (author_id);
create table if not exists posts (
id integer not null constraint posts_pkey primary key,
cooked text not null,
create_at timestamp default now() not null,
delete boolean default false not null,
delete_by_id integer,
index integer not null,
ip varchar(255) not null,
last_edit_at timestamp,
raw text not null,
author_id integer not null,
topic_id integer not null,
constraint uk_topic_id_index unique (topic_id, index)
);
create index if not exists posts_author_index on posts (author_id);
create table if not exists notifications (
id integer not null constraint notifications_pkey primary key,
create_at timestamp default now() not null,
read_at timestamp,
type varchar(255) not null,
post_id integer not null,
send_id integer not null,
to_id integer not null,
topic_id integer not null
);
create index if not exists notifications_to_index on notifications (to_id);
create table if not exists reports (
id integer not null constraint reports_pkey primary key,
create_at timestamp default now() not null,
handle_at timestamp,
reason varchar(255) not null,
by_id integer not null,
post_id integer not null
);
create index if not exists reports_post_index on reports (post_id);
create table if not exists topics_categories (
topic_id integer not null,
categories_id integer not null,
constraint topics_categories_pkey primary key (topic_id, categories_id)
);
create index if not exists topics_categories_categories on topics_categories (categories_id);
--- sequence
create sequence category_sequence;
create sequence group_sequence;
create sequence notification_sequence increment by 5;
create sequence post_sequence increment by 5;
create sequence report_sequence;
create sequence topic_sequence increment by 5;
create sequence user_sequence increment by 5;
|
USE peer_pressure_db;
INSERT INTO users (username, firstname, lastname, email, image_url)
VALUES ("PastorOfMuppets", "Keith", "Allmon", "adcatcher73@gmail.com", "https://scontent-sjc3-1.xx.fbcdn.net/v/t1.0-9/20708206_10203703099854122_2463177902792792532_n.jpg?_nc_cat=0&oh=0cd3fb9b72df9bc579cb683a903e0db7&oe=5B507F97"),
("StrangerThanFiction", "David", "Lee Roth", "jump@yahoo.com", "https://images-na.ssl-images-amazon.com/images/I/C1DWo0YTWAS._SL1000_.png"),
("Daver", "David", "Narf", "no@yahoo.com", "https://pbs.twimg.com/media/COjTEn7VEAEngBK.jpg"),
("TheStranger", "Albert", "Camus", "notnauseous@gmail.com", "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRbcY4uAfTXDFPES6iXRAHJJWeeEv1xT49KAQB3-0cGRNj7N6rM"),
("Writer4Life","Larry", "David", "haha@gmail.com", "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSL1uaCtQkZCQysqTHoPv969bBKwPjTFvyKRn1c09YHre8wkI9KaQ"),
("IShotFirst", "Han", "Solo", "solo@nono.com", "https://pbs.twimg.com/profile_images/574496403868647425/84GaJKHk.jpeg");
INSERT INTO Tasks (item_name, category, steps, criteria, created_by)
VALUES ("Leap Tall Building", "Goal", "Become Superman", "Under your own power, leap a building of at least ten stories", 1),
("Go to Ireland", "Bucket List", "Get a passport and a plane ticket", "Get on the plane and go", 1),
("Find Bellybutton", "Task", "Lift up shirt (your own shirt)", "Notice the little divot on the middle of your belly", 6),
("Eat something", "Idea", "Find some food, preferably tasty", "Put food in mouth, masticate, and swallow", 2),
("Quit smoking", "Goal", "Get rid of ashtrays; Get patches and nicotine gum; Get support of family and friends", "Go six months without smoking at all", 2),
("Lose ten pounds", "Goal", "Give up tortilla chips", "Lose ten pounds without cutting off a limb to do it", 2),
("Write a novel", "Bucket List", "Develop writing habits; stick to said habits; follow through", "Created finished manuscript of at least 80,000 words", 1),
("Nomsayn", "Idea", "Listen and understand", "truly KNOW what I am saying", 1),
("Finish this project", "Goal", "Plan the rest of the functionality; set up testing; test; implement", "Deliver finished product next Wednesday", 1),
("Spend a month in New Zealand", "Bucket List", "Save money; get time off work; go", "Pics or it didn't happen", 1),
("Finish reading A Song of Ice and Fire", "Goal", "Try to find it interesting again; hope G.R.R.M doesn't die before it's written", "Read it!", 3),
("Fiddle while Rome burns", "Idea", "Wait for socio-economic collapse; play the fiddle", "Actual collapse, not just politics as usual", 1),
("Get car registered", "Task", "Pass inspection and emissions test; fix if necessary until it does pass; go to the DMV; suffer", "Stick new sticker on license plate", 6),
("Get Developer job", "Goal", "Finish bootcamp; Clean up GitHub and LinkedIn; Polish Portfolio", "Land full-time job as developer", 1),
("Re-write resume", "Task", "Research good resumes; make changes", "This task never seems complete", 1),
("Make more coffee", "Task", "Get grounds; fill grounds basket; fill water reservoir; wait", "Sip fresh coffee", 5),
("Derp", "Bucket List", "Derp; derp some more", "Derp is your way of life", 5),
("Whoa", "Idea", "Strange things are afoot at the Circle-K", "Travel back in time", 1),
("Shazam", "Goal", "Iono", "Narf", 1),
("Sell Things", "Bucket List", "Have things", "Don't have some things you used to have; have money instead", 4),
("Finish being Finnish", "Goal", "Is this possible?", "Be something else (you can't)", 1),
("Fiddle with something", "Idea", "Take something apart; put it back together (almost)", "Ride a bike with no handlebars", 1),
("Get outta here!", "Task", "Be here, then leave", "Don't be there anymore", 4),
("Get bent", "Goal", "Don't be bent as much as you could be", "Bend", 3),
("Raise Hell", "Task", "Give birth to Hell", "Raise it to be a reprehensible member of society", 1),
("Make more money", "Task", "Get a printing press and a fake ID; fake your death; print money", "Sip drinks on a beach in Cancun", 1);
INSERT INTO UserTasks (TaskId, UserId)
VALUES (1, 1),
(2, 3),
(3, 1),
(4, 2),
(5, 1),
(6, 1),
(7, 1),
(8, 1),
(9, 1),
(10, 1),
(11, 1),
(12, 1),
(13, 1),
(14, 1),
(15, 1),
(16, 1),
(17, 1),
(18, 1),
(19, 1),
(20, 1),
(21, 1),
(22, 1),
(23, 1),
(24, 1),
(25, 1),
(26, 1);
INSERT INTO Ratings (item_id, user_id, rating)
VALUES (1, 1, 0),
(2, 3, 0),
(3, 1, 0),
(4, 2, 0),
(5, 1, 0),
(6, 1, 0),
(7, 1, 0),
(8, 1, 0),
(9, 1, 0),
(10, 1, 0),
(11, 1, 0),
(12, 1, 0),
(13, 1, 0),
(14, 1, 0),
(15, 1, 0),
(16, 1, 0),
(17, 1, 0),
(18, 1, 0),
(19, 1, 0),
(20, 1, 0),
(21, 1, 0),
(22, 1, 0),
(23, 1, 0),
(24, 1, 0),
(25, 1, 0),
(26, 1, 0); |
DROP TABLE IF EXISTS highest_education;
CREATE TABLE highest_education (value SMALLINT PRIMARY KEY, property VARCHAR (30) NOT NULL);
INSERT INTO highest_education (value, property) VALUES (0, 'Prefer Not To Say');
INSERT INTO highest_education (value, property) VALUES (1, 'High School');
INSERT INTO highest_education (value, property) VALUES (2, 'Some College');
INSERT INTO highest_education (value, property) VALUES (4, 'College Graduate');
INSERT INTO highest_education (value, property) VALUES (8, 'Some University');
INSERT INTO highest_education (value, property) VALUES (16, 'University Graduate');
|
CREATE TABLE IF NOT EXISTS categories(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(255),
content TEXT,
slug VARCHAR(255),
parent INTEGER DEFAULT null
);
CREATE TABLE IF NOT EXISTS products(
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT,
slug VARCHAR(255),
image_name VARCHAR(255),
name VARCHAR(255),
price VARCHAR(20),
promo VARCHAR(20),
featured INTEGER,
brand VARCHAR(40),
available INTEGER,
category INTEGER NOT NULL,
FOREIGN KEY(category) REFERENCES categories(id)
);
CREATE TABLE IF NOT EXISTS pages(
id INTEGER PRIMARY KEY AUTOINCREMENT,
slug VARCHAR(255),
title VARCHAR(255),
menu_order INTEGER DEFAULT NULL,
content TEXT
);
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY AUTOINCREMENT,
username VARCHAR(255),
email VARCHAR(255)
);
CREATE TABLE IF NOT EXISTS reviews(
id INTEGER PRIMARY KEY AUTOINCREMENT,
rating INTEGER,
user INTEGER,
content TEXT,
FOREIGN KEY(user) REFERENCES users(id)
);
CREATE TABLE IF NOT EXISTS login_attempts(
ip INTEGER,
attempts INTEGER,
time INTEGER
);
|
CREATE DATABASE restaurantorderingsystem_db;
USE restaurantorderingsystem_db;
DROP TABLE IF EXISTS `item`;
CREATE TABLE `item` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`description` varchar(200) NOT NULL,
`price` double NOT NULL,
`availability` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
LOCK TABLES `item` WRITE;
/*!40000 ALTER TABLE `item` DISABLE KEYS */;
INSERT INTO `item` VALUES (1,'Lasagna','Culinary dish made with stacked layers of pasta alternated with sauces and ingredients',15,1),(2,'Poutine','Dish that includes french fries and cheese curds topped with a brown gravy',4.35,1),(3,'Falafel','Deep-fried ball, or a flat or doughnut-shaped patty, made from ground chickpeas, fava beans, or both',8,1);
/*!40000 ALTER TABLE `item` ENABLE KEYS */;
UNLOCK TABLES;
|
-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 31, 2018 at 05:36 AM
-- Server version: 10.1.26-MariaDB
-- PHP Version: 7.1.9
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: `gondiadb`
--
-- --------------------------------------------------------
--
-- Table structure for table `daignosis`
--
CREATE TABLE `daignosis` (
`dia_id` int(11) NOT NULL,
`p_id` varchar(15) NOT NULL,
`symptoms` varchar(255) NOT NULL,
`earlier_treat` varchar(255) NOT NULL,
`conc` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `daignosis`
--
INSERT INTO `daignosis` (`dia_id`, `p_id`, `symptoms`, `earlier_treat`, `conc`) VALUES
(1, '45dw33', 'vommit,headache,fever, no stools', 'N/A', 'Food Poisioning'),
(2, '23se11', 'itching,skin redening', 'N/A', 'Skin allergy'),
(3, '6xy231', 'chest pain,high bp', 'Engioplasty', 'blockage in heart'),
(4, '89yy51', 'knee pain,cannot walk or stand', 'N/A', 'Knee plate damaged'),
(5, '44ac42', 'ear pain, hearing loss', 'N/A', 'EarDrum Rupture');
-- --------------------------------------------------------
--
-- Table structure for table `daily_reading`
--
CREATE TABLE `daily_reading` (
`daily_readid` int(11) NOT NULL,
`p_id` varchar(15) NOT NULL,
`pusle` varchar(10) NOT NULL,
`bp` varchar(50) NOT NULL,
`temp` varchar(50) NOT NULL,
`respi` varchar(50) NOT NULL,
`ivfluids` varchar(255) NOT NULL,
`date _time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `daily_reading`
--
INSERT INTO `daily_reading` (`daily_readid`, `p_id`, `pusle`, `bp`, `temp`, `respi`, `ivfluids`, `date _time`) VALUES
(1, '45dw33', '80', 'S: 110 D:130', '32', '121', 'Glucose: 33 Glucose 2: 55 Glucose 3:11', '2017-12-21 13:39:03'),
(2, '23se11', '84', 'S:90 D:133', '33', '31', 'Glucose: 31 Glucose 2: 25 Glucose 3:33', '2017-12-21 13:39:03'),
(3, '6xy231', '83', 'S:120 D:144', '34', '211', 'Glucose: 63 Glucose 2: 53 Glucose 3:43', '2017-12-21 13:39:03'),
(4, '89yy51', '70', 'S:93 D:123', '38', '123', 'Glucose: 31 Glucose 2: 57 Glucose 3:14', '2017-12-21 13:39:03'),
(5, '44ac42', '87', 'S: 99 D:122', '35', '122', 'Glucose: 32 Glucose 2: 35 Glucose 3:54', '2017-12-21 13:39:03');
-- --------------------------------------------------------
--
-- Table structure for table `doctor`
--
CREATE TABLE `doctor` (
`doc_id` int(10) NOT NULL,
`type` varchar(255) NOT NULL,
`specialist` varchar(255) NOT NULL,
`visiting` varchar(255) NOT NULL,
`hours` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `doctor`
--
INSERT INTO `doctor` (`doc_id`, `type`, `specialist`, `visiting`, `hours`) VALUES
(1, 'Cardiologist', 'specialist', 'Y', '9'),
(2, 'ENT', 'Normal', 'N', '24'),
(3, 'Dermatalogist', 'Specialist', 'Y', '16'),
(4, 'Dentist', 'Specialist', 'Y', '20'),
(5, 'Surgeon', 'Highly Specialized', 'Y', '10');
-- --------------------------------------------------------
--
-- Table structure for table `doctor_findings`
--
CREATE TABLE `doctor_findings` (
`Findings_id` int(11) NOT NULL,
`p_id` varchar(15) NOT NULL,
`Date` date DEFAULT NULL,
`Time` time DEFAULT NULL,
`Findings` varchar(255) NOT NULL,
`Td` varchar(255) NOT NULL,
`picpath` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `doctor_findings`
--
INSERT INTO `doctor_findings` (`Findings_id`, `p_id`, `Date`, `Time`, `Findings`, `Td`, `picpath`) VALUES
(1, '6xy231', '2017-12-12', '13:17:00', 'Chest pain, Head Ache', 'Amplopin 1-0-1. NO cheese, less salt diet', ''),
(2, '23se11', '2017-12-26', '04:18:00', 'itching, infection', 'Btex', ''),
(3, '44ac42', '2017-12-13', '03:19:00', 'Can\'t hear, Ear pain', 'Ear drops, Balm', ''),
(4, '45dw33', '2017-12-21', '03:19:00', 'Stomach ache, indigestion', 'Antacids, Digestion syrup', ''),
(5, '89yy51', '2017-12-23', '11:23:00', 'knee pain , can\'t walk', 'volini,high calcium diet', ''),
(8, '44ac42', '2017-12-13', '07:00:00', 'Head Ache', 'Saridon', ''),
(9, '45dw33', '0000-00-00', '00:00:00', 'Head Ache', 'Saridon', ''),
(10, '45dw33', '0000-00-00', '00:00:00', 'Head Ache', 'Saridon', ''),
(11, '45dw33', '0000-00-00', '00:00:00', 'Head Ache', 'Saridon', ''),
(12, '23se11', '2017-12-13', '02:01:00', 'fshbhd', 'fhbhbx', ''),
(13, '45dw33', '2017-12-12', '17:02:00', 'dhtdt', 'hgdg', ''),
(14, '23se11', '2017-12-06', '02:03:00', 'dthtsfh', 'dhhst', ''),
(15, '6xy231', '2018-03-08', '01:00:00', 'aaaaaa', 'asdsad', ''),
(16, '6xy231', '2018-03-20', '01:02:00', 'sgfdgH', 'bsHs', ''),
(17, '6xy231', '2018-03-22', '03:03:00', 'asdj', 'sjhbd', ''),
(18, '45dw33', NULL, NULL, '', '', 'uploads/1521901744_test1.jpg'),
(19, '89yy51', NULL, NULL, '', '', 'uploads/1521901973_test2.jpg'),
(20, '89yy51', NULL, NULL, '', '', 'uploads/1521902261_test1.jpg'),
(21, '6xy231', NULL, NULL, '', '', 'uploads/1522071824_test2.jpg'),
(22, '89yy51', NULL, NULL, '', '', 'uploads/1522086708_test2.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `inventory`
--
CREATE TABLE `inventory` (
`inven_id` varchar(10) NOT NULL,
`inven_name` varchar(20) NOT NULL,
`inven_cost` varchar(20) NOT NULL,
`available` int(11) NOT NULL DEFAULT '0',
`stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `inventory`
--
INSERT INTO `inventory` (`inven_id`, `inven_name`, `inven_cost`, `available`, `stamp`) VALUES
('I1', 'Consultation Charges', '344', 72, '2018-02-13 13:18:35'),
('I10', 'Rt. Catherter', '100', 25, '2017-12-21 08:46:01'),
('I11', 'Oxygen Plain', '400', 14, '2017-12-21 08:48:47'),
('I12', 'Pathology', '400', 15, '2017-12-20 10:41:04'),
('I13', 'X Ray', '600', 10, '2017-12-20 10:41:04'),
('I14', 'Nebulisation', '420', 2, '2017-12-21 12:00:16'),
('I15', 'Ventiliator', '600', 10, '2017-12-20 10:42:35'),
('I16', 'Oxygen', '700', 0, '2017-12-20 10:41:04'),
('I17', 'Intubution & HM', '500', 0, '2017-12-20 10:41:04'),
('I18', 'ECG', '400', 0, '2017-12-20 10:41:04'),
('I19', 'Bi-Pap', '500', 0, '2017-12-20 10:41:04'),
('I2', 'IPD Registration', '200', 0, '2017-12-20 10:41:04'),
('I20', 'Oxygen', '500', 0, '2017-12-20 10:41:04'),
('I21', 'Airbed', '400', 0, '2017-12-20 10:41:04'),
('I22', 'Special Visit', '500', 0, '2017-12-20 10:41:04'),
('I23', 'USG', '500', 0, '2017-12-20 10:41:04'),
('I24', 'Central Line & HM', '500', 0, '2017-12-20 10:41:04'),
('I25', 'Tapping & HM', '1000', 0, '2017-12-20 10:41:04'),
('I26', 'Thrombolysis & HM', '800', 0, '2017-12-20 10:41:04'),
('I27', 'Physio Visit', '1000', 0, '2017-12-20 10:41:04'),
('I28', 'Diet Charges', '1000', 0, '2017-12-20 10:41:04'),
('I29', 'Echo', '400', 0, '2017-12-20 10:41:04'),
('I3', 'Room Type', '300', 0, '2017-12-20 10:41:04'),
('I30', 'CPR', '500', 0, '2017-12-20 10:41:04'),
('I31', 'MLC', '1000', 0, '2017-12-20 10:41:04'),
('I32', 'Platelet Transfusion', '1000', 0, '2017-12-20 10:41:04'),
('I33', 'Blood Transfusion', '600', 0, '2017-12-20 10:41:04'),
('I34', 'Lumber Puncher', '600', 0, '2017-12-20 10:41:04'),
('I35', 'Other Charges', '700', 0, '2017-12-20 10:41:04'),
('I4', 'Bed Charges', '300', 0, '2017-12-20 10:41:04'),
('I5', 'Doctor Visit Charges', '400', 0, '2017-12-20 10:41:04'),
('I6', 'Nursing Charges', '500', 0, '2017-12-20 10:41:04'),
('I7', 'RMO Charges', '200', 0, '2017-12-20 10:41:04'),
('I8', 'Monitor', '200', 0, '2017-12-20 10:41:04'),
('I9', 'Pulse Oxy', '1000', 0, '2017-12-20 10:41:04');
--
-- Triggers `inventory`
--
DELIMITER $$
CREATE TRIGGER `availability_check` AFTER UPDATE ON `inventory` FOR EACH ROW BEGIN
IF NEW.available < 5 THEN
INSERT INTO reqtest values(NEW.inven_id);
END IF;
END
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `inventory_updatelog`
--
CREATE TABLE `inventory_updatelog` (
`Record` int(11) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`equipment_name` varchar(50) NOT NULL,
`Quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `inventory_updatelog`
--
INSERT INTO `inventory_updatelog` (`Record`, `timestamp`, `equipment_name`, `Quantity`) VALUES
(1, '2017-12-21 09:04:00', 'Rt. Catherter', 5),
(2, '2017-12-21 09:04:00', 'Rt. Catherter', 6),
(4, '2017-12-21 09:04:00', 'Oxygen Plain', 4),
(5, '0000-00-00 00:00:00', 'Consultation Charges', 2),
(6, '2017-12-21 09:05:15', 'Consultation Charges', 1),
(7, '2018-02-05 06:11:47', 'Consultation Charges', 25),
(8, '2018-02-05 06:50:52', 'Consultation Charges', 12);
-- --------------------------------------------------------
--
-- Table structure for table `inventory_used`
--
CREATE TABLE `inventory_used` (
`use_id` int(11) NOT NULL,
`Invent_id` varchar(20) NOT NULL,
`Date` date NOT NULL,
`Time` time NOT NULL,
`Quantity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `inventory_used`
--
INSERT INTO `inventory_used` (`use_id`, `Invent_id`, `Date`, `Time`, `Quantity`) VALUES
(1, 'I4', '2017-12-05', '06:13:00', 2),
(2, 'I5', '2017-12-03', '03:14:00', 1),
(3, 'I18', '2017-12-27', '06:00:00', 2);
-- --------------------------------------------------------
--
-- Table structure for table `patient`
--
CREATE TABLE `patient` (
`P_id` varchar(15) NOT NULL,
`P_name` varchar(100) NOT NULL,
`PType` varchar(30) DEFAULT NULL,
`Age` int(11) NOT NULL,
`Gender` varchar(10) NOT NULL,
`Consulting_DR` varchar(100) NOT NULL,
`Ref_by` varchar(100) NOT NULL,
`Admission_date` date NOT NULL,
`Discharge_date` date DEFAULT NULL,
`Admission_time` time NOT NULL,
`Ward_no` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `patient`
--
INSERT INTO `patient` (`P_id`, `P_name`, `PType`, `Age`, `Gender`, `Consulting_DR`, `Ref_by`, `Admission_date`, `Discharge_date`, `Admission_time`, `Ward_no`) VALUES
('23se11', 'Sushant Rajput', NULL, 22, 'Male', 'DR Venkat Subramaniam', 'Dr Iyer', '2017-12-05', '2017-12-13', '01:12:00', '2'),
('44ac42', 'Lucifer dubey', NULL, 30, 'Male', 'Dr Phantom ', '', '2017-12-06', '2017-12-27', '03:00:00', '5'),
('45dw33', 'Sushant Khattar', NULL, 35, 'Male', 'DR. Ram Manauj', 'DR. Yeshwant Jadhav', '2017-12-12', '2017-12-20', '05:00:00', '4'),
('6xy231', 'Tanmay Bhatt', NULL, 60, 'Male', 'Dr SHaymdas Pal', 'DR Sambandh Singh', '2017-12-05', '2017-12-21', '05:11:00', '5'),
('89yy51', 'Chetan Shah', NULL, 45, 'Male', 'DR Aurobindo ghosh', 'DR Sameer Gaikwad', '2017-12-19', '2017-12-21', '05:09:00', '2');
-- --------------------------------------------------------
--
-- Table structure for table `patient_inventory`
--
CREATE TABLE `patient_inventory` (
`patient_id` varchar(20) NOT NULL,
`inven_id` varchar(30) NOT NULL,
`Quantity` int(11) NOT NULL,
`timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `patient_inventory`
--
INSERT INTO `patient_inventory` (`patient_id`, `inven_id`, `Quantity`, `timestamp`) VALUES
('23se11', 'I20', 0, '2018-02-13 18:11:35'),
('44ac42', 'I2', 0, '2018-02-13 18:11:35'),
('45dw33', 'I3', 0, '2018-02-13 18:11:35'),
('6xy231', 'I24', 0, '2018-02-13 18:11:35'),
('89yy51', 'I28', 0, '2018-02-13 18:11:35'),
('44ac42', 'I27', 0, '2018-02-13 18:11:35'),
('44ac42', 'I1', 2, '0000-00-00 00:00:00'),
('44ac42', 'I1', 3, '0000-00-00 00:00:00'),
('44ac42', 'I1', 4, '2018-02-13 18:48:35');
-- --------------------------------------------------------
--
-- Table structure for table `reqtest`
--
CREATE TABLE `reqtest` (
`invenav` varchar(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `reqtest`
--
INSERT INTO `reqtest` (`invenav`) VALUES
('I14');
-- --------------------------------------------------------
--
-- Table structure for table `staff`
--
CREATE TABLE `staff` (
`S_id` varchar(15) NOT NULL,
`Name` varchar(100) NOT NULL,
`Address` varchar(100) NOT NULL,
`Age` int(11) NOT NULL,
`Gender` varchar(10) NOT NULL,
`Shift` varchar(15) NOT NULL,
`Salary` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `staff`
--
INSERT INTO `staff` (`S_id`, `Name`, `Address`, `Age`, `Gender`, `Shift`, `Salary`) VALUES
('S1E', 'Rahul Zaveri', 'G-2,bldg1,Mumbai', 22, 'Male', 'night', 15000),
('S2E', 'Dravish Shah', 'G-3,BLDG 2, Mumbai', 25, 'Male', 'Rotaional', 15000),
('S3E', 'Manoj Jathan', 'G-3,23,Mumbai', 23, 'Male', 'Day', 15000),
('S4E', 'Nirmala Guppta', 'G-3,Bkldg 3, Mumbai', 22, 'Female', 'Day', 12000),
('S5E', 'Anchal Mehra', 'G-6,Bldg3 , Mumbai', 30, 'Female', 'Rotational', 30000);
-- --------------------------------------------------------
--
-- Table structure for table `treatment_charges`
--
CREATE TABLE `treatment_charges` (
`C_ID` varchar(15) NOT NULL,
`Treatment` varchar(100) NOT NULL,
`Price` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `treatment_charges`
--
INSERT INTO `treatment_charges` (`C_ID`, `Treatment`, `Price`) VALUES
('c1', 'Consulting', 1000),
('c2', 'Others', 2000),
('c3', 'ICU', 4000),
('c4', 'general ward', 2000),
('c5', 'charge1', 1000);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `daignosis`
--
ALTER TABLE `daignosis`
ADD PRIMARY KEY (`dia_id`),
ADD KEY `F_k` (`p_id`);
--
-- Indexes for table `daily_reading`
--
ALTER TABLE `daily_reading`
ADD PRIMARY KEY (`daily_readid`),
ADD KEY `F_k1` (`p_id`);
--
-- Indexes for table `doctor`
--
ALTER TABLE `doctor`
ADD PRIMARY KEY (`doc_id`);
--
-- Indexes for table `doctor_findings`
--
ALTER TABLE `doctor_findings`
ADD PRIMARY KEY (`Findings_id`),
ADD KEY `F_k2` (`p_id`);
--
-- Indexes for table `inventory`
--
ALTER TABLE `inventory`
ADD PRIMARY KEY (`inven_id`);
--
-- Indexes for table `inventory_updatelog`
--
ALTER TABLE `inventory_updatelog`
ADD PRIMARY KEY (`Record`);
--
-- Indexes for table `inventory_used`
--
ALTER TABLE `inventory_used`
ADD PRIMARY KEY (`use_id`),
ADD KEY `fk4` (`Invent_id`);
--
-- Indexes for table `patient`
--
ALTER TABLE `patient`
ADD UNIQUE KEY `P_id` (`P_id`);
--
-- Indexes for table `patient_inventory`
--
ALTER TABLE `patient_inventory`
ADD KEY `fk3` (`patient_id`);
--
-- Indexes for table `reqtest`
--
ALTER TABLE `reqtest`
ADD UNIQUE KEY `invenav` (`invenav`);
--
-- Indexes for table `staff`
--
ALTER TABLE `staff`
ADD PRIMARY KEY (`S_id`);
--
-- Indexes for table `treatment_charges`
--
ALTER TABLE `treatment_charges`
ADD PRIMARY KEY (`C_ID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `daignosis`
--
ALTER TABLE `daignosis`
MODIFY `dia_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `daily_reading`
--
ALTER TABLE `daily_reading`
MODIFY `daily_readid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `doctor_findings`
--
ALTER TABLE `doctor_findings`
MODIFY `Findings_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT for table `inventory_updatelog`
--
ALTER TABLE `inventory_updatelog`
MODIFY `Record` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `inventory_used`
--
ALTER TABLE `inventory_used`
MODIFY `use_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `daignosis`
--
ALTER TABLE `daignosis`
ADD CONSTRAINT `F_k` FOREIGN KEY (`p_id`) REFERENCES `patient` (`P_id`);
--
-- Constraints for table `daily_reading`
--
ALTER TABLE `daily_reading`
ADD CONSTRAINT `F_k1` FOREIGN KEY (`p_id`) REFERENCES `patient` (`P_id`);
--
-- Constraints for table `doctor_findings`
--
ALTER TABLE `doctor_findings`
ADD CONSTRAINT `F_k2` FOREIGN KEY (`p_id`) REFERENCES `patient` (`P_id`);
--
-- Constraints for table `inventory_used`
--
ALTER TABLE `inventory_used`
ADD CONSTRAINT `fk4` FOREIGN KEY (`Invent_id`) REFERENCES `inventory` (`inven_id`);
--
-- Constraints for table `patient_inventory`
--
ALTER TABLE `patient_inventory`
ADD CONSTRAINT `fk3` FOREIGN KEY (`patient_id`) REFERENCES `patient` (`P_id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
ALTER TABLE ContactUs
ADD AppointmentDateTime datetime |
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE IF NOT EXISTS pod_monthly_metrics (
id uuid PRIMARY KEY DEFAULT (uuid_generate_v4()),
pod_name TEXT NOT NULL,
pod_version TEXT NOT NULL,
downloads integer,
apps integer,
tests integer,
extensions integer,
watch integer,
tries integer,
rollup_datestamp TEXT, -- e.g 2016-07
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT (NOW()),
updated_at TIMESTAMP WITH TIME ZONE,
UNIQUE(pod_name, pod_version, rollup_datestamp)
);
|
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF EXISTS (SELECT *
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[prc_ClientPortal_UnExpireUser]') AND type in (N'P'))
DROP PROCEDURE [dbo].[prc_ClientPortal_UnExpireUser]
GO
CREATE PROC prc_ClientPortal_UnExpireUser
@UserID int
,@AppUserID int
,@ErrorMessage varchar(500) OUT
AS
SET NOCOUNT ON;
BEGIN TRANSACTION
BEGIN TRY
UPDATE CWI_ClientContactPortal
SET IsExpired = 0
,IsPasswordReset = 1
,ClientModifiedBy = @AppUserID
,ClientModifiedOn = GetDate()
WHERE ID = @UserID
COMMIT TRANSACTION
END TRY
BEGIN CATCH
SELECT @ErrorMessage = ERROR_MESSAGE()
ROLLBACK TRANSACTION
END CATCH
GO
|
-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1
-- Généré le : ven. 02 juil. 2021 à 15:30
-- Version du serveur : 10.4.17-MariaDB
-- Version de PHP : 8.0.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `edt`
--
-- --------------------------------------------------------
--
-- Structure de la table `probleme`
--
CREATE TABLE `probleme` (
`id` int(11) NOT NULL,
`fichier` varchar(1000) NOT NULL,
`date_t` timestamp NOT NULL DEFAULT current_timestamp(),
`auteur` varchar(50) NOT NULL,
`composantes` varchar(300) NOT NULL,
`filiere` varchar(300) NOT NULL,
`formation` varchar(300) NOT NULL,
`annee` int(4) NOT NULL,
`periode` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `probleme`
--
INSERT INTO `probleme` (`id`, `fichier`, `date_t`, `auteur`, `composantes`, `filiere`, `formation`, `annee`, `periode`) VALUES
(1, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s1.xml', '2021-05-28 15:28:32', 'M. LESAINT', 'UFR-Sciences', 'Licence Pro - Sciences', 'Métiers du commerce international / Marketing et commerce international des vins de terroir ESA', 2019, 'Semestre 1'),
(2, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s44_dw.xml', '2021-05-31 09:46:33', 'M. RICHER', 'UFR-Sciences', 'Licence - Sciences', 'Licence 2 Sciences de la vie et de la terre - CMI -BSV', 2020, 'Semestre 2'),
(3, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s44_dw.xml', '2021-06-21 12:14:00', 'M. RICHER', 'UFR-Sciences', 'Portail L1/L2 - Sciences', 'Licence 1 Sciences, technologies, santé / Portail MPCIE - CMI CE', 2018, 'Période 2'),
(4, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s44_dw.xml', '2021-06-21 12:16:08', 'M. RICHER', 'UFR-Sciences', 'Licence Pro - Sciences', 'Commercialisation de produits alimentaires/ Valorisation innovation transformation de produits alimentaires ESA', 2018, 'Période 2'),
(5, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s1.xml', '2021-06-21 12:16:45', 'M. JAMIN', 'UFR-Sciences', 'Licence - Sciences', 'Licence 3 Informatique', 2020, 'Période 6'),
(6, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s1.xml', '2021-06-21 12:17:05', 'M. JAMIN', 'UFR-Sciences', 'Master - Sciences', 'Mathématiques et Applications / Mathématiques fondamentales et appliquées / Analyse et probabilités', 2020, 'Semestre 2'),
(7, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s44_dw.xml', '2021-06-22 09:42:41', 'M. JAMIN', 'UFR-Sciences', 'Licence Pro - Sciences', 'Métiers du commerce international / Marketing et commerce international des vins de terroir ESA', 2018, 'Période 10'),
(8, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', '2021-07-01 21:46:49', 'M. RICHER', 'UFR-Sciences', 'Portail L1/L2 - Sciences', 'Licence 1 Sciences, technologies, santé / Portail MPCIE - CMI PSI', 2020, 'Période 1'),
(9, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', '2021-07-01 23:37:20', 'M. JAMIN', 'UFR-Sciences', 'Master - Sciences', 'Physique Appliquée et Ingénierie Physique / Photonique signal imagerie', 2015, 'Période 12'),
(10, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s44_dw.xml', '2021-07-01 23:38:15', 'M. RICHER', 'UFR-Sciences', 'Licence - Sciences', 'Licence 3 Chimie - médicaments', 2015, 'Semestre 2'),
(11, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s1.xml', '2021-07-02 00:05:00', 'M. JAMIN', 'UFR-Sciences', 'Master - Sciences', 'Biologie Santé / Neurobiologie Cellulaire et Moléculaire', 2015, 'Période 11'),
(12, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', '2021-07-02 06:59:33', 'M. RICHER', 'UFR-Sciences', 'Licence - Sciences', 'Licence 1 Double Licence Math-Économie', 2017, 'Période 3'),
(13, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s44_dw.xml', '2021-07-02 11:58:17', 'M. LESAINT', 'UFR-Sciences', 'Licence - Sciences', 'Licence 3 Physique applications', 2016, 'Période 7'),
(14, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s1.xml', '2021-07-02 12:17:22', 'M. JAMIN', 'UFR-Sciences', 'Portail L1/L2 - Sciences', 'Licence 1 Sciences, technologies, santé / Portail MPCIE - Mise à niveau', 2019, 'Période 5'),
(15, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s1.xml', '2021-07-02 13:03:33', 'M. RICHER', 'UFR-Sciences', 'Master - Sciences', 'Bio-géoscience / Paléontologie, paléo-environnement & patrimoine', 2021, 'Semestre 1');
-- --------------------------------------------------------
--
-- Structure de la table `solutions`
--
CREATE TABLE `solutions` (
`id` int(255) NOT NULL,
`fichier_probleme` varchar(255) NOT NULL,
`fichier_solution` varchar(255) NOT NULL,
`timestamp_t` timestamp NOT NULL DEFAULT current_timestamp(),
`solver` varchar(100) NOT NULL,
`format` varchar(100) NOT NULL,
`representation` varchar(100) NOT NULL,
`temps_calcul` varchar(10) NOT NULL,
`initTime` float NOT NULL,
`solveTime` float NOT NULL,
`variables` int(255) NOT NULL,
`propagators` int(255) NOT NULL,
`propagations` int(255) NOT NULL,
`nodes` int(255) NOT NULL,
`failures` int(255) NOT NULL,
`restarts` int(255) NOT NULL,
`peakDepth` int(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `solutions`
--
INSERT INTO `solutions` (`id`, `fichier_probleme`, `fichier_solution`, `timestamp_t`, `solver`, `format`, `representation`, `temps_calcul`, `initTime`, `solveTime`, `variables`, `propagators`, `propagations`, `nodes`, `failures`, `restarts`, `peakDepth`) VALUES
(1, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', 'solution_ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw__2072021_02_13_43.xml', '2021-07-02 00:13:48', 'minizinc', 'dzn', 'intent', '02:11:06', 0.386, 0.017, 14011, 13537, 69148, 38, 0, 0, 37),
(2, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', 'solution_ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw__2072021_02_24_13.xml', '2021-07-02 00:24:17', 'minizinc', 'dzn', 'intent', '10:10:10', 0.391, 0.015, 14011, 13537, 69148, 38, 0, 0, 37),
(3, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', 'solution_ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw__2072021_09_00_06.xml', '2021-07-02 07:00:14', 'minizinc', 'dzn', 'intent', '10:00:00', 0.691, 0.018, 14011, 13537, 69148, 38, 0, 0, 37),
(4, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', 'solution_ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw__2072021_12_09_56.xml', '2021-07-02 10:10:00', 'minizinc', 'dzn', 'intent', '10:20:30', 0.383, 0.017, 14011, 13537, 69148, 38, 0, 0, 37),
(5, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', 'solution_ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw__2072021_02_20_37.xml', '2021-07-02 12:20:42', 'minizinc', 'dzn', 'intent', '10:10:10', 0.376, 0.015, 14011, 13537, 69148, 38, 0, 0, 37),
(6, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', 'solution_ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw__2072021_02_28_58.xml', '2021-07-02 12:29:02', 'minizinc', 'dzn', 'intent', '20:20:04', 0.411, 0.018, 14011, 13537, 69148, 38, 0, 0, 37),
(7, 'ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw.xml', 'solution_ua_l3info_20s6_w12d5s8_e0r5t2g4_s45_dw__2072021_03_05_01.xml', '2021-07-02 13:05:05', 'minizinc', 'dzn', 'intent', '00:00:10', 0.38, 0.022, 14011, 13537, 69148, 38, 0, 0, 37);
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `probleme`
--
ALTER TABLE `probleme`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `solutions`
--
ALTER TABLE `solutions`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT pour la table `probleme`
--
ALTER TABLE `probleme`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT pour la table `solutions`
--
ALTER TABLE `solutions`
MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE TABLE users (
id int(11) NOT NULL,
prenom VARCHAR(30) NOT NULL,
nom VARCHAR(30) NOT NULL,
login VARCHAR(30) NOT NULL,
mdp VARCHAR(30) NOT NULL,
bday DATE NOT NULL,
mw VARCHAR(1) NOT NULL
);
ALTER TABLE users
ADD PRIMARY KEY (id);
ALTER TABLE users
MODIFY id int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
INSERT INTO users (id, prenom, nom, login, mdp, bday, mw) VALUES
(1, 'un', 'un', '0123456789', '1', '2016-01-02', 'm'),
(2, 'deux', 'deux', '9876543210', '2', '2015-02-01', 'w'),
(3, 'trois', 'trois', 'abc@gmail.com', '3', '2016-03-01', 'm'); |
use TelerikAcademy;
select count(*) as [Total Sales Department Employees] from
(select * from Employees e
where e.DepartmentID = (select d.DepartmentID from Departments d
where d.Name = 'Sales')) x; |
INSERT INTO xh_basecount.product_stw_daycount
SELECT
sta1.userid,
sta1.username,
sta1.schoolid,
sta1.schoolname,
sta1.classname,
sta1.classid,
sta1.bookname,
sta1.bookid,
sta4.hp,
sta4.credit,
sta6.newintegral,
sta2.sumhomework,
sta2.sumselfwork,
sta2.numtopic,
sta2.sumright,
sta2.sumright/sta2.numtopic AS rightlv,
sta2.sumtime,
sta1.datetime
FROM
(SELECT DISTINCT
a1.userid,
a1.username,
a1.schoolname,
a1.schoolid,
a1.classname,
a1.classid,
a1.bookname,
a1.bookid,
FROM_UNIXTIME(a1.createtime,'yyyy-MM-dd') AS datetime
FROM
xh_basecount.product_stw_base a1
WHERE a1.udatetime >= unix_timestamp(from_unixtime(unix_timestamp()-60*60*24*0,'yyyy-MM-dd'),'yyyy-MM-dd')
)sta1
LEFT JOIN(
SELECT
a3.userid,
a3.bookid,
FROM_UNIXTIME(a3.createtime,'yyyy-MM-dd') AS datetime,
SUM(IF(a3.ishomework = 0,1,0)) AS sumhomework,
SUM(IF(a3.ishomework != 0,1,0)) AS sumselfwork,
COUNT(a3.ishomework)*10 AS numtopic,
SUM(if(a3.rightnum>10,10,a3.rightnum)) AS sumright,
SUM(a3.timecost) AS sumtime
FROM
xh_basecount.product_stw_base a3
WHERE a3.udatetime >= unix_timestamp(from_unixtime(unix_timestamp()-60*60*24*0,'yyyy-MM-dd'),'yyyy-MM-dd')
GROUP BY
a3.userid,
a3.bookid,
FROM_UNIXTIME(a3.createtime,'yyyy-MM-dd')
) sta2 on sta2.userid=sta1.userid and sta2.bookid=sta1.bookid
and sta2.datetime = sta1.datetime
LEFT JOIN(
SELECT DISTINCT
a4.userid,
a4.hp,
a4.credit
FROM xh_basecount.product_stw_base a4
JOIN (select userid,max(updatetime)as maxtime
FROM xh_basecount.product_stw_base
WHERE udatetime >= unix_timestamp(from_unixtime(unix_timestamp()-60*60*24*0,'yyyy-MM-dd'),'yyyy-MM-dd')
GROUP BY userid) a5
on a4.userid=a5.userid and a4.updatetime=a5.maxtime
WHERE a4.udatetime >= unix_timestamp(from_unixtime(unix_timestamp()-60*60*24*0,'yyyy-MM-dd'),'yyyy-MM-dd')
)sta4 ON sta1.userid=sta4.userid
LEFT JOIN (
SELECT DISTINCT a6.userid,
a6.bookid,a6.newintegral
FROM xh_basecount.product_stw_base a6
JOIN (select userid,bookid,max(updatetime)as maxtime
FROM xh_basecount.product_stw_base
WHERE udatetime >= unix_timestamp(from_unixtime(unix_timestamp()-60*60*24*0,'yyyy-MM-dd'),'yyyy-MM-dd') GROUP BY userid,bookid) a7
on a6.userid=a7.userid and a6.bookid=a7.bookid and a6.updatetime=a7.maxtime
WHERE a6.udatetime >= unix_timestamp(from_unixtime(unix_timestamp()-60*60*24*0,'yyyy-MM-dd'),'yyyy-MM-dd')
)sta6 ON sta1.userid = sta6.userid AND sta1.bookid=sta6.bookid;
|
USE employees
SELECT mgr.emp_no, YEAR(mgr.from_date) AS fd
FROM titles AS mgr, titles AS other
WHERE mgr.emp_no = other.emp_no
AND mgr.title = 'Manager'
AND mgr.title <> other.title
AND YEAR(mgr.from_date) = YEAR(other.from_date);
SELECT emp_no, YEAR(from_date) AS fd
FROM titles WHERE title = 'Manager' AND
(emp_no, YEAR(from_date)) IN
(SELECT emp_no, YEAR(from_date)
FROM titles WHERE title <> 'Manager');
SELECT first_name, last_name
FROM employees, titles
WHERE (employees.emp_no, first_name, last_name, title) =
(titles.emp_no, 'Marjo', 'Giarratana', 'Senior Staff');
|
CREATE TABLE `transfer` (
`id` bigint(20) NOT NULL,
`transfer_amount` decimal(19,2) DEFAULT NULL,
`transferred_id` bigint(20) DEFAULT NULL,
`transferrer_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FK_TRANSFER_ACCOUNT_TRANSFERRED_ID` (`transferred_id`),
KEY `FK_TRANSFER_ACCOUNT_TRANSFERRER_ID` (`transferrer_id`),
CONSTRAINT `FK_TRANSFER_ACCOUNT_TRANSFERRED_ID` FOREIGN KEY (`transferred_id`) REFERENCES `account` (`id`),
CONSTRAINT `FK_TRANSFER_ACCOUNT_TRANSFERRER_ID` FOREIGN KEY (`transferrer_id`) REFERENCES `account` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
DROP TABLE paystubs CASCADE CONSTRAINTS;
--DROP TABLE pays CASCADE CONSTRAINTS;
--DROP TABLE id_pw CASCADE CONSTRAINTS;
DROP TABLE members CASCADE CONSTRAINTS;
DROP TABLE departments CASCADE CONSTRAINTS;
CREATE TABLE departments(
dept_no NUMBER(10) NULL PRIMARY KEY,
dept_name VARCHAR2(40) NOT NULL
);
CREATE TABLE members(
member_no NUMBER(20) NULL PRIMARY KEY,
member_name VARCHAR2(30) NULL ,
jobdate DATE DEFAULT sysdate NULL ,
job VARCHAR2(50) NULL ,
lev VARCHAR2(20) NULL ,
jobtime NUMBER(30) DEFAULT 0 NULL,
member_id VARCHAR2(100) NULL,
member_password VARCHAR2(60) NULL,
dept_no NUMBER(10) NOT NULL,
FOREIGN KEY (dept_no) REFERENCES departments (dept_no)
);
/*
CREATE TABLE id_pw(
member_no NUMBER(20) NULL PRIMARY KEY,
ID VARCHAR2(100) NOT NULL,
password VARCHAR2(60) NOT NULL
);
*/
/*
CREATE TABLE pays(
regi_num NUMBER(20) NULL PRIMARY KEY,
member_no NUMBER(20) NOT NULL,
overtimework NUMBER(20) DEFAULT 0 NULL ,
holidaywork NUMBER(20) DEFAULT 0 NULL ,
nomalpay NUMBER(20) NULL ,
levpay NUMBER(20) NULL ,
pay_bouns NUMBER(20) NULL ,
workMonth VARCHAR2(20) NULL,
FOREIGN KEY (member_no) REFERENCES members (member_no)
);
*/
CREATE TABLE paystubs(
page_num NUMBER(20) NULL PRIMARY KEY,
member_no NUMBER(20) NOT NULL,
issuance_date VARCHAR2(50) DEFAULT sysdate NULL ,
income_tax NUMBER(30) NOT NULL,
residents_tax NUMBER(30) NOT NULL,
food_exp NUMBER(30) DEFAULT 0 NULL ,
traffic_exp NUMBER(30) DEFAULT 0 NULL ,
welfare NUMBER(30) DEFAULT 0 NULL ,
overtimework NUMBER(20) DEFAULT 0 NULL ,
holidaywork NUMBER(20) DEFAULT 0 NULL ,
nomalpay NUMBER(20) NULL ,
levpay NUMBER(20) NULL ,
pay_bouns NUMBER(20) NULL ,
workMonth VARCHAR2(20) NULL,
FOREIGN KEY (member_no) REFERENCES members (member_no)
);
drop SEQUENCE payroll_seq;
CREATE SEQUENCE payroll_seq
INCREMENT BY 1
START WITH 100000;
|
insert into course (id, title, description) values (1, 'Angular Fundamentals', 'This is a course');
insert into course (id, title, description) values (2, 'Angular Fundamentals', 'This is a course');
insert into course (id, title, description) values (3, 'Angular Fundamentals', 'This is a course');
insert into customer(id, first_name, last_name) values (1, 'Ken', 'Rimple');
|
/*
** https://leetcode.com/problems/article-views-i/
*/
-- method 1
SELECT DISTINCT v.author_id AS id
FROM Views v
WHERE v.author_id = v.viewer_id
ORDER BY id;
|
create table account(
id number(5),
password VARCHAR2(20),
name VARCHAR2(20),
balance number(8,2));
alter table account add primary key(id);
desc account;
insert into account values(1,'First Member','Joginder Singh',8500.50);
select * from account;
commit; |
drop database hibernate;
create database hibernate;
use hibernate;
create table news_inf
(
news_id int primary key auto_increment,
title varchar(255),
content varchar(255)
);
insert into news_inf
values(null , '疯狂Java联盟' , '疯狂Java联盟成立了,网址是www.crazyit.org');
insert into news_inf
values(null , '天快亮了' , '等到那一天,四周一下光亮了,空气中酝酿着自由、民主的芬芳!');
|
--修改日期:20121219
--修改人:费滔
--需求编号:兴业账户信息查询
--修改内容:兴业账户信息查询,新增字段,用来接受接口扫回的数据
alter table BIS_ACC_HIS_BAL add CONTROL_MONEY NUMBER(15,2);
alter table BIS_ACC_HIS_BAL add FREEZE_MONEY NUMBER(15,2);
comment on column BIS_ACC_HIS_BAL.CONTROL_MONEY is '控制额度';
comment on column BIS_ACC_HIS_BAL.FREEZE_MONEY is '冻结额度';
commit; |
CREATE USER tcr;
ALTER USER tcr CREATEDB;
CREATE DATABASE tcr;
ALTER DATABASE tcr OWNER TO tcr;
GRANT ALL PRIVILEGES ON DATABASE tcr TO tcr;
CREATE USER tcr_test;
ALTER USER tcr_test CREATEDB;
CREATE DATABASE tcr_test;
ALTER DATABASE tcr_test OWNER TO tcr_test;
GRANT ALL PRIVILEGES ON DATABASE tcr_test TO tcr_test;
|
USE p2_population;
-- EXTRACT: PERCENTAGES OF GENDER DISTRIBUTION IN BARCELONA PER YEAR
-- Gender distribution per year
SELECT year, gender, sum(immigrants) as total_immigrants_per_gender
FROM gender
GROUP BY gender, year;
-- Immigrants per year
SELECT year, sum(immigrants) as total_immigrants
FROM gender
GROUP BY year;
-- Gender distribution per year (percentage)
SELECT i.year, i.gender, ((sum(i.immigrants)/ sub_q.total_immigrants)*100) as percentage_immigrants_per_gender
FROM gender AS i
LEFT JOIN(SELECT year, sum(immigrants) as total_immigrants
FROM gender
GROUP BY year) sub_q ON i.year = sub_q.year
GROUP BY i.gender, i.year;
-- EXTRACT: PERCENTAGES OF AGE RANGE DISTRIBUTION IN BARCELONA PER YEAR
-- Age distribution per year (percentage)
SELECT i.year, i.age, ((sum(i.immigrants)/ sub_q.total_immigrants)*100) as percentage_immigrants_per_gender
FROM age AS i
LEFT JOIN(SELECT year, sum(immigrants) as total_immigrants
FROM age
GROUP BY year) sub_q ON i.year = sub_q.year
GROUP BY i.age, i.year;
|
USE db_alakatos;
SELECT count(*) AS 'films' FROM historique_membre WHERE (DATE(date) > DATE('2006-10-30') AND DATE(date) < DATE('2007-07-27')) OR DATE(date) LIKE "%-12-24";
|
Create Function fn_ListInvNo_ITC(@DocType as nVarchar(50))
Returns @Invoice Table(InvoiceID Int)
As
Begin
if @DocType = N'All DocType' or @DocType ='%'
Set @DocType ='%'
Insert Into @Invoice
Select InvoiceID From InvoiceAbstract Where
DocSerialType like @DocType And IsNull(Status,0) & 192 =0
Return
End
|
/*
产品推荐
*/
delimiter $
drop trigger if exists Tgr_RecommendationAddress_AftereInsert $
create trigger Tgr_RecommendationAddress_AftereInsert after insert
on RecommendationAddress
for each row
begin
call Proc_Customers_LastRecommend(new.CustomerShortName);-- 客户资料-最近推荐
end$
/*恢复结束符为;*/
delimiter ; |
--MARCO PO RECORDS IN DESC ORDER WITH FREIGHT/COST INFORMATION BY ITEM #
SELECT CONVERT(varchar, PH.ord_dt, 101) AS OrdDate, LTRIM(LEFT(PH.ord_no,6)) AS PO#, PL.line_no,
CASE WHEN LTRIM(AP.vend_no) = '8859' THEN 'AIFEI' WHEN LTRIM(AP.vend_no) = '8830' THEN 'PAFIC' ELSE AP.vend_name END AS vend_name,
LTRIM(PH.vend_no) AS Vend#, RTRIM(PL.item_no) AS ITEM, RTRIM(PL.item_desc_1) AS Desc1,
RTRIM(PL.item_desc_2) AS Desc2, pl.qty_ordered, PL.uom, PL.act_unit_cost,
CASE WHEN LTRIM(PL.vend_no) NOT IN (SELECT vend_no FROM BG_CH_Vendors) THEN NULL
WHEN PL.qty_received = 0 THEN NULL
WHEN PL.qty_received > 0 AND PC.flat_amt = 0 THEN NULL
ELSE CAST(ROUND(((PC.flat_amt / PL.qty_received) + PL.act_unit_cost),2) AS FLOAT) END AS Landed_Cost,
PC.flat_amt AS [TOTAL FREIGHT], PL.extra_8 AS Ship_Dt, PL.stk_loc, CONVERT(varchar, PL.receipt_dt, 101) AS RcptDt, PL.qty_received,
PL.user_def_fld_1
FROM poordlin_sql PL JOIN poordhdr_sql PH ON PL.ord_no = PH.ord_no JOIN apvenfil_sql AP ON AP.vend_no = PH.vend_no
LEFT OUTER JOIN (SELECT ord_no, line_no, SUM(PC.flat_amt) AS flat_amt FROM popurcst_sql PC GROUP BY ord_no, line_no) AS PC ON PC.ord_no = PL.ord_no AND PC.line_no = PL.line_no
WHERE PL.ord_status <> 'X' AND PH.ord_status <> 'X' and receipt_dt > '01/01/2012' --AND PL.qty_received > 0
ORDER BY PL.receipt_dt DESC--, PL.item_no ASC
--SELECT ord_no, line_no FROM dbo.popurcst_sql GROUP BY ord_no, line_no HAVING COUNT(*) > 1 ORDER BY ord_no, line_no
--SELECT * FROM dbo.popurcst_sql WHERE ord_no = '11833300'
--SELECT * FROM dbo.poordlin_sql WHERE item_no = 'WM-MOVIEDUMPBIN'
|
/*Challenge 1*/
SELECT A.[PurchaseOrderID]
,A.[PurchaseOrderDetailID]
,A.[OrderQty]
,A.[UnitPrice]
,A.[LineTotal]
,B.[OrderDate]
,[OrderSizeCategory] =
CASE
WHEN A.[OrderQty] > 500 THEN 'Large'
WHEN A.[OrderQty] > 50 THEN 'Medium'
ELSE 'Small'
END
,[ProductName] = C.[Name]
,[Subcategory] = ISNULL(D.[Name], 'None')
,[Category] = ISNULL(E.[Name],'None')
FROM [AdventureWorks2019].[Purchasing].[PurchaseOrderDetail] A
JOIN [AdventureWorks2019].[Purchasing].[PurchaseOrderHeader] B
ON A.[PurchaseOrderID] = B.[PurchaseOrderID]
JOIN [AdventureWorks2019].[Production].[Product] C
ON A.[ProductID] = C.[ProductID]
LEFT JOIN [AdventureWorks2019].[Production].[ProductSubcategory] D
ON C.[ProductSubcategoryID] = d.[ProductSubcategoryID]
LEFT JOIN [AdventureWorks2019].[Production].[ProductCategory] E
ON D.[ProductCategoryID] = E.[ProductCategoryID]
WHERE MONTH(B.[OrderDate]) = 12
/*Challenge 2*/
SELECT
[OrderType] = 'Sale'
,[OrderID] = A.[SalesOrderID]
,[OrderDetailID] = A.[SalesOrderDetailID]
,A.[OrderQty]
,A.[UnitPrice]
,A.[LineTotal]
,B.[OrderDate]
,[OrderSizeCategory] =
CASE
WHEN A.[OrderQty] > 500 THEN 'Large'
WHEN A.[OrderQty] > 50 THEN 'Medium'
ELSE 'Small'
END
,[ProductName] = C.[Name]
,[Subcategory] = ISNULL(D.[Name], 'None')
,[Category] = ISNULL(E.[Name],'None')
FROM [AdventureWorks2019].[Sales].[SalesOrderDetail] A
JOIN [AdventureWorks2019].[Sales].[SalesOrderHeader] B
ON A.[SalesOrderID] = B.[SalesOrderID]
JOIN [AdventureWorks2019].[Production].[Product] C
ON A.[ProductID] = C.[ProductID]
LEFT JOIN [AdventureWorks2019].[Production].[ProductSubcategory] D
ON C.[ProductSubcategoryID] = d.[ProductSubcategoryID]
LEFT JOIN [AdventureWorks2019].[Production].[ProductCategory] E
ON D.[ProductCategoryID] = E.[ProductCategoryID]
WHERE MONTH(B.[OrderDate]) = 12
UNION ALL
SELECT
[OrderType] = 'Purchase'
,A.[PurchaseOrderID]
,A.[PurchaseOrderDetailID]
,A.[OrderQty]
,A.[UnitPrice]
,A.[LineTotal]
,B.[OrderDate]
,[OrderSizeCategory] =
CASE
WHEN A.[OrderQty] > 500 THEN 'Large'
WHEN A.[OrderQty] > 50 THEN 'Medium'
ELSE 'Small'
END
,[ProductName] = C.[Name]
,[Subcategory] = ISNULL(D.[Name], 'None')
,[Category] = ISNULL(E.[Name],'None')
FROM [AdventureWorks2019].[Purchasing].[PurchaseOrderDetail] A
JOIN [AdventureWorks2019].[Purchasing].[PurchaseOrderHeader] B
ON A.[PurchaseOrderID] = B.[PurchaseOrderID]
JOIN [AdventureWorks2019].[Production].[Product] C
ON A.[ProductID] = C.[ProductID]
LEFT JOIN [AdventureWorks2019].[Production].[ProductSubcategory] D
ON C.[ProductSubcategoryID] = d.[ProductSubcategoryID]
LEFT JOIN [AdventureWorks2019].[Production].[ProductCategory] E
ON D.[ProductCategoryID] = E.[ProductCategoryID]
WHERE MONTH(B.[OrderDate]) = 12
ORDER BY [OrderDate] DESC
/*Challenge 3*/
SELECT A.[BusinessEntityID]
,A.[PersonType]
,[FullName] =
A.[FirstName] + ' ' +
CASE WHEN A.[MiddleName] IS NULL THEN '' ELSE A.[MiddleName] + ' ' END +
A.[LastName]
,[Address] = C.[AddressLine1]
,C.[City]
,C.[PostalCode]
,[State] = D.[Name]
,[Country] = E.[Name]
FROM [AdventureWorks2019].[Person].[Person] A
JOIN [AdventureWorks2019].[Person].[BusinessEntityAddress] B
ON A.[BusinessEntityID] = B.[BusinessEntityID]
JOIN [AdventureWorks2019].[Person].[Address] C
ON B.[AddressID] = C.[AddressID]
JOIN [AdventureWorks2019].[Person].[StateProvince] D
ON C.[StateProvinceID] = D.[StateProvinceID]
JOIN [AdventureWorks2019].[Person].[CountryRegion] E
ON D.[CountryRegionCode] = E.[CountryRegionCode]
WHERE (LEFT(C.[PostalCode], 1) = '9' AND LEN(C.[PostalCode]) = 5 AND E.[Name] = 'United States')
OR A.[PersonType] = 'SP'
/*Challenge 4*/
SELECT A.[BusinessEntityID]
,A.[PersonType]
,[FullName] =
A.[FirstName] + ' ' +
CASE WHEN A.[MiddleName] IS NULL THEN '' ELSE A.[MiddleName] + ' ' END +
A.[LastName]
,[Address] = C.[AddressLine1]
,C.[City]
,C.[PostalCode]
,[State] = D.[Name]
,[Country] = E.[Name]
,[JobTitle] = ISNULL(F.[JobTitle],'NA')
,[JobCategory] =
CASE
WHEN F.[JobTitle] LIKE '%Manager%' OR F.[JobTitle] LIKE '%President%' OR F.[JobTitle] LIKE '%Executive%' THEN 'Management'
WHEN F.[JobTitle] LIKE '%Engineer%' THEN 'Engineering'
WHEN F.[JobTitle] LIKE '%Production%' THEN 'Production'
WHEN F.[JobTitle] LIKE '%Marketing%' THEN 'Marketing'
WHEN F.[JobTitle] IS NULL THEN 'NA'
WHEN F.[JobTitle] IN('Recruiter', 'Benefits Specialist', 'Human Resources Administrative Assistant') THEN 'Human Resources'
ELSE 'Other'
END
FROM [AdventureWorks2019].[Person].[Person] A
JOIN [AdventureWorks2019].[Person].[BusinessEntityAddress] B
ON A.[BusinessEntityID] = B.[BusinessEntityID]
JOIN [AdventureWorks2019].[Person].[Address] C
ON B.[AddressID] = C.[AddressID]
JOIN [AdventureWorks2019].[Person].[StateProvince] D
ON C.[StateProvinceID] = D.[StateProvinceID]
JOIN [AdventureWorks2019].[Person].[CountryRegion] E
ON D.[CountryRegionCode] = E.[CountryRegionCode]
LEFT JOIN [AdventureWorks2019].[HumanResources].[Employee] F
ON A.[BusinessEntityID] = F.[BusinessEntityID]
WHERE (LEFT(C.[PostalCode], 1) = '9' AND LEN(C.[PostalCode]) = 5 AND E.[Name] = 'United States')
OR A.[PersonType] = 'SP'
/*Challenge 5*/
SELECT [Days Until EOM] =
DATEDIFF(DAY, GETDATE(),
DATEADD(DAY, -1,
DATEADD(MONTH,1,
DATEFROMPARTS(YEAR(GETDATE()), MONTH(GETDATE()), 1)))) |
DROP TABLE IF EXISTS player;
CREATE TABLE player (
playerId int(11) NOT NULL,
fName varchar(45) NOT NULL,
lastName varchar(45) NOT NULL,
position varchar(2) NOT NULL,
team varchar(45) NOT NULL,
PRIMARY KEY (playerId)
)
DROP TABLE IF EXISTS stats;
CREATE TABLE stats (
pointsScored int(11) NOT NULL,
gamesPlayed varchar(45) NOT NULL,
Player_playerId int(11) NOT NULL,
rushingTDs int(11) NOT NULL,
rushingYDs int(11) NOT NULL,
fumblesLost int(11) DEFAULT NULL,
receptions int(11) DEFAULT NULL,
receivingTDs int(11) DEFAULT NULL,
receivingYDs int(11) DEFAULT NULL,
passingYDs int(11) DEFAULT NULL,
passingINTs int(11) DEFAULT NULL,
passingTDs int(11) DEFAULT NULL,
Year int(11) DEFAULT NULL,
Week varchar(45) DEFAULT NULL,
statsID int(11) NOT NULL,
PRIMARY KEY (Player_playerId,statsID),
CONSTRAINT fk_Stats_Player FOREIGN KEY (Player_playerId) REFERENCES player (playerId)
)
|
-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 07, 2019 at 10:52 AM
-- Server version: 10.1.36-MariaDB
-- PHP Version: 7.0.32
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: `jobgara`
--
-- --------------------------------------------------------
--
-- Table structure for table `application`
--
CREATE TABLE `application` (
`appId` int(11) NOT NULL,
`appTitle` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`appSubject` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`appDate` datetime NOT NULL,
`appStatus` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`eId` int(11) NOT NULL,
`jsId` int(11) NOT NULL,
`catName` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`jId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `application`
--
INSERT INTO `application` (`appId`, `appTitle`, `appSubject`, `appDate`, `appStatus`, `eId`, `jsId`, `catName`, `jId`) VALUES
(3, 'JR WEB DEVELOPER', 'I would like to Apply for this Job. Please review my CV. Thank You!', '2018-12-16 04:12:04', 'Sent', 3, 1, 'Web Development', 17),
(4, 'JR WEB DEVELOPER', 'I would like to Apply for this Job. Please review my CV. Thank You!', '2018-12-17 10:12:36', 'Sent', 3, 1, 'Web Development', 17);
-- --------------------------------------------------------
--
-- Table structure for table `employer`
--
CREATE TABLE `employer` (
`eId` int(11) NOT NULL,
`eName` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`eEmail` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`ePassword` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`eDetails` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`eVerified` int(11) NOT NULL,
`eAddress` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`ePhone` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`eType` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`eWebsite` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`eEstd` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`eEmployesNo` varchar(1000) COLLATE utf8_unicode_ci NOT NULL,
`eLogo` varchar(400) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `employer`
--
INSERT INTO `employer` (`eId`, `eName`, `eEmail`, `ePassword`, `eDetails`, `eVerified`, `eAddress`, `ePhone`, `eType`, `eWebsite`, `eEstd`, `eEmployesNo`, `eLogo`) VALUES
(3, 'Gangotri Softwares', 'premlamsal2@gmail.com', 'premlamsal', 'fdsafds', 1, 'Samkhusi', '9868616747', 'IT SOFTWARE HUB', 'http://gangotrisuppliers.com.np', '2018-11-29', '11', '../uploads/1544611699iconman.png'),
(4, 'Icare Tech Pvt.ltd ', 'icaregroup3@gmail.com', '123456', 'fadsf', 0, 'Gangabu Kathmandu', '896786786', 'IT company', 'icare.com.np', '2018-12-19', '10', '../uploads/1545546656icare.png');
-- --------------------------------------------------------
--
-- Table structure for table `emsg`
--
CREATE TABLE `emsg` (
`mId` int(11) NOT NULL,
`mTitle` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`mBody` int(200) NOT NULL,
`mStatus` int(11) NOT NULL,
`jsId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `jobcat`
--
CREATE TABLE `jobcat` (
`catId` int(11) NOT NULL,
`catName` varchar(40) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `jobcat`
--
INSERT INTO `jobcat` (`catId`, `catName`) VALUES
(1, 'Web Development'),
(2, 'Graphic Designer'),
(3, 'IT Technician '),
(4, 'Hotel & Resturant'),
(5, 'Administration '),
(6, 'Hospitals');
-- --------------------------------------------------------
--
-- Table structure for table `jobs`
--
CREATE TABLE `jobs` (
`jId` int(11) NOT NULL,
`jName` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`jEndDate` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`jType` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`jLevel` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`jExperience` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`jLocation` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`jTotalNo` varchar(1000) COLLATE utf8_unicode_ci NOT NULL,
`jGenderPreffered` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`jRequirement` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`jQualification` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`jPosted` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`jExtraDetails` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`eId` int(11) NOT NULL,
`catName` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`jSalary` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`catId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `jobs`
--
INSERT INTO `jobs` (`jId`, `jName`, `jEndDate`, `jType`, `jLevel`, `jExperience`, `jLocation`, `jTotalNo`, `jGenderPreffered`, `jRequirement`, `jQualification`, `jPosted`, `jExtraDetails`, `eId`, `catName`, `jSalary`, `catId`) VALUES
(17, 'JR WEB DEVELOPER', '2018-11-30', 'Full Time', 'Senior', '<ul><li>2 year on Related Field</li></ul>', 'Kathmandu, Nepal', '2', 'Male', '<ul><li>PHP<br></li><li>JQUERY<br></li><li>MYSQL<br></li></ul>', '<ul><li>Must-Have Bachelor Degree </li><li>Professional Course Will be Plus point.<br></li></ul>', '2018-12-15 12:12:20', '<ul><li>Breakfast Available </li><li>5 days Week Work </li><li>Tranportation<br></li></ul>', 3, 'Web Development', '49000', 1),
(18, 'Marketing Manager', '2018-12-12', '', 'Senior', 'fsadnflnl', 'kathmandu', '2', 'Male', 'fdsa', 'fasd', '2018-12-23 06:12:57', 'fasdfasd', 3, 'Administration ', '200000', 2);
-- --------------------------------------------------------
--
-- Table structure for table `jobseeker`
--
CREATE TABLE `jobseeker` (
`jsId` int(11) NOT NULL,
`jsName` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`jsEmail` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`jsPassword` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`jsPhone` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`jsAddress` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`jsWebsite` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`jsJoinedDate` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`jsBio` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`jsCatFirst` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`jsCatSecond` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`jsCatThird` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`jsVerified` int(11) NOT NULL,
`jsLogo` varchar(400) COLLATE utf8_unicode_ci NOT NULL,
`jsResume` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `jobseeker`
--
INSERT INTO `jobseeker` (`jsId`, `jsName`, `jsEmail`, `jsPassword`, `jsPhone`, `jsAddress`, `jsWebsite`, `jsJoinedDate`, `jsBio`, `jsCatFirst`, `jsCatSecond`, `jsCatThird`, `jsVerified`, `jsLogo`, `jsResume`) VALUES
(1, 'JobSeeker Prem', 'premlamsal2@gmail.com', 'premlamsal', '9868616747', 'Samkhusi, Tokha Road', 'http://premlamsal.com.np', '0000-00-00 00:00:00', 'Software Developer', 'Programmer', 'Desinger', 'SEO', 0, '../uploads/15446813445b43ccf31335b831008b4c1c-750-563.jpg', '../uploads/1544662570Resume.pdf');
-- --------------------------------------------------------
--
-- Table structure for table `jsmsg`
--
CREATE TABLE `jsmsg` (
`mId` int(11) NOT NULL,
`mTitle` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`mBody` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`mStatus` int(11) NOT NULL,
`eId` int(11) NOT NULL,
`jsId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `jsmsg`
--
INSERT INTO `jsmsg` (`mId`, `mTitle`, `mBody`, `mStatus`, `eId`, `jsId`) VALUES
(1, 'Application Accepted', 'Your application has been approved.', 0, 3, 1),
(2, 'Declined Application', 'You application declined', 0, 3, 1);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`uId` int(11) NOT NULL,
`uName` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`uEmail` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`uPassword` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`uAddress` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`uLastLogin` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`uPhone` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`uPhoto` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
`uRole` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`uId`, `uName`, `uEmail`, `uPassword`, `uAddress`, `uLastLogin`, `uPhone`, `uPhoto`, `uRole`) VALUES
(1, 'Prem Lamsal', 'premlamsal2@gmail.com', 'premlamsal', 'ktm', '0000-00-00 00:00:00', '9888888', '../uploads/1544680833Job_kolkata3 (1).jpg', 2018),
(2, 'hfabdskjf', 'jnfkjsdnf@fanskjd.com', 'jkafdnkasd', 'nnfjasd', '2018-12-14 07:12:25', '97979798', '../uploads/15447689655b43ccf31335b831008b4c1c-750-563.jpg', 0);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `application`
--
ALTER TABLE `application`
ADD PRIMARY KEY (`appId`),
ADD KEY `eId` (`eId`),
ADD KEY `jsId` (`jsId`);
--
-- Indexes for table `employer`
--
ALTER TABLE `employer`
ADD PRIMARY KEY (`eId`);
--
-- Indexes for table `emsg`
--
ALTER TABLE `emsg`
ADD PRIMARY KEY (`mId`),
ADD KEY `jsId` (`jsId`);
--
-- Indexes for table `jobcat`
--
ALTER TABLE `jobcat`
ADD PRIMARY KEY (`catId`);
--
-- Indexes for table `jobs`
--
ALTER TABLE `jobs`
ADD PRIMARY KEY (`jId`),
ADD KEY `eId` (`eId`),
ADD KEY `catId` (`catId`);
--
-- Indexes for table `jobseeker`
--
ALTER TABLE `jobseeker`
ADD PRIMARY KEY (`jsId`);
--
-- Indexes for table `jsmsg`
--
ALTER TABLE `jsmsg`
ADD PRIMARY KEY (`mId`),
ADD KEY `eId` (`eId`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`uId`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `application`
--
ALTER TABLE `application`
MODIFY `appId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `employer`
--
ALTER TABLE `employer`
MODIFY `eId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `emsg`
--
ALTER TABLE `emsg`
MODIFY `mId` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `jobcat`
--
ALTER TABLE `jobcat`
MODIFY `catId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `jobs`
--
ALTER TABLE `jobs`
MODIFY `jId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
--
-- AUTO_INCREMENT for table `jobseeker`
--
ALTER TABLE `jobseeker`
MODIFY `jsId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `jsmsg`
--
ALTER TABLE `jsmsg`
MODIFY `mId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `uId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `application`
--
ALTER TABLE `application`
ADD CONSTRAINT `application_ibfk_1` FOREIGN KEY (`eId`) REFERENCES `employer` (`eId`),
ADD CONSTRAINT `application_ibfk_2` FOREIGN KEY (`jsId`) REFERENCES `jobseeker` (`jsId`);
--
-- Constraints for table `emsg`
--
ALTER TABLE `emsg`
ADD CONSTRAINT `emsg_ibfk_1` FOREIGN KEY (`jsId`) REFERENCES `jobseeker` (`jsId`);
--
-- Constraints for table `jobs`
--
ALTER TABLE `jobs`
ADD CONSTRAINT `jobs_ibfk_1` FOREIGN KEY (`eId`) REFERENCES `employer` (`eId`),
ADD CONSTRAINT `jobs_ibfk_2` FOREIGN KEY (`catId`) REFERENCES `jobcat` (`catId`);
--
-- Constraints for table `jsmsg`
--
ALTER TABLE `jsmsg`
ADD CONSTRAINT `jsmsg_ibfk_1` FOREIGN KEY (`eId`) REFERENCES `employer` (`eId`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE TABLE StudentCourse
(
IdStudent INT NOT NULL,
IdCourse INT NOT NULL,
PRIMARY KEY (IdStudent, IdCourse),
FOREIGN KEY (IdStudent) REFERENCES Student,
FOREIGN KEY (IdCourse) REFERENCES Course
)
|
-- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: 04-Out-2018 às 01:50
-- Versão do servidor: 5.7.21
-- PHP Version: 7.0.29
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: `baiucasdatabase`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `empresa`
--
DROP TABLE IF EXISTS `empresa`;
CREATE TABLE IF NOT EXISTS `empresa` (
`nome_empresa` varchar(250) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`cnpj_empresa` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`logo_empresa_dir` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`logo_sistema_dir` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`email_folder_dir` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`endereco_empresa` varchar(500) NOT NULL,
`wpp_empresa` varchar(500) NOT NULL,
`horario_empresa` varchar(500) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `empresa`
--
INSERT INTO `empresa` (`nome_empresa`, `cnpj_empresa`, `logo_empresa_dir`, `logo_sistema_dir`, `email_folder_dir`, `endereco_empresa`, `wpp_empresa`, `horario_empresa`) VALUES
('Baiucas Lanches', '10342509900', 'Empresa/Imagens/logoEmpresa.png', 'Empresa/Imagens/logoSistema.png', 'Empresa/Imagens/email.png', ' Bela Vista, Ibirama - SC, 89140-000', '554791864020', 'Segunda a Sexta 08:00 às 12:30 14:00 às 22:00 Sábados 17:00 às 22:00');
-- --------------------------------------------------------
--
-- Estrutura da tabela `events`
--
DROP TABLE IF EXISTS `events`;
CREATE TABLE IF NOT EXISTS `events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(220) DEFAULT NULL,
`color` varchar(10) DEFAULT NULL,
`start` datetime DEFAULT NULL,
`end` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estrutura da tabela `mesas`
--
DROP TABLE IF EXISTS `mesas`;
CREATE TABLE IF NOT EXISTS `mesas` (
`numero_mesa` int(11) NOT NULL,
`ocupado` tinyint(1) NOT NULL,
PRIMARY KEY (`numero_mesa`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `mesas_produtos`
--
DROP TABLE IF EXISTS `mesas_produtos`;
CREATE TABLE IF NOT EXISTS `mesas_produtos` (
`id_produto_mesa` int(11) NOT NULL AUTO_INCREMENT,
`fk_mesa` varchar(100) NOT NULL,
`fk_produto` varchar(100) NOT NULL,
`quantidade_produto` varchar(11) NOT NULL,
`valor_produto` varchar(50) NOT NULL,
`valor_total` varchar(100) NOT NULL,
`descricao_produto` varchar(100) NOT NULL,
PRIMARY KEY (`id_produto_mesa`)
) ENGINE=MyISAM AUTO_INCREMENT=552 DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `movimentacoes_credito`
--
DROP TABLE IF EXISTS `movimentacoes_credito`;
CREATE TABLE IF NOT EXISTS `movimentacoes_credito` (
`id_vendedor` varchar(100) NOT NULL,
`id_usuario` varchar(100) NOT NULL,
`tipo_movimentacao` varchar(250) DEFAULT NULL,
`data_movimentacao` date DEFAULT NULL,
`id_movimentacao` int(11) NOT NULL AUTO_INCREMENT,
`valor_movimentacao` decimal(10,2) NOT NULL,
PRIMARY KEY (`id_movimentacao`)
) ENGINE=MyISAM AUTO_INCREMENT=67 DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `produtos`
--
DROP TABLE IF EXISTS `produtos`;
CREATE TABLE IF NOT EXISTS `produtos` (
`codigo` int(10) NOT NULL AUTO_INCREMENT,
`preco_venda` decimal(10,2) DEFAULT NULL,
`preco_compra` decimal(10,2) DEFAULT NULL,
`descricao` varchar(200) DEFAULT NULL,
`estoque` int(10) DEFAULT NULL,
`estoque_minimo` int(10) DEFAULT NULL,
`tipo_produto` int(11) NOT NULL,
`unidade` varchar(100) NOT NULL,
`ativo` tinyint(1) NOT NULL,
`ultima_vez_atualizado` varchar(100) DEFAULT NULL,
`tipo_ultima_alteracao` varchar(200) DEFAULT NULL,
`controlar_estoque` int(11) DEFAULT NULL,
PRIMARY KEY (`codigo`)
) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `usuarios`
--
DROP TABLE IF EXISTS `usuarios`;
CREATE TABLE IF NOT EXISTS `usuarios` (
`cpf` varchar(100) NOT NULL,
`nome` varchar(500) NOT NULL,
`email` varchar(500) NOT NULL,
`senha` varchar(100) NOT NULL,
`niveis_acesso_id` int(11) NOT NULL DEFAULT '3',
`credito` decimal(10,2) NOT NULL,
PRIMARY KEY (`cpf`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `usuarios`
--
INSERT INTO `usuarios` (`cpf`, `nome`, `email`, `senha`, `niveis_acesso_id`, `credito`) VALUES
('10342509900', 'André Cristen', 'andrecristenibirama@gmail.com', '202cb962ac59075b964b07152d234b70', 1, '1229.55'),
('1111111', '1111111111111111', '111111111111111111@1', 'c4ca4238a0b923820dcc509a6f75849b', 3, '0.00'),
('789', 'Teste Cadastro', 'andrecristenibirama@gmail.com', '202cb962ac59075b964b07152d234b70', 3, '982.50');
-- --------------------------------------------------------
--
-- Estrutura da tabela `vendas`
--
DROP TABLE IF EXISTS `vendas`;
CREATE TABLE IF NOT EXISTS `vendas` (
`id_venda` int(11) NOT NULL AUTO_INCREMENT,
`id_usuario` varchar(100) DEFAULT NULL,
`id_vendedor` varchar(100) DEFAULT NULL,
`data_venda` date DEFAULT NULL,
`valor_total` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id_venda`)
) ENGINE=MyISAM AUTO_INCREMENT=329 DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `vendas_adicionais`
--
DROP TABLE IF EXISTS `vendas_adicionais`;
CREATE TABLE IF NOT EXISTS `vendas_adicionais` (
`id_adicional` int(11) NOT NULL AUTO_INCREMENT,
`fk_venda` varchar(100) NOT NULL,
`descricao_adicional` text NOT NULL,
PRIMARY KEY (`id_adicional`)
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `vendas_produtos`
--
DROP TABLE IF EXISTS `vendas_produtos`;
CREATE TABLE IF NOT EXISTS `vendas_produtos` (
`id_vendas_produtos` int(11) NOT NULL AUTO_INCREMENT,
`fk_venda` varchar(100) DEFAULT NULL,
`fk_produto` varchar(100) DEFAULT NULL,
`quantidade_produto` varchar(11) DEFAULT NULL,
`valor_produto` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id_vendas_produtos`),
KEY `fk_venda` (`fk_venda`),
KEY `fk_produto` (`fk_produto`)
) ENGINE=MyISAM AUTO_INCREMENT=40938 DEFAULT CHARSET=latin1;
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 */;
|
-- phpMyAdmin SQL Dump
-- version 4.3.8
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 26, 2016 at 05:37 PM
-- Server version: 5.6.24
-- PHP Version: 5.6.5
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `info230_SP16_rdo26sp16`
--
-- --------------------------------------------------------
--
-- Table structure for table `Photos`
--
CREATE TABLE IF NOT EXISTS `Photos` (
`pID` int(11) NOT NULL,
`PhotoName` varchar(32) NOT NULL,
`caption` varchar(255) NOT NULL,
`image_url` varchar(255) NOT NULL,
`date_taken` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `Photos`
--
INSERT INTO `Photos` (`pID`, `PhotoName`, `caption`, `image_url`, `date_taken`) VALUES
(1, 'Overlooking Cornell', 'Aerial view of the Cornell campus and Cayuga Lake', 'Images/OverlookingCornell.jpg', '2016-05-29'),
(2, 'Overlooking Ho Plaza', 'View of Ho Plaza with the famous McGraw Tower', 'Images/OverlookingHoPlaza.jpg', '2015-09-17'),
(3, 'Cornell University Entrance Sign', 'A popular location for Cornell visitors!', 'Images/CUEntranceSign.jpg', '2013-07-08'),
(4, 'Overlooking the Arts Quad', 'With Ezra Cornell!', 'Images/CUArtsQuad.jpg', '2016-06-02'),
(5, 'Ho Plaza in the wintertime', 'Students make their way to class regardless of the weather', 'Images/HoPlazaWinter.jpg', '2016-01-31'),
(6, 'George Washington', 'First President of the U.S.', 'Images/GeorgeWashington.jpg', '1789-02-04'),
(7, 'Albert Einstein', 'Voted "Person of the Century" by Time Magazine in 2000', 'Images/AlbertEinstein', '1999-12-31'),
(8, 'Ezra Cornell', 'Co-founder of Cornell University!', 'Images/EzraCornell.jpg', '1865-04-27'),
(9, 'Neil deGrasse Tyson', 'Director of the Hayden Planetarium', 'Images/NeilDeGrasseTyson.jpg', '2016-03-14'),
(10, 'Will Smith', 'The Fresh Prince of Bel-Air', 'Images/WillSmith.jpg', '2014-08-09'),
(11, 'Superman', 'Alter ego: Clark Kent', 'Images/Superman.png', '1938-04-18'),
(12, 'Spiderman', 'Alter ego: Peter Parker', 'Images/Spiderman.png', '1962-08-01'),
(13, 'Wonder Woman', 'Alto ego: Diana Prince', 'Images/Wonderwoman.png', '1941-12-01'),
(14, 'Batman', 'Alto ego: Bruce Wayne', 'Images/Batman.png', '1939-05-01'),
(15, 'Ironman', 'Alto ego: Tony Stark', 'Images/Ironman.png', '1963-03-01'),
(16, 'New York City', 'Overlooking Manhatten', 'Images/NYC.jpg', '2012-10-03'),
(17, 'London', 'Overlooking The River Thames and Big Ben', 'Images/London.jpg', '2015-09-29'),
(18, 'Paris', 'Overlooking The Eiffel Tower', 'Images/Paris.jpg', '2015-04-08'),
(19, 'Sydney', 'Overlooking The Sydney Opera House', 'Images/Sydney.jpg', '2013-11-13');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `Photos`
--
ALTER TABLE `Photos`
ADD PRIMARY KEY (`pID`);
/*!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 */;
|
-- phpMyAdmin SQL Dump
-- version 4.2.12deb2+deb8u1build0.15.04.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 10, 2017 at 06:38 PM
-- Server version: 5.6.28-0ubuntu0.15.04.1
-- PHP Version: 5.6.4-4ubuntu6.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `midlands_open`
--
USE `midlands_open`;
-- --------------------------------------------------------
--
-- Table structure for table `bjj_events`
--
CREATE TABLE IF NOT EXISTS `bjj_events` (
`id` int(10) unsigned NOT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`event_start` datetime NOT NULL,
`content` text COLLATE utf8_unicode_ci,
`early_reg_fee` int(10) unsigned NOT NULL,
`late_reg_fee` int(10) unsigned NOT NULL,
`teen_early_reg_fee` int(10) unsigned NOT NULL,
`teen_late_reg_fee` int(10) unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `bjj_events`
--
INSERT INTO `bjj_events` (`id`, `title`, `event_start`, `content`, `early_reg_fee`, `late_reg_fee`, `teen_early_reg_fee`, `teen_late_reg_fee`, `created_at`, `updated_at`) VALUES
(1, 'Midlands Open BJJ 1 ', '2017-02-25 00:00:00', 'first fight @ 9am', 3000, 4000, 2000, 2500, '2017-01-10 05:00:00', '2017-01-10 05:00:00');
-- --------------------------------------------------------
--
-- Table structure for table `bjj_event_results`
--
CREATE TABLE IF NOT EXISTS `bjj_event_results` (
`id` int(10) unsigned NOT NULL,
`bjj_event_id` int(10) unsigned NOT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`place` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`name_and_surname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`club_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `bjj_participants`
--
CREATE TABLE IF NOT EXISTS `bjj_participants` (
`id` int(10) unsigned NOT NULL,
`first_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`last_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`gender` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`age_group` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`date_of_birth` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`belt` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`weight_category` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`years_training` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`club_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`instructor_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone_number` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`paid` tinyint(1) NOT NULL,
`bjj_event_id` int(10) unsigned NOT NULL,
`terms_conditions` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `contact_form`
--
CREATE TABLE IF NOT EXISTS `contact_form` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`message` text COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE IF NOT EXISTS `migrations` (
`id` int(10) unsigned NOT NULL,
`migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `migrations`
--
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(27, '2014_10_12_000000_create_users_table', 1),
(28, '2014_10_12_100000_create_password_resets_table', 1),
(29, '2017_01_02_150205_create_bjj_events_table', 1),
(30, '2017_01_02_152611_create_bjj_participants_table', 1),
(31, '2017_01_02_211119_create_mma_participants_table', 1),
(32, '2017_01_02_211426_create_mma_events_table', 1),
(33, '2017_01_05_130151_create_bjj_event_results_table', 1),
(34, '2017_01_05_130200_create_mma_event_results_table', 1),
(35, '2017_01_09_183556_create_contact_form_table', 1);
-- --------------------------------------------------------
--
-- Table structure for table `mma_events`
--
CREATE TABLE IF NOT EXISTS `mma_events` (
`id` int(10) unsigned NOT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`event_start` datetime NOT NULL,
`content` text COLLATE utf8_unicode_ci,
`early_reg_fee` int(10) unsigned NOT NULL,
`late_reg_fee` int(10) unsigned NOT NULL,
`teen_early_reg_fee` int(10) unsigned NOT NULL,
`teen_late_reg_fee` int(10) unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `mma_events`
--
INSERT INTO `mma_events` (`id`, `title`, `event_start`, `content`, `early_reg_fee`, `late_reg_fee`, `teen_early_reg_fee`, `teen_late_reg_fee`, `created_at`, `updated_at`) VALUES
(1, 'Midlands Open MMA League Round 1 ', '2017-03-05 00:00:00', 'first fight @ 9am', 4000, 5000, 2500, 3000, '2017-01-10 05:00:00', '2017-01-10 05:00:00');
-- --------------------------------------------------------
--
-- Table structure for table `mma_event_results`
--
CREATE TABLE IF NOT EXISTS `mma_event_results` (
`id` int(10) unsigned NOT NULL,
`mma_event_id` int(10) unsigned NOT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`place` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`name_and_surname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`club_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `mma_participants`
--
CREATE TABLE IF NOT EXISTS `mma_participants` (
`id` int(10) unsigned NOT NULL,
`first_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`last_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`gender` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`age_group` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`date_of_birth` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`level` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`weight_category` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`years_training` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`club_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`instructor_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone_number` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`paid` tinyint(1) NOT NULL,
`mma_event_id` int(10) unsigned NOT NULL,
`terms_conditions` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE IF NOT EXISTS `password_resets` (
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `bjj_events`
--
ALTER TABLE `bjj_events`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `bjj_event_results`
--
ALTER TABLE `bjj_event_results`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `bjj_participants`
--
ALTER TABLE `bjj_participants`
ADD PRIMARY KEY (`id`), ADD KEY `bjj_participants_bjj_event_id_index` (`bjj_event_id`);
--
-- Indexes for table `contact_form`
--
ALTER TABLE `contact_form`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `mma_events`
--
ALTER TABLE `mma_events`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `mma_event_results`
--
ALTER TABLE `mma_event_results`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `mma_participants`
--
ALTER TABLE `mma_participants`
ADD PRIMARY KEY (`id`), ADD KEY `mma_participants_mma_event_id_index` (`mma_event_id`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`), ADD KEY `password_resets_token_index` (`token`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `bjj_events`
--
ALTER TABLE `bjj_events`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `bjj_event_results`
--
ALTER TABLE `bjj_event_results`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `bjj_participants`
--
ALTER TABLE `bjj_participants`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `contact_form`
--
ALTER TABLE `contact_form`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=36;
--
-- AUTO_INCREMENT for table `mma_events`
--
ALTER TABLE `mma_events`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `mma_event_results`
--
ALTER TABLE `mma_event_results`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `mma_participants`
--
ALTER TABLE `mma_participants`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
/*!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 */;
|
-- **********************************************
-- IT2351 Assignment 6 Part 1 - Abimael Rivera
-- Creating a procedure named productCount() that displays if the amount of products we have is greater than or less than 20
-- **********************************************
DROP PROCEDURE IF EXISTS productCount;
DELIMITER //
CREATE PROCEDURE productCount()
BEGIN
DECLARE countprod int;
SELECT count(*) into countprod
FROM products ;
if countprod>=20 then
select 'The number of products is greater than or equal to 20' as col1;
else
select 'The number of products is less than 20' as col1;
end if;
END //
DELIMITER ;
call productCount() |
/*
Monitor\Search
view name
1. receipts receipts 'Receipts'
2. pullSignals pullsignals 'Pull Signals'
3. pullLines pulllines 'Pull Lines'
4. dispatches dispatches 'Dispatches'
5. events events 'Events'
6. sa sa 'SA'
*/
/**************************************
1. receipts receipts 'Receipts'
**********************************
************************************************/
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Receipts'
,'Receipts'
,'cdp.mxebgvmi.roles.receipts::access'
,'receipts::access'
,'view role '
,'MXEBGVMI'
,? ) ;
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Receipts'
,'Receipts'
,'cdp.mxebgvmi.roles.receipts::exportable'
,'receipts::exportable'
,'exportable role '
,'MXEBGVMI'
,? ) ;
/* CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
<module_name> ,<view_name> ,<role_name>, IN aMAP_TYPE NVARCHAR(50),?);
*/
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'receipts' ,'cdp.mxebgvmi.roles.receipts::access', 'view',?);
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'receipts' ,'cdp.mxebgvmi.roles.receipts::exportable', 'controllor',?);
/**************************************
2. pullSignals pullsignals 'Pull Signals'
************************************************/
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Pull Signals'
,'Pull Signals'
,'cdp.mxebgvmi.roles.pullsignals::access'
,'pullsignals::access'
,'view role '
,'MXEBGVMI'
,? ) ;
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Pull Signals'
,'Pull Signals'
,'cdp.mxebgvmi.roles.pullsignals::exportable'
,'pullsignals::exportable'
,'exportable role '
,'MXEBGVMI'
,? ) ;
/*
*/
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'pullSignals' ,'cdp.mxebgvmi.roles.pullsignals::access', 'view',?);
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'pullSignals' ,'cdp.mxebgvmi.roles.pullsignals::exportable', 'controllor',?);
/**************************************
3. pullLines pulllines 'Pull Lines'
************************************************/
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Pull Lines'
,'Pull Lines'
,'cdp.mxebgvmi.roles.pulllines::access'
,'pulllines::access'
,'view role '
,'MXEBGVMI'
,? ) ;
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Pull Lines'
,'Pull Lines'
,'cdp.mxebgvmi.roles.pulllines::exportable'
,'pulllines::exportable'
,'exportable role '
,'MXEBGVMI'
,? ) ;
/*
*/
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'pullLines' ,'cdp.mxebgvmi.roles.pulllines::access', 'view',?);
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'pullLines' ,'cdp.mxebgvmi.roles.pulllines::exportable', 'controllor',?);
/**************************************
4. dispatches dispatches 'Dispatches'
************************************************/
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Dispatches'
,'Dispatches'
,'cdp.mxebgvmi.roles.dispatches::access'
,'dispatches::access'
,'view role '
,'MXEBGVMI'
,? ) ;
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Dispatches'
,'Dispatches'
,'cdp.mxebgvmi.roles.dispatches::exportable'
,'dispatches::exportable'
,'exportable role '
,'MXEBGVMI'
,? ) ;
/*
4*/
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'dispatches' ,'cdp.mxebgvmi.roles.dispatches::access', 'view',?);
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'dispatches' ,'cdp.mxebgvmi.roles.dispatches::exportable', 'controllor',?);
/**************************************
5. events events 'Events'
************************************************/
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Events'
, 'Events'
,'cdp.mxebgvmi.roles.events::access'
,'events::access'
,'view role '
,'MXEBGVMI'
,? ) ;
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'Events'
, 'Events'
,'cdp.mxebgvmi.roles.events::exportable'
,'events::exportable'
,'exportable role '
,'MXEBGVMI'
,? ) ;
/*
5*/
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'events' ,'cdp.mxebgvmi.roles.events::access', 'view',?);
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'events' ,'cdp.mxebgvmi.roles.events::exportable', 'controllor',?);
/**************************************
6. sa sa 'SA'
************************************************/
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'SA'
,'SA'
,'cdp.mxebgvmi.roles.sa::access'
,'sa::access'
,'view role '
,'MXEBGVMI'
,? ) ;
CALL "SECURITY"."cdp.security.procedures::createInfoRole" (
'SA'
,'SA'
,'cdp.mxebgvmi.roles.sa::exportable'
,'sa::exportable'
,'exportable role '
,'MXEBGVMI'
,? ) ;
/*
6*/
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'sa' ,'cdp.mxebgvmi.roles.sa::access', 'view',?);
CALL "SECURITY"."cdp.security.procedures::createMapViewRole" (
'MXEBGVMI' ,'sa' ,'cdp.mxebgvmi.roles.sa::exportable', 'controllor',?);
|
# Oefening 10:
# Toon de naam & populatie van de Nederlandse steden.
# Toon ook de naam & populatie van de Belgische steden.
SELECT city.name, city.population FROM city INNER JOIN
country ON city.countrycode=country.code
WHERE country.name="Netherlands"
UNION
SELECT city.name, city.population FROM city INNER JOIN
country ON city.countrycode=country.code
WHERE country.name="Belgium"
## ANDERE/KORTERE MOGELIJKHEID:
SELECT city.name, city.population FROM city INNER JOIN
country ON city.countrycode=country.code
WHERE country.name IN ("Netherlands","Belgium")
# Toon de naam van de Aziatische steden waar de onafhankelijkheid van het land is gevierd voor 1955.
# Toon ook de naam van de Europese steden waar de onafhankelijkheid van het land is gevierd na 1925.
SELECT city.name FROM city INNER JOIN
country ON city.countrycode=country.code
WHERE continent="Asia" AND indepyear < 1955
UNION
SELECT city.name FROM city INNER JOIN
country ON city.countrycode=country.code
WHERE continent="Europe" AND indepyear > 1925
# Toon de naam van de Europese steden waar de levensverwachting hoger is dan 60 en
# de populatie (vd. stad) groter is dan 200000.
# Toon ook de naam en levensverwachting van het land.
# Toon ook de naam van de Amerikaanse steden waar de levensverwachting lager is dan 60.
# Toon ook de naam en levensverwachting van het land.
# Sorteer alfabetisch op de naam van het land.
SELECT city.name AS stad, lifeexpectancy, country.name AS country FROM city INNER JOIN
# kijkt enkel naar eerste query voor de aliasen, dus na UNION overbodig om AS te gebruiken
country ON city.countrycode=country.code
WHERE continent="Europe" AND lifeexpectancy > 60 AND city.population > 200000
UNION
SELECT city.name, lifeexpectancy, country.name FROM city INNER JOIN
country ON city.countrycode=country.code
WHERE continent="America" AND lifeexpectancy < 60
ORDER BY country
# Toon de naam van de Europese landen, de officiële taal & door hoeveel percent van de bevolking ze gesproken wordt
# Toon ook de naam van de Afrikaanse landen, de officiële taal & door hoeveel percent van de bevolking ze gesproken wordt
# Maak geen gebruik van aliassen
# Sorteer alfabetisch op naam land
SELECT country.name, language, percentage FROM country INNER JOIN
countrylanguage ON country.code=countrylanguage.countrycode
WHERE continent="Europe" AND isofficial="T"
UNION
SELECT country.name, language, percentage FROM country INNER JOIN
countrylanguage ON country.code=countrylanguage.countrycode
WHERE continent="Africa" AND isofficial="T"
ORDER BY 1 # enkel sorteren op kolommen die in de result set steken!
# Toon de naam van de Spaanse steden met een bevolking > 300000.
# Toon ook de naam, continent en region van het land en de officiële taal die ze er spreken.
# Toon ook de naam van de Engelse steden met een bevolking > 500000.
# Toon ook de naam, continent en region van het land en de officiële taal die ze er spreken.
# Sorteer alfabetisch op naam van het land, dan op naam stad
SELECT city.name, continent, region, language FROM country INNER JOIN
(city INNER JOIN countrylanguage ON city.countrycode=countrylanguage.countrycode)
ON country.code = city.countrycode
WHERE country.name="Spain" AND isofficial="T" AND city.population > 300000
UNION
SELECT city.name, continent, region, language FROM country INNER JOIN
(city INNER JOIN countrylanguage ON city.countrycode=countrylanguage.countrycode)
ON country.code = city.countrycode
WHERE country.name="United Kingdom" AND isofficial="T" AND city.population > 500000
ORDER BY 1 # enkel sorteren op kolommen die in de result set steken! |
Recursion and Common Table Expression (CTE) |
-- We first looked at duplicates of the cgm data (the implanted device
-- that provides readings every 5 minutes, but has to be regularly
-- uploaded to Diasend). Duplicates can appear for reasons that are
-- not clear.
-- This script is idempotent.
-- In this script, we look at duplicates in the mgm data (finger sticks)
-- Because of the arithmetic operations, even simple stuff like
-- computing differences between max and min, we need to have an mgm_1
-- table with proper datatypes.
drop table if exists mgm_1;
create table mgm_1 (
user varchar(20) not null, -- same as mgm
date_time datetime not null, -- different datatype
mgdl mediumint unsigned, -- different datatype
rec_num int(6) -- same as mgm
);
insert into mgm_1
select user,cast(date as datetime),cast(mgdl as unsigned),rec_num
from mgm;
-- the output of the following is zero, which shows that there are no rows where
-- both the timestamp and the mgdl are repeated.
select 'num datetime and mgdl duplicates in mgm',
(select count(*) from (
select date_time,min(mgdl) from mgm_1
group by date_time
having count(*) > 1 and min(mgdl) = max(mgdl)) as T) as num_row_duplicates;
-- It turns out that deleting duplicates using a subquery in the same table fails,
-- so, since we have to have an extra table anyhow, let's go ahead and pull out
-- all the duplicates:
drop table if exists mgm_duplicates;
create table mgm_duplicates like mgm_1;
insert into mgm_duplicates
(select * from mgm_1 where date_time in
(select date_time
from mgm_1
group by date_time
having count(*) > 1));
-- the output of this shows how many rows have duplicate timestamps (151) and where they occur
select 'num date_time duplicates in mgm';
select count(*) from
(select count(*) as len,min(rec_num)
from mgm_1
group by date_time
having count(*) > 1) as t;
-- The output of this shows how many times an timestamp is repeated more than once.
-- Fortunately, it's pretty rare.
select 'num multiple date_time duplicates in mgm';
select count(*) from
(select date_time, count(*) as len,min(rec_num),max(rec_num)
from mgm_duplicates
group by date_time
having count(*) > 2) as t;
-- the following shows the range that mgdl differs over a group
select 'mgdl range on date_time duplicates in mgm';
select date_time as 'duplicated date_time',
len,
big,
small,
big-small as diff,
lpad(format(100*big/small-100,2),6,' ') as '%more',
lpad(format(mean,1),5,' ') as mean,
lpad(format(std,1),5,' ') as stdev,
lpad(format(std/mean,2),4,' ') as 'cov'
from (select date_time,
count(*) as len,
max(mgdl) as big,
min(mgdl) as small,
avg(mgdl) as mean,
std(mgdl) as std
from mgm_duplicates
group by date_time
having count(*) > 1) as T
order by len desc,diff desc,date_time asc;
-- Okay, time to implement the rule: average if COV < 0.1 otherwise discard
-- We do this in several steps:
-- 1. create a new table mgm_noduplicates with date as primary key
-- 2. insert into mgm_noduplicates all rows that are in mgm_1 but not in mgm_duplicates
-- 3. insert into mgm_noduplicates all rows from mgm_duplicates with COV < 0.1
-- optionally, can drop mgm_1
-- first, record what we are doing
select 'discard',date_time,std(mgdl)/avg(mgdl) as cov
from mgm_duplicates
group by date_time
having std(mgdl)/avg(mgdl) > 0.1;
select 'average',date_time,avg(mgdl) as average
from mgm_duplicates
group by date_time
having std(mgdl)/avg(mgdl) <= 0.1;
-- now, step 1, create the table
drop table if exists mgm_noduplicates;
create table mgm_noduplicates (
user varchar(20) not null, -- same as mgm
date_time datetime primary key, -- different datatype and now primary key
mgdl mediumint unsigned -- different datatype. Allow NULL
);
-- step 2, all non-duplicate rows
-- This step is slightly different from the dup-cgm-readings script
-- because that script gets from cgm_1, which has already converted to
-- a datetime datatype for the date_time field. Here, we are reading
-- from mgm and mgm_duplicates, which only have varchar fields. So,
-- we'll use the "date" field, which is relatively easy to coerce to a
-- datetime datatype.
insert into mgm_noduplicates
(select user,date_time,mgdl
from mgm_1
where date_time not in (select date_time from mgm_duplicates));
-- step 3, all averages of groups with COV <= 0.1.
-- Note, we have to group by user because MySQL doesn't know we only have one value for that
-- When we have multiple users, we'll have to deal with duplicates for each user
insert into mgm_noduplicates
(select user,date_time,avg(mgdl)
from mgm_duplicates
group by user,date_time
having std(mgdl)/avg(mgdl) <= 0.1);
|
BEGIN TRANSACTION;
CREATE TABLE `comments` (
`id` INTEGER,
`sub_id` INTEGER,
`comment` TEXT,
PRIMARY KEY(`id`)
);
INSERT INTO `comments` VALUES (27,51,'eJTZryxk,c');
INSERT INTO `comments` VALUES (28,52,'eJTZryxk,c');
INSERT INTO `comments` VALUES (29,53,'eJTZryxk,c');
INSERT INTO `comments` VALUES (30,54,'eJTZryxk,c');
INSERT INTO `comments` VALUES (31,23,'asdasd');
INSERT INTO `comments` VALUES (32,24,'google');
INSERT INTO `comments` VALUES (33,25,'testowy');
INSERT INTO `comments` VALUES (34,26,'testowy');
INSERT INTO `comments` VALUES (35,27,'testowy');
INSERT INTO `comments` VALUES (36,28,'testowy');
INSERT INTO `comments` VALUES (37,29,'testowy');
INSERT INTO `comments` VALUES (38,30,'testowy');
INSERT INTO `comments` VALUES (39,31,'testowy');
INSERT INTO `comments` VALUES (40,32,'testowy');
CREATE TABLE "Users_team"
(
ID INTEGER PRIMARY KEY,
ID_TEAM INTEGER NOT NULL,
ID_USER INTEGER NOT NULL
);
INSERT INTO `Users_team` VALUES (1,26,11);
CREATE TABLE `Users_checkpoints` ( `ID` INTEGER PRIMARY KEY AUTOINCREMENT, `ID_CHECKPOINT` INTEGER NOT NULL, `DATE` TEXT NOT NULL, `GRADE` NUMERIC NOT NULL, `ID_STUDENT` INTEGER NOT NULL, `ID_MENTOR_1` INTEGER NOT NULL, `ID_MENTOR_2` INTEGER NOT NULL );
INSERT INTO `Users_checkpoints` VALUES (135,44,'2017-03-24','red',11,2,21);
INSERT INTO `Users_checkpoints` VALUES (136,44,'2017-03-24','red',45,2,21);
CREATE TABLE "Users" (
`ID` INTEGER PRIMARY KEY AUTOINCREMENT,
`Name` TEXT NOT NULL,
`Surname` TEXT NOT NULL,
`Email` TEXT NOT NULL UNIQUE,
`Telephone` TEXT,
`Password` TEXT NOT NULL,
`Type` TEXT NOT NULL
);
INSERT INTO `Users` VALUES (2,'Przemysław','Ciąćka','prosty',NULL,'b''\xb2\xf7=\xf0\xc9\xdat\xe1\xa3\xcf\xb7\xe6\x80ee\xff@\r\xf6\x13f\x10|\x18N\xa3\xcbb\x83\xa7r\x85''','Mentor');
INSERT INTO `Users` VALUES (11,'Kamil','Mika','kam@kam.com','1223342142','b''\xb2\xf7=\xf0\xc9\xdat\xe1\xa3\xcf\xb7\xe6\x80ee\xff@\r\xf6\x13f\x10|\x18N\xa3\xcbb\x83\xa7r\x85''','Student');
INSERT INTO `Users` VALUES (21,'Mateusz','Ostafil','prosty2',NULL,'b''\xb2\xf7=\xf0\xc9\xdat\xe1\xa3\xcf\xb7\xe6\x80ee\xff@\r\xf6\x13f\x10|\x18N\xa3\xcbb\x83\xa7r\x85''','Mentor');
INSERT INTO `Users` VALUES (22,'Rafał','Stępień','prosty3',NULL,'b''\xb2\xf7=\xf0\xc9\xdat\xe1\xa3\xcf\xb7\xe6\x80ee\xff@\r\xf6\x13f\x10|\x18N\xa3\xcbb\x83\xa7r\x85''','Mentor');
INSERT INTO `Users` VALUES (34,'Employee','Codecool','nw',NULL,'b''\xb2\xf7=\xf0\xc9\xdat\xe1\xa3\xcf\xb7\xe6\x80ee\xff@\r\xf6\x13f\x10|\x18N\xa3\xcbb\x83\xa7r\x85''','Employee');
INSERT INTO `Users` VALUES (44,'Manager','Codecool','jurek',NULL,'b''\xb2\xf7=\xf0\xc9\xdat\xe1\xa3\xcf\xb7\xe6\x80ee\xff@\r\xf6\x13f\x10|\x18N\xa3\xcbb\x83\xa7r\x85''','Manager');
INSERT INTO `Users` VALUES (45,'Student','Codecool','ty',NULL,'b''\xb2\xf7=\xf0\xc9\xdat\xe1\xa3\xcf\xb7\xe6\x80ee\xff@\r\xf6\x13f\x10|\x18N\xa3\xcbb\x83\xa7r\x85''','Student');
CREATE TABLE `TEAMS` ( `ID` INTEGER PRIMARY KEY AUTOINCREMENT, `NAME` TEXT NOT NULL );
INSERT INTO `TEAMS` VALUES (26,'Nowy Team');
CREATE TABLE "Sumbissions"
(
ID INTEGER PRIMARY KEY,
ID_ASSIGMENT INTEGER NOT NULL,
ID_STUDENT INTEGER NOT NULL,
GRADE INTEGER,
DATE TEXT NOT NULL,
LINK TEXT NOT NULL,
ID_MENTOR INTEGER
);
INSERT INTO `Sumbissions` VALUES (3,3,1,37,'2017-02-09','https://github.com/patiem',2);
INSERT INTO `Sumbissions` VALUES (4,4,1,37,'2017-02-09','https://github.com/patiem',2);
INSERT INTO `Sumbissions` VALUES (23,2,1,69,'2017-03-20','asda',2);
INSERT INTO `Sumbissions` VALUES (24,1,45,38,'2017-03-20','www.google.pl',2);
INSERT INTO `Sumbissions` VALUES (25,13,5,61,'2017-03-21','www.facebook.com',2);
INSERT INTO `Sumbissions` VALUES (26,13,6,61,'2017-03-21','www.facebook.com',2);
INSERT INTO `Sumbissions` VALUES (27,13,13,61,'2017-03-21','www.facebook.com',2);
INSERT INTO `Sumbissions` VALUES (28,13,11,61,'2017-03-21','www.facebook.com',2);
INSERT INTO `Sumbissions` VALUES (29,13,11,61,'2017-03-21','www.facebook.com',2);
INSERT INTO `Sumbissions` VALUES (30,13,12,61,'2017-03-21','www.facebook.com',2);
INSERT INTO `Sumbissions` VALUES (31,13,45,61,'2017-03-21','www.facebook.com',2);
INSERT INTO `Sumbissions` VALUES (32,13,46,61,'2017-03-21','www.facebook.com',2);
CREATE TABLE `Checkpoints`( `ID` INTEGER PRIMARY KEY AUTOINCREMENT, `ID_USER` INTEGER NOT NULL, `TITLE` TEXT NOT NULL, `START_DATE` TEXT NOT NULL);
INSERT INTO `Checkpoints` VALUES (44,2,'SQL','2017-03-10');
INSERT INTO `Checkpoints` VALUES (45,2,'Test','2017-03-10');
INSERT INTO `Checkpoints` VALUES (46,2,'asdf','2017-03-10');
INSERT INTO `Checkpoints` VALUES (47,2,'asdf','2017-03-10');
INSERT INTO `Checkpoints` VALUES (48,2,'test2','2017-03-20');
CREATE TABLE `Attendance`( `ID` INTEGER PRIMARY KEY AUTOINCREMENT, `ID_STUDENT` INTEGER NOT NULL, `DATE` TEXT NOT NULL, `STATUS` TEXT NOT NULL );
INSERT INTO `Attendance` VALUES (7,11,'2017-03-10','Present');
INSERT INTO `Attendance` VALUES (10,45,'2017-03-10','Absent');
INSERT INTO `Attendance` VALUES (12,11,'2017-03-20','Present');
INSERT INTO `Attendance` VALUES (14,45,'2017-03-20','Present');
INSERT INTO `Attendance` VALUES (15,11,'2017-03-21','Present');
INSERT INTO `Attendance` VALUES (16,45,'2017-03-21','Present');
INSERT INTO `Attendance` VALUES (29,11,'2017-03-23','Present');
INSERT INTO `Attendance` VALUES (30,45,'2017-03-23','Late');
INSERT INTO `Attendance` VALUES (33,11,'2017-03-24','None');
INSERT INTO `Attendance` VALUES (34,45,'2017-03-24','None');
CREATE TABLE `Assigments`( `ID` INTEGER PRIMARY KEY AUTOINCREMENT, `ID_MENTOR` INTEGER NOT NULL, `TITLE` TEXT NOT NULL, `START_DATA` TEXT NOT NULL, `END_DATA` TEXT NOT NULL, `LINK` TEXT NOT NULL, `GROUP` TEXT);
INSERT INTO `Assigments` VALUES (1,2,'Test_123','2017-02-05','2017-02-15','<section>
<div class="description">
<article>
<h3>Story</h3>
<div>A client came and asked about a software for displaying information about cities, towns and villages in Małopolska.
Good news is that he is providing data file (Link (Łącza do strony zewnętrznej.)).
Bad news, he''s totally newbie when it comes to IT and is interesting only in results.
ASAP results, to be more precised. </div>
</article>
<article>
<h3>Descripion</h3>
<div>Please:
I. Define what classes you''ll implement in the system.
II. Draw UML Class diagram.
III. Create a python program that suits client''s needs. </div>
</article>
<article>
<h3>Illustration</h3>
<figure>
<img src="https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/1524687_10202387511361199_1643696660_n.jpg?oh=78f4151af1f0c67ea5c5fae54e2360a3&oe=593E63FD" />
</figure>
</article>
</div>
</section>','0');
INSERT INTO `Assigments` VALUES (2,2,'Test_2','2017-02-20','2017-02-28','<section>
<div class="description">
<article>
<h3>Story</h3>Dupa dupa dupa dupa </div>
</article>
<article>
<h3>Descripion</h3>
<div>Please:
I. Define what classes you''ll implement in the system.
II. Draw UML Class diagram.
III. Create a python program that suits client''s needs. </div>
</article>
<article>
<h3>Illustration</h3>
<figure>
<img src="https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/1524687_10202387511361199_1643696660_n.jpg?oh=78f4151af1f0c67ea5c5fae54e2360a3&oe=593E63FD" />
</figure>
</article>
</div>
</section>','0');
INSERT INTO `Assigments` VALUES (3,2,'Test_3','2017-01-05','2017-01-15','<section>
<div class="description">
<article>
<h3>Story</h3>Dupa dupa dupa dupa </div>
</article>
<article>
<h3>Descripion</h3>
<div>Please:
I. Define what classes you''ll implement in the system.
II. Draw UML Class diagram.
III. Create a python program that suits client''s needs. </div>
</article>
<article>
<h3>Illustration</h3>
<figure>
<img src="https://scontent-waw1-1.xx.fbcdn.net/v/t1.0-9/1524687_10202387511361199_1643696660_n.jpg?oh=78f4151af1f0c67ea5c5fae54e2360a3&oe=593E63FD" />
</figure>
</article>
</div>
</section>','1');
INSERT INTO `Assigments` VALUES (4,2,'Test_4','2017-02-05','2017-02-15','ass_3.txt','1');
INSERT INTO `Assigments` VALUES (13,2,'Testowy','2017-02-23','2017-02-25','Testowy','1');
COMMIT;
|
CREATE DATABASE if not exists power_rangers;
USE power_rangers;
CREATE TABLE if not exists customers (
cust_id INT,
fname STRING,
lname STRING,
email STRING,
phone MAP<STRING, STRING>,
order_ids ARRAY<INT>,
order_value STRUCT<min:INT,max:INT,avg:INT,total:INT>
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
COLLECTION ITEMS TERMINATED BY ','
MAP KEYS TERMINATED BY ':';
desc customers;
ALTER TABLE customers CHANGE fname fullname STRING;
desc customers; |
# SALES
# SELECT
# x.Month
# , x.Sales
# , y.Fees 'Vendor Fees'
# , ROUND(y.Fees / x.Sales * 100, 2) 'COGS %'
# FROM
# (
# SELECT
# MONTHNAME(t.dts) 'Month'
# , SUM(t.amount) 'Sales'
# FROM orders o
# JOIN client_transactions t ON t.orderid = o.id
# WHERE o.companyid = 1
# AND o.order_status = 7
# AND t.dts >= '2015-05-01 00:00:00' AND t.dts < '2015-08-01 00:00:00'
# GROUP BY MONTH(t.dts)
# ) x
# JOIN
# (
# SELECT
# MONTHNAME(t.dts) 'Month'
# , SUM(p.vendorfee) 'Fees'
# FROM orders o
# JOIN order_parts p ON p.orderid = o.id
# JOIN client_transactions t ON t.orderid = o.id
# WHERE o.companyid = 1
# AND o.order_status = 7
# AND p.order_status = 7
# AND t.dts >= '2015-05-01 00:00:00' AND t.dts < '2015-08-01 00:00:00'
# GROUP BY MONTH(t.dts)
# ) y ON y.Month = x.Month;
# Fannie Mae (2015 YTD)
SELECT
x.client_name 'Client Name'
, o.id 'Order No.'
, DATE(o.ordereddate) 'Order Date'
, DATE(t.dts) 'Completion Date'
, CONCAT_WS(' ', o.propertyaddress, o.propertycity, o.propertystate, o.propertyzipcode) 'Property Address'
, ot.descrip 'Product/Service'
, IFNULL(a.vendor, '') 'Vendor A'
, IFNULL(a.fee, 0) 'Fee A'
, IFNULL(b.vendor, '') 'Vendor B'
, IFNULL(b.fee, 0) 'Fee B'
, IFNULL(c.vendor, '') 'Vendor C'
, IFNULL(c.fee, 0) 'Fee C'
, IFNULL(a.fee, 0) + IFNULL(b.fee, 0) + IFNULL(c.fee, 0) 'Total Fees'
, t.amount 'Invoice Amount'
FROM
(
SELECT
o.id
, CONCAT_WS(' ', TRIM(v.firstname), TRIM(v.lastname)) 'vendor'
, p.vendorfee 'fee'
FROM orders o
JOIN order_parts p ON o.id = p.orderid AND p.part_label = 'A'
JOIN user_data_vendor v ON v.userid = p.acceptedby
# JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED' AND t.clientid = 17 # Fannie Mae
JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED'
AND t.clientid IN
(313, 318, 319, 321, 320, 331, 178, 271, 187, 326, 315, 317, 316, 314, 324, 328, 329, 323, 332, 327, 325, 168, 330, 422, 163, 169, 166, 167)
WHERE o.companyid = 1
AND o.order_status = 7 # Completed
AND p.order_status = 7 # Completed
AND p.part_type NOT IN (2, 3, 4) # Exterior, Interior, AVM
AND o.ordereddate >= '2015-01-01 00:00:00'
) a
LEFT JOIN
(
SELECT
o.id
, CONCAT_WS(' ', TRIM(v.firstname), TRIM(v.lastname)) 'vendor'
, p.vendorfee 'fee'
FROM orders o
JOIN order_parts p ON o.id = p.orderid AND p.part_label = 'B'
JOIN user_data_vendor v ON v.userid = p.acceptedby
# JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED' AND t.clientid = 17 # Fannie Mae
JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED'
AND t.clientid IN
(313, 318, 319, 321, 320, 331, 178, 271, 187, 326, 315, 317, 316, 314, 324, 328, 329, 323, 332, 327, 325, 168, 330, 422, 163, 169, 166, 167)
WHERE o.companyid = 1
AND o.order_status = 7 # Completed
AND p.order_status = 7 # Completed
AND p.part_type NOT IN (2, 3, 4) # Exterior, Interior, AVM
AND o.ordereddate >= '2015-01-01 00:00:00'
) b ON b.id = a.id
LEFT JOIN
(
SELECT
o.id
, CONCAT_WS(' ', TRIM(v.firstname), TRIM(v.lastname)) 'vendor'
, p.vendorfee 'fee'
FROM orders o
JOIN order_parts p ON o.id = p.orderid AND p.part_label = 'C'
JOIN user_data_vendor v ON v.userid = p.acceptedby
# JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED' AND t.clientid = 17 # Fannie Mae
JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED'
AND t.clientid IN
(313, 318, 319, 321, 320, 331, 178, 271, 187, 326, 315, 317, 316, 314, 324, 328, 329, 323, 332, 327, 325, 168, 330, 422, 163, 169, 166, 167)
WHERE o.companyid = 1
AND o.order_status = 7 # Completed
AND p.order_status = 7 # Completed
AND p.part_type NOT IN (2, 3, 4) # Exterior, Interior, AVM
AND o.ordereddate >= '2015-01-01 00:00:00'
) c ON c.id = a.id
JOIN orders o ON o.id = a.id
JOIN order_types ot ON ot.id = o.order_type
JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED'
JOIN clients x ON x.id = t.clientid
ORDER BY t.dts;
# Orders
SELECT
c.client_name 'Client Name'
, o.id 'Order No'
, CONCAT_WS(' ', o.propertyaddress, o.propertycity, o.propertystate, o.propertyzipcode) 'Property Address'
, ot.descrip 'Product/Service'
, t.amount 'Invoice Amount'
, DATE(o.ordereddate) 'Order Date'
, DATE(t.dts) 'Completed Date'
, ROUND(TIME_TO_SEC(TIMEDIFF(t.dts, o.ordereddate)) / 3600, 2) 'Turn Time (Hours)'
FROM orders o
JOIN order_types ot ON ot.id = o.order_type
JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED'
# JOIN clients c ON c.id = t.clientid AND c.id = 17 # Fannie Mae
JOIN clients c ON c.id = t.clientid
AND c.id IN
(313, 318, 319, 321, 320, 331, 178, 271, 187, 326, 315, 317, 316, 314, 324, 328, 329, 323, 332, 327, 325, 168, 330, 422, 163, 169, 166, 167)
WHERE o.companyid = 1
AND o.order_status = 7
AND o.ordereddate >= '2015-01-01 00:00:00'
ORDER BY o.ordereddate, t.dts;
# Parts
SELECT
o.id 'Order No'
, o.ordereddate 'Order Date'
, p.accepteddate 'Accepted Date'
, p.start_dts 'Start Date'
, p.effective_date 'Effective Date'
, t.dts 'Completed Date'
, ROUND(TIME_TO_SEC(TIMEDIFF(p.accepteddate, o.ordereddate)) / 3600, 2) 'Placement Delay (Hours)'
, ROUND(TIME_TO_SEC(TIMEDIFF(p.start_dts, p.accepteddate)) / 3600, 2) 'Start Delay (Hours)'
, ROUND(TIME_TO_SEC(TIMEDIFF(p.effective_date, p.accepteddate)) / 3600, 2) 'Turn Time (Hours)'
, p.part_label 'Label'
, p.acceptedby 'Vendor No'
, CONCAT_WS(' ', TRIM(v.firstname), TRIM(v.lastname)) 'Vendor Name'
, p.vendorfee 'Vendor Fee'
FROM orders o
JOIN order_parts p ON p.orderid = o.id
JOIN user_data_vendor v ON v.userid = p.acceptedby
JOIN client_transactions t ON t.orderid = o.id AND t.type = 'COMPLETED'
# JOIN clients c ON c.id = t.clientid AND c.id = 17 # Fannie Mae
JOIN clients c ON c.id = t.clientid
AND c.id IN
(313, 318, 319, 321, 320, 331, 178, 271, 187, 326, 315, 317, 316, 314, 324, 328, 329, 323, 332, 327, 325, 168, 330, 422, 163, 169, 166, 167)
WHERE o.companyid = 1
AND o.order_status = 7
AND p.order_status = 7
AND p.part_type NOT IN (2, 3, 4) # Exterior, Interior, AVM
AND o.ordereddate >= '2015-01-01 00:00:00'
ORDER BY o.id, p.part_label;
# 115 Morgan Stanley
# 216 J.P. Morgan
SELECT *
FROM clients c
WHERE c.client_name LIKE 'Solution%'
# Solution Star (313,318,319,321,320,331,178,271,187,326,315,317,316,314,324,328,329,323,332,327,325,168,330,422,163,169,166,167)
|
CREATE DATABASE IF NOT EXISTS `test` DEFAULT CHARACTER SET utf8;
-- DROP TABLE IF EXISTS `job`;
CREATE TABLE IF NOT EXISTS `job` (
`JOB_NAME` VARCHAR(100) DEFAULT '' COMMENT '任务名',
`JOB_GROUP` VARCHAR(30) DEFAULT 'DEFAULT' COMMENT '任务组',
`JOB_CLASS_NAME` VARCHAR(200) DEFAULT '' COMMENT '任务实现类',
`TRIGGER_TYPE` VARCHAR(10) DEFAULT '' COMMENT '触发器类型 SIMPLE 普通 CRON 表达式',
`TRIGGER_CRON` VARCHAR(50) DEFAULT '' COMMENT 'CRON 表达式',
`TRIGGER_INTERVAL` INT(11) DEFAULT 0 COMMENT '执行间隔(毫秒)',
`TRIGGER_REPEAT` INT(2) DEFAULT 0 COMMENT '重复执行次数',
`JAR_PATH` VARCHAR(255) DEFAULT '' COMMENT 'JAR包文件名,包括目录',
`IS_ENABLE` CHAR(1) DEFAULT '0' COMMENT '0 禁用 1 启动',
PRIMARY KEY (`JOB_NAME`)
) COMMENT = '定时任务';
-- DROP TABLE IF EXISTS `job_param`;
CREATE TABLE IF NOT EXISTS `job_param` (
`JOB_NAME` VARCHAR(100) DEFAULT '' COMMENT '任务名',
`PARAM_KEY` VARCHAR(30) DEFAULT '' COMMENT '参数名',
`PARAM_VALUE` VARCHAR(200) DEFAULT '' COMMENT '参数值',
`IS_ENABLE` CHAR(1) DEFAULT '0' COMMENT '0 禁用 1 启动',
UNIQUE KEY UNIQUE_JOB_NAME_PARAM_KEY(`JOB_NAME`, `PARAM_KEY`)
) COMMENT = '定时任务参数';
-- DROP TABLE IF EXISTS `job_history`;
CREATE TABLE IF NOT EXISTS `job_history` (
`JOB_NAME` VARCHAR(100) DEFAULT '' COMMENT '任务名',
`JOB_LOG` TEXT COMMENT '执行日志',
`CREATE_DATE` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
INDEX INDEX_JOB_NAME(`JOB_NAME`)
) COMMENT = '任务执行记录';
-- DROP TABLE IF EXISTS `contact`;
CREATE TABLE IF NOT EXISTS `contact` (
`NAME` VARCHAR(100) DEFAULT '' COMMENT '姓名',
`PHONE` VARCHAR(11) DEFAULT '' COMMENT '电话',
`EMAIL` VARCHAR(150) DEFAULT '' COMMENT '邮箱',
`GROUPING` VARCHAR(30) DEFAULT 'DEFAULT' COMMENT '分组 jobName',
`IS_ENABLE` CHAR(1) DEFAULT '0' COMMENT '0 禁用 1 启动',
UNIQUE KEY UNIQUE_NAME_GROUPING(`NAME`, `GROUPING`)
) COMMENT = '联系人'; |
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
use TutorSegundoGrado;
DROP PROCEDURE IF EXISTS ObtenerNivel;
DELIMITER $$
CREATE PROCEDURE ObtenerNivel (IN pUsuario INT, IN pNumeroEjercicio INT, OUT pNivel INT)
BEGIN
DECLARE countNivel INT;
SELECT
COUNT(nivel)
INTO countNivel
FROM ejercicio
WHERE usuario = pUsuario
AND numero = pNumeroEjercicio
LIMIT 1;
IF countNivel < 1 THEN
INSERT INTO ejercicio (numero,nivel,usuario) VALUES(pNumeroEjercicio, 1 /*Valor de Nivel Facil*/,pUsuario);
END IF;
SELECT
nivel
INTO pNivel
FROM ejercicio
WHERE usuario=pUsuario
AND numero = pNumeroEjercicio
LIMIT 1;
END |
ALTER TABLE ? NOCHECK CONSTRAINT ALL
ALTER TABLE ? DISABLE TRIGGER ALL
DELETE FROM ?
ALTER TABLE ? CHECK CONSTRAINT ALL
ALTER TABLE ? ENABLE TRIGGER ALL
SELECT * FROM ?
|
DROP TABLE IF EXISTS cash_sessions; |
/**
* Creates table matching Illuminate section ids with subjects and travel groups.
* When syncing gradebooks, teachers see the Illuminate section id, but not the
* local section id which contains the travel group name. This query pulls this
* information and presents it in a format teachers can easily use. */
SELECT DISTINCT site.site_name, u.last_name, u.first_name,
CASE WHEN COUNT(DISTINCT ses.academic_year) = 1 THEN 'Beginner' END
FROM public.users u
INNER JOIN (SELECT user_id, MIN(section_id) AS sid
FROM public.section_teacher_aff
WHERE start_date >= '8/10/15'
GROUP BY user_id) AS sta ON u.user_id = sta.user_id
INNER JOIN public.user_term_role_aff utrf ON utrf.user_id = u.user_id
INNER JOIN public.terms t ON utrf.term_id = t.term_id
INNER JOIN public.roles r ON r.role_id = utrf.role_id
INNER JOIN public.sessions ses ON ses.session_id = t.session_id
INNER JOIN public.sites site ON site.site_id = ses.site_id
WHERE u.active = 't'
AND r.role_name NOT IN ('School Leadership', 'Grade Level Chair')
GROUP BY site.site_name, u.last_name, u.first_name
ORDER BY site.site_name, u.last_name, u.first_name |
CREATE DEFINER=`root`@`localhost` PROCEDURE `sendinvite`(IN typedEmailID VARCHAR(50),IN adEmailID VARCHAR(50))
BEGIN
insert userssendinvite
select typedEmailID,adEmailID;
insert userconnectionrespond
select adEmailID,typedEmailID;
Call showallconnections(typedEmailID);
END |
-- Rename resource_description.parameters to stop confusion with job/analysis/pipeline parameters:
ALTER TABLE resource_description CHANGE COLUMN parameters submission_cmd_args VARCHAR(255) NOT NULL DEFAULT '';
-- Add resource-specific worker_cmd_args :
ALTER TABLE resource_description ADD COLUMN worker_cmd_args VARCHAR(255) NOT NULL DEFAULT '';
-- UPDATE hive_sql_schema_version
UPDATE hive_meta SET meta_value=54 WHERE meta_key='hive_sql_schema_version' AND meta_value='53';
|
INSERT INTO gam_departments VALUES(1,'IT hardware');
INSERT INTO gam_departments VALUES(2,'Finance');
INSERT INTO gam_departments VALUES(3,'Human Resources');
INSERT INTO gam_departments VALUES(4,'IT software');
INSERT INTO gam_departments VALUES(5,'Security');
INSERT INTO gam_employees VALUES(1,'IONESCU','Alin',to_date('10.01.1990','DD.MM.YYYY'),to_date('01.01.2015','DD.MM.YYYY'),'M',900,1);
INSERT INTO gam_employees VALUES(2,'OANCEA','Maria',to_date('31.03.1970','DD.MM.YYYY'),to_date('15.10.2016','DD.MM.YYYY'),'F',4000,1);
INSERT INTO gam_employees VALUES(3,'CRISTESCU','VASILE',to_date('15.04.1984','DD.MM.YYYY'),to_date('20.04.2014','DD.MM.YYYY'),'M',5500,1);
INSERT INTO gam_employees VALUES(4,'POPESCU','Oana',to_date('23.05.1981','DD.MM.YYYY'),to_date('03.06.2016','DD.MM.YYYY'),'F',750,1);
INSERT INTO gam_employees VALUES(5,'STROE','Ion',to_date('29.09.1982','DD.MM.YYYY'),to_date('01.01.2017','DD.MM.YYYY'),'M',3560,2);
INSERT INTO gam_employees VALUES(6,'GRECU','Radu',to_date('31.10.1992','DD.MM.YYYY'),to_date('30.08.2016','DD.MM.YYYY'),'M',4570,2);
INSERT INTO gam_employees VALUES(7,'POPESCU','Mihai',to_date('20.08.1994','DD.MM.YYYY'),to_date('15.06.2015','DD.MM.YYYY'),'M',230,2);
INSERT INTO gam_employees VALUES(8,'GANEA','Bogdan',to_date('01.02.1997','DD.MM.YYYY'),to_date('01.01.2017','DD.MM.YYYY'),'M',1100,2);
INSERT INTO gam_employees VALUES(9,'MARINESCU','Emil',to_date('25.12.1995','DD.MM.YYYY'),to_date('23.05.2016','DD.MM.YYYY'),'M',1200,3);
INSERT INTO gam_employees VALUES(10,'GRIGORE','Raul',to_date('13.10.1993','DD.MM.YYYY'),to_date('06.07.2014','DD.MM.YYYY'),'M',940,3);
INSERT INTO gam_employees VALUES(11,'MARINCA','Eugenia',to_date('29.11.1985','DD.MM.YYYY'),to_date('04.12.2015','DD.MM.YYYY'),'F',900,3);
INSERT INTO gam_employees VALUES(12,'POPA','Rodica',to_date('06.04.1988','DD.MM.YYYY'),to_date('20.10.2015','DD.MM.YYYY'),'F',700,3);
INSERT INTO gam_employees VALUES(13,'ICHIM','Cristina',to_date('15.11.1993','DD.MM.YYYY'),to_date('05.11.2016','DD.MM.YYYY'),'F',200,null);
COMMIT;
--2. Selectati toti angajatii care au data nasterii intre 01.01.1990 si 31.12.1995
SELECT id_emp,
nume,
prenume,
to_char(data_nasterii,'DD.MM.YYYY') DATA_NASTERII,
to_char(data_angajare,'DD.MM.YYYY') DATA_ANGAJARE,
gen,
salariul,
id_dept
FROM GAM_EMPLOYEES
WHERE data_nasterii>=to_date('01.01.1990','DD.MM.YYYY') and data_nasterii<=to_date('31.12.1995','DD.MM.YYYY');
--3. Numarati angajatii din fiecare departament, care au data angajarii>01.01.2016.
SELECT id_dept,
COUNT(*) as Numar_angajati
FROM GAM_EMPLOYEES
WHERE data_angajare>=to_date('01.01.2016','DD.MM.YYYY')
GROUP BY id_dept;
--4. Selectati angajatii din fiecare department care au primele 2 salarii ca marime din departamentul lor.
SELECT * FROM (
SELECT nume,
prenume,
to_char(data_nasterii,'DD.MM.YYYY') DATA_NASTERII,
to_char(data_angajare,'DD.MM.YYYY') DATA_ANGAJARE,
salariul,
id_dept,
ROW_NUMBER() OVER (PARTITION BY id_dept order by salariul DESC) R
FROM gam_employees)
WHERE R<3;
--5. Afisati toti angajatii care au salariul mai mare decat media salariului din firma
SELECT id_emp,
nume,
prenume,
to_char(data_nasterii,'DD.MM.YYYY') DATA_NASTERII,
to_char(data_angajare,'DD.MM.YYYY') DATA_ANGAJARE,
gen,
salariul,
id_dept
FROM gam_employees
WHERE salariul >= ( SELECT AVG(salariul)
FROM gam_employees );
--6. Scrieti un query care sa afiseze intr-o singura coloana.
SELECT 'Angajatul '||nume||' '||prenume||' are salariul '||salariul||'.'
FROM gam_employees;
--7. Scrieti un query care sa afiseze pozitia caracterului ‘o’ din coloana NUME pentru angajatii care au acest character in nume.
SELECT nume,
prenume,
INSTR(nume, 'O') as POZITIE
FROM gam_employees
WHERE nume LIKE '%O%';
|
CREATE USER jflanegan
IDENTIFIED BY password;
//2. login denied without create session
GRANT CREATE SESSION, CREATE ANY TABLE, ALTER ANY TABLE
TO jflanegan;
CREATE ROLE CUSTOMERREP;
GRANT INSERT, DELETE
ON STUDENT.ORDERS
TO CUSTOMERREP;
GRANT INSERT, DELETE
ON STUDENT.ORDERITEMS
TO CUSTOMERREP;
GRANT CUSTOMERREP
TO jflanegan;
//6. login as jflanegan and determine privilidges...derp
REVOKE DELETE
ON STUDENT.ORDERS
FROM CUSTOMERREP;
REVOKE DELETE
ON STUDENT.ORDERITEMS
FROM CUSTOMERREP;
REVOKE CUSTOMERREP
FROM jflanegan;
DROP ROLE CUSTOMERREP;
DROP USER jflanegan; |
/*
VERSION
Formatted
*/
SELECT A.*, C.DES SERVICE_NAME, D.STRING04 HARDGOOD_TYPE FROM
(
SELECT CA.ACTION_TYPE_ENTRY , CA.CAXACT, CA.CACHKNUM, CA.CACHKDATE, CA.CACHKAMT_PAY, TTD.DESCRIPTION, BA.BILLING_ACCOUNT_CODE,
CA.ORDER_ID_ENTRY, CAREFERENCE4, CAREFERENCE5,
CASE
WHEN CAREFERENCE4 IN ('CC', 'DC') THEN CABANKACC||'****'||CAREFERENCE20
ELSE NULL
END "CARD_NUMBER"
FROM CASHRECEIPTS_ALL CA, TRANSACTION_TYPE_DEF TTD, FIN_USE_CASE_DEF UC,BILLING_ACCOUNT BA
WHERE CA.CATYPE = TTD.TRANS_TYPE_ID
AND CA.CAREASONCODE = UC.REASONCODE
AND TTD.SHDES = 'PAR'
AND UC.SHDES = 'PAYMENTREFUND'
AND CA.CUSTOMER_ID = BA.CUSTOMER_ID
AND CA.ACTION_TYPE_ENTRY = 'RETURN'
) A,
(
SELECT CADXACT, CADOXACT, CADOSEQ
FROM CASHTRAILER
) B,
(
SELECT OTXACT, OTSEQ, SN.DES
FROM ORDERTRAILER OT, MPUSNTAB SN
WHERE OT.SNCODE = SN.SNCODE
) C ,
(
SELECT OTXACT, OTSEQ, STRING04, STRING10, EXT_ID, ACTION_TYPE_MODIFICATION
FROM ORDERTRLR_CHARACTERISTICS OTC, CHARACTERISTICS_DEF CD
WHERE OTC.CHAR_ID = CD.CHAR_ID
AND CD.CHAR_SHDES ='FDHGE'
) D
WHERE A.CAXACT = B.CADXACT
AND B.CADOXACT = C.OTXACT
AND B.CADOSEQ = C.OTSEQ
AND C.OTXACT = D.OTXACT(+)
AND C.OTSEQ = D.OTSEQ(+)
AND A.ORDER_ID_ENTRY = D.STRING10 (+)
ORDER BY CAXACT DESC
|
-- phpMyAdmin SQL Dump
-- version 4.4.15.9
-- https://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 31, 2018 at 09:29 PM
-- Server version: 5.6.37
-- PHP Version: 5.6.31
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `sales`
--
-- --------------------------------------------------------
--
-- Table structure for table `characters`
--
CREATE TABLE IF NOT EXISTS `characters` (
`id` int(2) NOT NULL,
`name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`money in hand` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `characters`
--
INSERT INTO `characters` (`id`, `name`, `money in hand`) VALUES
(1, '孙红雷', 0),
(2, '黄渤', 0),
(3, '黄磊', 0),
(4, '小猪', 0),
(5, '王迅', 0),
(6, '张艺兴', 150);
-- --------------------------------------------------------
--
-- Table structure for table `factory`
--
CREATE TABLE IF NOT EXISTS `factory` (
`id` int(11) NOT NULL,
`rent` int(11) NOT NULL,
`numEmployees` int(11) NOT NULL,
`empSalary` int(11) NOT NULL,
`owner` int(11) DEFAULT NULL,
`stock` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `factory`
--
INSERT INTO `factory` (`id`, `rent`, `numEmployees`, `empSalary`, `owner`, `stock`) VALUES
(1, 50, 0, 0, 6, 0),
(2, 50, 0, 0, NULL, 0),
(3, 50, 0, 0, NULL, 0),
(4, 50, 0, 0, NULL, 0);
-- --------------------------------------------------------
--
-- Table structure for table `factoryTransaction`
--
CREATE TABLE IF NOT EXISTS `factoryTransaction` (
`id` int(11) NOT NULL,
`factory_id` int(11) NOT NULL,
`date` date NOT NULL,
`numEmp` int(11) NOT NULL,
`newNumEmp` int(11) NOT NULL,
`owner` int(11) DEFAULT NULL,
`newOwner` int(11) NOT NULL,
`empSalary` int(11) NOT NULL,
`newEmpSalary` int(11) NOT NULL,
`MoneytoBuyfactory` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE IF NOT EXISTS `orders` (
`order_id` int(11) NOT NULL,
`factory_id` int(11) DEFAULT NULL,
`sales_id` int(11) DEFAULT NULL,
`numItem` int(11) NOT NULL,
`deposit` int(11) NOT NULL,
`duration` int(11) NOT NULL,
`startDate` date NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `orders`
--
INSERT INTO `orders` (`order_id`, `factory_id`, `sales_id`, `numItem`, `deposit`, `duration`, `startDate`) VALUES
(1, 1, 2, 10, 100, 3, '2018-01-01');
-- --------------------------------------------------------
--
-- Table structure for table `price`
--
CREATE TABLE IF NOT EXISTS `price` (
`id` int(11) NOT NULL,
`salesPrice` int(11) NOT NULL,
`salesDate` date NOT NULL,
`factoryPrice` int(11) NOT NULL,
`factoryDate` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `price`
--
INSERT INTO `price` (`id`, `salesPrice`, `salesDate`, `factoryPrice`, `factoryDate`) VALUES
(1, 150, '2018-01-01', 180, '2018-02-01');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `characters`
--
ALTER TABLE `characters`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `factory`
--
ALTER TABLE `factory`
ADD PRIMARY KEY (`id`),
ADD KEY `ownerdef` (`owner`);
--
-- Indexes for table `factoryTransaction`
--
ALTER TABLE `factoryTransaction`
ADD PRIMARY KEY (`id`),
ADD KEY `factoryUpdate` (`factory_id`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`order_id`),
ADD KEY `factory-order` (`factory_id`),
ADD KEY `sales-order` (`sales_id`);
--
-- Indexes for table `price`
--
ALTER TABLE `price`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `factoryTransaction`
--
ALTER TABLE `factoryTransaction`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `order_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `factory`
--
ALTER TABLE `factory`
ADD CONSTRAINT `ownerdef` FOREIGN KEY (`owner`) REFERENCES `characters` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `factoryTransaction`
--
ALTER TABLE `factoryTransaction`
ADD CONSTRAINT `factoryUpdate` FOREIGN KEY (`factory_id`) REFERENCES `factory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
ADD CONSTRAINT `factory-order` FOREIGN KEY (`factory_id`) REFERENCES `factory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `sales-order` FOREIGN KEY (`sales_id`) REFERENCES `characters` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `price`
--
ALTER TABLE `price`
ADD CONSTRAINT `order-price` FOREIGN KEY (`id`) REFERENCES `orders` (`order_id`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE TABLE dbo.Products
(
ProductID int PRIMARY KEY NOT NULL,
ProductName varchar(25) NOT NULL,
Price money NULL,
ProdDesc text NULL
); |
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
DROP DATABASE IF EXISTS `quantox`;
CREATE DATABASE quantox;
USE quantox;
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1; |
USE dmab0914_2sem_7;
CREATE TABLE Zipcode_City
(
zipcode int NOT NULL,
city varchar(15) NOT NULL,
PRIMARY KEY(zipcode, city)
) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.