text stringlengths 6 9.38M |
|---|
select
p.PaymentWayName
,cast(cast(crr.Score * 100 as int) / 5.0 as int) * 0.05 as Score
,p.ClientId
,p.Productid
,p.Amount
,case
when p.Status = 8 then N'Приостановлен'
else p.StatusName
end as StatusName
,p.StartedOn
,dateadd(d, p.Period, p.StartedOn) as ContractPayDay
,p.DatePaid
,cb.*
from prd.vw_product p
outer apply
(
select top 1
nullif(crr.Score, 0) as Score
from cr.CreditRobotResult crr
where crr.ClientId = p.ClientId
order by crr.CreatedOn
) crr
outer apply
(
select
sum(cb.TotalAmount) as AmountPaid
,sum(cb.TotalPercent) as PercentPaid
,sum(cb.TotalDebt - cb.TotalAmount - cb.TotalPercent) as OtherPaid
from bi.CreditBalance cb
where cb.ProductId = p.Productid
and cb.InfoType = 'payment'
) cb
where p.StartedOn >= '20180101'
and p.Status > 2
order by 1, 2, 3, 4 |
delete from HtmlLabelInfo where indexId=20450
/
delete from HtmlLabelIndex where id=20450
/
INSERT INTO HtmlLabelIndex values(20450,'附件存放目录')
/
INSERT INTO HtmlLabelInfo VALUES(20450,'附件存放目录',7)
/
INSERT INTO HtmlLabelInfo VALUES(20450,'Accessory Category',8)
/
delete from HtmlLabelInfo where indexId=20476
/
delete from HtmlLabelIndex where id=20476
/
INSERT INTO HtmlLabelIndex values(20476,'附件存放目录未设置!')
/
INSERT INTO HtmlLabelInfo VALUES(20476,'附件存放目录未设置!',7)
/
INSERT INTO HtmlLabelInfo VALUES(20476,'Accessory category has not been set up!',8)
/ |
create database dibai charset utf8;
use dibai;
create table t_user(
f_id bigint unsigned not null primary key,
f_name varchar(20) not null default '' comment '姓名',
f_identify_code char(4) not null default '' comment '最新有效验证码',
f_id_number char(18) not null default '' unique comment '身份证',
f_mobile char(11) not null default '' unique comment '最新手机号',
f_invitation_code char(6) not null default '' comment '注册时输入的邀请码',
f_register_time datetime not null default current_timestamp comment '手机验证时间',
f_auth_time datetime not null default '0000-00-00 00:00:00' comment '身份证验证时间',
f_auth_status tinyint unsigned not null default 0 comment '认证状态0手机认证,1身份证验证,2缴纳押金,3完成认证',
f_use_status tinyint unsigned not null default 0 comment '使用状态0未使用1正在使用',
f_use_count int unsigned not null default 0 comment '骑行次数',
f_balance int not null default 0 comment '余额,单位分',
f_discount_coupon int unsigned not null default 0 comment '有效折扣券数量',
f_credit int unsigned not null default 100 comment '信誉积分',
f_gender tinyint unsigned not null dafault 0 comment '性别 0男 1女',
f_deposit int unsigned not null default 0 comment '押金,单位分',
f_pay_channel tinyint unsigned not null default 0 comment '支付渠道0支付宝1微信2银联',
index idx_register_time(f_register_time),
index idx_auth_time(f_auth_time),
index idx_balance(f_balance)
);
create table t_sms_identify(
f_id bigint unsigned not null primary key,
f_to char(11) not null default '' comment '发送者手机号',
f_app_id char(32) not null default '' comment '短信运营商appId',
f_identify_code char(4) not null default '' comment '验证码',
f_template_id varchar(10) not null default '' comment '短信模板ID',
f_datas varchar(70) not null default '' comment '模板占位符数据',
f_create_time datetime not null default current_timestamp comment '记录构建时间',
f_date_created datetime not null default '0000-00-00 00:00:00' comment '短信运营商返回的短信创建时间',
f_sms_message_sid char(32) not null default '' unique comment '短信唯一标示,运营商返回',
f_status_code char(6) not null default '' comment '状态码,运营商返回',
f_status tinyint not null default 0 comment '短信状态0调用发送接口,1返回状态码非000000,2已成功发送,不代表到达,3返回内容与预期不符,4返回dateCreated格式错误,5已送达,6丢失',
f_query_status_code char(6) not null default '' comment '状态报告请求的状态码,000000成功,112356短信已发出但未收到回执请稍后查询,112351短信状态不存在',
f_receiver char(11) not null default '' comment '接收短信的手机号码',
f_send_status char(1) not null default '' comment '通道发送状态,0成功1失败',
f_send_time char(19) not null default '' comment '发送时间',
f_deliver_status char(0) not null default '' comment '到达状态,即运营商网关返回的手机接收报告。送达结果:0成功1失败',
f_receive_time char(19) not null default '' comment '状态报告时间,即运营商网关返回的手机接收报告时间',
index idx_to_identify_code(f_to,f_identify_code),
index idx_create_time(f_create_time),
index idx_date_created(f_date_created)
);
create table t_sms_template(
f_id bigint unsigned not null primary key,
f_product_type char(1) not null default '',
f_addr varchar(255) not null default '',
f_title varchar(50) not null default '',
f_signature varchar(50) not null default '',
f_template_content varchar(70) not null default '',
f_status_code char(6) not null default '',
f_template_id varchar(10) not null default '',
f_create_time datetime not null default current_timestamp,
f_response_time datetime not null default '0000-00-00 00:00:00',
f_status tinyint not null default 0,
index idx_title(f_title),
index idx_create_time(f_create_time),
index idx_response_time(f_response_time)
);
create table f_deposit_record(
f_id bigint unsigned not null primary key,
f_user_id bigint unsigned not null default 0 comment '用户ID',
f_trade_type tinyint unsigned not null default 0 comment '交易类型0充值 1退款',
f_pay_channel tinyint unsigned not null default 0 comment '押金渠道0支付宝1微信2银联',
f_amount int unsigned not null default 0 comment '押金或退款,单位分',
f_trade_type tinyint unsigned not null default 0 comment '交易状态0创建1进行中2成功3失败',
f_account_id varchar(50) not null default '' comment '客户交易账号',
f_trade_instruction char(28) not null default '' unique comment '交易流水号',
f_create_time datetime not null default current_timestamp comment '交易开始时间',
f_end_time datetime not null default '0000-00-00 00:00:00' comment '交易关闭时间',
index idx_user_id(f_user_id),
index idx_end_time(f_end_time),
);
|
rem
rem $Header: catprc.sql,v 1.6 1995/03/16 12:18:57 mramache Exp $ prctrg.sql
rem
Rem Copyright (c) 1990 by Oracle Corporation
Rem NAME
Rem CATPRC.SQL
Rem FUNCTION
Rem Creates data dictionary views for stored procedures and triggers.
Rem NOTES
Rem Must be run while connected to sys or internal.
Rem
Rem MODIFIED
Rem mramache 03/13/95 - user_errors now handles triggers
Rem wmaimone 05/26/94 - #186155 add public synoyms for dba_
Rem jbellemo 05/09/94 - merge changes from branch 1.2.710.2
Rem jbellemo 12/17/93 - merge changes from branch 1.2.710.1
Rem jbellemo 04/27/94 - #199905: fix security in ALL_ERRORS
Rem jbellemo 11/09/93 - #170173: change uid to userenv schemaid
Rem tpystyne 10/28/92 - use create or replace view
Rem glumpkin 10/20/92 - Renamed from PRCTRG.SQL
Rem mmoore 10/15/92 - #(131033) add trigger column views for marketing
Rem mmoore 09/29/92 - #(131033) add more info to the triggers view
Rem jwijaya 08/17/92 - add sequence to error$
Rem jwijaya 07/17/92 - remove database link owner from name
Rem mmoore 06/03/92 - #(111923) change trigger view names
Rem mmoore 06/02/92 - #(96526) remove v$enabledroles
Rem mroberts 06/01/92 - change privileges for all_errors view
Rem rkooi 04/15/92 - test tools
Rem rkooi 01/18/92 - add synonym
Rem rkooi 01/18/92 - add object_sizes views
Rem rkooi 01/10/92 - synchronize with catalog.sql
Rem rkooi 12/23/91 - testing
Rem rkooi 10/20/91 - add public_dependency
Rem jwijaya 07/14/91 - remove LINKNAME IS NULL
Rem rkooi 05/22/91 - get rid of _object in some catalog names
Rem rkooi 05/22/91 - change *_references to *_dependencies
Rem rkooi 05/05/91 - fix up permissions on all* cats
Rem jwijaya 04/12/91 - remove LINKNAME IS NULL
Rem rkooi 03/29/91 - add views for pcode & diana
Rem Kooi 03/12/91 - Creation
Rem Kooi 03/12/91 - Creation
Rem
remark
remark FAMILY "ERRORS"
remark Errors for stored objects - currently these are
remark PL/SQL packages, package bodies, procedures and functions.
remark
create or replace view USER_ERRORS
(NAME, TYPE, SEQUENCE, LINE, POSITION, TEXT)
as
select o.name,
decode(o.type, 4, 'VIEW', 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
e.sequence, e.line, e.position, e.text
from sys.obj$ o, sys.error$ e
where o.obj# = e.obj#
and o.type in (4, 7, 8, 9, 11, 12)
and o.owner# = userenv('SCHEMAID')
/
comment on table USER_ERRORS is
'Current errors on stored objects owned by the user'
/
comment on column USER_ERRORS.NAME is
'Name of the object'
/
comment on column USER_ERRORS.TYPE is
'Type: "VIEW", "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE BODY" or "TRIGGER"'
/
comment on column USER_ERRORS.SEQUENCE is
'Sequence number used for ordering purposes'
/
comment on column USER_ERRORS.LINE is
'Line number at which this error occurs'
/
comment on column USER_ERRORS.POSITION is
'Position in the line at which this error occurs'
/
comment on column USER_ERRORS.TEXT is
'Text of the error'
/
drop public synonym USER_ERRORS
/
create public synonym USER_ERRORS for USER_ERRORS
/
grant select on USER_ERRORS to public with grant option
/
remark
remark User is allowed to see errors on any object that they own
remark or could have created.
remark
create or replace view ALL_ERRORS
(OWNER, NAME, TYPE, SEQUENCE, LINE, POSITION, TEXT)
as
select u.name, o.name,
decode(o.type, 4, 'VIEW', 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
e.sequence, e.line, e.position, e.text
from sys.obj$ o, sys.error$ e, sys.user$ u
where o.obj# = e.obj#
and o.owner# = u.user#
and o.type in (4, 7, 8, 9, 11, 12)
and
(
o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
or
(
(
(
(o.type = 7 or o.type = 8 or o.type = 9)
and
o.obj# in (select obj# from sys.objauth$
where grantee# in (select kzsrorol from x$kzsro)
and privilege# = 12 /* EXECUTE */)
)
or
(
o.type = 4
and
o.obj# in (select obj# from sys.objauth$
where grantee# in (select kzsrorol from x$kzsro)
and privilege# in (3 /* DELETE */, 6 /* INSERT */,
7 /* LOCK */, 9 /* SELECT */,
10 /* UPDATE */))
)
or
exists
(
select null from sys.sysauth$
where grantee# in (select kzsrorol from x$kzsro)
and
(
(
/* procedure */
(o.type = 7 or o.type = 8 or o.type = 9)
and
(
privilege# = -144 /* EXECUTE ANY PROCEDURE */
or
privilege# = -141 /* CREATE ANY PROCEDURE */
)
)
or
(
/* trigger */
o.type = 12 and
privilege# = -152 /* CREATE ANY TRIGGER */
)
or
(
/* package body */
o.type = 11 and
privilege# = -141 /* CREATE ANY PROCEDURE */
)
or
(
/* view */
o.type = 4
and
(
privilege# in ( -91 /* CREATE ANY VIEW */,
-45 /* LOCK ANY TABLE */,
-47 /* SELECT ANY TABLE */,
-48 /* INSERT ANY TABLE */,
-49 /* UPDATE ANY TABLE */,
-50 /* DELETE ANY TABLE */)
)
)
)
)
)
)
)
/
comment on table ALL_ERRORS is
'Current errors on stored objects that user is allowed to create'
/
comment on column ALL_ERRORS.OWNER is
'Owner of the object'
/
comment on column ALL_ERRORS.NAME is
'Name of the object'
/
comment on column ALL_ERRORS.TYPE is
'Type: "VIEW", "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE BODY" or "TRIGGER"'
/
comment on column ALL_ERRORS.SEQUENCE is
'Sequence number used for ordering purposes'
/
comment on column ALL_ERRORS.LINE is
'Line number at which this error occurs'
/
comment on column ALL_ERRORS.POSITION is
'Position in the line at which this error occurs'
/
comment on column ALL_ERRORS.TEXT is
'Text of the error'
/
drop public synonym ALL_ERRORS
/
create public synonym ALL_ERRORS for ALL_ERRORS
/
grant select on ALL_ERRORS to public with grant option
/
create or replace view DBA_ERRORS
(OWNER, NAME, TYPE, SEQUENCE, LINE, POSITION, TEXT)
as
select u.name, o.name,
decode(o.type, 4, 'VIEW', 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
e.sequence, e.line, e.position, e.text
from sys.obj$ o, sys.error$ e, sys.user$ u
where o.obj# = e.obj#
and o.owner# = u.user#
and o.type in (4, 7, 8, 9, 11, 12)
/
drop public synonym DBA_ERRORS
/
create public synonym DBA_ERRORS for DBA_ERRORS
/
comment on table DBA_ERRORS is
'Current errors on all stored objects in the database'
/
comment on column DBA_ERRORS.NAME is
'Name of the object'
/
comment on column DBA_ERRORS.TYPE is
'Type: "VIEW", "PROCEDURE", "FUNCTION", "PACKAGE", "PACKAGE BODY" or "TRIGGER"'
/
comment on column DBA_ERRORS.SEQUENCE is
'Sequence number used for ordering purposes'
/
comment on column DBA_ERRORS.LINE is
'Line number at which this error occurs'
/
comment on column DBA_ERRORS.POSITION is
'Position in the line at which this error occurs'
/
comment on column DBA_ERRORS.TEXT is
'Text of the error'
/
remark
remark FAMILY "SOURCE"
remark SOURCE for stored objects - currently these are
remark PL/SQL packages, package bodies, procedures and functions.
remark
create or replace view USER_SOURCE
(NAME, TYPE, LINE, TEXT)
as
select o.name,
decode(o.type, 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 'UNDEFINED'),
s.line, s.source
from sys.obj$ o, sys.source$ s
where o.obj# = s.obj#
and o.type in (7, 8, 9, 11)
and o.owner# = userenv('SCHEMAID')
/
comment on table USER_SOURCE is
'Source of stored objects accessible to the user'
/
comment on column USER_SOURCE.NAME is
'Name of the object'
/
comment on column USER_SOURCE.TYPE is
'Type of the object: "PROCEDURE", "FUNCTION", "PACKAGE" or "PACKAGE BODY"'
/
comment on column USER_SOURCE.LINE is
'Line number of this line of source'
/
comment on column USER_SOURCE.TEXT is
'Source text'
/
drop public synonym USER_SOURCE
/
create public synonym USER_SOURCE for USER_SOURCE
/
grant select on USER_SOURCE to public with grant option
/
create or replace view ALL_SOURCE
(OWNER, NAME, TYPE, LINE, TEXT)
as
select u.name, o.name,
decode(o.type, 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 'UNDEFINED'),
s.line, s.source
from sys.obj$ o, sys.source$ s, sys.user$ u
where o.obj# = s.obj#
and o.owner# = u.user#
and o.type in (7, 8, 9, 11)
and
(
o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
or
(
(
(
(o.type = 7 or o.type = 8 or o.type = 9)
and
o.obj# in (select obj# from sys.objauth$
where grantee# in (select kzsrorol from x$kzsro)
and privilege# = 12 /* EXECUTE */)
)
or
exists
(
select null from sys.sysauth$
where grantee# in (select kzsrorol from x$kzsro)
and
(
(
/* procedure */
(o.type = 7 or o.type = 8 or o.type = 9)
and
(
privilege# = -144 /* EXECUTE ANY PROCEDURE */
or
privilege# = -141 /* CREATE ANY PROCEDURE */
)
)
or
(
/* package body */
o.type = 11 and
privilege# = -141 /* CREATE ANY PROCEDURE */
)
)
)
)
)
)
/
comment on table ALL_SOURCE is
'Current source on stored objects that user is allowed to create'
/
comment on column ALL_SOURCE.OWNER is
'Owner of the object'
/
comment on column ALL_SOURCE.NAME is
'Name of the object'
/
comment on column ALL_SOURCE.TYPE is
'Type of the object: "PROCEDURE", "FUNCTION", "PACKAGE" or "PACKAGE BODY"'
/
comment on column ALL_SOURCE.LINE is
'Line number of this line of source'
/
comment on column ALL_SOURCE.TEXT is
'Source text'
/
drop public synonym ALL_SOURCE
/
create public synonym ALL_SOURCE for ALL_SOURCE
/
grant select on ALL_SOURCE to public with grant option
/
create or replace view DBA_SOURCE
(OWNER, NAME, TYPE, LINE, TEXT)
as
select u.name, o.name,
decode(o.type, 7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE',
11, 'PACKAGE BODY', 'UNDEFINED'),
s.line, s.source
from sys.obj$ o, sys.source$ s, sys.user$ u
where o.obj# = s.obj#
and o.owner# = u.user#
and o.type in (7, 8, 9, 11)
/
drop public synonym DBA_SOURCE
/
create public synonym DBA_SOURCE for DBA_SOURCE
/
comment on table DBA_SOURCE is
'Source of all stored objects in the database'
/
comment on column DBA_SOURCE.NAME is
'Name of the object'
/
comment on column DBA_SOURCE.TYPE is
'Type of the object: "PROCEDURE", "FUNCTION", "PACKAGE" or "PACKAGE BODY"'
/
comment on column DBA_SOURCE.LINE is
'Line number of this line of source'
/
comment on column DBA_SOURCE.TEXT is
'Source text'
/
remark
remark FAMILY "TRIGGERS"
remark Database trigger definitions.
remark This family has no "ALL" member.
remark
create or replace view USER_TRIGGERS
(TRIGGER_NAME, TRIGGER_TYPE, TRIGGERING_EVENT, TABLE_OWNER, TABLE_NAME,
REFERENCING_NAMES, WHEN_CLAUSE, STATUS, DESCRIPTION, TRIGGER_BODY)
as
select trigobj.name,
decode(t.type, 0, 'BEFORE STATEMENT',
1, 'BEFORE EACH ROW',
2, 'AFTER STATEMENT',
3, 'AFTER EACH ROW', 'UNDEFINED'),
decode(t.insert$*100 + t.update$*10 + t.delete$,
100, 'INSERT',
010, 'UPDATE',
001, 'DELETE',
110, 'INSERT OR UPDATE',
101, 'INSERT OR DELETE',
011, 'UPDATE OR DELETE',
111, 'INSERT OR UPDATE OR DELETE', 'ERROR'),
u.name, tabobj.name,
'REFERENCING NEW AS '||t.refnewname||' OLD AS '||t.refoldname,
t.whenclause,decode(t.enabled, 0, 'DISABLED', 1, 'ENABLED', 'ERROR'),
t.definition,t.action
from sys.obj$ trigobj, sys.obj$ tabobj, sys.trigger$ t, sys.user$ u
where trigobj.obj# = t.obj#
and tabobj.obj# = t.baseobject
and trigobj.owner# = userenv('SCHEMAID')
and tabobj.owner# = u.user#
/
comment on table USER_TRIGGERS is
'Triggers owned by the user'
/
comment on column USER_TRIGGERS.TRIGGER_NAME is
'Name of the trigger'
/
comment on column USER_TRIGGERS.TRIGGER_TYPE is
'Type of the trigger (when it fires) - BEFORE/AFTER and STATEMENT/ROW'
/
comment on column USER_TRIGGERS.TRIGGERING_EVENT is
'Statement that will fire the trigger - INSERT, UPDATE and/or DELETE'
/
comment on column USER_TRIGGERS.TABLE_OWNER is
'Owner of the table that this trigger is associated with'
/
comment on column USER_TRIGGERS.TABLE_NAME is
'Name of the table that this trigger is associated with'
/
comment on column USER_TRIGGERS.REFERENCING_NAMES is
'Names used for referencing to OLD and NEW values within the trigger'
/
comment on column USER_TRIGGERS.WHEN_CLAUSE is
'WHEN clause must evaluate to true in order for triggering body to execute'
/
comment on column USER_TRIGGERS.STATUS is
'If DISABLED then trigger will not fire'
/
comment on column USER_TRIGGERS.DESCRIPTION is
'Trigger description, useful for re-creating trigger creation statement'
/
comment on column USER_TRIGGERS.TRIGGER_BODY is
'Action taken by this trigger when it fires'
/
drop public synonym USER_TRIGGERS
/
create public synonym USER_TRIGGERS for USER_TRIGGERS
/
grant select on USER_TRIGGERS to public with grant option
/
create or replace view ALL_TRIGGERS
(OWNER, TRIGGER_NAME, TRIGGER_TYPE, TRIGGERING_EVENT, TABLE_OWNER, TABLE_NAME,
REFERENCING_NAMES, WHEN_CLAUSE, STATUS, DESCRIPTION, TRIGGER_BODY)
as
select triguser.name, trigobj.name,
decode(t.type, 0, 'BEFORE STATEMENT',
1, 'BEFORE EACH ROW',
2, 'AFTER STATEMENT',
3, 'AFTER EACH ROW', 'UNDEFINED'),
decode(t.insert$*100 + t.update$*10 + t.delete$,
100, 'INSERT',
010, 'UPDATE',
001, 'DELETE',
110, 'INSERT OR UPDATE',
101, 'INSERT OR DELETE',
011, 'UPDATE OR DELETE',
111, 'INSERT OR UPDATE OR DELETE', 'ERROR'),
tabuser.name, tabobj.name,
'REFERENCING NEW AS '||t.refnewname||' OLD AS '||t.refoldname,
t.whenclause,decode(t.enabled, 0, 'DISABLED', 1, 'ENABLED', 'ERROR'),
t.definition,t.action
from sys.obj$ trigobj, sys.obj$ tabobj, sys.trigger$ t, sys.user$ tabuser,
sys.user$ triguser
where trigobj.obj# = t.obj#
and tabobj.obj# = t.baseobject
and trigobj.owner# = triguser.user#
and tabobj.owner# = tabuser.user#
and
(
trigobj.owner# = userenv('SCHEMAID') or tabobj.owner# = userenv('SCHEMAID')
or
exists (select null from sys.sysauth$
where grantee# in (select kzsrorol from x$kzsro)
and privilege# = -152 /* CREATE ANY TRIGGER */)
)
/
comment on table ALL_TRIGGERS is
'Triggers accessible to the current user'
/
comment on column ALL_TRIGGERS.OWNER is
'Owner of the trigger'
/
comment on column ALL_TRIGGERS.TRIGGER_NAME is
'Name of the trigger'
/
comment on column ALL_TRIGGERS.TRIGGER_TYPE is
'When the trigger fires - BEFORE/AFTER and STATEMENT/ROW'
/
comment on column ALL_TRIGGERS.TRIGGERING_EVENT is
'Statement that will fire the trigger - INSERT, UPDATE and/or DELETE'
/
comment on column ALL_TRIGGERS.TABLE_OWNER is
'Owner of the table that this trigger is associated with'
/
comment on column ALL_TRIGGERS.TABLE_NAME is
'Name of the table that this trigger is associated with'
/
comment on column ALL_TRIGGERS.REFERENCING_NAMES is
'Names used for referencing to OLD and NEW values within the trigger'
/
comment on column ALL_TRIGGERS.WHEN_CLAUSE is
'WHEN clause must evaluate to true in order for triggering body to execute'
/
comment on column ALL_TRIGGERS.STATUS is
'If DISABLED then trigger will not fire'
/
comment on column ALL_TRIGGERS.DESCRIPTION is
'Trigger description, useful for re-creating trigger creation statement'
/
comment on column ALL_TRIGGERS.TRIGGER_BODY is
'Action taken by this trigger when it fires'
/
drop public synonym ALL_TRIGGERS
/
create public synonym ALL_TRIGGERS for ALL_TRIGGERS
/
grant select on ALL_TRIGGERS to public with grant option
/
create or replace view DBA_TRIGGERS
(OWNER, TRIGGER_NAME, TRIGGER_TYPE, TRIGGERING_EVENT, TABLE_OWNER, TABLE_NAME,
REFERENCING_NAMES, WHEN_CLAUSE, STATUS, DESCRIPTION, TRIGGER_BODY)
as
select trigusr.name, trigobj.name,
decode(t.type, 0, 'BEFORE STATEMENT',
1, 'BEFORE EACH ROW',
2, 'AFTER STATEMENT',
3, 'AFTER EACH ROW', 'UNDEFINED'),
decode(t.insert$*100 + t.update$*10 + t.delete$,
100, 'INSERT',
010, 'UPDATE',
001, 'DELETE',
110, 'INSERT OR UPDATE',
101, 'INSERT OR DELETE',
011, 'UPDATE OR DELETE',
111, 'INSERT OR UPDATE OR DELETE', 'ERROR'),
tabusr.name, tabobj.name,
'REFERENCING NEW AS '||t.refnewname||' OLD AS '||t.refoldname,
t.whenclause,decode(t.enabled, 0, 'DISABLED', 1, 'ENABLED', 'ERROR'),
t.definition,t.action
from sys.obj$ trigobj, sys.obj$ tabobj, sys.trigger$ t,
sys.user$ tabusr, sys.user$ trigusr
where trigobj.obj# = t.obj#
and tabobj.obj# = t.baseobject
and tabobj.owner# = tabusr.user#
and trigobj.owner# = trigusr.user#
/
drop public synonym DBA_TRIGGERS
/
create public synonym DBA_TRIGGERS for DBA_TRIGGERS
/
comment on table DBA_TRIGGERS is
'All triggers in the database'
/
comment on column DBA_TRIGGERS.OWNER is
'Owner of the trigger'
/
comment on column DBA_TRIGGERS.TRIGGER_NAME is
'Name of the trigger'
/
comment on column DBA_TRIGGERS.TRIGGER_TYPE is
'When the trigger fires - BEFORE/AFTER and STATEMENT/ROW'
/
comment on column DBA_TRIGGERS.TRIGGERING_EVENT is
'Statement that will fire the trigger - INSERT, UPDATE and/or DELETE'
/
comment on column DBA_TRIGGERS.TABLE_OWNER is
'Owner of the table that this trigger is associated with'
/
comment on column DBA_TRIGGERS.TABLE_NAME is
'Name of the table that this trigger is associated with'
/
comment on column DBA_TRIGGERS.REFERENCING_NAMES is
'Names used for referencing to OLD and NEW values within the trigger'
/
comment on column DBA_TRIGGERS.WHEN_CLAUSE is
'WHEN clause must evaluate to true in order for triggering body to execute'
/
comment on column DBA_TRIGGERS.STATUS is
'If DISABLED then trigger will not fire'
/
comment on column DBA_TRIGGERS.DESCRIPTION is
'Trigger description, useful for re-creating trigger creation statement'
/
comment on column DBA_TRIGGERS.TRIGGER_BODY is
'Action taken by this trigger when it fires'
/
remark
remark USER_TRIGGER_COLS shows usage of columns in triggers owned by the
remark current user or in triggers on tables owned by the current user
remark
create or replace view USER_TRIGGER_COLS
(TRIGGER_OWNER, TRIGGER_NAME, TABLE_OWNER, TABLE_NAME, COLUMN_NAME,
COLUMN_LIST, COLUMN_USAGE)
as
select /*+ ORDERED NOCOST */ u.name, o.name, u2.name, o2.name, c.name,
max(decode(tc.type,0,'YES','NO')) COLUMN_LIST,
decode(sum(decode(tc.type, 5, 1, -- one occurrence of new in
6, 2, -- one occurrence of old in
9, 4, -- one occurrence of new out
10, 8, -- one occurrence of old out (impossible)
13, 5, -- one occurrence of new in out
14, 10, -- one occurrence of old in out (imp.)
null)
), -- result in the following combinations across occurrences
1, 'NEW IN',
2, 'OLD IN',
3, 'NEW IN OLD IN',
4, 'NEW OUT',
5, 'NEW IN OUT',
6, 'NEW OUT OLD IN',
7, 'NEW IN OUT OLD IN',
'NONE')
from sys.trigger$ t, sys.obj$ o, sys.user$ u, sys.user$ u2,
sys.col$ c, sys.obj$ o2, sys.triggercol$ tc
where t.obj# = tc.obj# -- find corresponding trigger definition
and o.obj# = t.obj# -- and corresponding trigger name
and c.obj# = t.baseobject -- and corresponding row in COL$ of
and c.col# = tc.col# -- the referenced column
and o2.obj# = t.baseobject -- and name of the table containing the trigger
and u2.user# = o2.owner# -- and name of the user who owns the table
and u.user# = o.owner# -- and name of user who owns the trigger
and ((o.owner# = userenv('SCHEMAID') and u.user# = userenv('SCHEMAID')) -- triggers owned by the current user
or
(o2.owner# = userenv('SCHEMAID') and u2.user# = userenv('SCHEMAID'))) -- on the current user's tables
group by u.name, o.name, u2.name, o2.name, c.name
/
comment on table USER_TRIGGER_COLS is
'Column usage in user''s triggers'
/
comment on column USER_TRIGGER_COLS.TRIGGER_OWNER is
'Owner of the trigger'
/
comment on column USER_TRIGGER_COLS.TRIGGER_NAME is
'Name of the trigger'
/
comment on column USER_TRIGGER_COLS.TABLE_OWNER is
'Owner of the table'
/
comment on column USER_TRIGGER_COLS.TABLE_NAME is
'Name of the table on which the trigger is defined'
/
comment on column USER_TRIGGER_COLS.COLUMN_NAME is
'Name of the column used in trigger definition'
/
comment on column USER_TRIGGER_COLS.COLUMN_LIST is
'Is column specified in UPDATE OF clause?'
/
comment on column USER_TRIGGER_COLS.COLUMN_USAGE is
'Usage of column within trigger body'
/
drop public synonym USER_TRIGGER_COLS
/
create public synonym USER_TRIGGER_COLS for USER_TRIGGER_COLS
/
grant select on USER_TRIGGER_COLS to public
/
remark
remark ALL_TRIGGER_COLS shows usage of columns in triggers owned by the
remark current user or in triggers on tables owned by the current user
remark or on all triggers if current user has CREATE ANY TRIGGER privilege
remark (either directly or through a role).
remark
create or replace view ALL_TRIGGER_COLS
(TRIGGER_OWNER, TRIGGER_NAME, TABLE_OWNER, TABLE_NAME, COLUMN_NAME,
COLUMN_LIST, COLUMN_USAGE)
as
select /*+ ORDERED NOCOST */ u.name, o.name, u2.name, o2.name, c.name,
max(decode(tc.type,0,'YES','NO')) COLUMN_LIST,
decode(sum(decode(tc.type, 5, 1, -- one occurrence of new in
6, 2, -- one occurrence of old in
9, 4, -- one occurrence of new out
10, 8, -- one occurrence of old out (impossible)
13, 5, -- one occurrence of new in out
14, 10, -- one occurrence of old in out (imp.)
null)
), -- result in the following combinations across occurrences
1, 'NEW IN',
2, 'OLD IN',
3, 'NEW IN OLD IN',
4, 'NEW OUT',
5, 'NEW IN OUT',
6, 'NEW OUT OLD IN',
7, 'NEW IN OUT OLD IN',
'NONE')
from sys.trigger$ t, sys.obj$ o, sys.user$ u, sys.user$ u2,
sys.col$ c, sys.obj$ o2, sys.triggercol$ tc
where t.obj# = tc.obj# -- find corresponding trigger definition
and o.obj# = t.obj# -- and corresponding trigger name
and c.obj# = t.baseobject -- and corresponding row in COL$ of
and c.col# = tc.col# -- the referenced column
and o2.obj# = t.baseobject -- and name of the table containing the trigger
and u2.user# = o2.owner# -- and name of the user who owns the table
and u.user# = o.owner# -- and name of user who owns the trigger
and
( o.owner# = userenv('SCHEMAID') or o2.owner# = userenv('SCHEMAID')
or
exists -- an enabled role (or current user) with CREATE ANY TRIGGER priv
( select null from sys.sysauth$ sa -- does
where privilege# = -152 -- CREATE ANY TRIGGER privilege exist
and (grantee# in -- for current user or public
(select kzsrorol from x$kzsro) -- currently enabled role
)
)
)
group by u.name, o.name, u2.name, o2.name, c.name
/
comment on table ALL_TRIGGER_COLS is
'Column usage in user''s triggers or in triggers on user''s tables'
/
comment on column ALL_TRIGGER_COLS.TRIGGER_OWNER is
'Owner of the trigger'
/
comment on column ALL_TRIGGER_COLS.TRIGGER_NAME is
'Name of the trigger'
/
comment on column ALL_TRIGGER_COLS.TABLE_OWNER is
'Owner of the table'
/
comment on column ALL_TRIGGER_COLS.TABLE_NAME is
'Name of the table on which the trigger is defined'
/
comment on column ALL_TRIGGER_COLS.COLUMN_NAME is
'Name of the column used in trigger definition'
/
comment on column ALL_TRIGGER_COLS.COLUMN_LIST is
'Is column specified in UPDATE OF clause?'
/
comment on column ALL_TRIGGER_COLS.COLUMN_USAGE is
'Usage of column within trigger body'
/
drop public synonym ALL_TRIGGER_COLS
/
create public synonym ALL_TRIGGER_COLS for ALL_TRIGGER_COLS
/
grant select on ALL_TRIGGER_COLS to public
/
remark
remark DBA_TRIGGER_COLS shows usage of columns in all triggers defined
remark by any user, on any user's table.
remark
create or replace view DBA_TRIGGER_COLS
(TRIGGER_OWNER, TRIGGER_NAME, TABLE_OWNER, TABLE_NAME, COLUMN_NAME,
COLUMN_LIST, COLUMN_USAGE)
as
select /*+ ORDERED NOCOST */ u.name, o.name, u2.name, o2.name, c.name,
max(decode(tc.type,0,'YES','NO')) COLUMN_LIST,
decode(sum(decode(tc.type, 5, 1, -- one occurrence of new in
6, 2, -- one occurrence of old in
9, 4, -- one occurrence of new out
10, 8, -- one occurrence of old out (impossible)
13, 5, -- one occurrence of new in out
14, 10, -- one occurrence of old in out (imp.)
null)
), -- result in the following combinations across occurrences
1, 'NEW IN',
2, 'OLD IN',
3, 'NEW IN OLD IN',
4, 'NEW OUT',
5, 'NEW IN OUT',
6, 'NEW OUT OLD IN',
7, 'NEW IN OUT OLD IN',
'NONE')
from sys.trigger$ t, sys.obj$ o, sys.user$ u, sys.user$ u2,
sys.col$ c, sys.obj$ o2, sys.triggercol$ tc
where t.obj# = tc.obj# -- find corresponding trigger definition
and o.obj# = t.obj# -- and corresponding trigger name
and c.obj# = t.baseobject -- and corresponding row in COL$ of
and c.col# = tc.col# -- the referenced column
and o2.obj# = t.baseobject -- and name of the table containing the trigger
and u2.user# = o2.owner# -- and name of the user who owns the table
and u.user# = o.owner# -- and name of user who owns the trigger
group by u.name, o.name, u2.name, o2.name, c.name
/
drop public synonym DBA_TRIGGER_COLS
/
create public synonym DBA_TRIGGER_COLS for DBA_TRIGGER_COLS
/
comment on table DBA_TRIGGER_COLS is
'Column usage in all triggers'
/
comment on column DBA_TRIGGER_COLS.TRIGGER_OWNER is
'Owner of the trigger'
/
comment on column DBA_TRIGGER_COLS.TRIGGER_NAME is
'Name of the trigger'
/
comment on column DBA_TRIGGER_COLS.TABLE_OWNER is
'Owner of the table'
/
comment on column DBA_TRIGGER_COLS.TABLE_NAME is
'Name of the table on which the trigger is defined'
/
comment on column DBA_TRIGGER_COLS.COLUMN_NAME is
'Name of the column used in trigger definition'
/
comment on column DBA_TRIGGER_COLS.COLUMN_LIST is
'Is column specified in UPDATE OF clause?'
/
comment on column DBA_TRIGGER_COLS.COLUMN_USAGE is
'Usage of column within trigger body'
/
remark
remark FAMILY "DEPENDENCIES"
remark Dependencies between database objects
remark
create or replace view USER_DEPENDENCIES
(NAME, TYPE, REFERENCED_OWNER, REFERENCED_NAME,
REFERENCED_TYPE, REFERENCED_LINK_NAME)
as
select o.name,
decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
decode(po.linkname, null, pu.name, po.remoteowner), po.name,
decode(po.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
po.linkname
from sys.obj$ o, sys.obj$ po, sys.dependency$ d, sys.user$ pu
where o.obj# = d.d_obj#
and po.obj# = d.p_obj#
and po.owner# = pu.user#
and o.owner# = userenv('SCHEMAID')
/
comment on table USER_DEPENDENCIES is
'Dependencies to and from a users objects'
/
comment on column USER_DEPENDENCIES.NAME is
'Name of the object'
/
comment on column USER_DEPENDENCIES.TYPE is
'Type of the object'
/
comment on column USER_DEPENDENCIES.REFERENCED_OWNER is
'Owner of referenced object (remote owner if remote object)'
/
comment on column USER_DEPENDENCIES.REFERENCED_NAME is
'Name of referenced object'
/
comment on column USER_DEPENDENCIES.REFERENCED_TYPE is
'Type of referenced object'
/
comment on column USER_DEPENDENCIES.REFERENCED_LINK_NAME is
'Name of dblink if this is a remote object'
/
drop public synonym USER_DEPENDENCIES
/
create public synonym USER_DEPENDENCIES for USER_DEPENDENCIES
/
grant select on USER_DEPENDENCIES to public with grant option
/
create or replace view ALL_DEPENDENCIES
(OWNER, NAME, TYPE, REFERENCED_OWNER, REFERENCED_NAME,
REFERENCED_TYPE, REFERENCED_LINK_NAME)
as
select u.name, o.name,
decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
decode(po.linkname, null, pu.name, po.remoteowner), po.name,
decode(po.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
po.linkname
from sys.obj$ o, sys.obj$ po, sys.dependency$ d, sys.user$ u, sys.user$ pu
where o.obj# = d.d_obj#
and o.owner# = u.user#
and po.obj# = d.p_obj#
and po.owner# = pu.user#
and
(
o.owner# in (userenv('SCHEMAID'), 1 /* PUBLIC */)
or
(
(
(
(o.type = 7 or o.type = 8 or o.type = 9)
and
o.obj# in (select obj# from sys.objauth$
where grantee# in (select kzsrorol from x$kzsro)
and privilege# = 12 /* EXECUTE */)
)
or
(
o.type = 4
and
o.obj# in (select obj# from sys.objauth$
where grantee# in (select kzsrorol from x$kzsro)
and privilege# in (3 /* DELETE */, 6 /* INSERT */,
7 /* LOCK */, 9 /* SELECT */,
10 /* UPDATE */))
)
or
exists
(
select null from sys.sysauth$
where grantee# in (select kzsrorol from x$kzsro)
and
(
(
/* procedure */
(o.type = 7 or o.type = 8 or o.type = 9)
and
(
privilege# = -144 /* EXECUTE ANY PROCEDURE */
or
privilege# = -141 /* CREATE ANY PROCEDURE */
)
)
or
(
/* trigger */
o.type = 12 and
privilege# = -152 /* CREATE ANY TRIGGER */
)
or
(
/* package body */
o.type = 11 and
privilege# = -141 /* CREATE ANY PROCEDURE */
)
or
(
/* view */
o.type = 4
and
(
privilege# in ( -91 /* CREATE ANY VIEW */,
-45 /* LOCK ANY TABLE */,
-47 /* SELECT ANY TABLE */,
-48 /* INSERT ANY TABLE */,
-49 /* UPDATE ANY TABLE */,
-50 /* DELETE ANY TABLE */)
)
)
)
)
)
)
/* don't worry about tables, sequences, synonyms since they cannot */
/* depend on anything */
)
/
comment on table ALL_DEPENDENCIES is
'Dependencies to and from objects accessible to the user'
/
comment on column ALL_DEPENDENCIES.OWNER is
'Owner of the object'
/
comment on column ALL_DEPENDENCIES.NAME is
'Name of the object'
/
comment on column ALL_DEPENDENCIES.TYPE is
'Type of the object'
/
comment on column ALL_DEPENDENCIES.REFERENCED_OWNER is
'Owner of referenced object (remote owner if remote object)'
/
comment on column ALL_DEPENDENCIES.REFERENCED_NAME is
'Name of referenced object'
/
comment on column ALL_DEPENDENCIES.REFERENCED_TYPE is
'Type of referenced object'
/
comment on column ALL_DEPENDENCIES.REFERENCED_LINK_NAME is
'Name of dblink if this is a remote object'
/
drop public synonym ALL_DEPENDENCIES
/
create public synonym ALL_DEPENDENCIES for ALL_DEPENDENCIES
/
grant select on ALL_DEPENDENCIES to public with grant option
/
create or replace view DBA_DEPENDENCIES
(OWNER, NAME, TYPE, REFERENCED_OWNER, REFERENCED_NAME,
REFERENCED_TYPE, REFERENCED_LINK_NAME)
as
select u.name, o.name,
decode(o.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
decode(po.linkname, null, pu.name, po.remoteowner), po.name,
decode(po.type, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',
4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',
8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',
11, 'PACKAGE BODY', 12, 'TRIGGER', 'UNDEFINED'),
po.linkname
from sys.obj$ o, sys.obj$ po, sys.dependency$ d, sys.user$ u, sys.user$ pu
where o.obj# = d.d_obj#
and o.owner# = u.user#
and po.obj# = d.p_obj#
and po.owner# = pu.user#
/
drop public synonym DBA_DEPENDENCIES
/
create public synonym DBA_DEPENDENCIES for DBA_DEPENDENCIES
/
comment on table DBA_DEPENDENCIES is
'Dependencies to and from objects'
/
comment on column DBA_DEPENDENCIES.OWNER is
'Owner of the object'
/
comment on column DBA_DEPENDENCIES.NAME is
'Name of the object'
/
comment on column DBA_DEPENDENCIES.TYPE is
'Type of the object'
/
comment on column DBA_DEPENDENCIES.REFERENCED_OWNER is
'Owner of referenced object (remote owner if remote object)'
/
comment on column DBA_DEPENDENCIES.REFERENCED_NAME is
'Name of referenced object'
/
comment on column DBA_DEPENDENCIES.REFERENCED_TYPE is
'Type of referenced object'
/
comment on column DBA_DEPENDENCIES.REFERENCED_LINK_NAME is
'Name of dblink if this is a remote object'
/
remark
remark PUBLIC_DEPENDENCIES
remark Hierarchic dependency information by object number
remark
create or replace view PUBLIC_DEPENDENCY
(OBJECT_ID, REFERENCED_OBJECT_ID)
as
select d.d_obj#, d.p_obj# from dependency$ d
/
comment on table PUBLIC_DEPENDENCY is
'Dependencies to and from objects, by object number'
/
comment on column PUBLIC_DEPENDENCY.OBJECT_ID is
'Object number'
/
comment on column PUBLIC_DEPENDENCY.REFERENCED_OBJECT_ID is
'The referenced (parent) object'
/
drop public synonym PUBLIC_DEPENDENCY
/
create public synonym PUBLIC_DEPENDENCY for PUBLIC_DEPENDENCY
/
grant select on PUBLIC_DEPENDENCY to public with grant option
/
remark
remark FAMILY "OBJECT_SIZE"
remark Sizes of pl/sql items.
remark source_size - this part must be in memory when the object
remark is compiled, or dynamically recompiled
remark parsed_size - this part must be in memory when an object that
remark references this object is being compiled
remark code_size - this part must be in memory when this object
remark is executing
remark error_size - this part exists if the object has compilation
remark errors and need only be in memory until the
remark compilation completes
remark Tables and views will also appear if they were ever referenced by
remark a pl/sql object. They will only have a parsed component.
remark
remark Define some of the supporting views
create or replace view CODE_PIECES
(OBJ#, BYTES)
as
select i.obj#, i.length
from sys.idl_ub1$ i
where i.part in (1,2)
union all
select i.obj#, i.length
from sys.idl_ub2$ i
where i.part in (1,2)
union all
select i.obj#, i.length
from sys.idl_sb4$ i
where i.part in (1,2)
union all
select i.obj#, i.length
from sys.idl_char$ i
where i.part in (1,2)
/
create or replace view CODE_SIZE
(OBJ#, BYTES)
as
select c.obj#, sum(c.bytes)
from sys.code_pieces c
group by c.obj#
/
create or replace view PARSED_PIECES
(OBJ#, BYTES)
as
select i.obj#, i.length
from sys.idl_ub1$ i
where i.part = 0
union all
select i.obj#, i.length
from sys.idl_ub2$ i
where i.part = 0
union all
select i.obj#, i.length
from sys.idl_sb4$ i
where i.part = 0
union all
select i.obj#, i.length
from sys.idl_char$ i
where i.part = 0
/
create or replace view PARSED_SIZE
(OBJ#, BYTES)
as
select c.obj#, sum(c.bytes)
from sys.parsed_pieces c
group by c.obj#
/
create or replace view SOURCE_SIZE
(OBJ#, BYTES)
as
select s.obj#, sum(length(s.source))
from sys.source$ s
group by s.obj#
/
create or replace view ERROR_SIZE
(OBJ#, BYTES)
as
select e.obj#, sum(e.textlength)
from sys.error$ e
group by e.obj#
/
create or replace view DBA_OBJECT_SIZE
(OWNER, NAME, TYPE, SOURCE_SIZE, PARSED_SIZE, CODE_SIZE, ERROR_SIZE)
as
select u.name, o.name,
decode(o.type, 2, 'TABLE', 4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE',
7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE', 11, 'PACKAGE BODY',
'UNDEFINED'),
nvl(s.bytes,0), nvl(p.bytes,0), nvl(c.bytes,0), nvl(e.bytes,0)
from sys.obj$ o, sys.user$ u,
sys.source_size s, sys.parsed_size p, sys.code_size c, sys.error_size e
where o.type in (2, 4, 5, 6, 7, 8, 9, 11)
and o.owner# = u.user#
and o.obj# = s.obj# (+)
and o.obj# = p.obj# (+)
and o.obj# = c.obj# (+)
and o.obj# = e.obj# (+)
and nvl(s.bytes,0) + nvl(p.bytes,0) + nvl(c.bytes,0) + nvl(e.bytes,0) > 0
/
drop public synonym DBA_OBJECT_SIZE
/
create public synonym DBA_OBJECT_SIZE for DBA_OBJECT_SIZE
/
comment on table DBA_OBJECT_SIZE is
'Sizes, in bytes, of various pl/sql objects'
/
comment on column DBA_OBJECT_SIZE.OWNER is
'Owner of the object'
/
comment on column DBA_OBJECT_SIZE.NAME is
'Name of the object'
/
comment on column DBA_OBJECT_SIZE.TYPE is
'Type of the object: "TABLE", "VIEW", "SYNONYM", "SEQUENCE", "PROCEDURE",
"FUNCTION", "PACKAGE" or "PACKAGE BODY"'
/
comment on column DBA_OBJECT_SIZE.SOURCE_SIZE is
'Size of the source, in bytes. Must be in memory during compilation, or
dynamic recompilation'
/
comment on column DBA_OBJECT_SIZE.PARSED_SIZE is
'Size of the parsed form of the object, in bytes. Must be in memory when
an object is being compiled that references this object'
/
comment on column DBA_OBJECT_SIZE.CODE_SIZE is
'Code size, in bytes. Must be in memory when this object is executing'
/
comment on column DBA_OBJECT_SIZE.ERROR_SIZE is
'Size of error messages, in bytes. In memory during the compilation of the object when there are compilation errors'
/
create or replace view USER_OBJECT_SIZE
(NAME, TYPE, SOURCE_SIZE, PARSED_SIZE, CODE_SIZE, ERROR_SIZE)
as
select o.name,
decode(o.type, 2, 'TABLE', 4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE',
7, 'PROCEDURE', 8, 'FUNCTION', 9, 'PACKAGE', 11, 'PACKAGE BODY',
'UNDEFINED'),
nvl(s.bytes,0), nvl(p.bytes,0), nvl(c.bytes,0), nvl(e.bytes,0)
from sys.obj$ o,
sys.source_size s, sys.parsed_size p, sys.code_size c, sys.error_size e
where o.type in (2, 4, 5, 6, 7, 8, 9, 11)
and o.owner# = userenv('SCHEMAID')
and o.obj# = s.obj# (+)
and o.obj# = p.obj# (+)
and o.obj# = c.obj# (+)
and o.obj# = e.obj# (+)
and nvl(s.bytes,0) + nvl(p.bytes,0) + nvl(c.bytes,0) + nvl(e.bytes,0) > 0
/
comment on table USER_OBJECT_SIZE is
'Sizes, in bytes, of various pl/sql objects'
/
comment on column USER_OBJECT_SIZE.NAME is
'Name of the object'
/
comment on column USER_OBJECT_SIZE.TYPE is
'Type of the object: "TABLE", "VIEW", "SYNONYM", "SEQUENCE", "PROCEDURE",
"FUNCTION", "PACKAGE" or "PACKAGE BODY"'
/
comment on column USER_OBJECT_SIZE.SOURCE_SIZE is
'Size of the source, in bytes. Must be in memory during compilation, or
dynamic recompilation'
/
comment on column USER_OBJECT_SIZE.PARSED_SIZE is
'Size of the parsed form of the object, in bytes. Must be in memory when
an object is being compiled that references this object'
/
comment on column USER_OBJECT_SIZE.CODE_SIZE is
'Code size, in bytes. Must be in memory when this object is executing'
/
comment on column USER_OBJECT_SIZE.ERROR_SIZE is
'Size of error messages, in bytes. In memory during the compilation of the object when there are compilation errors'
/
drop public synonym USER_OBJECT_SIZE
/
create public synonym USER_OBJECT_SIZE for USER_OBJECT_SIZE
/
grant select on USER_OBJECT_SIZE to public with grant option
/
|
ALTER TABLE `lzh_prize_log`
ADD COLUMN `is_send` tinyint(1) NULL DEFAULT 0 COMMENT '是否已寄出' AFTER `info`;
|
/*create database crimefile;*/
drop table login;
drop table registration;
drop table complaintreg;
drop table crimereport;
drop table complaintstatus;
drop table adminregistration;
drop table prisonerregister;
drop table takecrimeaction;
drop table takecomplaintaction;
drop table postmortem;
drop table hotnews;
drop table feedback;
drop table contactus;
drop table mostwanted1;
drop table mostwanted;
drop table mail;
drop table missingperson;
drop table chargesheet;
drop table premortem;
drop table history;
drop table FIR;
drop table deleteuser;
drop table addelete;
drop table criminalregister;
create table login(username varchar2(20) primary key ,password varchar2(25),status varchar2(10));
insert into login values('vidya','vidya123','u');
insert into login values('athira','athira123','a');
insert into login values('nikita','xxxxxx','u');
insert into login values('sssss','vvvvvvvv','a');
create table registration(name varchar2(20),username varchar2(20) primary key,secretquestion varchar2(50),answer varchar2(50),address varchar2(50),pincode int(9),phone int(9),email varchar2(30),village varchar2(15),taluk varchar2(15),district varchar2(15),state varchar2(15));
insert into registration values('vidya','paru','Where is your house','aaaaaa','akalkssfopoftrlklhgk','695010','2431735','vidi@gmail.com','village','taluk','tvm','kerala');
create table complaintreg(userid varchar2(15) primary key,detailssuspect varchar2(20),Description varchar2(25),Datc date,typeofcrime varchar2(10));
insert into complaintreg values('u321','aaaaaaaaaaa','ccccc','1992-02-10','murder');
create table crimereport(userid varchar2(15) primary key,ninformant varchar2(15),addressinf varchar2(30),detailssuspect varchar2(15),description varchar2(15),datec date);
insert into crimereport values('u321','gowri','aaaaaaaaaa','jajdggffsgdh','eeeeeeeeeeee','1987-11-10');
create table complaintstatus(complaintno varchar2(10),viewstatus varchar2(20));
insert into complaintstatus values('e122','cust');
create table admnregistration(username varchar2(20) ,question varchar2(20),answer varchar2(20),name varchar2(15),designation varchar2(20),officialaddress varchar2(25),phonen int(11),residentialaddress varchar2(25),pincode int(9),phone int(11),email varchar2(30));
insert into admnregistration values('paru','dwwrttyuy','asff','vidya','IG','akalkssfopoftrlklhgk',2462248,'retryuuyiioopplkj','695010','2431735','vidi@gmail.com');
create table prisonerregister(prisonerno varchar2(10),chargesheetno varchar2(15) primary key,nickname varchar2(15),typeofcrime varchar2(15),familymembers varchar2(20),identificationmarks varchar2(25),height varchar2(15),weight varchar2(15),colour varchar2(10));
insert into prisonerregister values('p10','c1','paru','murder','asdfdghjkll','qwertyuiop','169','55','white');
create table criminalregister(criminalno varchar2(10) primary key,name varchar2(15),nickname varchar2(15),age varchar2(10),occupation varchar2(15),crimetype varchar2(15),address varchar2(15),mostyesorno varchar2(12));
insert into criminalregister values('c10','vasu','gundukadu','35','gunda','murder','aaaaaaa');
create table addelete(adminname varchar2(20),securityanswer varchar2(20));
insert into addelete values('john','cat');
create table deleteuser(username varchar2(15) primary key,password varchar2(10),securityanswer varchar2(15));
insert into deleteuser values('sabu','123456','car');
create table FIR(district varchar2(10),Datc date,time varchar2(10),typeofinformation varchar2(15),placeofoccurence varchar2(10),foreignlocal varchar2(15),act varchar2(10),firno varchar2(10),section varchar2(10),diaryrefno varchar2(15),informantadd varchar2(15),passportno varchar2(10),complaintno varchar2(10),police varchar2(10),receivedtime varchar2(10),informationrec varchar2(10),distancefrmpolst varchar2(10));
insert into FIR values('TVM','1987-12-12','9.30am','mail','asddft','local','niuih','f90','ipc12','d123','hgxsgxkhs','p56','c234','asdfg','3.25pm','hfhf','56');
create table history(prisoner varchar2(15) primary key,typecrime varchar2(15),dateofoccu varchar2(10),placeofocc varchar2(15),briefdisofcase varchar2(10));
insert into history values('p12','c123','murder','1990-10-25','gfhg');
create table premortem(premortemno varchar2(10),postmortemno varchar2(10),Doctorsname varchar2(10),policestation varchar2(10),pdatec date);
insert into premortem values('p145','po2435','smith','safsd','1977-09-04');
create table chargesheet(chargesheetno varchar2(10), nameofpolicesta varchar2(10), Datc date, FIRno varchar2(10), district varchar2(10),infname varchar2(15),infaddress varchar2(20),infoccupation varchar2(12),infparticulars varchar2(12),accname varchar2(10),accaddress varchar2(20),male varchar2(15),female varchar2(15),accage int(5),accoccupation varchar2(13),accstatus varchar2(15),accaction varchar2(10),wtsname varchar2(12),wtsaddress varchar2(20),wtsoccupation varchar2(20));
insert into chargesheet values('c234','fzsgf','1987-11-10','f10','TVM','vidhya','aaaaa','occupation','dsagf','atsk','gfdcxgdg','55','gxshgx',55 ,'babu','gsfxx','hjsdh','ssddefffe','dfffefe','dfee');
create table missingperson(firno varchar2(10),district varchar2(10),nameofpol varchar2(10),datem date,dater date,sex varchar2(4), age varchar2(6),complex varchar2(10),height varchar2(5),fat varchar2(10),idmark varchar2(10),apparels varchar2(15),namaddr varchar2(15),bc varchar2(14));
insert into missingperson values('f123','tvm','vanchiyoor','1985-06-22','1985-06-30','M','20','fair','169','fat','blackscar','stud and chain','asggfdffghggggg','ffg');
create table mostwanted(name varchar2(10),age varchar2(10),address varchar2(15),typeofcrime varchar2(10),complexion varchar2(10),hair varchar2(10),built varchar2(10),passportno varchar2(10),casedescription varchar2(10));
insert into mostwanted values('aaaa','12','aaaaaaa','ssss','fair','sssshj','ffff','pppp','hhhhh');
create table mostwanted1(user varchar2(10),name varchar2(10),age varchar2(10),address varchar2(15),typeofcrime varchar2(10),complexion varchar2(10),hair varchar2(10),built varchar2(10),passportno varchar2(10),casedescription varchar2(10));
insert into mostwanted values('aaaa','12','aaaaaaa','ssss','fair','sssshj','ffff','pppp','hhhhh');
create table contactus(name varchar2(15),email varchar2(17),fax varchar2(13),address varchar2(14),message varchar2(16));
insert into contactus values('sds','vvasb@gmail.com','45667','ddds','gghjjj');
create table feedback(name varchar2(15),email varchar2(17),message varchar2(45));
insert into feedback values('sds','vvasb@gmail.com','gghjjj');
create table hotnews(matter varchar2(40),time varchar2(10),place varchar2(15));
insert into hotnews values('aasasasasasasasasasasasa','12:10','hjsh');
create table mail(to1 varchar2(30),from1 varchar2(30),cc varchar2(25),bcc varchar2(25),subject varchar2(30),msg varchar2(70));
insert into mail values('cfms@.com','user@.com','ccc','bccc','sub','mess');
create table postmortem(postno varchar2(12),dname varchar2(12),postno2 varchar2(12),post1 varchar2(13));
create table takecomplaintaction(user varchar2(19),complaintid varchar2(12) primary key,takeaction varchar2(35));
create table takecrimeaction(user varchar2(19),crimeid varchar2(12) primary key,takeaction varchar2(35));
|
CREATE OR REPLACE VIEW view_VolGroup AS
SELECT VolunteerGroup.vgID, Volunteergroup.Organization,Student.stdID, Student.name, Student.address, Student.phone, Rav.Ravname
FROM Student INNER JOIN Rav ON Student.ravID = Rav.Ravid
INNER JOIN VolunteerGroup ON Student.vgID = VolunteerGroup.vgID
ORDER BY Volunteergroup.Organization
|
-- phpMyAdmin SQL Dump
-- version 4.0.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 11, 2014 at 02:48 AM
-- Server version: 5.6.12-log
-- PHP Version: 5.4.12
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: `mcqdata`
--
CREATE DATABASE IF NOT EXISTS `mcqdata` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `mcqdata`;
-- --------------------------------------------------------
--
-- Table structure for table `admin_login`
--
CREATE TABLE IF NOT EXISTS `admin_login` (
`id` int(2) NOT NULL AUTO_INCREMENT,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `admin_login`
--
INSERT INTO `admin_login` (`id`, `username`, `password`) VALUES
(1, 'root', '22aad504937080f0b5f15601518ca821');
-- --------------------------------------------------------
--
-- Table structure for table `details`
--
CREATE TABLE IF NOT EXISTS `details` (
`Number` int(11) NOT NULL AUTO_INCREMENT,
`gender` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`branch` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`score` int(10) NOT NULL,
`Logout_status` int(1) NOT NULL DEFAULT '1',
`Year` int(11) NOT NULL,
PRIMARY KEY (`Number`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `details`
--
INSERT INTO `details` (`Number`, `gender`, `name`, `branch`, `email`, `password`, `score`, `Logout_status`, `Year`) VALUES
(1, 'Male', 'Prashant Chaudhary', 'CS1', 'a@a.com', '0cc175b9c0f1b6a831c399e269772661', 1, 1, 2);
-- --------------------------------------------------------
--
-- Table structure for table `enable_mcq`
--
CREATE TABLE IF NOT EXISTS `enable_mcq` (
`mcq_state` tinyint(1) NOT NULL,
UNIQUE KEY `mcq_state` (`mcq_state`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `enable_mcq`
--
INSERT INTO `enable_mcq` (`mcq_state`) VALUES
(1);
-- --------------------------------------------------------
--
-- Table structure for table `marking_scheme`
--
CREATE TABLE IF NOT EXISTS `marking_scheme` (
`negative_marking` tinyint(1) NOT NULL,
`negative` int(3) NOT NULL,
`positive` int(3) NOT NULL,
UNIQUE KEY `negative_marking` (`negative_marking`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `marking_scheme`
--
INSERT INTO `marking_scheme` (`negative_marking`, `negative`, `positive`) VALUES
(0, 0, 1);
-- --------------------------------------------------------
--
-- Table structure for table `questions`
--
CREATE TABLE IF NOT EXISTS `questions` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`question` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`ans` varchar(255) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `time_and_questions`
--
CREATE TABLE IF NOT EXISTS `time_and_questions` (
`serial_num` int(11) NOT NULL AUTO_INCREMENT,
`no_of_questions` int(11) NOT NULL,
`timer` int(11) NOT NULL,
PRIMARY KEY (`serial_num`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `time_and_questions`
--
INSERT INTO `time_and_questions` (`serial_num`, `no_of_questions`, `timer`) VALUES
(1, 10, 5);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
#DROP DATABASE IF EXISTS bugs;
#CREATE DATABASE IF NOT EXISTS bugs;
#USE bugs;
DROP TABLE IF EXISTS projects;
CREATE TABLE projects (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(32) NOT NULL,
description TEXT,
private BOOL NOT NULL,
count INT(16)
) ;
INSERT INTO projects VALUES (NULL,'All Projects','Virtual project for global view',0,0);
DROP TABLE IF EXISTS tickets;
CREATE TABLE tickets (
id INT(32) PRIMARY KEY AUTO_INCREMENT,
project INT(16) NOT NULL,
brief VARCHAR(128) NOT NULL,
description TEXT NOT NULL,
code TEXT,
version INT(16) NOT NULL,
fixedin INT(16) NOT NULL,
category INT(8) NOT NULL,
severity INT(8) NOT NULL,
status INT(8) NOT NULL,
resolution INT(8) NOT NULL,
priority INT(8) NOT NULL,
reproduce INT(8) NOT NULL,
type INT(32) NOT NULL,
platform INT(32) NOT NULL,
comments INT(8) NOT NULL,
user INT(16) NOT NULL,
created DATETIME NOT NULL,
modified DATETIME NOT NULL,
closed DATETIME DEFAULT NULL,
INDEX (
project, version, fixedin, category,
severity, priority, status, resolution, user,
created, closed
)
);
DROP TABLE IF EXISTS logs;
CREATE TABLE logs (
id INT(32) PRIMARY KEY AUTO_INCREMENT,
ticket INT(32) NOT NULL,
date DATETIME NOT NULL,
user VARCHAR(32) NOT NULL,
action INT(8) NOT NULL,
field INT(8) NOT NULL,
opt_id INT(32),
old INT(16),
new INT(16),
msg TEXT,
INDEX (ticket, field, new, date)
);
DROP TABLE IF EXISTS comments;
CREATE TABLE comments (
id INT(32) PRIMARY KEY AUTO_INCREMENT,
ticket INT(32) NOT NULL,
comment TEXT NOT NULL,
user INT(16) NOT NULL,
created DATETIME NOT NULL,
INDEX (ticket)
);
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
login VARCHAR(32) NOT NULL,
pasw VARCHAR(32) NOT NULL,
email VARCHAR(128) NOT NULL,
vkey VARCHAR(32) DEFAULT NULL,
vdate DATETIME DEFAULT NULL,
role INT(8) NOT NULL,
deleted BOOL NOT NULL,
created DATETIME NOT NULL,
modified DATETIME
);
DROP TABLE IF EXISTS rights;
CREATE TABLE rights (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
user INT(16) NOT NULL,
project INT(16) NOT NULL,
role INT(8) NOT NULL,
INDEX (user)
);
DROP TABLE IF EXISTS prefs;
CREATE TABLE prefs (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
user INT(16) NOT NULL,
data TEXT NOT NULL,
INDEX (user)
);
DROP TABLE IF EXISTS files;
CREATE TABLE files (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
ticket INT(32) NOT NULL,
name VARCHAR(128) NOT NULL,
file VARCHAR(32) NOT NULL,
created DATETIME NOT NULL,
user INT(16) NOT NULL,
INDEX (ticket, file)
);
DROP TABLE IF EXISTS versions;
CREATE TABLE versions (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
project INT(16) NOT NULL,
label VARCHAR(32) NOT NULL,
deleted BOOL NOT NULL
);
INSERT INTO versions VALUES (NULL,0,'n/a',0);
DROP TABLE IF EXISTS categories;
CREATE TABLE categories (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
project INT(16) NOT NULL,
label VARCHAR(32) NOT NULL,
deleted BOOL NOT NULL,
position INT(8) DEFAULT 0
);
INSERT INTO categories VALUES (NULL,0,'n/a',0,0);
DROP TABLE IF EXISTS severities;
CREATE TABLE severities (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO severities (label) VALUES
('not a bug'),
('trivial'),
('text'),
('tweak'),
('minor'),
('major'),
('crash'),
('block');
DROP TABLE IF EXISTS statuses;
CREATE TABLE statuses (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO statuses (label) VALUES
('submitted'),
('reviewed'),
('problem'),
('waiting'),
('deferred'),
('dismissed'),
('pending'),
('built'),
('tested'),
('complete');
DROP TABLE IF EXISTS resolutions;
CREATE TABLE resolutions (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO resolutions (label) VALUES
('open'),
('fixed'),
('reopened'),
('unable to reproduce'),
('not fixable'),
('duplicate'),
('no change required'),
('suspended'),
('won\'t fix');
DROP TABLE IF EXISTS priorities;
CREATE TABLE priorities (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO priorities (label) VALUES
('none'),
('low'),
('normal'),
('high'),
('urgent'),
('immediate');
DROP TABLE IF EXISTS roles;
CREATE TABLE roles (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO roles (label) VALUES
('Viewer'),
('Reporter'),
('Developer'),
('Admin');
DROP TABLE IF EXISTS reproduces;
CREATE TABLE reproduces (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO reproduces (label) VALUES
('Always'),
('Sometimes'),
('Random'),
('Have not tried'),
('Unable to reproduce'),
('Not applicable');
DROP TABLE IF EXISTS types;
CREATE TABLE types (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO types (label) VALUES
('Bug'),
('Wish'),
('Issue'),
('Note'),
('Nuts');
DROP TABLE IF EXISTS platforms;
CREATE TABLE platforms (
id INT(16) PRIMARY KEY AUTO_INCREMENT,
label VARCHAR(32) NOT NULL
);
INSERT INTO platforms (label) VALUES
('All'),
('N/A'),
('Windows'),
('Mac OSX'),
('Linux x86 libc6'),
('FreeBSD x86');
INSERT INTO users VALUES (
NULL,
'admin',
'EE10C315EBA2C75B403EA99136F5B48D',
'default@curecode.org',
'00000000000000000000000000000000',
NOW(),
4,
0,
NOW(),
NOW()
);
|
create or replace PACKAGE BODY PO AS
PROCEDURE update_po(po_id IN PO_DETAIL.PO_NUMBER%TYPE) IS
rejectedstatus boolean;
pendingstatus boolean;
CURSOR c_po_items is
SELECT status FROM po_detail where PO_DETAIL.PO_NUMBER=po_id;
BEGIN
rejectedstatus:=false;
pendingstatus:=false;
for n in c_po_items loop
if(n.status='Rejected')
then
rejectedstatus :=true;
update po_master set po_master.status='Rejected' where PO_NUMBER=po_id;
commit;
EXIT;
end if;
if( rejectedstatus=false AND n.status='Pending')
then
pendingstatus:=true;
update po_master set po_master.status='Pending' where PO_NUMBER=po_id;
commit;
end if;
end loop;
if(pendingstatus=false AND rejectedstatus=false)
then
update po_master set po_master.status='Approved' where PO_NUMBER=po_id;
commit;
end if;
END update_po;
END PO; |
ALTER TABLE poitem ADD COLUMN poitem_rlsd_duedate date; |
-- phpMyAdmin SQL Dump
-- version phpStudy 2014
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2017 年 06 月 14 日 09:02
-- 服务器版本: 5.5.53
-- PHP 版本: 5.4.45
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 */;
--
-- 数据库: `pet`
--
-- --------------------------------------------------------
--
-- 表的结构 `pets`
--
CREATE TABLE IF NOT EXISTS `pets` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`petname` varchar(50) NOT NULL,
`describe` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
--
-- 转存表中的数据 `pets`
--
INSERT INTO `pets` (`id`, `name`, `petname`, `describe`) VALUES
(1, '小明', '黄毛', '厌食'),
(2, '小红', '香香', '狂吠'),
(3, 'aaa', 'sss', 'aaaa'),
(4, '张三', '金毛', '脱毛');
/*!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 NAME FROM mydb.user; |
-- 聚合函数
-- count() 统计
select count(`id`) from `user`;
-- sum() 求和
select sum(`id`) from `user`;
-- avg() 平均值
select avg(`id`) from `user`;
-- max() 最大值
-- min() 最小值
select max(`id`) from `user`;
-- 字符串拼接函数
-- concat( 字符串 或 字段名, 字符串 或 字段名, ... )
select concat(`nickname`, '----', `tel`, '---', `sex` ) from `user`;
|
INSERT INTO empleados (nombre,apellido,dni,fechaNacimiento,correo, sexo, celular) VALUES ('Josť', 'Lovon Vega','74417486','1998-02-17','joslui1720082@gmail.com',true, 982087241);
INSERT INTO empleados (nombre,apellido,dni,fechaNacimiento,correo, sexo, celular) VALUES ('Miguel Angel', 'Calderon','74417222','1998-03-20','miguelcalderon@gmail.com',true, 998523641);
INSERT INTO empleados (nombre,apellido,dni,fechaNacimiento,correo, sexo, celular) VALUES ('Alex', 'Meza','744174309','1998-08-02','alexmeza@gmail.com',true, 963647894);
INSERT INTO clientes (nombre,apellido,dni,fechaNacimiento,correo, sexo, celular) VALUES ('Maria', 'Lopez','75893615','1988-10-15','marialo88@gmail.com',false, 923619866);
INSERT INTO clientes (nombre,apellido,dni,fechaNacimiento,correo, sexo, celular) VALUES ('Pedro', 'Fierro Ramos','78152366','1990-01-27','pedrofierro27@gmail.com',true, 923651889);
INSERT INTO clientes (nombre,apellido,dni,fechaNacimiento,correo, sexo, celular) VALUES ('Juan', 'Pacheco','79856214','1999-05-16','pacheco05123@gmail.com',true, 993652784);
INSERT INTO departamentos (nombre) VALUES ('Lima');
INSERT INTO departamentos (nombre) VALUES ('Ayacucho');
INSERT INTO departamentos (nombre) VALUES ('Cusco');
INSERT INTO departamentos (nombre) VALUES ('Madre de Dios');
INSERT INTO departamentos (nombre) VALUES ('Tacna');
INSERT INTO departamentos (nombre) VALUES ('Piura');
INSERT INTO departamentos (nombre) VALUES ('Arequipa');
INSERT INTO departamentos (nombre) VALUES ('Puno');
INSERT INTO cargos (nombre) VALUES ('Recepcionista');
INSERT INTO cargos (nombre) VALUES ('Consultor de Viajes');
INSERT INTO buses (placa,cantAsiento) VALUES ('ABC526', 40);
INSERT INTO buses (placa,cantAsiento) VALUES ('XYZ158', 40);
INSERT INTO buses (placa,cantAsiento) VALUES ('AXH165', 40);
INSERT INTO buses (placa,cantAsiento) VALUES ('FJB635', 40);
INSERT INTO buses (placa,cantAsiento) VALUES ('BVR365', 40);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,1,true,1);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,1,true,2);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,1,true,3);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,1,true,4);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,1,true,5);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,2,true,1);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,2,true,2);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,2,true,3);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,2,true,4);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,2,true,5);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,3,true,1);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,3,true,2);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,3,true,3);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,3,true,4);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,3,true,5);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,4,true,1);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,4,true,2);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,4,true,3);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,4,true,4);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,4,true,5);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,5,true,1);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,5,true,2);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,5,true,3);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,5,true,4);
INSERT INTO asientos(piso,bus_id,disponible,numero) VALUES (1,5,true,5);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-12-30 12:38:00','2019-12-30 20:38:00', 48.00,1, 1,2,3);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-12-10 07:00:00','2019-12-11 13:38:00', 100.00,2, 1,3,3);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-10-26 12:38:00','2019-10-28 06:38:00', 50.00,3, 2,7,3);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-04-12 12:38:00','2019-04-12 22:38:00', 30.00,4, 4,8,3);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-05-10 12:38:00','2019-05-11 12:38:00', 36.00,5, 2,4,3);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-05-14 12:38:00','2019-05-15 09:38:00', 50.00,3, 1,5,3);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-08-12 12:38:00','2019-08-12 23:38:00', 90.00,1, 6,7,3);
INSERT INTO viajes (fechaInicio,fechaFinal,precio,bus_id,dptoOrigen_id,dptoDestino_id,empleado_id) VALUES ('2019-09-11 12:38:00','2019-09-12 11:38:00', 80.00,2, 1,8,3);
INSERT INTO usuarios(nombre,clave,cargo_id,empleado_id) VALUES ('lovon98','123456',1,1);
INSERT INTO usuarios(nombre,clave,cargo_id,empleado_id) VALUES ('angelupc','123456',1,2);
INSERT INTO usuarios(nombre,clave,cargo_id,empleado_id) VALUES ('mezacuba','123456',2,3);
INSERT INTO boletas(monto,fechaEmision,cliente_id,viaje_id,empleado_id,asiento_id,bus_id) VALUES (80.00,'2019-08-10 09:03:00',1,1,1,1,5);
INSERT INTO boletas(monto,fechaEmision,cliente_id,viaje_id,empleado_id,asiento_id,bus_id) VALUES (100.00,'2019-08-10 09:10:00',2,2,1,1,2);
INSERT INTO boletas(monto,fechaEmision,cliente_id,viaje_id,empleado_id,asiento_id,bus_id) VALUES (100.00,'2019-08-10 10:03:00',3,2,1,2,2);
|
-- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Erstellungszeit: 06. Feb 2020 um 17:54
-- Server-Version: 10.4.11-MariaDB
-- PHP-Version: 7.4.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
CREATE DATABASE IF NOT EXISTS todo;
USE todo;
/*!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 */;
--
-- Datenbank: `todo`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `todos`
--
CREATE TABLE `todos` (
`item_id` int(11) NOT NULL,
`list_id` int(11) NOT NULL COMMENT 'FK',
`title` varchar(25) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`finished` tinyint(1) NOT NULL DEFAULT 0,
`due_date` timestamp NULL DEFAULT current_timestamp(),
`address` longtext DEFAULT NULL,
`priority` int(11) NOT NULL DEFAULT 0,
`subtasks` longtext DEFAULT NULL,
`reminder` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `todo_lists`
--
CREATE TABLE `todo_lists` (
`list_id` int(11) NOT NULL,
`name` varchar(25) NOT NULL,
`description` varchar(500) DEFAULT NULL,
`hex_color` varchar(7) DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Daten für Tabelle `todo_lists`
--
INSERT INTO `todo_lists` (`list_id`, `name`, `description`, `hex_color`, `created_at`) VALUES
(1, 'default', 'default', '#FFFFFF', '2020-02-06 16:40:59');
--
-- Indizes der exportierten Tabellen
--
--
-- Indizes für die Tabelle `todos`
--
ALTER TABLE `todos`
ADD PRIMARY KEY (`item_id`);
--
-- Indizes für die Tabelle `todo_lists`
--
ALTER TABLE `todo_lists`
ADD PRIMARY KEY (`list_id`);
--
-- AUTO_INCREMENT für exportierte Tabellen
--
--
-- AUTO_INCREMENT für Tabelle `todos`
--
ALTER TABLE `todos`
MODIFY `item_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT für Tabelle `todo_lists`
--
ALTER TABLE `todo_lists`
MODIFY `list_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 name, street
from customers
where city = 'Porto Alegre' |
SELECT *
FROM {{ref('joined_tables')}}
WHERE is_erc721 = True |
DELIMITER //
CREATE PROCEDURE banc_db.InsertTransaction(
IN entity1id int,
IN entity1 text,
IN link_name text,
IN link_add_info text,
IN amount float,
IN service_fee_paid float,
IN amount_net float,
IN form_date datetime,
IN form_memo text,
IN form_ref text,
IN bank_transaction_memo text,
IN bank_transaction_ref text,
IN bank_transaction_date datetime,
IN inbound bool,
IN transaction_type_id int,
IN summary bool)
BEGIN
-- Variable declared
DECLARE txnId INT DEFAULT 0;
-- exit if the duplicate key occurs
DECLARE EXIT HANDLER FOR 1062 SELECT * from banc_db.transaction where amount=amount and transaction_type_id=transaction_type_id and form_ref=form_ref;
-- insert a new row into the transaction
INSERT INTO banc_db.transaction (amount, service_fee_paid, amount_net, form_date_utc, form_memo,
form_ref, bank_transaction_memo, bank_transaction_ref, bank_transaction_date_utc, inbound, transaction_type_id, summary)
VALUES (amount, service_fee_paid, amount_net, form_date_utc, form_memo,
form_ref, bank_transaction_memo, bank_transaction_ref, bank_transaction_date_utc, inbound, transaction_type_id, summary);
SET txnId = LAST_INSERT_ID();
-- insert a transaction link
if entity1id > 0 then
INSERT INTO banc_db.transaction_link (entity1_id, entity2_id, entity1, entity2, name, form_ref, txn_form_date, additional_info)
VALUES (entity1id, txnId, entity1, 'transaction', link_name, form_ref, form_date_utc,link_add_info);
end if;
END //
DELIMITER ;
|
CREATE TABLE user (
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
username varchar(20) NOT NULL COMMENT '用户名',
password varchar(32) NOT NULL COMMENT '密码',
nickname varchar(20) NOT NULL COMMENT '昵称',
userLevel int(255) NOT NULL COMMENT '等级',
createTime datetime(0) NOT NULL COMMENT '创建时间',
lastLoginTime datetime(0) COMMENT '最后登录时间',
sex varchar(1) COMMENT '性别',
birthday date COMMENT '生日',
email varchar(50) NOT NULL COMMENT '邮箱',
experience int(11) NOT NULL COMMENT '经验值',
remark varchar(200) COMMENT '用户说明',
PRIMARY KEY (`id`) USING BTREE
);
CREATE TABLE admin (
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
adminUsername varchar(20) NOT NULL COMMENT '账号',
adminPassword varchar(32) NOT NULL COMMENT '密码',
realname varchar(20) NOT NULL COMMENT '真实姓名',
createTime datetime(0) NOT NULL COMMENT '创建时间',
PRIMARY KEY (id) USING BTREE
);
CREATE TABLE section(
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
sectionName varchar(20) NOT NULL COMMENT '版块名称',
userId int(11) NOT NULL COMMENT '版主ID',
remark varchar(200) NOT NULL COMMENT '版块说明',
createTime datetime(0) NOT NULL COMMENT '创建时间',
clickCount int(11) NOT NULL COMMENT '点击数',
topicCount int(11) NOT NULL COMMENT '主贴数',
PRIMARY KEY (id)
);
CREATE INDEX index_section_name on section(sectionName);
drop TABLE IF EXISTS topic;
CREATE TABLE topic(
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
title varchar(100) NOT NULL COMMENT '主贴标题',
createTime datetime(0) NOT NULL COMMENT '发帖时间',
userId int(11) NOT NULL COMMENT '发帖人ID',
sectionId int(11) NOT NULL COMMENT '发帖版块',
content varchar(500) NOT NULL COMMENT '帖子内容',
clickCount int(11) NOT NULL COMMENT '浏览次数',
lastReplyTime datetime(0) NOT NULL COMMENT '最后回复时间',
PRIMARY KEY (id)
);
drop TABLE IF EXISTS reply ;
CREATE TABLE reply(
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
topicId int(11) NOT NULL COMMENT '主贴ID',
replyContent varchar(500) NOT NULL COMMENT '回复内容',
replyTime datetime(0) NOT NULL COMMENT '回复时间',
replyClickCount int(11) NOT NULL COMMENT '浏览次数',
PRIMARY KEY (id)
);
CREATE VIEW topic_view
AS select t.id,t.title,t.createTime,t.content,r.replyContent,r.replyTime
from topic t, reply r
where t.id = r.topicId
CREATE TRIGGER section_topicCount
AFTER INSERT ON topic FOR EACH ROW
UPDATE section set topicCount = topicCount+1 where id=NEW.sectionId
CREATE TRIGGER topic_delete
AFTER DELETE ON topic FOR EACH ROW
BEGIN
UPDATE section set topicCount = topicCount-1
where id=OLD.sectionId;
DELETE from reply where topicId = OLD.id;
END
|
-- up
CREATE TABLE user (
cpf varchar(50),
email TEXT,
password INTEGER
);
-- down
drop table user; |
CREATE VIEW dbo.roles_v
AS
SELECT created_by, created_date, updated_by, updated_date, role_id, role_name, is_export_excel, is_export_pdf, is_import_excel, dbo.countRoleMenus(role_id)
AS countRoleMenus, dbo.countUsers(role_id) AS countUsers
FROM dbo.roles
|
select rs.resortname, c.describe, c.cabintype, c.bedroomcount
from resort rs join cabin c
on c.resortid=rs.resortid
order by rs.resortid; |
DELIMITER //
DROP PROCEDURE IF EXISTS `sp_pc_upsert`//
CREATE PROCEDURE sp_pc_upsert
(
IN p_pc_id INTEGER,
IN p_pc VARCHAR(7),
IN p_ldu_type_cde VARCHAR(50),
IN p_fsa_id INTEGER,
IN p_fsa VARCHAR(3),
IN p_lfcl_stat_cde VARCHAR(50),
IN p_dm_type_cd VARCHAR(50),
IN p_dm_disp_nme VARCHAR(6),
IN p_df_id INTEGER,
IN p_df_disp_nme VARCHAR(100),
IN p_df_pc_id INTEGER,
IN p_df_pc_disp_nme VARCHAR(7),
IN p_rpo_id INTEGER,
IN p_rpo_nme VARCHAR(50),
IN p_rpo_bus_nme VARCHAR(50),
IN p_rpo_addr_line1 VARCHAR(50),
IN p_rpo_addr_line3 VARCHAR(50),
IN p_latitude DECIMAL(38,8),
IN p_longitude DECIMAL(38,8)
)
BEGIN
REPLACE INTO AMS_PC_SPD
(
PC_ID,
PC,
LDU_TYPE_CDE,
FSA_ID,
FSA,
LFCL_STAT_CDE,
DM_TYPE_CDE,
DM_DISP_NME,
DF_ID,
DF_DISP_NME,
DF_PC_ID,
DF_PC_DISP_NME,
RPO_ID,
RPO_NME,
RPO_BUS_NME,
RPO_ADDR_LINE1,
RPO_ADDR_LINE3,
LATITUDE,
LONGITUDE
)
VALUES
(
p_pc_id,
p_pc,
p_ldu_type_cde,
p_fsa_id,
p_fsa,
p_lfcl_stat_cde,
p_dm_type_cd,
p_dm_disp_nme,
p_df_id,
p_df_disp_nme,
p_df_pc_id,
p_df_pc_disp_nme,
p_rpo_id,
p_rpo_nme,
p_rpo_bus_nme,
p_rpo_addr_line1,
p_rpo_addr_line3,
p_latitude,
p_longitude
);
END//
DELIMITER ;
|
-- Os resultados da planilha nao estao em conformidade com a proposta do exercicio
-- Por exemplo, na base teste2, os dois registros mais antigos de event_type = 2 sao
-- 2015-05-09 12:42:00 com value = 5 e 2015-05-09 12:54:39 com value = 7,
-- ou seja, a diferenca e 7-5 = 2, e nao -3. Este cenario se repete nas outras bases
select ev.event_type as EVENT_TYPE,
(select penultimate.value
from events penultimate
where penultimate.event_type = ev.event_type
order by time asc
limit 1 offset 1)
-
(select last.value from events last where last.event_type = ev.event_type order by time asc limit 1) as VALUE
from events ev
group by ev.event_type
having count(ev.event_type) > 1; |
CREATE TABLE sample_workflow (
sample_workflow_id int(10) unsigned NOT NULL AUTO_INCREMENT,
sample_id int(11) unsigned NOT NULL,
workflow_id int(11) unsigned NOT NULL,
PRIMARY KEY (sample_workflow_id),
UNIQUE KEY sample_workflow_id_UNIQUE (sample_workflow_id)
)
|
-- DELIVERABLE 1 -- DELIVERABLE 1 -- DELIVERABLE 1-- DELIVERABLE 1
-- Join employee and titles Tables
SELECT e.emp_no,
e.first_name,
e.last_name,
e.birth_date,
t.title,
t.from_date,
t.to_date
INTO retirement_titles
FROM employees as e
INNER JOIN titles as t
ON e.emp_no = t.emp_no;
SELECT * FROM retirement_titles;
-- Filter by BDate and btween 1952 & 1955
SELECT emp_no,
first_name,
last_name,
birth_date,
title,
from_date,
to_date
INTO retirement_titles1
FROM retirement_titles
WHERE (birth_date BETWEEN '1952-01-01' AND '1955-12-31')
ORDER BY emp_no;
SELECT * FROM retirement_titles;
-- Use Dictinct with Orderby to remove duplicate rows
SELECT emp_no,
first_name,
last_name,
birth_date,
from_date,
to_date,
title
INTO retirement_titles
FROM retirement_titles1
WHERE to_date = '9999-01-01'
ORDER BY to_date DESC;
SELECT * FROM retirement_titles;
-- Create a Unique Titles Table using the INTO clause
SELECT DISTINCT ON (emp_no)
emp_no,
first_name,
last_name,
title
INTO unique_titles
FROM retirement_titles
ORDER BY emp_no, to_date DESC;
SELECT * FROM unique_titles;
-- Retrieve TOTAL employee count by title from the Unique Titles Table
SELECT COUNT(emp_no), title
INTO retiring_titles
FROM unique_titles
GROUP BY title
ORDER BY count DESC;
SELECT * FROM retiring_titles;
-- DELIVERABLE 2 -- DELIVERABLE 2 -- DELIVERABLE 2 -- DELIVERABLE 2
-- Filter by BDate in 1965
SELECT emp_no,
first_name,
last_name,
birth_date,
title,
from_date,
to_date
INTO current_emp
FROM retirement_titles
WHERE (birth_date BETWEEN '1965-01-01' AND '1965-12-31')
ORDER BY emp_no;
SELECT * FROM current_emp;
-- Use Dictinct with Orderby to remove duplicate rows
SELECT emp_no,
first_name,
last_name,
birth_date,
from_date,
to_date,
title
INTO mentorship_eligibility
FROM current_emp
WHERE to_date = '9999-01-01'
ORDER BY to_date DESC;
SELECT * FROM mentorship_eligibility;
-- EXTRA | Created a mentorship Titles Table using the INTO clause
SELECT DISTINCT ON (emp_no)
emp_no,
first_name,
last_name,
title
INTO mentorship_titles
FROM mentorship_eligibility2
ORDER BY emp_no ASC;
SELECT * FROM mentorship_titles;
-- EXTRA | Retrieved TOTAL employee count by title from the mentorship titles Table
SELECT COUNT(emp_no), title
INTO mentorship_eligibility_titles
FROM mentorship_titles
GROUP BY title
ORDER BY count DESC;
SELECT * FROM mentorship_eligibility_titles;
-- DELIVERABLE 3 -- DELIVERABLE 3 -- DELIVERABLE 3 -- DELIVERABLE 3
-- Q1
-- Total Number of Current Employees
SELECT COUNT(first_name)
FROM mentorship_eligibility
-- OUPUT = 1549
--Total number of Retiring Employees
SELECT COUNT(first_name)
FROM unique_titles2
--OUTPUT = 72458
--Q2
--Create query for retiring employees vs current employees count by department
--Step 1 Current Emp -- JOIN departments and dept_emp tables
SELECT de.emp_no,
de.from_date,
de.to_date,
d.dept_name
INTO current_dept_emp_univ
FROM departments as d
INNER JOIN dept_emp as de
ON de.dept_no = d.dept_no
WHERE to_date='9999-01-01'
SELECT * FROM current_dept_emp_univ;
-- Step 2 Total of current employees by departments
SELECT COUNT(emp_no), dept_name
INTO current_dept
FROM current_dept_emp_univ
GROUP BY dept_name
ORDER BY count DESC;
SELECT * FROM current_dept;
-- Step 3 Join retirement and dept_emp tables
SELECT r.emp_no,
r.birth_date,
r.from_date,
r.to_date,
de.dept_no
INTO retiring_dept_emp_univ
FROM retirement_titles as r
INNER JOIN dept_emp as de
ON r.emp_no = de.emp_no
WHERE (birth_date BETWEEN '1952-01-01' AND '1955-12-31');
-- Step 4 Join retirement_titles and departments table
SELECT rt.emp_no,
rt.birth_date,
rt.from_date,
rt.to_date,
d.dept_name
INTO retiring_dept_emp
FROM retiring_dept_emp_univ as rt
INNER JOIN departments as d
ON rt.dept_no = d.dept_no;
SELECT * FROM retiring_dept_emp;
-- Step 5 Total of retiring employees by departments
SELECT COUNT(emp_no), dept_name
INTO retiring_dept
FROM retiring_dept_emp
GROUP BY dept_name
ORDER BY count DESC;
SELECT * FROM retiring_dept;
|
CREATE TABLE [AsData_PL].[Assessor_Organisations]
(
[Id] [uniqueidentifier] PRIMARY KEY NOT NULL,
[CreatedAt] [datetime2](7) NOT NULL,
[DeletedAt] [datetime2](7) NULL,
[EndPointAssessorName] [nvarchar](100) NULL,
[EndPointAssessorOrganisationId] [nvarchar](12) NULL,
[EndPointAssessorUkprn] [int] NULL,
[Status] [nvarchar](10) NULL,
[UpdatedAt] [datetime2](7) NULL,
[OrganisationTypeId] [int] NULL,
[ApiEnabled] [bit] NULL,
[ApiUser] [nvarchar](100) NULL,
[RecognitionNumber] [nvarchar](100) NULL,
[AsDm_UpdatedDateTime] [Datetime2](7) default getdate()
)
|
SELECT t.TitleID,
i.ItemID,
p.PageID,
t.FullTitle + ' ' + t.PartNumber + ' ' + t.PartName AS Title,
dbo.fnCOinSAuthorStringForTitle(t.TitleID, 0) AS Authors,
dbo.fnAssociationStringForTitle(t.TitleID) AS Associations,
dbo.fnVariantStringForTitle(t.TitleID) AS Variants,
dbo.fnKeywordStringForTitle(t.TitleID) AS Keywords,
dbo.fnCollectionStringForTitleAndItem(t.TitleID, i.ItemID) AS Collections,
t.Datafield_260_a AS PublicationPlace,
t.Datafield_260_b AS PublisherName,
t.Datafield_260_c AS PublicationDate,
t.StartYear,
t.EndYear,
i.Year,
t.EditionStatement,
l.LanguageName,
inst.InstitutionName,
b.BibliographicLevelName,
i.Volume,
dbo.fnPageTypeStringForPage(p.PageID) AS PageTypes,
ISNULL(ip.PagePrefix, '') AS PagePrefix,
ISNULL(ip.PageNumber, '') AS PageNumber
FROM dbo.Title t
INNER JOIN dbo.TitleItem ti on t.TitleID = ti.TitleID
INNER JOIN dbo.Item i on ti.ItemID = i.ItemID
INNER JOIN dbo.Page p on i.ItemID = p.ItemID
LEFT JOIN dbo.IndicatedPage ip on p.PageID = ip.PageID AND ip.Sequence = 1
INNER JOIN dbo.Language l ON i.LanguageCode = l.LanguageCode
INNER JOIN dbo.Institution inst ON i.InstitutionCode = inst.InstitutionCode
INNER JOIN dbo.BibliographicLevel b ON t.BibliographicLevelID = b.BibliographicLevelID
WHERE i.Barcode = 'proceedingsofzoo19221zool'
AND t.PublishReady = 1
AND i.ItemStatusID = 40
AND p.Active = 1
|
CREATE DATABASE providers_db;
USE providers_db;
CREATE TABLE providers (
ID INTEGER AUTO_INCREMENT,
img VARCHAR(999) NOT NULL,
name VARCHAR(100) not null,
address VARCHAR(100) not null,
description VARCHAR(300) not null,
type VARCHAR(50) not null,
capacity VARCHAR(20) not null,
budget VARCHAR(20) not null,
price INTEGER,
PRIMARY KEY (ID)
);
SELECT * FROM Providers; |
drop database if exists `sbes`;
CREATE DATABASE `sbes` /*!40100 DEFAULT CHARACTER SET utf8 */;
use `sbes`;
CREATE TABLE `s_movie` (
`s_movie_id` bigint(20) NOT NULL AUTO_INCREMENT,
`s_movie_name` varchar(255) NOT NULL,
`s_movie_rating` double DEFAULT NULL,
`dtype` varchar(31) NOT NULL,
PRIMARY KEY (`s_movie_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `s_genre` (
`s_genre_id` bigint(20) NOT NULL AUTO_INCREMENT,
`s_genre_name` varchar(255) NOT NULL,
`s_movie_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`s_genre_id`),
KEY `FK_S_MOVIE_ID` (`s_movie_id`),
CONSTRAINT `FK_S_MOVIE_ID` FOREIGN KEY (`s_movie_id`) REFERENCES `s_movie` (`s_movie_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `s_user` (
`s_user_id` bigint(20) NOT NULL AUTO_INCREMENT,
`s_user_name` varchar(255) NOT NULL,
`s_user_Password` varchar(255) NOT NULL,
`create_date` datetime NOT NULL,
`create_user_id` bigint(20) NOT NULL,
`mod_date` datetime,
`mod_user_id` bigint(20),
PRIMARY KEY (`s_user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
INSERT INTO `sbes`.`s_user`
(
`s_user_name`,
`s_user_Password`,
`create_date`,
`create_user_id`)
VALUES
(
'neals',
'123456',
'2017-08-02',
1);
|
ALTER TABLE accounts ADD failed_attempts INTEGER ;
UPDATE accounts SET failed_attempts = 0;
ALTER TABLE accounts ALTER failed_attempts SET DEFAULT 0; |
/*查询订单分配单*/
select a.*,
(a.plan_amount - IFNULL(a.complete_amount, 0)) as remainder_amount
from (select t.*,
(SELECT SUM(C.plan_amount) FROM cs_distribution_cargo c WHERE c.distribution_no = t.distribution_no ) as plan_amount,
(SELECT SUM(IFNULL(C.complete_amount, 0)) FROM cs_distribution_cargo c WHERE c.distribution_no = t.distribution_no ) as complete_amount
from cs_distribution t
where 1=1
<< and id in (:ids) >>
<< and t.order_no = :order_no >>
<< and t.distribution_no = :distribution_no >>
<< and t.carrier_code = :carrier_code >>
<< and t.status = :status >>
order by t.create_time desc
) a
|
-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Aug 07, 2020 at 04:06 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12
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: `chatter_techvegan`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE IF NOT EXISTS `admin` (
`id` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `name`, `password`) VALUES
('techvegan', 'Tech Vegan', '534fc3dc50b1573791f6e96d62f18e0280ab4367');
-- --------------------------------------------------------
--
-- Table structure for table `box`
--
CREATE TABLE IF NOT EXISTS `box` (
`id` int(255) NOT NULL AUTO_INCREMENT,
`sender` varchar(255) NOT NULL,
`msg` varchar(255) NOT NULL,
`date` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
-- --------------------------------------------------------
--
-- Table structure for table `message`
--
CREATE TABLE IF NOT EXISTS `message` (
`id` int(255) NOT NULL AUTO_INCREMENT,
`sender` varchar(255) NOT NULL,
`receiver` varchar(255) NOT NULL,
`msg` varchar(255) NOT NULL,
`date` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=27 ;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(255) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`nick` varchar(255) NOT NULL,
`dob` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`contact` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`date` varchar(40) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `nick` (`nick`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema igarden
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema igarden
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `igarden` DEFAULT CHARACTER SET utf8 ;
USE `igarden` ;
-- -----------------------------------------------------
-- Table `igarden`.`luminities`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `igarden`.`luminities` (
`id` INT NOT NULL AUTO_INCREMENT,
`value` FLOAT NULL,
`time` DATETIME NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `igarden`.`humidities`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `igarden`.`humidities` (
`id` INT NOT NULL AUTO_INCREMENT,
`value` FLOAT NULL,
`time` DATETIME NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `igarden`.`temperatures`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `igarden`.`temperatures` (
`id` INT NOT NULL AUTO_INCREMENT,
`value` FLOAT NULL,
`time` DATETIME NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
-- phpMyAdmin SQL Dump
-- version 4.4.14
-- http://www.phpmyadmin.net
--
-- Client : 127.0.0.1:3306
-- Généré le : Mer 11 Novembre 2015 à 18:26
-- Version du serveur : 5.5.45
-- Version de PHP : 5.4.45
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `prisoners_offences`
--
-- --------------------------------------------------------
--
-- Structure de la table `categories`
--
CREATE TABLE `categories` (
`id` int(10) unsigned NOT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `categories`
--
INSERT INTO `categories` (`id`, `title`) VALUES
(2, 'Dangereux'),
(3, 'Calme'),
(4, 'Rechercher');
-- --------------------------------------------------------
--
-- Structure de la table `comments`
--
CREATE TABLE `comments` (
`id` int(10) unsigned NOT NULL,
`prisoner_id` int(255) NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`text` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created` date NOT NULL,
`modified` date NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `comments`
--
INSERT INTO `comments` (`id`, `prisoner_id`, `name`, `email`, `text`, `created`, `modified`) VALUES
(13, 7, 'Meurtre commis en cellule', 'membre@hotmail.com', 'Bob a tuer son partenaire de cellule.', '2015-10-07', '2015-10-07'),
(14, 5, 'Suicide', 'super@hotmail.com', 'Charles a tenté de ce suicidé.', '2015-10-07', '2015-10-07');
-- --------------------------------------------------------
--
-- Structure de la table `ethnies`
--
CREATE TABLE `ethnies` (
`id` int(11) NOT NULL,
`sex_id` int(11) DEFAULT NULL,
`name` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `ethnies`
--
INSERT INTO `ethnies` (`id`, `sex_id`, `name`) VALUES
(1, 2, 'Afro-Américaine'),
(2, 2, 'Coréene'),
(3, 2, 'Galloise'),
(4, 3, 'Afro-Américain'),
(5, 3, 'Coréen'),
(6, 3, 'Gallois'),
(10, 2, 'Arabe'),
(11, 3, 'Arabe');
-- --------------------------------------------------------
--
-- Structure de la table `names`
--
CREATE TABLE `names` (
`id` int(11) NOT NULL,
`name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`created` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`modified` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `names`
--
INSERT INTO `names` (`id`, `name`, `created`, `modified`) VALUES
(36, 'Adam', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(37, 'Alex', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(38, 'Alexandre', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(39, 'Alexis', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(40, 'Anthony', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(41, 'Antoine', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(42, 'benjamin', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(43, 'Cédric', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(44, 'Charles', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(45, 'Christopher', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(46, 'David', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(47, 'Dylan', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(48, 'Édouard', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(49, 'Elliot', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(50, 'Émile', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(51, 'Étienne', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(52, 'Félix', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(53, 'Gabriel', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(54, 'Guillaume', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(55, 'Hugo', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(56, 'Isaac', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(57, 'Jacob', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(58, 'Jérémy', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(59, 'Jonathan', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(60, 'Julien', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(61, 'Justin', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(62, 'Léo', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(63, 'Logan', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(64, 'Mathieu', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(65, 'Mathis', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(66, 'Nathan', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(67, 'Nicolas', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(68, 'Raphaël', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(69, 'Samuel', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(70, 'Tristan', '2015-11-09 17:50:05', '2015-11-09 17:50:05'),
(71, 'Alice', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(72, 'Catherine', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(73, 'Coralie', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(74, 'Élodie', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(75, 'Émilie', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(76, 'Ève', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(77, 'Florence', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(78, 'Justine', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(79, 'Léanne', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(80, 'Maika', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(81, 'Marianne', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(82, 'Mégan', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(83, 'Noémie', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(84, 'Océane', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(85, 'Olivia', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(86, 'Rosalie', '2015-11-09 18:01:43', '2015-11-09 18:01:43'),
(87, 'Rose', '2015-11-09 18:01:43', '2015-11-09 18:01:43');
-- --------------------------------------------------------
--
-- Structure de la table `offences`
--
CREATE TABLE `offences` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `offences`
--
INSERT INTO `offences` (`id`, `name`, `description`) VALUES
(3, 'Vol', 'S''approprier furtivement ou par la force le bien d''autrui.'),
(4, 'Meurtre', 'Fait de tuer volontairement quelqu''un.'),
(5, 'Viol', 'Rapport sexuel imposé à quelqu''un par la violence, obtenu par la contrainte, qui constitue pénalement un crime.');
-- --------------------------------------------------------
--
-- Structure de la table `prisoners`
--
CREATE TABLE `prisoners` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`number` int(11) NOT NULL,
`details` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`user_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
`created` date NOT NULL,
`modified` date NOT NULL,
`filename` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`ethny_id` int(11) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `prisoners`
--
INSERT INTO `prisoners` (`id`, `name`, `number`, `details`, `user_id`, `category_id`, `created`, `modified`, `filename`, `ethny_id`) VALUES
(6, 'Mathieu', 3545342, 'Solitaire', 12, 3, '2015-10-07', '2015-10-07', NULL, 1),
(7, 'Bob', 48457345, 'Être 2 gardiens lors de déplacement.', 12, 2, '2015-10-07', '2015-10-07', NULL, 1),
(8, 'sdfsdf', 5, 'dfsdfsdf', 10, 3, '2015-11-06', '2015-11-07', 'uploads/Penguins.jpg', 1),
(9, 'Anthony', 2147483647, 'dfsdfsdfsdfsdfds', 10, 2, '2015-11-09', '2015-11-10', 'uploads/Tulips.jpg', 5);
-- --------------------------------------------------------
--
-- Structure de la table `prisoners_offences`
--
CREATE TABLE `prisoners_offences` (
`id` int(11) NOT NULL,
`prisoner_id` int(11) DEFAULT NULL,
`offence_id` int(11) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `prisoners_offences`
--
INSERT INTO `prisoners_offences` (`id`, `prisoner_id`, `offence_id`) VALUES
(11, 6, 3),
(12, 7, 3),
(13, 7, 4),
(14, 8, 4),
(15, 9, 3),
(16, 9, 4),
(17, 9, 5);
-- --------------------------------------------------------
--
-- Structure de la table `sexes`
--
CREATE TABLE `sexes` (
`id` int(11) NOT NULL,
`name` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `sexes`
--
INSERT INTO `sexes` (`id`, `name`) VALUES
(1, ' '),
(2, 'Femme'),
(3, 'Homme');
-- --------------------------------------------------------
--
-- Structure de la table `users`
--
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL,
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`role` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created` date NOT NULL,
`modified` date NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `users`
--
INSERT INTO `users` (`id`, `username`, `password`, `role`, `email`, `created`, `modified`, `active`) VALUES
(10, 'admin', '$2a$10$EmDwJDM69tFzXCHZx1SYg.LAAaSPIA7nRZ3ZpYX9hu8srxE9AqusC', 'admin', 'admin@hotmail.com', '2015-10-07', '2015-10-07', 1),
(12, 'super', '$2a$10$Snsw5oKuOq7.5Mt0agdYb.fACoXnMKUvb.ySPjiYntBFaI5e8G0iq', 'super-users', 'super@hotmail.com', '2015-10-07', '2015-10-07', 0),
(13, 'membre', '$2a$10$EbVMfuu476PVOINJEYm/IOc.L5kblXnZir.lC8u9ZgeBpmywYvSIC', 'membre', 'membre@hotmail.com', '2015-10-07', '2015-10-07', 0),
(14, 'simon', '$2a$10$G151iOOSttv0lAxxdqUy7.5QuSAIQCwGYeUxzix74r0fDjEPZHlnq', 'admin', 'mathieu.dubreuil33@gmail.com', '2015-11-11', '2015-11-11', 0),
(15, 'malik', '$2a$10$oMJ5.6.l/o2C8hTdPSxNO.WvoT35JLQAGOdEyoyhiNRVR2UmJ9tq2', 'admin', 'mathieu.dubreuil33@gmail.com', '2015-11-11', '2015-11-11', 0),
(16, 'bobtest', '$2a$10$wwPD/.DtkOOu7g1P44YtpejZ5RTxpE5cdn1rJ8maulEC6bgnWvV7G', 'admin', 'mathieu.dubreuil33@gmail.com', '2015-11-11', '2015-11-11', 1),
(17, 'boby', '$2a$10$KhqkYZVlzpVZg6IyJJGj4.4mlmYYedPvRJCGY9LPQJ2FEFfz3g9xm', 'super-users', 'mathieu.dubreuil33@gmail.com', '2015-11-11', '2015-11-11', 1),
(23, 'ant', '$2a$10$bYxxSaAzl875P8t62bOvv.HToaNUSmkojQcsxwufP2LIRfjmtj.Ci', 'super-users', 'mathieu.dubreuil33@gmail.com', '2015-11-11', '2015-11-11', 1);
--
-- Index pour les tables exportées
--
--
-- Index pour la table `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `comments`
--
ALTER TABLE `comments`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `ethnies`
--
ALTER TABLE `ethnies`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `names`
--
ALTER TABLE `names`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `offences`
--
ALTER TABLE `offences`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `prisoners`
--
ALTER TABLE `prisoners`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `prisoners_offences`
--
ALTER TABLE `prisoners_offences`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `sexes`
--
ALTER TABLE `sexes`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT pour les tables exportées
--
--
-- AUTO_INCREMENT pour la table `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT pour la table `comments`
--
ALTER TABLE `comments`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT pour la table `ethnies`
--
ALTER TABLE `ethnies`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT pour la table `names`
--
ALTER TABLE `names`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=88;
--
-- AUTO_INCREMENT pour la table `offences`
--
ALTER TABLE `offences`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT pour la table `prisoners`
--
ALTER TABLE `prisoners`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT pour la table `prisoners_offences`
--
ALTER TABLE `prisoners_offences`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT pour la table `sexes`
--
ALTER TABLE `sexes`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT pour la table `users`
--
ALTER TABLE `users`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=24;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
DROP DATABASE IF EXISTS product_features;
CREATE DATABASE product_features;
\c product_features;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE features (
id_encid uuid DEFAULT uuid_generate_v4(),
product_id SERIAL NOT NULL,
feature_banner_header VARCHAR(125) NOT NULL,
feature_banner_text_1 VARCHAR(500) NOT NULL,
feature_banner_text_2 VARCHAR(500) NOT NULL,
feature_setup_header VARCHAR(125) NOT NULL,
feature_setup_description_1 VARCHAR(125) NOT NULL,
feature_setup_description_2 VARCHAR(125) NOT NULL,
feature_setup_description_3 VARCHAR(125) NOT NULL,
additional_features_header VARCHAR(125) NOT NULL,
additional_features_description VARCHAR(500) NOT NULL
);
CREATE TABLE features_list (
id_encid uuid DEFAULT uuid_generate_v4(),
id_decid SERIAL NOT NULL,
header VARCHAR(125) NOT NULL,
description VARCHAR(500) NOT NULL,
product_id INT NOT NULL
);
CREATE TABLE content_grid_feature_items (
id_encid uuid DEFAULT uuid_generate_v4(),
id_decid SERIAL NOT NULL,
title VARCHAR(18) NOT NULL,
description VARCHAR(500) NOT NULL,
product_id INT NOT NULL
);
|
// Daniel Tapia A01022285
// Bases de Datos Avanzadas
//Consultas
// 1: Respuesta: 102
match (p:Person)-[r:ACTED_IN]->() return p
// 2: Respuesta: 8
match (p:Person)-[r:PRODUCED]->() return p
// 3: Respuesta: 28
match (p:Person)-[r:DIRECTED]->() return p
// 4: Respuesta: 32
match (m:Movie) return m, count(m)
// 5: Respuesta: Lilly Wachowski y Lana Wachowski con 2
match (p:Person)-[r:WROTE]->() return p,count(r) order by count(r) desc
// 6 Respuesta:
MATCH p=()-[r:REVIEWED]->(m:Movie) RETURN m, avg(r.rating) AS rating order by rating desc limit 5
// 7 Respuesta:
match t=(p:Person)-[r1:ACTED_IN]->(:Movie)<-[r2:PRODUCED]-(p) return p |
# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table coordinate (
id bigint not null,
latitude float,
longitude float,
constraint pk_coordinate primary key (id))
;
create table fish (
id bigint not null,
common_name varchar(255),
genus varchar(255),
species varchar(255),
scientific varchar(255),
family varchar(255),
image varchar(255),
num_added bigint,
constraint pk_fish primary key (id))
;
create table fish_count (
id bigint not null,
location_id bigint,
fish_id bigint,
count bigint,
constraint pk_fish_count primary key (id))
;
create table location (
id bigint not null,
name varchar(255),
longitude float,
latitude float,
description varchar(255),
good_for varchar(255),
image varchar(255),
constraint pk_location primary key (id))
;
create table location_coordinate (
location_id bigint not null,
coordinate_id bigint not null,
constraint pk_location_coordinate primary key (location_id, coordinate_id))
;
create table location_fish (
location_id bigint not null,
fish_id bigint not null,
constraint pk_location_fish primary key (location_id, fish_id))
;
create sequence coordinate_seq;
create sequence fish_seq;
create sequence fish_count_seq;
create sequence location_seq;
alter table fish_count add constraint fk_fish_count_location_1 foreign key (location_id) references location (id);
create index ix_fish_count_location_1 on fish_count (location_id);
alter table location_coordinate add constraint fk_location_coordinate_locati_01 foreign key (location_id) references location (id);
alter table location_coordinate add constraint fk_location_coordinate_coordi_02 foreign key (coordinate_id) references coordinate (id);
alter table location_fish add constraint fk_location_fish_location_01 foreign key (location_id) references location (id);
alter table location_fish add constraint fk_location_fish_fish_02 foreign key (fish_id) references fish (id);
# --- !Downs
drop table if exists coordinate cascade;
drop table if exists location_coordinate cascade;
drop table if exists fish cascade;
drop table if exists location_fish cascade;
drop table if exists fish_count cascade;
drop table if exists location cascade;
drop sequence if exists coordinate_seq;
drop sequence if exists fish_seq;
drop sequence if exists fish_count_seq;
drop sequence if exists location_seq;
|
set lines 200
select sum(bytes/(1024*1024)) as "DB SIZE IN MB", sum(bytes/(1024*1024*1024)) as "DB SIZE IN GB" from dba_data_files;
|
WITH distinct_res AS (
SELECT home_team, away_team, COUNT(*) AS cnt
FROM event_entity
GROUP BY 1, 2
),
joined_teams AS (
SELECT t1.home_team as t1_home_team, t1.away_team as t1_away_team, t1.cnt as t1_cnt, t2.home_team as t2_home_team, t2.away_team as t2_away_team, t2.cnt as t2_cnt
FROM distinct_res t1
LEFT JOIN distinct_res t2 ON t1.home_team = t2.away_team AND t2.home_team = t1.away_team
),
union_data AS (
SELECT t1_home_team, t1_away_team, t1_cnt
FROM joined_teams
UNION ALL
SELECT t2_away_team, t2_home_team, t1_cnt
FROM joined_teams
)
SELECT t1_home_team, t1_away_team, SUM(t1_cnt)
FROM union_data
WHERE t1_home_team IS NOT NULL AND t1_away_team IS NOT NULL
GROUP BY 1, 2
ORDER BY 3 ASC
|
-- Authors: Leonardo Camargo && Rafael Reis
-- DATE: 22/05/2017
-- ------------- Criação -------------
DROP DATABASE IF EXISTS venda;
CREATE DATABASE venda;
USE venda;
CREATE TABLE Cliente(
cli_codigo INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cli_nome VARCHAR(255) NOT NULL,
cli_nascimento DATE,
cli_cpf VARCHAR(15),
cli_rg VARCHAR(10),
cli_endereco VARCHAR(255),
cli_email VARCHAR(255)
);
CREATE TABLE Categoria(
cat_codigo INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat_descricao VARCHAR(255)
);
CREATE TABLE Produto(
pro_codigo INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat_codigo INT NOT NULL,
FOREIGN KEY(cat_codigo)
REFERENCES Categoria(cat_codigo),
pro_nome VARCHAR(255),
pro_preco FLOAT(15),
pro_estoque integer(15)
);
CREATE TABLE Venda(
ven_codigo INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cli_codigo INT NOT NULL,
FOREIGN KEY(cli_codigo) REFERENCES Cliente(cli_codigo),
ven_data DATE
);
CREATE TABLE Item_Venda(
item_codigo INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
pro_codigo INT NOT NULL,
FOREIGN KEY(pro_codigo)
REFERENCES Produto(pro_codigo),
ven_codigo INT NOT NULL,
FOREIGN KEY(ven_codigo)
REFERENCES Venda(ven_codigo),
item_quantidade VARCHAR(15),
item_valor DECIMAL(15, 3)
);
-- ------------- Tabela Cliente -------------
INSERT INTO Cliente (cli_nome, cli_nascimento, cli_cpf, cli_rg, cli_endereco, cli_email)
VALUES ('Gato de Schrodinger', 261001, '54545413/56', '65446586-4', 'Rua do paradoxo', 'morri@etec.sp.gov.br'),
('Gravidade da Situacao', 120513, '667428700/00', '54544554-7', 'Rua da ForcaG', 'StephenHalking@etec.sp.gov.br'),
('Vaccum', 111101, '299792458/00', '60130008-7', 'Rua da velocidade da luz', 'Einstein@etec.sp.gov.br'),
('XABLAU', 261001, '111111111/11', '60130008-7', 'Rua dos numerozinteiro', 'integer@etec.sp.gov.br'),
('Melhor numero que vc respeita', 261001, '314159265/35', '60130008-7', 'Rua do PI', 'pi3.141592653589793@etec.sp.gov.br'),
('Tangente', 261001, '561651651/35', '60130008-7', 'Rua da hipotenusa', 'seno/cosseno=eu@etec.sp.gov.br'),
('Senhor das Trevas', 261001, '90909090/35', '60130008-7', 'Rua Adjacente', 'systemctl@etec.sp.gov.br'),
('Mol', 261001, '6022101100/00', '60130008-7', 'Rua do seno', ' AugustWilhelm@etec.sp.gov.br'),
('minino', 261001, '30303030/30', '60130008-7', 'Rua do minino', 'dhcpd@etec.sp.gov.br'),
('Linus Torvalds', 261001, '65132165/32', '60130008-7', 'Rua do Sistema bom', 'LinuxMelhorQueRuindows@etec.sp.gov.br');
-- ------------- Tabela Categoria -------------
INSERT INTO Categoria (cat_descricao) VALUES ('Frutas');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (1, 'Uva', 4.00, 10),
(1, 'Laranja', 2.00, 52),
(1, 'Maca', 3.00, 23),
(1, 'Kiwi', 4.00, 10);
INSERT INTO Categoria (cat_descricao) VALUES ('Carne');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (2, 'Picanha', 26.00, 10),
(2, 'Joelho de Porco', 10.00, 10),
(2, 'Maminha', 20.00, 5),
(2, 'Frango', 23.00, 3);
INSERT INTO Categoria (cat_descricao) VALUES ('Graos');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (3, 'Feijao', 3.00, 150),
(3, 'Arroz', 2.00, 150),
(3, 'Cereal', 4.00, 150),
(3, 'Cariopse', 10.00, 150);
INSERT INTO Categoria (cat_descricao) VALUES ('Frios');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (4, 'Salame', 8.00, 100),
(4, 'Presunto', 5.00, 100),
(4, 'Mussarela', 6.00, 100),
(4, 'Mortandela', 8.00, 100);
INSERT INTO Categoria (cat_descricao) VALUES ('MAR');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (5, 'Tilapia', 31.00, 50),
(5, 'Pacu', 20.00, 50),
(5, 'Camarao', 28.00, 50),
(5, 'Bicuda', 25.00, 50);
INSERT INTO Categoria (cat_descricao) VALUES ('Bebidas');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (6, 'Mountain Dew', 2.00, 100),
(6, 'Coca-Cola', 9.00, 100),
(6, 'Red Bull', 12.00, 100),
(6, 'TNT', 11.00, 100);
INSERT INTO Categoria (cat_descricao) VALUES ('Doces');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (7, 'Bala', 0.10, 2000),
(7, 'Chiclete', 1.75, 1000),
(7, 'Chocolate', 5.00, 1000),
(7, 'Pirulito', 1.50, 1000);
INSERT INTO Categoria (cat_descricao) VALUES ('Chipps');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (8, 'Doritos', 6.00, 1000),
(8, 'Cheetos', 5.50, 1000),
(8, 'Ruffles', 6.50, 1000),
(8, 'Pringles', 16.00, 1000);
INSERT INTO Categoria (cat_descricao) VALUES ('Paes');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (9, 'Croissant', 8.00, 1000),
(9, 'Bisnaguinha', 2.00, 1000),
(9, 'Forma', 3.00, 1000),
(9, 'Frances', 5.00, 1000);
INSERT INTO Categoria (cat_descricao) VALUES ('Salgados');
INSERT INTO Produto (cat_codigo, pro_nome, pro_preco, pro_estoque)
VALUES (10, 'Coxinha', 2.50, 30),
(10, 'Risoles', 3.50, 30),
(10, 'Pastel', 2.00, 1),
(10, 'Kibe', 2.00, 1);
-- List number of clients
select count(cli_codigo) from Clientes;
-- List number of categories
select count(*) from Categoria;
-- List
select cat_descricao from Categoria;
-- List
-- codigo Base
--select count(cat_codigo) from Produto where cat_codigo = 1;
-- ------------- Tabela Venda ---------------
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor),
VALUES (1, 5, item_quantidade * 4.00),
VALUES (2, 3, item_quantidade * 2.00);
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES (6, 4, (item_quantidade * 10.00)),
VALUES (7, 9, (item_quantidade * 20.00));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES (9, 1, (item_quantidade * 3.00)),
VALUES (8, 2, (item_quantidade * 23.00));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES (23, 7, (item_quantidade * 9.00)),
VALUES (15, 4, (item_quantidade * 6.00));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor
VALUES (29, 2, (item_quantidade * 6.00)),
VALUES (15, 6, (item_quantidade * 6.00)),
VALUES (9, 5, (item_quantidade * 3.00)),
VALUES (10, 15, (item_quantidade * 2.00));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES (31, 4, (item_quantidade * 6.50)),
VALUES (32, 2, (item_quantidade * 16.00));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES (33, 2, (item_quantidade * 8.00)),
VALUES (34, 8, (item_quantidade * 2.00));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES (35, 5, (item_quantidade * 3.00)),
VALUES (36, 5, (item_quantidade * 5.00));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES(37, 3, (item_quantidade * 2.50)),
VALUES(38, 5, (item_quantidade * 3.50));
INSERT INTO Item_Venda (pro_codigo, item_quantidade, item_valor)
VALUES (39, 1, (item_quantidade * 2.00)),
VALUES (40, 1, (item_quantidade * 2.00));
|
drop table if exists madlibtestdata.evaluation_lda;
create table madlibtestdata.evaluation_lda (
eval_src text, -- 'R'
dataset text, -- Name of data set
topic_no integer,-- Number of topics
perplexity double precision
);
alter table madlibtestdata.evaluation_lda owner to madlibtester;
----------------------------------------------------------------------------
insert into madlibtestdata.evaluation_lda values
('R', 'AssociatedPress', 10, 2356.61687563252),
('R', 'AssociatedPress', 20, 1987.22860262696),
('R', 'AssociatedPress', 30, 1792.40716887695),
('R', 'AssociatedPress', 40, 1680.8284780254),
('R', 'AssociatedPress', 50, 1597.29612635741),
('R', 'AssociatedPress', 60, 1544.01058613653),
('R', 'AssociatedPress', 70, 1503.20411970059),
('R', 'AssociatedPress', 80, 1468.83501487259),
('R', 'AssociatedPress', 90, 1446.54200105897),
('R', 'AssociatedPress', 100, 1429.71636336914);
|
/**
*Liam Salazar
*Employee Relation has data of PV Airways's employees
*/
CREATE TABLE employees(
employee_ID VARCHAR(4) AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Branch VARCHAR(50) NOT NULL,
Position VARCHAR(50) NOT NULL,
Email VARCHAR(50) NOT NULL,
Phone VARCHAR(25) NOT NULL,
CONSTRAINT fk_EmployeesBranch FOREIGN KEY (Branch)
REFERENCES branch(branch_ID)
);
|
DROP DATABASE IF EXISTS bookMatch;
CREATE DATABASE bookMatch;
DROP DATABASE IF EXISTS testdb;
CREATE DATABASE testdb;
|
insert into restaurant(name)
values ('Central'), ('Física'), ('Prefeitura'), ('Química'); |
DROP TABLE IF EXISTS `tb_message_package_no`;
CREATE TABLE `tb_message_package_no` (
`no` int(11) DEFAULT '0' COMMENT '消息包编号',
`create_time` datetime DEFAULT NULL COMMENT '创建时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='消息包编号表'; |
SELECT * from student |
CREATE TABLE infos (
id integer NOT NULL,
name varchar(100) NOT NULL,
text varchar(100) NOT NULL
);
INSERT INTO infos(id,name,text) VALUES('0','Database','PostgreSQL');
|
drop database if exists lawyer;
create database lawyer;
use lawyer;
create table lawyer(
id int not null primary key auto_increment,
contact int not null,
price decimal(8,2) not null
);
create table defense(
id int not null primary key auto_increment,
lawyer int not null,
duration datetime not null
);
create table defense_client(
defense int not null,
client int not null
);
create table client(
id int not null primary key auto_increment,
contact int not null
);
create table defense_associate(
defense int not null,
associate int not null
);
create table associate(
id int not null primary key auto_increment,
experience varchar(50) not null,
contact int not null
);
alter table defense add foreign key (lawyer) references lawyer(id);
alter table defense_client add foreign key (defense) references defense(id);
alter table defense_client add foreign key (client) references client(id);
alter table defense_associate add foreign key (defense) references defense(id);
alter table defense_associate add foreign key (associate) references associate(id);
|
CREATE VIEW PostView AS
SELECT POS.*, CTY.Name AS CountryName, CTY.NameInt AS CountryNameInternational, USR.Username AS CreatedUser
FROM Post AS POS
LEFT OUTER JOIN User AS USR ON USR.Id = POS.CreatedBy
LEFT OUTER JOIN Country AS CTY ON CTY.Id = POS.Country |
-- is database is no exists
CREATE DATABASE IF NOT EXISTS hbtn_0c_0;
|
insert into medicine values('Panadol','200mg p','UN');
insert into medicine values('Revanen','300mg r','Man');
insert into medicine values('Voltaren','110mg v','IL&S');
insert into medicine values('Panda','150mg p','yNet');
insert into medicine values('Rolman','225mg r','s'); |
USE comboioslusitanos;
-- bilhete com custo mínimo
CREATE VIEW BilheteMínimo AS
SELECT MIN(CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END) AS BilheteMaisBarato
FROM Bilhete AS B INNER JOIN Reserva AS R;
-- bilhete com custo máximo
CREATE VIEW BilheteMáximo AS
SELECT MAX(CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END) AS BilheteMaisBarato
FROM Bilhete AS B INNER JOIN Reserva AS R;
-- 4 bihetes com menor custo
CREATE VIEW 4BilhetesMínimos AS
SELECT DISTINCT nrbilhete, (CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END) AS custo
FROM Bilhete AS B INNER JOIN Reserva AS R
ORDER BY custo
LIMIT 4;
-- junção da tabela Cliente com os seus Endereços
CREATE VIEW ClienteEOSeuEndereço AS
SELECT *
FROM Cliente AS C INNER JOIN Endereco AS E
ON C.email=E.cliente_email;
-- criação de uma tabela auxiliar com bilhetes da classe executiva
CREATE VIEW Normal AS
SELECT nrbilhete, DataChegada, DataPartida, CustoNormal AS Custo, numeroB, carruagemB, classeB, Viagem_idV, Reserva_idR
FROM Bilhete
WHERE ClasseB='executiva';
-- criação de uma tabela auxiliar com bilhetes da classe económica
CREATE VIEW Barato AS
SELECT nrbilhete, DataChegada, DataPartida, CustoNormal AS Custo, numeroB, carruagemB, classeB, Viagem_idV, Reserva_idR
FROM Bilhete
WHERE ClasseB='económica';
-- custo real bilhete
CREATE VIEW CustoBilhete AS
SELECT (CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END) AS CustoReal, CustoNormal, idR, Cliente_Email, Data, DataPartida
FROM Reserva AS R INNER JOIN Bilhete AS B
WHERE R.idR=B.Reserva_idR;
-- montante de cada reserva
CREATE VIEW MontanteReserva AS
SELECT (SUM(CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END)) AS CustoPorReserva, idR, Cliente_Email
FROM Reserva AS R INNER JOIN Bilhete AS B
ON R.idr=B.reserva_idr
INNER JOIN Cliente AS C
ON R.cliente_email = C.email
GROUP BY idr;
-- montante a pagar por cada cliente pelas suas reservas
CREATE VIEW CustoReservasCliente AS
SELECT (SUM(CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END)) AS CustoPorCliente, Nome, Cliente_Email
FROM Reserva AS R INNER JOIN Bilhete AS B
ON R.idr=B.reserva_idr
INNER JOIN Cliente AS C
ON R.cliente_email = C.email
GROUP BY email;
-- lucro total de cada viagem
CREATE VIEW LucroViagem AS
SELECT (SUM(CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END)) AS LucroDeCadaViagem, idV, comboio_idc
FROM Reserva AS R INNER JOIN Bilhete AS B
ON R.idr=B.reserva_idr
INNER JOIN Viagem AS V
ON B.Viagem_idV=V.idV
GROUP BY idv;
-- lucro total de todas as viagens
CREATE VIEW LucroViagens AS
SELECT (SUM(CASE WHEN R.Data<B.DataPartida THEN B.CustoDesconto ELSE B.CustoNormal END)) AS LucroTotal
FROM Reserva AS R INNER JOIN Bilhete AS B
ON R.idr=B.reserva_idr
INNER JOIN Viagem AS V
ON B.Viagem_idV=V.idV;
-- numero total de utilizadores que compram bilhete
CREATE VIEW NúmeroUtilizadoresCompramBilhete AS
SELECT COUNT(*)
FROM (SELECT DISTINCT email
FROM Cliente AS C INNER JOIN Reserva AS R
ON C.email=R.Cliente_Email) AS E;
-- id reservas feitas por um utilizador
CREATE VIEW ReservasDeUtilizador AS
SELECT idR, Cliente_Email
FROM Reserva AS R INNER JOIN Cliente AS C
WHERE R.Cliente_Email=C.Email
ORDER BY email;
-- numero de reservas feitas por cada utilizador
CREATE VIEW NúmeroReservasUtilizador AS
SELECT nome, COUNT(idr)
FROM Reserva AS R INNER JOIN Cliente AS C
ON R.cliente_email=C.email
GROUP BY nome;
-- quantidade de bilhetes comprados por cada utilizador
CREATE VIEW QuantidadeBilhetesUtilizador AS
SELECT nome, COUNT(nrbilhete)
FROM Bilhete AS B INNER JOIN Reserva AS R
ON B.reserva_idr=R.idr
INNER JOIN Cliente AS C
ON R.cliente_email=C.email
GROUP BY nome;
-- bilhetes comprados por cada utilizador e origem e destino de cada um dos bilhetes
CREATE VIEW BilhetesCompradosUtilizador AS
SELECT nome, nrbilhete, origem, destino
FROM Viagem AS V INNER JOIN Bilhete AS B
ON V.idv=B.viagem_idv
INNER JOIN Reserva AS R
ON B.reserva_idr=R.idr
INNER JOIN Cliente AS C
ON R.cliente_email=C.email;
-- comboio destinado a cada bilhete e origem e destino da viagem correspondente a esse bilhete
CREATE VIEW ComboioBilhete AS
SELECT nrbilhete, comboio_idc, origem, destino
FROM Bilhete AS B INNER JOIN Viagem AS V
ON B.viagem_idv=V.idv
ORDER BY nrbilhete;
-- viagens e comboios respetivos
CREATE VIEW ViagemComboio AS
SELECT idv, comboio_idc, origem, destino FROM Viagem;
-- todas viagens com origens e destinos correspondentes
CREATE VIEW Viagens AS
SELECT idv, nrbilhete, comboio_idc, origem, destino
FROM Bilhete AS B INNER JOIN Viagem AS V
ON B.viagem_idv=V.idv
ORDER BY idv;
-- viagens e horários respetivos
CREATE VIEW ViagensHorários AS
SELECT idv, horariopartida, horariochegada, origem, destino
FROM Viagem;
-- horário correspondente a cada bilhete
CREATE VIEW BilheteHorário AS
SELECT nrbilhete, horariopartida, horariochegada, origem, destino, datapartida, datachegada, idv
FROM Viagem AS V INNER JOIN Bilhete AS B
ON V.idv = B.viagem_idv
ORDER BY nrbilhete;
-- lugares ocupados em cada comboio numa viagem
CREATE VIEW LugaresOcupadosViagem AS
SELECT idc, numerob, carruagemb, classeb, nrbilhete, idv, origem, destino
FROM Comboio AS C INNER JOIN Viagem AS V
ON C.idc = V.comboio_idc
INNER JOIN Bilhete AS B
ON V.idv = B.viagem_idv
ORDER BY idc;
-- numero de lugares ocupados em cada comboio numa viagem
CREATE VIEW NúmeroLugaresOcupadosViagem AS
SELECT idc, count(numerob), idv, origem, destino
FROM Comboio AS C INNER JOIN Viagem AS V
ON C.idc = V.comboio_idc
INNER JOIN Bilhete AS B
ON V.idv = B.viagem_idv
GROUP BY idc;
-- numero de lugares livres num comboio de uma dada viagem
CREATE VIEW NúmeroLugaresLivresViagem AS
SELECT idc, idv, (Lotacao-COUNT(numerob)) AS LugLiv, DataPartida, HorarioPartida, DataChegada, HorarioChegada, Origem, Destino
FROM Comboio AS C INNER JOIN Viagem AS V
ON C.idc = V.comboio_idc
INNER JOIN Bilhete AS B
ON V.idv = B.viagem_idv
GROUP BY NrBilhete
Order By idC;
-- lugares livres em cada comboio
CREATE VIEW LugaresLivresComboio AS
SELECT idc, nrbilhete, numerob, origem, destino, datapartida, datachegada, idv, numero, carruagem
FROM Lugar AS L INNER JOIN Comboio C
ON L.comboio_idc = C.idc
INNER JOIN Viagem AS V
ON C.idc = V.comboio_idc
INNER JOIN Bilhete AS B
ON V.idv = B.viagem_idv
WHERE numerob <> numero; |
with collnk
as (
select
i.table_name,
i.schema_name,
string_agg(h.column_name+' '+h.data_type+
case when h.character_maximum_length is null then '' else '('+h.character_maximum_length+')' end +
case when h.numeric_precision is null then '' else '('+h.numeric_precision+','+h.numeric_scale+')' end +
' NOT NULL', ',')
within group (order by i.column_position) as column_list,
string_agg(i.column_name,',')
within group (order by i.column_position) as column_ui_list
from adf.meta_lnk_mapping i
inner join adf.meta_hub_mapping h
on i.hub_table_name = h.table_name
and i.column_name = h.column_name
where i.active_ind = 1
group by i.table_name, i.schema_name
)
SELECT -- lnk
replace(
replace(
replace(
replace(g.core, '<column_ui_list>', h.column_ui_list)
, '<column_statement_list>', h.column_list)
, '<table_name>', h.table_name)
, '<schema_name>', h.schema_name
) + char(10) + char(13)
FROM [mtd].[master_generator] g
cross join collnk h
inner join adf.meta_lnk_mapping s
on h.table_name = s.table_name
and s.column_position = 1
where generator_type = 'create_lnk_table'
and active_ind = 1 |
ALTER TABLE "public"."users" ADD COLUMN "gravatar" jsonb NULL; |
SELECT
note.ID AS ID,
note.NOTE AS NOTE,
note.NOTENAME AS NOTENAME,
note.CREATEDBY AS CREATEDBY,
note.CREATEDDURATION AS CREATEDDURATION,
note.MODIFIEDDURATION AS MODIFIEDDURATION,
note.VERSION AS VERSION,
note.MODIFIEDBY AS MODIFIEDBY,
note.MODIFIEDDATE AS MODIFIEDDATE,
note.CASENOTEID AS CASENOTEID,
note.TASKNOTEID AS TASKNOTEID,
note.DOCUMENTNOTEID AS DOCUMENTNOTEID,
note.EXTERNALPARTYNOTE AS EXTERNALPARTYNOTE,
note.CASEWORKERNOTE AS CASEWORKERNOTE,
note.CREATEDBY_NAME AS CREATEDBY_NAME,
note.MODIFIEDBY_NAME AS MODIFIEDBY_NAME,
(CASE WHEN NVL(:Task_Id,0) = 0 then
(SELECT dcs.col_ISFINISH FROM tbl_case cs
INNER JOIN tbl_cw_workitem cw ON cs.col_cw_workitemcase = cw.col_id
INNER JOIN tbl_dict_casestate dcs ON cw.col_cw_workitemdict_casestate = dcs.col_id
WHERE cs.col_id = note.CASENOTEID)
ELSE
(SELECT dts.col_ISFINISH FROM tbl_task tsk
INNER JOIN tbl_tw_workitem tw ON tsk.col_tw_workitemtask = tw.col_id
INNER JOIN tbl_dict_taskstate dts ON tw.col_tw_workitemdict_taskstate = dts.col_id
WHERE tsk.col_id = note.TASKNOTEID)
END) AS STATE_ISFINISH
FROM (
select
tn.COL_ID AS ID,
tn.COL_NOTE AS NOTE,
tn.COL_NOTENAME AS NOTENAME,
tn.COL_CREATEDBY AS CREATEDBY,
F_UTIL_GETDRTNFRMNOW (tn.COL_CREATEDDATE) AS CREATEDDURATION,
F_UTIL_GETDRTNFRMNOW (tn.COL_MODIFIEDDATE) AS MODIFIEDDURATION,
tn.COL_VERSION AS VERSION,
tn.COL_MODIFIEDBY AS MODIFIEDBY,
tn.COL_MODIFIEDDATE AS MODIFIEDDATE,
tn.COL_CASENOTE AS CASENOTEID,
tn.COL_TASKNOTE AS TASKNOTEID,
tn.COL_NOTEDOCUMENT AS DOCUMENTNOTEID,
tn.COL_EXTERNALPARTYNOTE AS EXTERNALPARTYNOTE,
tn.COL_NOTEPPL_CASEWORKER AS CASEWORKERNOTE,
F_getnamefromaccesssubject(tn.COL_CREATEDBY) AS CREATEDBY_NAME,
F_getnamefromaccesssubject(tn.COL_MODIFIEDBY) AS MODIFIEDBY_NAME
from TBL_NOTE tn
where (:Document_Id IS NOT NULL
<%= IfNotNull(":Document_Id", " AND tn.COL_NOTEDOCUMENT = :Document_Id") %> )
or
(:Document_Id IS NULL
<%= IfNotNull(":Case_Id", " AND tn.COL_CASENOTE = :Case_Id") %>
<%= IfNotNull(":Task_Id", " AND tn.COL_TASKNOTE = :Task_Id") %>
<%= IfNotNull(":ExternalParty_Id", " AND tn.COL_EXTERNALPARTYNOTE = :ExternalParty_Id") %>
<%= IfNotNull(":CaseWorker_Id", " AND tn.COL_NOTEPPL_CASEWORKER = :CaseWorker_Id") %>)
) note
<%=IfNotNull("@SORT@", " ORDER BY @SORT@ @DIR@, 1")%> |
CREATE TABLE [AsData_PL].[Va_Application]
(
[ApplicationId] BigInt IDENTITY(1,1) PRIMARY KEY
,[CandidateId] Bigint
,[VacancyId] Bigint
,[ApplicationStatusTypeId] Int
,[ApplicationStatusDesc] Varchar(255)
,[CandidateAgeAtApplication] int
,[BeingSupportedBy] nvarchar(50)
,[LockedForSupportUntil] datetime
,[IsWithdrawn] bit
,[ApplicationGuid] Varchar(256)
,[CreatedDateTime] DateTime
,[SourceDb] Varchar(100)
,[SourceApplicationId] INT
,[AsDm_UpdatedDateTime] [datetime2](7) DEFAULT (getdate())
,Foreign Key (CandidateId) References [AsData_PL].[Va_Candidate](CandidateId)
,Foreign Key (VacancyId) References [AsData_PL].[Va_Vacancy](VacancyId)
) |
#--TP 1 - by fakumax
SHOW databases;
USE editorial;
#--1.2. Listar todAS lAS columnAS de empleados y la descripción del cargo que tienen.
SELECT empleados.*,cargos.cargo_descripcion
FROM empleados,cargos
WHERE empleados.cargo_id= cargos.cargo_id;
|
DROP DATABASE finalgroup;
CREATE DATABASE finalgroup;
USE finalgroup;
CREATE TABLE state (
state_id int NOT NULL,
state_name VARCHAR(15) NOT NULL,
PRIMARY KEY (state_id)
);
INSERT INTO state(state_id, state_name)
VALUES(1, 'Missouri');
INSERT INTO state(state_id, state_name)
VALUES(2, 'Kansas');
CREATE TABLE city (
city_id int NOT NULL,
city_name VARCHAR(25) NOT NULL,
state_id int NOT NULL,
PRIMARY KEY (city_id),
FOREIGN KEY (state_id) REFERENCES state(state_id)
);
INSERT INTO city(city_id, city_name, state_id)
VALUES(1, 'Kansas City', 1);
INSERT INTO city(city_id, city_name, state_id)
VALUES(2, 'Raymore', 1);
INSERT INTO city(city_id, city_name, state_id)
VALUES(3, 'Overland Park', 2);
CREATE TABLE street_address (
address_id int NOT NULL,
street_address VARCHAR(225) NOT NULL,
city_id int NOT NULL,
PRIMARY KEY (address_id),
FOREIGN KEY (city_id) REFERENCES city(city_id)
);
INSERT INTO street_address(address_id, street_address, city_id)
VALUES (1, '1405 Young Circle', 2);
INSERT INTO street_address(address_id, street_address, city_id)
VALUES (2, '14102 Cody', 3);
INSERT INTO street_address(address_id, street_address, city_id)
VALUES (3, '101 E 134th Street', 1);
CREATE TABLE student (
fname VARCHAR (25) NOT NULL,
lname VARCHAR (25) NOT NULL,
student_id int NOT NULL,
address_id int NOT NULL,
PRIMARY KEY (student_id),
FOREIGN KEY (address_id) REFERENCES street_address (address_id)
);
INSERT INTO student(fname, lname, student_id, address_id)
VALUES ('Anthony', 'Kammerer', 1, 3);
INSERT INTO student(fname, lname, student_id, address_id)
VALUES ('Kyle', 'Ruark', 2, 2);
INSERT INTO student(fname, lname, student_id, address_id)
VALUES ('Conner', 'Raby', 3, 1);
CREATE TABLE phone_number (
phone_id int NOT NULL,
Phone_number VARCHAR(12) NOT NULL,
student_id int NOT NULL,
PRIMARY KEY (phone_id),
FOREIGN KEY (student_id) REFERENCES student(student_id)
);
INSERT INTO phone_number(phone_id, Phone_number, student_id)
VALUES (1, '8162136356', 1);
INSERT INTO phone_number(phone_id, Phone_number, student_id)
VALUES (2, '9137481641', 2);
INSERT INTO phone_number(phone_id, Phone_number, student_id)
VALUES (3, '8167218855', 3);
|
SELECT Nodes.Caption AS [Device], Nodes.DetailsURL AS [_LinkFor_Device]
,'/Orion/images/StatusIcons/Small-' + StatusIcon AS [_IconFor_Device]
, Nodes.IP_Address as [IP], Nodes.DetailsURL as [_LinkFor_IP]
, ssm.MacAddress
, ssm.Role
, ssm.SwitchNumber
, ssm.SwPriority
, Nodes.MachineType
, ssm.SerialNumber
, Cpu.AvgLoad AS CPU
, CONCAT(HOURDIFF(tolocal(Nodes.LastBoot),getdate())/24,' Day(s) ',
HOURDIFF(tolocal(Nodes.LastBoot),getdate())-(HOURDIFF(tolocal(Nodes.LastBoot),getdate())/24)*24,'h ',
MINUTEDIFF(tolocal(Nodes.LastBoot),getdate())-(MINUTEDIFF(tolocal(Nodes.LastBoot),getdate())/60)*60,'m') AS Uptime
FROM Orion.CPUMultiLoadCurrent AS cpu
INNER JOIN Orion.Nodes AS Nodes ON cpu.NodeID = Nodes.NodeID
INNER JOIN Orion.NPM.SwitchStackMember AS ssm ON ssm.NodeID = cpu.NodeID AND ssm.MemberID = cpu.CPUIndex
WHERE Cpu.AvgLoad >= 80
ORDER BY Cpu.AvgLoad DESC
|
DELIMITER //
CREATE PROCEDURE banc_db.UpdatePerson(
IN id int,
IN fname text,
IN mname text,
IN lname text,
IN mail text,
IN pr bool,
IN dp bool,
IN aId text,
IN tel text,
IN mtel text,
IN isM bool
)
BEGIN
-- exit if the duplicate key occurs
DECLARE EXIT HANDLER FOR 1062 SELECT firstname, lastname, entity_id from banc_db.person where firstname=fname and middlename=mname and lastname=lname and email=mail;
-- insert update a row in Person
UPDATE banc_db.person SET firstname=fname, middlename=mname,lastname=lname, email=mail, prime=pr, dependent=dp, affiliationId=aId,
telephone=tel, mobile=mtel, isMinor=isM WHERE entity_id=id;
END //
DELIMITER ;
|
-- phpMyAdmin SQL Dump
-- Host: localhost:3306
-- Generation Time: Mar 21, 2019 at 04:26 PM
-- Server version: 5.7.23
-- Database: `eshopdb`
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`login` varchar(40) NOT NULL,
`password` varchar(80) NOT NULL,
`name` varchar(30) DEFAULT NULL,
`address` varchar(50) DEFAULT NULL,
`comment` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `login`, `password`, `name`, `address`, `comment`) VALUES
(4, 'admin', '1e8949373cf0dc044b49c9dd3ddd1835', 'Alexander', 'Odessa', 'admin'),
(5, 'lex@gmail.com', '-5039f9f6cecff39cf359c1de1fbc2b7f', 'Alex', 'Kiev', 'call before delivery'),
(6, 'mash198@ukr.net', '53df562cd13c57455c2c1bbe1854458f', 'Maria', 'Lviv', 'don\'t call'),
(9, 'julia@gmail.com', '-63d66444ee4a31da4af4872610e66a14', 'Julia', 'Kiev', 'don\'t call'),
(10, 'serg@ukr.net', '-63d66444ee4a31da4af4872610e66a14', 'Serg Kovalenko', 'Kiev, Zdolbunovskogo str., 38', '-'),
(14, 't@test.com', '-63d66444ee4a31da4af4872610e66a14', 'test', 'kiev', '');
-- --------------------------------------------------------
-- Table structure for table `categories`
--
CREATE TABLE `categories` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `categories`
--
INSERT INTO `categories` (`id`, `name`) VALUES
(1, 'dresses'),
(2, 'shoes'),
(3, 'accessories');
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`category` int(11) DEFAULT NULL,
`price` int(11) DEFAULT NULL,
`description` varchar(300) DEFAULT NULL,
`image` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `name`, `category`, `price`, `description`, `image`) VALUES
(1, 'Nora Naviano Imressive dusty blue', 1, 3450, 'Blue evening dress with an embroidered bodice and a narrow belt. Model of 2019 year. Main material: atlas. Light shine of a fabric and the romantic muffled shade of blue will submit the most dreamy girls. ', 'dusty-blue-400x650_3400.jpg'),
(2, 'Very berry marsala', 1, 1654, 'Very berry. Long satin dress with a guipure top, a high waistline and a boat neckline. Color: Marsala.', 'evening_dress_f1_2300.jpg'),
(3, 'Dress \'Felicia\'', 1, 3400, 'Silk satin dress. The top of the dress is laced. Silk satin skirt fits perfectly on the hips due to the folds. Dresses of A-shaped cut look amazing in a satin version, especially in pastel colors: ashy rose, peach, coffee colors.', 'evening_dress_felicia_4500.jpg'),
(4, 'Shoes ROSE GOLD Rock Glitter Ankle', 2, 2100, 'Comfortable stylish shoes decorated with sequins', 'baletki_1255.jpg'),
(5, 'Dolce & Gabbana', 2, 3500, 'Shoes Dolce & Gabbana, velvet wine shade, decorated with rhinestones', 'Dolce & Gabbana_3500.jpg'),
(6, 'Rene Caovilla', 2, 3750, 'Evening shoes Rene Caovilla, black velvet with rhinestones.', 'Rene_Caovilla_4300.jpg'),
(7, 'Lady bag Parfois 163918-BU', 3, 1429, 'Portugal, size 28 x 29 x 13 см', 'parfois_163918-BU.jpg'),
(8, 'Lady bag Furla', 3, 1200, 'Italy, size 22 х 4,5 х 15 см', 'furla_1.jpg'),
(9, 'Evening clutch with rhinestones', 3, 1200, 'The outer part of the bag is completely covered with rhinestone ornament. The back of the accessory is silver brocade. The case is rigid, the metal frame is silver. The size 22 х 4,5 х 12 см', 'klatch.jpg');
-- --------------------------------------------------------
-- Table structure for table `carts`
--
CREATE TABLE `carts` (
`userId` int(11) DEFAULT NULL,
`productId` int(11) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `carts`
--
INSERT INTO `carts` (`userId`, `productId`, `quantity`) VALUES
(4, 1, 3),
(4, 5, 1),
(4, 4, 2);
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`orderNumber` int(11) DEFAULT NULL,
`status` varchar(100) DEFAULT NULL,
`userId` int(11) DEFAULT NULL,
`productId` int(11) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `orders`
--
INSERT INTO `orders` (`orderNumber`, `status`, `userId`, `productId`, `quantity`) VALUES
(1, 'ordered', 4, 5, 3),
(1, 'ordered', 4, 1, 3),
(2, 'ordered', 4, 2, 2),
(3, 'ordered', 4, 7, 1),
(4, 'ordered', 4, 9, 2),
(4, 'ordered', 4, 1, 1),
(5, 'ordered', 4, 4, 2),
(5, 'ordered', 4, 2, 1),
(6, 'ordered', 4, 1, 1),
(7, 'ordered', 4, 1, 1),
(8, 'ordered', 4, 4, 4),
(9, 'ordered', 4, 1, 1),
(9, 'ordered', 4, 4, 1),
(10, 'ordered', 4, 1, 1),
(11, 'ordered', 4, 2, 3),
(12, 'ordered', 4, 9, 3),
(13, 'ordered', 4, 5, 1),
(13, 'ordered', 4, 4, 2),
(14, 'ordered', 4, 1, 1),
(15, 'ordered', 4, 4, 1),
(15, 'ordered', 4, 2, 1),
(16, 'ordered', 4, 3, 2),
(17, 'ordered', 4, 8, 3),
(18, 'ordered', 9, 5, 1),
(18, 'ordered', 9, 3, 3),
(18, 'ordered', 9, 1, 1),
(19, 'ordered', 4, 3, 1),
(20, 'ordered', 4, 2, 1),
(21, 'ordered', 4, 5, 1),
(21, 'ordered', 4, 9, 2),
(21, 'ordered', 4, 1, 1),
(22, 'ordered', 4, 2, 1),
(23, 'ordered', 4, 7, 3),
(24, 'ordered', 4, 1, 1);
-- --------------------------------------------------------
--
-- Indexes for dumped tables
--
--
-- Indexes for table `carts`
--
ALTER TABLE `carts`
ADD KEY `userId` (`userId`),
ADD KEY `productId` (`productId`);
--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD KEY `userId` (`userId`),
ADD KEY `productId` (`productId`);
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`),
ADD KEY `category` (`category`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `login` (`login`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `carts`
--
ALTER TABLE `carts`
ADD CONSTRAINT `carts_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`),
ADD CONSTRAINT `carts_ibfk_2` FOREIGN KEY (`productId`) REFERENCES `products` (`id`);
--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
ADD CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`),
ADD CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`productId`) REFERENCES `products` (`id`);
--
-- Constraints for table `products`
--
ALTER TABLE `products`
ADD CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category`) REFERENCES `categories` (`id`);
SET FOREIGN_KEY_CHECKS=1;
|
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 15, 2019 at 10:30 AM
-- Server version: 10.1.38-MariaDB
-- PHP Version: 5.6.40
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: `hotel`
--
-- --------------------------------------------------------
--
-- Table structure for table `add_room`
--
CREATE TABLE `add_room` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`hotel_id` int(50) NOT NULL,
`wifi` varchar(100) NOT NULL,
`ac` varchar(100) NOT NULL,
`ac_per_day` int(50) NOT NULL,
`body_message` varchar(100) NOT NULL,
`body_message_per_day` int(50) NOT NULL,
`meal` varchar(100) NOT NULL,
`meal_per_day` int(50) NOT NULL,
`image` varchar(50) NOT NULL,
`price` int(11) NOT NULL,
`bed_cost` int(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `add_room`
--
INSERT INTO `add_room` (`id`, `name`, `hotel_id`, `wifi`, `ac`, `ac_per_day`, `body_message`, `body_message_per_day`, `meal`, `meal_per_day`, `image`, `price`, `bed_cost`) VALUES
(5, 'RDA109', 1, 'yes', 'yes', 100, 'yes', 500, 'yes', 1000, '680ad26a-d657-4264-b35c-82d7b32639e0.jpg', 1000, 500),
(6, 'RDA107', 1, 'yes', 'yes', 100, 'yes', 500, 'yes', 1000, '05.jpg', 1200, 600),
(7, 'RDA108', 1, 'yes', 'yes', 100, 'yes', 500, 'yes', 1000, '07.jpg', 1500, 700);
-- --------------------------------------------------------
--
-- Table structure for table `bed`
--
CREATE TABLE `bed` (
`sl_id` int(20) NOT NULL,
`bed_no` varchar(100) NOT NULL,
`room_id` varchar(100) NOT NULL,
`check_in` varchar(100) NOT NULL,
`check_out` varchar(100) NOT NULL,
`user_id` int(50) NOT NULL,
`status` int(50) NOT NULL,
`bed_image` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `bed`
--
INSERT INTO `bed` (`sl_id`, `bed_no`, `room_id`, `check_in`, `check_out`, `user_id`, `status`, `bed_image`) VALUES
(3, 'RDA109-1', '5', '', '', 0, 0, '11.jpg'),
(4, 'RDA109-2', '5', '', '', 0, 0, '12.jpg'),
(5, 'RDA107-1', '6', '', '', 0, 0, '11.jpg'),
(6, 'RDA107-2', '6', '', '', 0, 0, '12.jpg'),
(7, 'RDA108-1', '7', '', '', 0, 0, '14.jpg'),
(8, 'RDA108-2', '7', '', '', 0, 0, '14.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `booking`
--
CREATE TABLE `booking` (
`id` int(50) NOT NULL,
`user_id` int(50) NOT NULL,
`bed_no` varchar(100) NOT NULL,
`check_in` varchar(100) NOT NULL,
`check_out` varchar(100) NOT NULL,
`num_days` int(50) NOT NULL,
`ac` varchar(100) NOT NULL,
`meal` varchar(100) NOT NULL,
`spa` varchar(100) NOT NULL,
`total` int(50) NOT NULL,
`statas` int(50) NOT NULL,
`account_number` varchar(100) NOT NULL,
`transaction_id` varchar(100) NOT NULL,
`comission` int(30) NOT NULL,
`earn` int(30) NOT NULL,
`cus_name` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`mobile` varchar(100) NOT NULL,
`image` varchar(100) NOT NULL,
`visa_image` varchar(100) NOT NULL,
`cus_address` varchar(100) NOT NULL,
`bed_id` int(30) NOT NULL,
`date` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `booking`
--
INSERT INTO `booking` (`id`, `user_id`, `bed_no`, `check_in`, `check_out`, `num_days`, `ac`, `meal`, `spa`, `total`, `statas`, `account_number`, `transaction_id`, `comission`, `earn`, `cus_name`, `email`, `mobile`, `image`, `visa_image`, `cus_address`, `bed_id`, `date`) VALUES
(16, 7, 'RDA109-2', '2019-06-21', '2019-06-22', 2, 'yes', 'yes', '', 1995, 2, '01546541645', '01241jhghjgfjh', 5, 105, 'sumon', 'facebookhghj126@gmail.com', '1938531102', 'ddff7841-53ae-4db7-a2c5-2728771c2d82.jpg', '20f5a4ec-22d5-4125-b133-6baa098a4193.jpg', 'hkjk, hkhk', 4, ''),
(17, 7, 'RDA107-2', '2019-06-21', '2019-06-24', 2, 'yes', 'no', '', 3705, 1, ' none', 'none', 5, 195, 'Boishakhibd', 'ssk58021@gmail.com', '1938531102', '9cf3e750-f5d4-47c5-aa8a-30ff0f503c79.jpg', '815ed802-ed70-41b9-afcf-02b2d1ac6419.jpg', 'jhamgora', 6, ''),
(18, 0, 'RDA109-2', '2019-07-15', '2019-07-16', 2, 'no', 'no', 'no', 1000, 1, ' none', 'none', 0, 0, 'sksojib', 'ssk58021@gmail.com', '01718825371', 'bus3.jpg', 'bus8.jpg', 'dhaka', 4, '2019-07-15');
-- --------------------------------------------------------
--
-- Table structure for table `contact`
--
CREATE TABLE `contact` (
`id` int(10) UNSIGNED NOT NULL,
`fullname` varchar(100) DEFAULT NULL,
`phoneno` int(10) DEFAULT NULL,
`email` text,
`cdate` date DEFAULT NULL,
`approval` varchar(12) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `cost`
--
CREATE TABLE `cost` (
`id` int(30) NOT NULL,
`date` varchar(100) NOT NULL,
`cost` int(20) NOT NULL,
`desc` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `cost`
--
INSERT INTO `cost` (`id`, `date`, `cost`, `desc`) VALUES
(1, '2019-07-12', 1000, ' sdds'),
(2, '2019-07-12', 3000, ' room rent');
-- --------------------------------------------------------
--
-- Table structure for table `hotel`
--
CREATE TABLE `hotel` (
`id` int(20) NOT NULL,
`name` varchar(200) NOT NULL,
`description` text NOT NULL,
`location` varchar(100) NOT NULL,
`country` varchar(100) NOT NULL,
`feature_image` varchar(100) NOT NULL,
`gallary_images` varchar(100) NOT NULL,
`status` int(20) NOT NULL,
`wifi` varchar(100) NOT NULL,
`meal` varchar(200) NOT NULL,
`meal_price` int(20) NOT NULL,
`car_parking` varchar(150) NOT NULL,
`gym` varchar(150) NOT NULL,
`gym_price` int(20) NOT NULL,
`code_name` varchar(50) NOT NULL,
`swiming_pol` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `hotel`
--
INSERT INTO `hotel` (`id`, `name`, `description`, `location`, `country`, `feature_image`, `gallary_images`, `status`, `wifi`, `meal`, `meal_price`, `car_parking`, `gym`, `gym_price`, `code_name`, `swiming_pol`) VALUES
(1, 'radision', '', 'uttara,dhaka', 'China', 'g3.jpg', '', 1, 'Wifi', 'Meal', 1000, 'Car parking', 'Gym', 150, 'RDSN', 'Swiming pol');
-- --------------------------------------------------------
--
-- Table structure for table `login`
--
CREATE TABLE `login` (
`id` int(10) UNSIGNED NOT NULL,
`usname` varchar(30) DEFAULT NULL,
`pass` varchar(30) DEFAULT NULL,
`type` int(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `login`
--
INSERT INTO `login` (`id`, `usname`, `pass`, `type`) VALUES
(1, 'Admin', '1234', 1),
(2, 'manager', '12345', 0);
-- --------------------------------------------------------
--
-- Table structure for table `marchant_earn`
--
CREATE TABLE `marchant_earn` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`date` int(11) NOT NULL,
`bed_no` int(11) NOT NULL,
`total_sell` int(11) NOT NULL,
`comision _rate` int(11) NOT NULL,
`earn` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `marchant_login`
--
CREATE TABLE `marchant_login` (
`id` int(20) NOT NULL,
`username` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`mobile` int(20) NOT NULL,
`password` varchar(100) NOT NULL,
`address` varchar(100) NOT NULL,
`city` varchar(100) NOT NULL,
`status` int(20) NOT NULL,
`comission` int(10) NOT NULL,
`fullname` varchar(100) NOT NULL,
`image` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `marchant_login`
--
INSERT INTO `marchant_login` (`id`, `username`, `email`, `mobile`, `password`, `address`, `city`, `status`, `comission`, `fullname`, `image`) VALUES
(5, 'sazzad', 'ssk58021@gmail.com', 1938531102, '7d514ea48be82366c2bd145f0c6f5540', 'dhaka', 'uttara', 0, 0, 'sazzad', 'teamb1.jpg'),
(6, 'sazzad', 'ssk58021@gmail.com', 1938531102, '7d514ea48be82366c2bd145f0c6f5540', 'dhaka', 'uttara', 1, 5, 'sazzad', 'teamb1.jpg'),
(7, 'sksojib', 'ssk58021@gmail.com', 1718825371, 'b94b96942f89a9c19982e222340a5026', 'dhaka', 'uttara', 1, 5, 'sksojib', 'teamb4.jpg'),
(8, 'farzana', 'ssk58021@gmail.com', 1718825371, 'user123', 'dhaka', 'uttara', 1, 5, 'sksojib', 'teamb4.jpg');
-- --------------------------------------------------------
--
-- Table structure for table `newsletterlog`
--
CREATE TABLE `newsletterlog` (
`id` int(10) UNSIGNED NOT NULL,
`title` varchar(52) DEFAULT NULL,
`subject` varchar(100) DEFAULT NULL,
`news` text
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `newsletterlog`
--
INSERT INTO `newsletterlog` (`id`, `title`, `subject`, `news`) VALUES
(1, 'Most funny video | | try to not laugh', 'job offer', 'good morning');
-- --------------------------------------------------------
--
-- Table structure for table `payment`
--
CREATE TABLE `payment` (
`id` int(11) DEFAULT NULL,
`title` varchar(5) DEFAULT NULL,
`fname` varchar(30) DEFAULT NULL,
`lname` varchar(30) DEFAULT NULL,
`troom` varchar(30) DEFAULT NULL,
`tbed` varchar(30) DEFAULT NULL,
`nroom` int(11) DEFAULT NULL,
`cin` date DEFAULT NULL,
`cout` date DEFAULT NULL,
`ttot` double(8,2) DEFAULT NULL,
`fintot` double(8,2) DEFAULT NULL,
`mepr` double(8,2) DEFAULT NULL,
`meal` varchar(30) DEFAULT NULL,
`btot` double(8,2) DEFAULT NULL,
`noofdays` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `payment`
--
INSERT INTO `payment` (`id`, `title`, `fname`, `lname`, `troom`, `tbed`, `nroom`, `cin`, `cout`, `ttot`, `fintot`, `mepr`, `meal`, `btot`, `noofdays`) VALUES
(1, 'Mr.', 'sk', 'sojib', 'Single Room', 'Single', 1, '2019-05-09', '2019-05-11', 300.00, 303.00, 0.00, 'Room only', 3.00, 2),
(2, 'Mr.', 'sksojib', 'ghjf', 'Guest House', 'Single', 1, '2019-05-09', '2019-05-11', 360.00, 378.00, 14.40, 'Full Board', 3.60, 2),
(1, 'Mr.', 'sojib423', 'ghjf', 'Deluxe Room', 'Double', 1, '2019-05-09', '2019-05-11', 440.00, 448.80, 0.00, 'Room only', 8.80, 2),
(2, 'Mr.', 'sojib42', 'ghjf', 'Deluxe Room', 'Double', 1, '2019-05-09', '2019-05-11', 440.00, 466.40, 17.60, 'Breakfast', 8.80, 2),
(3, 'Mr.', 'Boishakhibd1', 'ghjf', 'Deluxe Room', 'Double', 1, '2019-05-09', '2019-05-11', 440.00, 448.80, 0.00, 'Room only', 8.80, 2);
-- --------------------------------------------------------
--
-- Table structure for table `reservation`
--
CREATE TABLE `reservation` (
`sl` int(20) NOT NULL,
`bed_no` varchar(100) NOT NULL,
`check_in` varchar(100) NOT NULL,
`check_out` varchar(100) NOT NULL,
`user_id` int(20) NOT NULL,
`status` int(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `reservation`
--
INSERT INTO `reservation` (`sl`, `bed_no`, `check_in`, `check_out`, `user_id`, `status`) VALUES
(1, '4', '2019-07-15', '2019-07-16', 0, 0);
-- --------------------------------------------------------
--
-- Table structure for table `room`
--
CREATE TABLE `room` (
`id` int(10) UNSIGNED NOT NULL,
`type` varchar(15) DEFAULT NULL,
`bedding` varchar(10) DEFAULT NULL,
`place` varchar(10) DEFAULT NULL,
`cusid` int(11) DEFAULT NULL,
`room_nmbr` int(30) DEFAULT NULL,
`price` int(30) NOT NULL,
`hotel_id` int(20) NOT NULL,
`hotel_name` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `room`
--
INSERT INTO `room` (`id`, `type`, `bedding`, `place`, `cusid`, `room_nmbr`, `price`, `hotel_id`, `hotel_name`) VALUES
(1, 'Superior Room', 'Single', 'Free', NULL, NULL, 0, 0, ''),
(2, 'Superior Room', 'Double', 'Free', NULL, NULL, 0, 0, ''),
(3, 'Superior Room', 'Triple', 'Free', NULL, NULL, 0, 0, ''),
(4, 'Single Room', 'Quad', 'Free', NULL, NULL, 0, 0, ''),
(5, 'Superior Room', 'Quad', 'Free', NULL, NULL, 0, 0, ''),
(6, 'Deluxe Room', 'Single', 'Free', NULL, NULL, 0, 0, ''),
(7, 'Deluxe Room', 'Double', 'Free', 0, NULL, 0, 0, ''),
(8, 'Deluxe Room', 'Triple', 'Free', NULL, NULL, 0, 0, ''),
(9, 'Deluxe Room', 'Quad', 'Free', NULL, NULL, 0, 0, ''),
(10, 'Guest House', 'Single', 'Free', 0, NULL, 0, 0, ''),
(11, 'Guest House', 'Double', 'Free', NULL, NULL, 0, 0, ''),
(12, 'Guest House', 'Quad', 'Free', NULL, NULL, 0, 0, ''),
(13, 'Single Room', 'Single', 'Free', 0, NULL, 0, 0, ''),
(14, 'Single Room', 'Double', 'Free', NULL, NULL, 0, 0, ''),
(15, 'Single Room', 'Triple', 'Free', NULL, NULL, 0, 0, ''),
(16, 'Guest House', 'Triple', 'Free', NULL, NULL, 0, 0, ''),
(17, '', 'Single', 'Free', NULL, NULL, 0, 0, ''),
(18, '105', 'Triple', 'Free', NULL, NULL, 0, 0, '');
-- --------------------------------------------------------
--
-- Table structure for table `roombook`
--
CREATE TABLE `roombook` (
`id` int(10) UNSIGNED NOT NULL,
`Title` varchar(5) DEFAULT NULL,
`FName` text,
`LName` text,
`Email` varchar(50) DEFAULT NULL,
`National` varchar(30) DEFAULT NULL,
`Country` varchar(30) DEFAULT NULL,
`Phone` text,
`TRoom` varchar(20) DEFAULT NULL,
`Bed` varchar(10) DEFAULT NULL,
`NRoom` varchar(2) DEFAULT NULL,
`Meal` varchar(15) DEFAULT NULL,
`cin` date DEFAULT NULL,
`cout` date DEFAULT NULL,
`stat` varchar(15) DEFAULT NULL,
`nodays` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `roombook`
--
INSERT INTO `roombook` (`id`, `Title`, `FName`, `LName`, `Email`, `National`, `Country`, `Phone`, `TRoom`, `Bed`, `NRoom`, `Meal`, `cin`, `cout`, `stat`, `nodays`) VALUES
(1, 'Mr.', 'sojib423', 'ghjf', 'ssk58021@gmail.com', 'Sri Lankan', 'Bangladesh', '1938531102', 'Deluxe Room', 'Double', '1', 'Room only', '2019-05-09', '2019-05-11', 'Conform', 2),
(2, 'Mr.', 'sojib42', 'ghjf', 'ssk58021@gmail.com', 'Sri Lankan', 'Bangladesh', '1938531102', 'Deluxe Room', 'Double', '1', 'Breakfast', '2019-05-09', '2019-05-11', 'Conform', 2),
(4, 'Dr.', 'sarif', 'ghjf', 'facebookhghj126@gmail.com', 'Sri Lankan', 'Bangladesh', '1938531102', 'Deluxe Room', 'Double', '1', 'Room only', '2019-05-09', '2019-05-11', 'Not Conform', 2);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `add_room`
--
ALTER TABLE `add_room`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `bed`
--
ALTER TABLE `bed`
ADD PRIMARY KEY (`sl_id`);
--
-- Indexes for table `booking`
--
ALTER TABLE `booking`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `contact`
--
ALTER TABLE `contact`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `cost`
--
ALTER TABLE `cost`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `hotel`
--
ALTER TABLE `hotel`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `login`
--
ALTER TABLE `login`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `marchant_earn`
--
ALTER TABLE `marchant_earn`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `marchant_login`
--
ALTER TABLE `marchant_login`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `newsletterlog`
--
ALTER TABLE `newsletterlog`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `reservation`
--
ALTER TABLE `reservation`
ADD PRIMARY KEY (`sl`);
--
-- Indexes for table `room`
--
ALTER TABLE `room`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `roombook`
--
ALTER TABLE `roombook`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `add_room`
--
ALTER TABLE `add_room`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `bed`
--
ALTER TABLE `bed`
MODIFY `sl_id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `booking`
--
ALTER TABLE `booking`
MODIFY `id` int(50) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
--
-- AUTO_INCREMENT for table `contact`
--
ALTER TABLE `contact`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `cost`
--
ALTER TABLE `cost`
MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `hotel`
--
ALTER TABLE `hotel`
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `login`
--
ALTER TABLE `login`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `marchant_earn`
--
ALTER TABLE `marchant_earn`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `marchant_login`
--
ALTER TABLE `marchant_login`
MODIFY `id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `newsletterlog`
--
ALTER TABLE `newsletterlog`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `reservation`
--
ALTER TABLE `reservation`
MODIFY `sl` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `room`
--
ALTER TABLE `room`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
--
-- AUTO_INCREMENT for table `roombook`
--
ALTER TABLE `roombook`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
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 StudentEmployee(
student_id int,
employee_id int
); |
INSERT INTO employees (first_name, last_name, age)
VALUES ('Joe', 'Brown', 21),
('Tom', 'Smith', 17),
('Pablo', 'Escobar', 45); |
SELECT e.primerNombre, e.apellidoPaterno, i.primerNombre as instructor, n.nombre as nivel
FROM instructor i JOIN horarioasignadoinstructor hai on i.idInstructor = hai.idInstructor
AND i.idInstructor = 1
JOIN nivel n on hai.idNivel = n.idNivel
JOIN inscripcionmensualidad im on hai.idHorarioAsignadoInstructor = im.idHorarioAsignadoInstructor
JOIN estudiante e on im.idEstudiante = e.idEstudiante;
|
/*Config
Retorno
-PlanoVinculadoEntidade
Parametros
-SQ_CONTRATO_TRABALHO:int
-SQ_PLANO_PREVIDENCIAL:int
*/
SELECT
FI_PLANO_PREVIDENCIAL.DS_PLANO_PREVIDENCIAL,
FI_SIT_PLANO.DS_SIT_PLANO,
FI_SIT_INSCRICAO.DS_SIT_INSCRICAO,
FI_MOT_SIT_PLANO.DS_MOT_SIT_PLANO,
FI_PLANO_PREVIDENCIAL.NR_CODIGO_CNPB,
FI_PLANO_VINCULADO.DT_INSC_PLANO,
FI_PLANO_VINCULADO.DT_SITUACAO,
FI_PLANO_PREVIDENCIAL.CD_INDICE_VALORIZACAO,
FI_PLANO_VINCULADO.*
FROM FI_PLANO_VINCULADO
INNER JOIN FI_PLANO_PREVIDENCIAL ON FI_PLANO_PREVIDENCIAL.SQ_PLANO_PREVIDENCIAL = FI_PLANO_VINCULADO.SQ_PLANO_PREVIDENCIAL
INNER JOIN FI_SIT_PLANO ON FI_SIT_PLANO.SQ_SIT_PLANO = FI_PLANO_VINCULADO.SQ_SIT_PLANO
INNER JOIN FI_MOT_SIT_PLANO ON FI_MOT_SIT_PLANO.SQ_MOT_SIT_PLANO = FI_PLANO_VINCULADO.SQ_MOT_SIT_PLANO
INNER JOIN FI_SIT_INSCRICAO ON FI_SIT_INSCRICAO.SQ_SIT_INSCRICAO = FI_PLANO_VINCULADO.SQ_SIT_INSCRICAO
WHERE SQ_CONTRATO_TRABALHO = @SQ_CONTRATO_TRABALHO
AND FI_PLANO_VINCULADO.SQ_SIT_PLANO NOT IN (2, 6)
AND FI_PLANO_PREVIDENCIAL.SQ_PLANO_PREVIDENCIAL = @SQ_PLANO_PREVIDENCIAL |
drop table t_department;
drop table t_employee; |
DO $$
BEGIN
-- SET statement_timeout = 0;
-- SET lock_timeout = 0;
SET client_encoding = 'UTF8';
-- SET standard_conforming_strings = on;
-- SET check_function_bodies = false;
-- SET client_min_messages = warning;
-- SET row_security = off;
-- CREATE DATABASE etl;
CREATE SCHEMA IF NOT EXISTS etl; -- SCHEMA DEVE SER IGUAL AO QUE ESTÁ NO KETTLE.PROPERTIES
SET search_path = etl, pg_catalog; -- SCHEMA DEVE SER IGUAL AO QUE ESTÁ NO KETTLE.PROPERTIES
-- SET default_tablespace = '';
-- SET default_with_oids = false;
CREATE TABLE IF NOT EXISTS channel (
id_batch integer,
channel_id character varying(255),
log_date timestamp without time zone,
logging_object_type character varying(255),
object_name character varying(255),
object_copy character varying(255),
repository_directory character varying(255),
filename character varying(255),
object_id character varying(255),
object_revision character varying(255),
parent_channel_id character varying(255),
root_channel_id character varying(255)
);
CREATE TABLE IF NOT EXISTS job (
id_job integer,
channel_id character varying(255),
jobname character varying(255),
status character varying(15),
lines_read bigint,
lines_written bigint,
lines_updated bigint,
lines_input bigint,
lines_output bigint,
lines_rejected bigint,
errors bigint,
startdate timestamp without time zone,
enddate timestamp without time zone,
logdate timestamp without time zone,
depdate timestamp without time zone,
replaydate timestamp without time zone,
log_field text
);
CREATE TABLE IF NOT EXISTS job_entry (
id_batch integer,
channel_id character varying(255),
log_date timestamp without time zone,
transname character varying(255),
stepname character varying(255),
lines_read bigint,
lines_written bigint,
lines_updated bigint,
lines_input bigint,
lines_output bigint,
lines_rejected bigint,
errors bigint,
result boolean,
nr_result_rows bigint,
nr_result_files bigint
);
CREATE TABLE IF NOT EXISTS transformation (
id_batch integer,
channel_id character varying(255),
transname character varying(255),
status character varying(15),
lines_read bigint,
lines_written bigint,
lines_updated bigint,
lines_input bigint,
lines_output bigint,
lines_rejected bigint,
errors bigint,
startdate timestamp without time zone,
enddate timestamp without time zone,
logdate timestamp without time zone,
depdate timestamp without time zone,
replaydate timestamp without time zone,
log_field text
);
CREATE TABLE IF NOT EXISTS transformation_metric (
id_batch integer,
channel_id character varying(255),
log_date timestamp without time zone,
metrics_date timestamp without time zone,
metrics_code character varying(255),
metrics_description character varying(255),
metrics_subject character varying(255),
metrics_type character varying(255),
metrics_value bigint
);
CREATE TABLE IF NOT EXISTS transformation_performance (
id_batch integer,
seq_nr integer,
logdate timestamp without time zone,
transname character varying(255),
stepname character varying(255),
step_copy integer,
lines_read bigint,
lines_written bigint,
lines_updated bigint,
lines_input bigint,
lines_output bigint,
lines_rejected bigint,
errors bigint,
input_buffer_rows bigint,
output_buffer_rows bigint
);
CREATE TABLE IF NOT EXISTS transformation_step (
id_batch integer,
channel_id character varying(255),
log_date timestamp without time zone,
transname character varying(255),
stepname character varying(255),
step_copy smallint,
lines_read bigint,
lines_written bigint,
lines_updated bigint,
lines_input bigint,
lines_output bigint,
lines_rejected bigint,
errors bigint
);
IF to_regclass('idx_job_1') IS NULL THEN
CREATE INDEX idx_job_1 ON job USING btree (id_job);
END IF;
IF to_regclass('idx_job_2') IS NULL THEN
CREATE INDEX idx_job_2 ON job USING btree (errors, status, jobname);
END IF;
IF to_regclass('idx_job_entry_1') IS NULL THEN
CREATE INDEX idx_job_entry_1 ON job_entry USING btree (id_batch);
END IF;
IF to_regclass('idx_transformation_1') IS NULL THEN
CREATE INDEX idx_transformation_1 ON transformation USING btree (id_batch);
END IF;
IF to_regclass('idx_transformation_2') IS NULL THEN
CREATE INDEX idx_transformation_2 ON transformation USING btree (errors, status, transname);
END IF;
CREATE TABLE IF NOT EXISTS etl_controle_execucao
(
id bigserial NOT NULL,
cliente_id character varying(100) NOT NULL,
cliente_nome character varying(400) NOT NULL,
cliente_uf character varying(2) NOT NULL,
job_nome character varying(400) NOT NULL,
data_cadastro date NOT NULL DEFAULT now(),
habilitado boolean DEFAULT true,
executando boolean DEFAULT false,
execucao_inicio timestamp without time zone,
execucao_fim timestamp without time zone,
CONSTRAINT controle_etl_pkey PRIMARY KEY (id),
CONSTRAINT controle_etl_uniq_cliente_id_job UNIQUE (cliente_id, job_nome)
);
CREATE TABLE IF NOT EXISTS etl_historico_execucao
(
id bigserial NOT NULL,
cliente_id character varying(100) NOT NULL,
cliente_nome character varying(400) NOT NULL,
cliente_uf character varying(2) NOT NULL,
job_nome character varying(400) NOT NULL,
status character varying(50) NOT NULL,
data_registro timestamp without time zone,
CONSTRAINT etl_historico_execucao_pkey PRIMARY KEY (id)
);
END $$; |
TRUNCATE TABLE category_types;
INSERT INTO category_types (id, name) VALUES (1, "income"), (2, "expense");
TRUNCATE TABLE currencies;
INSERT INTO currencies (id, name, unit) VALUES (1, "Euro", "€");
|
SELECT grape.add_setting ('product_name', '', 'Name of the current system', 'text', false);
SELECT grape.add_setting ('product_version', '', 'Product version', 'text', false);
SELECT grape.add_setting ('service_name', '', 'A name for the local service', 'text', false);
SELECT grape.add_setting ('system_url', 'http://', 'URL to access system''s frontend', 'text', false);
SELECT grape.add_setting ('grape_version', '1.1.3', 'Grape Version', 'text', false);
SELECT grape.add_setting ('auth.hash_passwords', 'true', 'Indicate whether passwords in grape.user is hashed', 'bool', false);
SELECT grape.add_setting ('auth.basic_roles', '', 'Comma-separated list of basic user roles (all new users will be assigned these roles)', 'text', false);
SELECT grape.add_setting ('auth.default_access_allowed', 'false', 'If a path is not found and this setting is true, access will be granted', 'bool', false);
SELECT grape.add_setting ('auth.user_ip_filter', 'false', 'Enable IP filtering on users', 'bool', false);
SELECT grape.add_setting ('disable_passwords', 'false', 'If true, authentication will not check whether passwords are correct', 'bool', false);
SELECT grape.add_setting ('logging.log_api_calls_to_db', 'false', 'Log all API calls to DB', 'bool', false);
SELECT grape.add_setting ('filter_processes', 'false', 'Apply role based filtering on processes', 'bool', false);
SELECT grape.add_setting ('dataimport.data_upload_schema', 'tmp', 'Default schema for data import tables', 'text', false);
SELECT grape.add_setting ('dataimport.process_in_background', 'false', 'Run data import processing functions in the background', 'bool', false);
SELECT grape.add_setting ('dataimport.test_table_schema', 'tmp', 'Default schema for data import test tables', 'text', false);
|
insert into ACT_GE_PROPERTY values ('common.schema.version', '6.2.0.0', 1);
insert into ACT_GE_PROPERTY values ('identitylink.schema.version', '6.2.0.0', 1);
alter table ACT_RU_TASK add column SCOPE_ID_ varchar(255);
alter table ACT_RU_TASK add column SUB_SCOPE_ID_ varchar(255);
alter table ACT_RU_TASK add column SCOPE_TYPE_ varchar(255);
alter table ACT_RU_TASK add column SCOPE_DEFINITION_ID_ varchar(255);
create index ACT_IDX_TASK_SCOPE on ACT_RU_TASK(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_TASK_SUB_SCOPE on ACT_RU_TASK(SUB_SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_TASK_SCOPE_DEF on ACT_RU_TASK(SCOPE_DEFINITION_ID_, SCOPE_TYPE_);
insert into ACT_GE_PROPERTY values ('task.schema.version', '6.2.0.0', 1);
alter table ACT_RU_VARIABLE add column SCOPE_ID_ varchar(255);
alter table ACT_RU_VARIABLE add column SUB_SCOPE_ID_ varchar(255);
alter table ACT_RU_VARIABLE add column SCOPE_TYPE_ varchar(255);
create index ACT_IDX_RU_VAR_SCOPE_ID_TYPE on ACT_RU_VARIABLE(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_RU_VAR_SUB_ID_TYPE on ACT_RU_VARIABLE(SUB_SCOPE_ID_, SCOPE_TYPE_);
insert into ACT_GE_PROPERTY values ('variable.schema.version', '6.2.0.0', 1);
insert into ACT_GE_PROPERTY values ('job.schema.version', '6.2.0.0', 1);
alter table ACT_HI_TASKINST add column SCOPE_ID_ varchar(255);
alter table ACT_HI_TASKINST add column SUB_SCOPE_ID_ varchar(255);
alter table ACT_HI_TASKINST add column SCOPE_TYPE_ varchar(255);
alter table ACT_HI_TASKINST add column SCOPE_DEFINITION_ID_ varchar(255);
create index ACT_IDX_HI_TASK_SCOPE on ACT_HI_TASKINST(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_HI_TASK_SUB_SCOPE on ACT_HI_TASKINST(SUB_SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_HI_TASK_SCOPE_DEF on ACT_HI_TASKINST(SCOPE_DEFINITION_ID_, SCOPE_TYPE_);
alter table ACT_HI_VARINST add column SCOPE_ID_ varchar(255);
alter table ACT_HI_VARINST add column SUB_SCOPE_ID_ varchar(255);
alter table ACT_HI_VARINST add column SCOPE_TYPE_ varchar(255);
create index ACT_IDX_HI_VAR_SCOPE_ID_TYPE on ACT_HI_VARINST(SCOPE_ID_, SCOPE_TYPE_);
create index ACT_IDX_HI_VAR_SUB_ID_TYPE on ACT_HI_VARINST(SUB_SCOPE_ID_, SCOPE_TYPE_);
alter table ACT_RU_EXECUTION add column CALLBACK_ID_ varchar(255);
alter table ACT_RU_EXECUTION add column CALLBACK_TYPE_ varchar(255);
update ACT_GE_PROPERTY set VALUE_ = '6.2.0.0' where NAME_ = 'schema.version';
update ACT_ID_PROPERTY set VALUE_ = '6.2.0.0' where NAME_ = 'schema.version';
CREATE TABLE act_cmmn_databasechangeloglock (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITHOUT TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT PK_ACT_CMMN_DATABASECHANGELOGLOCK PRIMARY KEY (ID));
DELETE FROM act_cmmn_databasechangeloglock;
INSERT INTO act_cmmn_databasechangeloglock (ID, LOCKED) VALUES (1, FALSE);
UPDATE act_cmmn_databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '192.168.1.5 (192.168.1.5)', LOCKGRANTED = '2019-03-13 21:23:48.727' WHERE ID = 1 AND LOCKED = FALSE;
CREATE TABLE act_cmmn_databasechangelog (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED TIMESTAMP WITHOUT TIME ZONE NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONTEXTS VARCHAR(255), LABELS VARCHAR(255), DEPLOYMENT_ID VARCHAR(10));
CREATE TABLE ACT_CMMN_DEPLOYMENT (ID_ VARCHAR(255) NOT NULL, NAME_ VARCHAR(255), CATEGORY_ VARCHAR(255), KEY_ VARCHAR(255), DEPLOY_TIME_ TIMESTAMP WITHOUT TIME ZONE, PARENT_DEPLOYMENT_ID_ VARCHAR(255), TENANT_ID_ VARCHAR(255) DEFAULT '', CONSTRAINT PK_ACT_CMMN_DEPLOYMENT PRIMARY KEY (ID_));
CREATE TABLE ACT_CMMN_DEPLOYMENT_RESOURCE (ID_ VARCHAR(255) NOT NULL, NAME_ VARCHAR(255), DEPLOYMENT_ID_ VARCHAR(255), RESOURCE_BYTES_ BYTEA, CONSTRAINT PK_CMMN_DEPLOYMENT_RESOURCE PRIMARY KEY (ID_));
ALTER TABLE ACT_CMMN_DEPLOYMENT_RESOURCE ADD CONSTRAINT ACT_FK_CMMN_RSRC_DPL FOREIGN KEY (DEPLOYMENT_ID_) REFERENCES ACT_CMMN_DEPLOYMENT (ID_);
CREATE INDEX ACT_IDX_CMMN_RSRC_DPL ON ACT_CMMN_DEPLOYMENT_RESOURCE(DEPLOYMENT_ID_);
CREATE TABLE ACT_CMMN_CASEDEF (ID_ VARCHAR(255) NOT NULL, REV_ INT NOT NULL, NAME_ VARCHAR(255), KEY_ VARCHAR(255) NOT NULL, VERSION_ INT NOT NULL, CATEGORY_ VARCHAR(255), DEPLOYMENT_ID_ VARCHAR(255), RESOURCE_NAME_ VARCHAR(4000), DESCRIPTION_ VARCHAR(4000), HAS_GRAPHICAL_NOTATION_ BOOLEAN, TENANT_ID_ VARCHAR(255) DEFAULT '', CONSTRAINT PK_ACT_CMMN_CASEDEF PRIMARY KEY (ID_));
ALTER TABLE ACT_CMMN_CASEDEF ADD CONSTRAINT ACT_FK_CASE_DEF_DPLY FOREIGN KEY (DEPLOYMENT_ID_) REFERENCES ACT_CMMN_DEPLOYMENT (ID_);
CREATE INDEX ACT_IDX_CASE_DEF_DPLY ON ACT_CMMN_CASEDEF(DEPLOYMENT_ID_);
CREATE TABLE ACT_CMMN_RU_CASE_INST (ID_ VARCHAR(255) NOT NULL, REV_ INT NOT NULL, BUSINESS_KEY_ VARCHAR(255), NAME_ VARCHAR(255), PARENT_ID_ VARCHAR(255), CASE_DEF_ID_ VARCHAR(255), STATE_ VARCHAR(255), START_TIME_ TIMESTAMP WITHOUT TIME ZONE, START_USER_ID_ VARCHAR(255), CALLBACK_ID_ VARCHAR(255), CALLBACK_TYPE_ VARCHAR(255), TENANT_ID_ VARCHAR(255) DEFAULT '', CONSTRAINT PK_ACT_CMMN_RU_CASE_INST PRIMARY KEY (ID_));
ALTER TABLE ACT_CMMN_RU_CASE_INST ADD CONSTRAINT ACT_FK_CASE_INST_CASE_DEF FOREIGN KEY (CASE_DEF_ID_) REFERENCES ACT_CMMN_CASEDEF (ID_);
CREATE INDEX ACT_IDX_CASE_INST_CASE_DEF ON ACT_CMMN_RU_CASE_INST(CASE_DEF_ID_);
CREATE INDEX ACT_IDX_CASE_INST_PARENT ON ACT_CMMN_RU_CASE_INST(PARENT_ID_);
CREATE TABLE ACT_CMMN_RU_PLAN_ITEM_INST (ID_ VARCHAR(255) NOT NULL, REV_ INT NOT NULL, CASE_DEF_ID_ VARCHAR(255), CASE_INST_ID_ VARCHAR(255), STAGE_INST_ID_ VARCHAR(255), IS_STAGE_ BOOLEAN, ELEMENT_ID_ VARCHAR(255), NAME_ VARCHAR(255), STATE_ VARCHAR(255), START_TIME_ TIMESTAMP WITHOUT TIME ZONE, START_USER_ID_ VARCHAR(255), REFERENCE_ID_ VARCHAR(255), REFERENCE_TYPE_ VARCHAR(255), TENANT_ID_ VARCHAR(255) DEFAULT '', CONSTRAINT PK_CMMN_PLAN_ITEM_INST PRIMARY KEY (ID_));
ALTER TABLE ACT_CMMN_RU_PLAN_ITEM_INST ADD CONSTRAINT ACT_FK_PLAN_ITEM_CASE_DEF FOREIGN KEY (CASE_DEF_ID_) REFERENCES ACT_CMMN_CASEDEF (ID_);
CREATE INDEX ACT_IDX_PLAN_ITEM_CASE_DEF ON ACT_CMMN_RU_PLAN_ITEM_INST(CASE_DEF_ID_);
ALTER TABLE ACT_CMMN_RU_PLAN_ITEM_INST ADD CONSTRAINT ACT_FK_PLAN_ITEM_CASE_INST FOREIGN KEY (CASE_INST_ID_) REFERENCES ACT_CMMN_RU_CASE_INST (ID_);
CREATE INDEX ACT_IDX_PLAN_ITEM_CASE_INST ON ACT_CMMN_RU_PLAN_ITEM_INST(CASE_INST_ID_);
CREATE TABLE ACT_CMMN_RU_SENTRY_PART_INST (ID_ VARCHAR(255) NOT NULL, REV_ INT NOT NULL, CASE_DEF_ID_ VARCHAR(255), CASE_INST_ID_ VARCHAR(255), PLAN_ITEM_INST_ID_ VARCHAR(255), ON_PART_ID_ VARCHAR(255), IF_PART_ID_ VARCHAR(255), TIME_STAMP_ TIMESTAMP WITHOUT TIME ZONE, CONSTRAINT PK_CMMN_SENTRY_PART_INST PRIMARY KEY (ID_));
ALTER TABLE ACT_CMMN_RU_SENTRY_PART_INST ADD CONSTRAINT ACT_FK_SENTRY_CASE_DEF FOREIGN KEY (CASE_DEF_ID_) REFERENCES ACT_CMMN_CASEDEF (ID_);
CREATE INDEX ACT_IDX_SENTRY_CASE_DEF ON ACT_CMMN_RU_SENTRY_PART_INST(CASE_DEF_ID_);
ALTER TABLE ACT_CMMN_RU_SENTRY_PART_INST ADD CONSTRAINT ACT_FK_SENTRY_CASE_INST FOREIGN KEY (CASE_INST_ID_) REFERENCES ACT_CMMN_RU_CASE_INST (ID_);
CREATE INDEX ACT_IDX_SENTRY_CASE_INST ON ACT_CMMN_RU_SENTRY_PART_INST(CASE_INST_ID_);
ALTER TABLE ACT_CMMN_RU_SENTRY_PART_INST ADD CONSTRAINT ACT_FK_SENTRY_PLAN_ITEM FOREIGN KEY (PLAN_ITEM_INST_ID_) REFERENCES ACT_CMMN_RU_PLAN_ITEM_INST (ID_);
CREATE INDEX ACT_IDX_SENTRY_PLAN_ITEM ON ACT_CMMN_RU_SENTRY_PART_INST(PLAN_ITEM_INST_ID_);
CREATE TABLE ACT_CMMN_RU_MIL_INST (ID_ VARCHAR(255) NOT NULL, NAME_ VARCHAR(255) NOT NULL, TIME_STAMP_ TIMESTAMP WITHOUT TIME ZONE NOT NULL, CASE_INST_ID_ VARCHAR(255) NOT NULL, CASE_DEF_ID_ VARCHAR(255) NOT NULL, ELEMENT_ID_ VARCHAR(255) NOT NULL, CONSTRAINT PK_ACT_CMMN_RU_MIL_INST PRIMARY KEY (ID_));
ALTER TABLE ACT_CMMN_RU_MIL_INST ADD CONSTRAINT ACT_FK_MIL_CASE_DEF FOREIGN KEY (CASE_DEF_ID_) REFERENCES ACT_CMMN_CASEDEF (ID_);
CREATE INDEX ACT_IDX_MIL_CASE_DEF ON ACT_CMMN_RU_MIL_INST(CASE_DEF_ID_);
ALTER TABLE ACT_CMMN_RU_MIL_INST ADD CONSTRAINT ACT_FK_MIL_CASE_INST FOREIGN KEY (CASE_INST_ID_) REFERENCES ACT_CMMN_RU_CASE_INST (ID_);
CREATE INDEX ACT_IDX_MIL_CASE_INST ON ACT_CMMN_RU_MIL_INST(CASE_INST_ID_);
CREATE TABLE ACT_CMMN_HI_CASE_INST (ID_ VARCHAR(255) NOT NULL, REV_ INT NOT NULL, BUSINESS_KEY_ VARCHAR(255), NAME_ VARCHAR(255), PARENT_ID_ VARCHAR(255), CASE_DEF_ID_ VARCHAR(255), STATE_ VARCHAR(255), START_TIME_ TIMESTAMP WITHOUT TIME ZONE, END_TIME_ TIMESTAMP WITHOUT TIME ZONE, START_USER_ID_ VARCHAR(255), CALLBACK_ID_ VARCHAR(255), CALLBACK_TYPE_ VARCHAR(255), TENANT_ID_ VARCHAR(255) DEFAULT '', CONSTRAINT PK_ACT_CMMN_HI_CASE_INST PRIMARY KEY (ID_));
CREATE TABLE ACT_CMMN_HI_MIL_INST (ID_ VARCHAR(255) NOT NULL, REV_ INT NOT NULL, NAME_ VARCHAR(255) NOT NULL, TIME_STAMP_ TIMESTAMP WITHOUT TIME ZONE NOT NULL, CASE_INST_ID_ VARCHAR(255) NOT NULL, CASE_DEF_ID_ VARCHAR(255) NOT NULL, ELEMENT_ID_ VARCHAR(255) NOT NULL, CONSTRAINT PK_ACT_CMMN_HI_MIL_INST PRIMARY KEY (ID_));
INSERT INTO act_cmmn_databasechangelog (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('1', 'flowable', 'org/flowable/cmmn/db/liquibase/flowable-cmmn-db-changelog.xml', NOW(), 1, '7:1ed01100eeb9bb6054c28320b6c5fb22', 'createTable tableName=ACT_CMMN_DEPLOYMENT; createTable tableName=ACT_CMMN_DEPLOYMENT_RESOURCE; addForeignKeyConstraint baseTableName=ACT_CMMN_DEPLOYMENT_RESOURCE, constraintName=ACT_FK_CMMN_RSRC_DPL, referencedTableName=ACT_CMMN_DEPLOYMENT; create...', '', 'EXECUTED', NULL, NULL, '3.5.3', '2508629224');
UPDATE act_cmmn_databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
UPDATE act_dmn_databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '192.168.1.5 (192.168.1.5)', LOCKGRANTED = '2019-03-13 21:23:49.619' WHERE ID = 1 AND LOCKED = FALSE;
UPDATE act_dmn_databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
UPDATE act_fo_databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '192.168.1.5 (192.168.1.5)', LOCKGRANTED = '2019-03-13 21:23:49.775' WHERE ID = 1 AND LOCKED = FALSE;
ALTER TABLE ACT_FO_FORM_INSTANCE ADD SCOPE_ID_ VARCHAR(255);
ALTER TABLE ACT_FO_FORM_INSTANCE ADD SCOPE_TYPE_ VARCHAR(255);
ALTER TABLE ACT_FO_FORM_INSTANCE ADD SCOPE_DEFINITION_ID_ VARCHAR(255);
INSERT INTO act_fo_databasechangelog (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('2', 'flowable', 'org/flowable/form/db/liquibase/flowable-form-db-changelog.xml', NOW(), 2, '7:4850f9311e7503d7ea30a372e79b4ea2', 'addColumn tableName=ACT_FO_FORM_INSTANCE', '', 'EXECUTED', NULL, NULL, '3.5.3', '2508629830');
UPDATE act_fo_databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
UPDATE act_co_databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '192.168.1.5 (192.168.1.5)', LOCKGRANTED = '2019-03-13 21:23:49.932' WHERE ID = 1 AND LOCKED = FALSE;
UPDATE act_co_databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
|
CREATE TABLE Tickets(tickets_id INT
CONSTRAINT pri_tick_id PRIMARY KEY
,ticket_type VARCHAR(25) NOT NULL; |
USE ISP_ajh158;
CREATE TABLE accounts
(
ID MEDIUMINT NOT NULL AUTO_INCREMENT,
first_name NVARCHAR(50) NULL,
last_name NVARCHAR(50) NULL,
email NVARCHAR(50) NULL,
login NVARCHAR(50) NULL,
password NVARCHAR(50) NULL,
PRIMARY KEY (ID)
);
INSERT INTO accounts (first_name, last_name, email, login, password)
VALUES ('Alec', 'Horne', 'ajh158@zips.uakron.edu', 'ajh158', 'ecfmqpts69'); |
SELECT TIMESTAMPDIFF(DAY, MIN(date), MAX(date)) AS 'uptime'
FROM member_history;
|
update tbl_accounts
set google2fa_secret = '%2'
where account_id = %1
|
Select cus.customerName As Customer_Name, concat(emp.lastName, ',', emp.firstName) As Sales_Rep
from classicmodels.customers cus Inner Join classicmodels.employees emp
on cus.salesRepEmployeeNumber=emp.employeeNumber order by 1;
|
--DROP TABLE tnc.tnc_trip_stats CASCADE;
-- Create table of tnc trips by hour from Drew's CSV file
CREATE TABLE tnc.tnc_trip_stats
(taz integer, day_of_week integer, time char(8), pickups double precision, dropoffs double precision);
COPY tnc.tnc_trip_stats FROM '/home/administrator/tnc_trip_stats.csv' DELIMITER ',' CSV HEADER;
ALTER TABLE tnc.tnc_trip_stats ADD COLUMN id SERIAL PRIMARY KEY;
CREATE INDEX ix_tnc_trip_stats_taz
ON tnc.tnc_trip_stats
USING btree
(taz);
CREATE INDEX ix_tnc_trip_stats_time
ON tnc.tnc_trip_stats
USING btree
(time);
GRANT SELECT ON TABLE tnc.tnc_trip_stats TO anon;
-- Create summary view too
CREATE VIEW tnc.taz_total (taz, day_of_week, dropoffs, pickups) AS
SELECT
taz,day_of_week,SUM(dropoffs),SUM(pickups)
FROM
tnc.tnc_trip_stats
GROUP BY day_of_week,taz
ORDER BY taz,day_of_week;
ALTER VIEW tnc.taz_total OWNER to anon;
GRANT SELECT ON TABLE tnc.taz_total TO anon;
|
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
CREATE TABLE IF NOT EXISTS `attributes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`keey` varchar(255) NOT NULL,
`value` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `users_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=83 ;
|
ALTER TABLE tipos_carrera DROP COLUMN tipo_resolucion; |
ALTER TABLE ADM_TUSGR ADD CONSTRAINT FK_ADM_TUSGR_ADM_TGRUP
FOREIGN KEY (USGR_GRUP) REFERENCES ADM_TGRUP (GRUP_GRUP)
;
ALTER TABLE ADM_TUSGR ADD CONSTRAINT FK_ADM_TUSGR_ADM_TUSUA
FOREIGN KEY (USGR_USUA) REFERENCES ADM_TUSUA (USUA_USUA)
;
|
# if(condition , true, false)
SELECT empno, ename, salary,
salary * IF(salary >=50000, 2, 1.5) AS 'bonus'
FROM employee;
# case 語法結尾要end
SELECT empno, ename, salary,
CASE
WHEN salary > 100000 THEN 'A'
WHEN salary BETWEEN 70000 AND 100000 THEN 'B'
WHEN salary BETWEEN 50000 AND 69999 THEN 'C'
WHEN salary BETWEEN 30000 AND 49999 THEN 'D'
ELSE 'E'
END 'Grade'
FROM employee;
# 使用distinct關鍵字剔除重複資料
SELECT DISTINCT deptno FROM employee;
# distinct 兩個欄位,表示兩個欄位都重複才會剔除
SELECT DISTINCT deptno,title FROM employee;
# Where 代表條件搜尋
SELECT * FROM employee WHERE deptno = 100;
SELECT * FROM employee WHERE title = 'engineer';
SELECT * FROM employee WHERE hiredate = '2007/07/06';
SELECT * FROM employee WHERE salary >= 50000;
SELECT * FROM employee WHERE salary BETWEEN 30000 AND 40000;
SELECT * FROM employee WHERE title IN ('manager','engineer');
SELECT * FROM department WHERE mgrno IS NULL;
# LIKE 就是關鍵字搜尋
SELECT * FROM employee WHERE ename LIKE '林%';
SELECT * FROM employee WHERE ename LIKE '%生';
SELECT * FROM employee WHERE ename LIKE '%麗%';
SELECT * FROM employee WHERE ename LIKE '_麗%';
# mysql 裡的跳脫字元預設用 \
SELECT * FROM employee WHERE title LIKE '%SA\_%';
SELECT * FROM employee WHERE title LIKE '%SA/_%' ESCAPE '/';
# and or not 條件判斷
SELECT * FROM employee WHERE salary > 45000 AND ename LIKE '林%';
SELECT * FROM employee WHERE salary > 45000 OR ename LIKE '林%';
SELECT * FROM employee WHERE title NOT IN ('manager','engineer');
SELECT * FROM department WHERE mgrno IS NOT NULL;
SELECT * FROM employee WHERE salary NOT BETWEEN 30000 AND 40000;
SELECT * FROM employee WHERE ename NOT LIKE '林%';
# 排序方法預設 ASC 表示升冪排序, DESC 表示降冪排序
# 多個欄位排序,如果排序方法不一樣要分別寫
SELECT * FROM employee ORDER BY hiredate DESC ;
SELECT ename, deptno, salary FROM employee ORDER BY deptno, salary DESC ;
SELECT ename, deptno, salary FROM employee ORDER BY deptno DESC, salary DESC ;
SELECT ename, salary*12 AS 'Annual' FROM employee ORDER BY Annual;
SELECT ename, salary*12 AS 'Annual' FROM employee ORDER BY salary*12;
SELECT ename, deptno, salary FROM employee ORDER BY 3;
SELECT * FROM employee ORDER BY 3;
# limit 4,3 表示傳回5,6,7筆 ,可以用在計算分頁
SELECT * FROM employee LIMIT 3;
SELECT * FROM employee LIMIT 4,3;
SELECT * FROM employee ORDER BY hiredate LIMIT 3;
SELECT * FROM employee ORDER BY salary DESC LIMIT 3;
# sum, avg, count 這些函數計算時會剔除null
#
SELECT SUM(salary), AVG(salary), MAX(salary), MIN(salary) FROM employee;
select count(*) from employee;
select count(distinct deptno) from employee;
# rollup 關鍵字表示小計
select deptno, avg(salary) as 'Average' from employee group by deptno;
select deptno, avg(salary) as 'Average' from employee group by deptno order by AVG(salary);
select deptno, avg(salary) as 'Average' from employee group by deptno order by Average;
select deptno, count(*) as 'Count' from employee group by deptno;
select deptno, title, sum(salary) as 'Total' from employee group by deptno, title;
select deptno, title, sum(salary) as 'Total' from employee group by deptno, title with rollup;
select title, sum(salary) as 'Total'
from employee
where title not like '%SA%'
group by title
having sum(salary) > 10000
order by sum(salary) desc;
|
INSERT INTO hpBaseElement( id,elementtype,title,logo,perpage,linkmode,moreurl,elementdesc) VALUES ( 29,'2','自定义页面','/images/homepage/element/1.gif',-1,'2','getIframeMore','自定义页面元素')
/
INSERT INTO hpWhereElement( id,elementid,settingshowmethod,getwheremethod) VALUES ( 29,29,'getIframeSettingStr','')
/
INSERT INTO hpextelement( id,extsettinge,extopreate,extshow,description) VALUES ( 29,'','','Iframe.jsp','显示自定义页面')
/
|
-- MySQL Script generated by MySQL Workbench
-- Mon 16 Oct 2017 11:58:25 AM ICT
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema churn_dw
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `churn_dw` ;
-- -----------------------------------------------------
-- Schema churn_dw
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `churn_dw` DEFAULT CHARACTER SET utf8 ;
SHOW WARNINGS;
USE `churn_dw` ;
-- -----------------------------------------------------
-- Table `churn_dw`.`t_region_state`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `churn_dw`.`t_region_state` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `churn_dw`.`t_region_state` (
`id` INT NOT NULL,
`region` VARCHAR(45) NULL,
`state` VARCHAR(45) NULL,
`state_full_name` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `churn_dw`.`t_calls`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `churn_dw`.`t_calls` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `churn_dw`.`t_calls` (
`id` INT NOT NULL,
`total_day_calls` VARCHAR(45) NULL,
`total_night_calls` VARCHAR(45) NULL,
`number_customer_service_calls` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `churn_dw`.`t_call_duration`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `churn_dw`.`t_call_duration` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `churn_dw`.`t_call_duration` (
`id` INT NOT NULL,
`total_day_minutes` VARCHAR(20) NULL,
`total_eve_minutes` VARCHAR(45) NULL,
`total_night_minutes` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `churn_dw`.`t_charge`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `churn_dw`.`t_charge` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `churn_dw`.`t_charge` (
`id` INT NOT NULL,
`total_day_charges` VARCHAR(45) NULL,
`total_eve_charges` VARCHAR(45) NULL,
`total_night_charges` VARCHAR(45) NULL,
`total_intl_charges` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SHOW WARNINGS;
-- -----------------------------------------------------
-- Table `churn_dw`.`t_fact_churn`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `churn_dw`.`t_fact_churn` ;
SHOW WARNINGS;
CREATE TABLE IF NOT EXISTS `churn_dw`.`t_fact_churn` (
`id` INT NOT NULL,
`areacode_phonenumber` VARCHAR(45) NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk_t_region_state_id`
FOREIGN KEY (`id`)
REFERENCES `churn_dw`.`t_region_state` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_t_calls_id`
FOREIGN KEY (`id`)
REFERENCES `churn_dw`.`t_calls` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_t_call_duration_id`
FOREIGN KEY (`id`)
REFERENCES `churn_dw`.`t_call_duration` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_t_charge_id`
FOREIGN KEY (`id`)
REFERENCES `churn_dw`.`t_charge` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SHOW WARNINGS;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
CREATE TABLE IF NOT EXISTS organization (
id INTEGER NOT NULL COMMENT 'Уникальный идентификатор' PRIMARY KEY ,
name VARCHAR NOT NULL COMMENT 'Краткое название организации',
inn VARCHAR(12) NOT NULL COMMENT 'ИНН организации',
isActive BOOLEAN NOT NULL DEFAULT 'FALSE' COMMENT 'Статус организации: активна/ликвидирована',
fullName VARCHAR NOT NULL COMMENT 'Полное название организации',
kpp VARCHAR(9) NOT NULL COMMENT 'КПП организации',
address VARCHAR NOT NULL COMMENT 'Официальный адрес юридического лица',
phone VARCHAR COMMENT 'Основной телефон организации' UNIQUE,
version INTEGER NOT NULL COMMENT 'Служебная метка версионирования'
);
COMMENT ON TABLE organization IS 'Список организаций';
CREATE TABLE IF NOT EXISTS office (
id INTEGER NOT NULL COMMENT 'Уникальный идентификатор' PRIMARY KEY ,
name VARCHAR COMMENT 'Краткое наименование офиса',
phone VARCHAR COMMENT 'Телефон приемной/секретаря' UNIQUE,
isActive BOOLEAN NOT NULL DEFAULT 'FALSE' COMMENT 'Статус офиса: функционирует/упразднен',
address VARCHAR NOT NULL COMMENT 'Адрес офиса',
orgId INTEGER NOT NULL COMMENT 'Идентификатор организации, которой принадлежит офис',
version INTEGER NOT NULL COMMENT 'Служебная метка версионирования'
);
COMMENT ON TABLE office IS 'Офисы организации';
CREATE TABLE IF NOT EXISTS user (
id INTEGER NOT NULL COMMENT 'Уникальный идентификатор сотрудника' PRIMARY KEY ,
firstName VARCHAR NOT NULL COMMENT 'Имя сотрудника',
secondName VARCHAR NOT NULL COMMENT 'Фамилия сотрудника',
middleName VARCHAR COMMENT 'Отчество сотрудника',
phone VARCHAR COMMENT 'Рабочий телефон сотрудника' UNIQUE,
citizenship VARCHAR NOT NULL COMMENT 'Идентификатор гражданства сотрудника',
position INTEGER NOT NULL COMMENT 'Идентификатор должности сотрудника',
version INTEGER NOT NULL COMMENT 'Служебная метка версионирования'
);
COMMENT ON TABLE user IS 'Сотрудники организации';
CREATE TABLE IF NOT EXISTS user_office (
id INTEGER NOT NULL COMMENT 'Уникальный идентификатор' PRIMARY KEY ,
user_id INTEGER NOT NULL COMMENT 'Уникальный идентификатор сотрудника',
office_id INTEGER NOT NULL COMMENT 'Уникальный идентификатор офиса',
primary_office BOOLEAN NOT NULL DEFAULT 'FALSE' COMMENT 'Метка основного офиса сотрудника'
);
COMMENT ON TABLE user_office IS 'Таблица связи сотрудников и офисов';
CREATE TABLE IF NOT EXISTS user_doc (
id INTEGER NOT NULL COMMENT 'Уникальный идентификатор' PRIMARY KEY ,
doc_code VARCHAR NOT NULL COMMENT 'Уникальный идентификатор типа документа',
doc_number VARCHAR NOT NULL COMMENT 'Номер документа',
user_id INTEGER NOT NULL COMMENT 'Уникальный идентификатор сотрудника',
isIdentified BOOLEAN NOT NULL DEFAULT 'FALSE' COMMENT 'Метка подтвержденного документа',
doc_date DATE COMMENT 'Дата выдачи документа'
);
COMMENT ON TABLE user_doc IS 'Документы сотрудника';
CREATE TABLE IF NOT EXISTS document (
code VARCHAR NOT NULL COMMENT 'Уникальный код типа документа' PRIMARY KEY,
name VARCHAR NOT NULL COMMENT 'Русскоязычное название документа'
);
COMMENT ON TABLE document IS 'Справочник типов документов';
CREATE TABLE IF NOT EXISTS country (
code VARCHAR NOT NULL COMMENT 'Уникальный код страны' PRIMARY KEY,
name VARCHAR NOT NULL COMMENT 'Официальное название страны'
);
COMMENT ON TABLE country IS 'Справочник стран';
CREATE TABLE IF NOT EXISTS title (
id INTEGER NOT NULL COMMENT 'Уникальный идентификатор' PRIMARY KEY,
title_name VARCHAR NOT NULL COMMENT 'Название должности'
);
COMMENT ON TABLE title IS 'Справочник должностей';
CREATE INDEX IX_office_orgId ON office (orgId);
ALTER TABLE office ADD FOREIGN KEY (orgId) REFERENCES organization(id);
ALTER TABLE user ADD FOREIGN KEY (citizenship) REFERENCES country(code);
ALTER TABLE user ADD FOREIGN KEY (position) REFERENCES title(id);
ALTER TABLE user_doc ADD FOREIGN KEY (doc_code) REFERENCES document(code);
CREATE INDEX IX_user_doc_id ON user_doc (user_id);
ALTER TABLE user_doc ADD FOREIGN KEY (user_id) REFERENCES user(id);
CREATE INDEX IX_user_office_userId ON user_office (user_id);
ALTER TABLE user_office ADD FOREIGN KEY (user_id) REFERENCES user(id);
CREATE INDEX IX_user_office_officeId ON user_office (office_id);
ALTER TABLE user_office ADD FOREIGN KEY (office_id) REFERENCES office(id);
CREATE SEQUENCE ID_SEQ START WITH 10 INCREMENT BY 1 MINVALUE 10 NOMAXVALUE NOCYCLE NOCACHE; |
DROP TABLE IF EXISTS realty_users;
CREATE TABLE realty_users (
id BIGINT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password_hash VARCHAR(255) NOT NULL
);
DROP SEQUENCE IF EXISTS realty_users_id_seq;
CREATE SEQUENCE realty_users_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
DROP TABLE IF EXISTS realty_authorities;
CREATE TABLE realty_authorities (
id BIGINT PRIMARY KEY,
authority VARCHAR(50) NOT NULL
);
ALTER TABLE realty_authorities
ADD CONSTRAINT unique_authority UNIQUE (authority);
DROP SEQUENCE IF EXISTS realty_authorities_id_seq;
CREATE SEQUENCE realty_authorities_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
DROP TABLE IF EXISTS realty_users_authorities;
CREATE TABLE realty_users_authorities (
user_id BIGINT NOT NULL,
authority_id BIGINT NOT NULL
);
ALTER TABLE realty_users_authorities
ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id)
REFERENCES realty_users (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE realty_users_authorities
ADD CONSTRAINT fk_authority_id FOREIGN KEY (authority_id)
REFERENCES realty_authorities (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE; |
CREATE TABLE expense_report (
id INT NOT NULL AUTO_INCREMENT,
title CHAR(50) NOT NULL,
PRIMARY KEY (id)
); |
delete from HtmlLabelIndex where id=16654
/
delete from HtmlLabelInfo where indexid=16654
/
INSERT INTO HtmlLabelIndex values(16654,'月计划')
/
INSERT INTO HtmlLabelInfo VALUES(16654,'月计划',7)
/
INSERT INTO HtmlLabelInfo VALUES(16654,'Month',8)
/
INSERT INTO HtmlLabelInfo VALUES(16654,'月計劃',9)
/
delete from HtmlLabelIndex where id=16655
/
delete from HtmlLabelInfo where indexid=16655
/
INSERT INTO HtmlLabelIndex values(16655,'周计划')
/
INSERT INTO HtmlLabelInfo VALUES(16655,'周计划',7)
/
INSERT INTO HtmlLabelInfo VALUES(16655,'Week',8)
/
INSERT INTO HtmlLabelInfo VALUES(16655,'周計劃',9)
/
delete from HtmlLabelIndex where id=16656
/
delete from HtmlLabelInfo where indexid=16656
/
INSERT INTO HtmlLabelIndex values(16656,'日计划')
/
INSERT INTO HtmlLabelInfo VALUES(16656,'日计划',7)
/
INSERT INTO HtmlLabelInfo VALUES(16656,'Day',8)
/
INSERT INTO HtmlLabelInfo VALUES(16656,'日計劃',9)
/
|
ALTER TABLE "public"."projects_funding" DROP COLUMN "id";
|
SELECT
cc.id,
STRING_AGG(DISTINCT gc.title, '␥') AS "grouptitle_ss"
FROM collectionobjects_common cc
JOIN hierarchy h1 ON (cc.id = h1.id)
JOIN relations_common rc ON (h1.name = rc.subjectcsid AND rc.objectdocumenttype = 'Group')
JOIN hierarchy h2 ON (rc.objectcsid = h2.name)
LEFT OUTER JOIN groups_common gc ON (h2.id = gc.id)
GROUP BY cc.id
|
-- PostGIS can convert any geometry to a GeoJSON view
CREATE OR REPLACE VIEW api.taz_boundaries AS
SELECT *,
st_asgeojson(tnc.taz_boundaries.geom) AS geometry
FROM tnc.taz_boundaries;
ALTER VIEW api.taz_boundaries OWNER to postgres;
GRANT SELECT ON TABLE api.taz_boundaries TO anon;
|
-- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: 09-Nov-2017 às 20:10
-- Versão do servidor: 10.1.25-MariaDB
-- PHP Version: 7.1.7
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: `clubhub`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `assinantes`
--
CREATE TABLE `assinantes` (
`id` int(11) NOT NULL,
`nome` varchar(255) NOT NULL,
`cpf` varchar(11) NOT NULL,
`rg` varchar(9) NOT NULL,
`nascimento` date NOT NULL,
`sexo` char(1) NOT NULL,
`cep` varchar(8) NOT NULL,
`rua` varchar(255) NOT NULL,
`numero` varchar(10) NOT NULL,
`complemento` varchar(50) DEFAULT NULL,
`bairro` varchar(60) NOT NULL,
`cidade` varchar(60) NOT NULL,
`uf` int(11) NOT NULL,
`cepEntrega` varchar(8) DEFAULT NULL,
`ruaEntrega` varchar(255) DEFAULT NULL,
`numeroEntrega` varchar(10) DEFAULT NULL,
`complementoEntrega` varchar(50) DEFAULT NULL,
`bairroEntrega` varchar(60) NOT NULL,
`cidadeEntrega` varchar(60) DEFAULT NULL,
`ufEntrega` char(2) DEFAULT NULL,
`telefone` varchar(11) NOT NULL,
`celular` varchar(11) NOT NULL,
`email` varchar(255) NOT NULL,
`senha` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `assinantes`
--
INSERT INTO `assinantes` (`id`, `nome`, `cpf`, `rg`, `nascimento`, `sexo`, `cep`, `rua`, `numero`, `complemento`, `bairro`, `cidade`, `uf`, `cepEntrega`, `ruaEntrega`, `numeroEntrega`, `complementoEntrega`, `bairroEntrega`, `cidadeEntrega`, `ufEntrega`, `telefone`, `celular`, `email`, `senha`) VALUES
(1, 'Marco Antonio de Oliveira Junior', '39299476845', '417407518', '1994-04-23', 'M', '17052330', 'Rua Fortunato Resta', '640', '', 'Vila Giunta', 'Bauru', 0, '', '', '', '', '', '0', NULL, '1432430816', '14981047450', 'marco_oliveira94@live.com', 'd90c7638025bb8e4d6dbda0c7051d9e7'),
(2, 'Marco Antonio de Oliveira Junior', '21786482584', '417407519', '1994-04-23', 'M', '17052330', 'Rua Fortunato Resta', '640', '', 'Vila Giunta', '0', 0, '', '', '', '', '', '0', NULL, '1432430816', '14981047450', 'marquinho_loco80@hotmail.com', 'd90c7638025bb8e4d6dbda0c7051d9e7'),
(5, 'Marco Antonio de Oliveira Junior', '48160884826', '417407511', '1994-04-23', 'M', '17052330', 'Rua Fortunato Resta', '640', '', 'Vila Giunta', '0', 0, '', '', '', '', '', '0', NULL, '1432430816', '14981047450', 'teste@teste.com.br', 'd90c7638025bb8e4d6dbda0c7051d9e7'),
(6, 'Teste', '15716472281', '123456777', '1994-04-23', 'M', '17052330', 'Rua Fortunato Resta', '640', '', 'Vila Giunta', '0', 0, '', '', '', '', '', '0', NULL, '1431042050', '14991850101', 'mais@teste.com.br', 'd90c7638025bb8e4d6dbda0c7051d9e7'),
(7, 'Marco Oliveira', '23973534233', '123456789', '1994-04-23', 'M', '17052330', 'Rua Fortunato Resta', '640', '', 'Vila Giunta', '0', 0, '', '', '', '', '', '0', NULL, '1431042050', '14991850101', 'onelastime@teste.com', 'd90c7638025bb8e4d6dbda0c7051d9e7'),
(8, 'Ariana Grande', '15957604070', '123555555', '1994-04-23', 'M', '17052330', 'Rua Fortunato Resta', '640', '', 'Vila Giunta', '0', 0, '', '', '', '', '', '0', NULL, '1431042050', '14991850101', 'ariana@grande.com', 'd90c7638025bb8e4d6dbda0c7051d9e7');
-- --------------------------------------------------------
--
-- Estrutura da tabela `assinatura`
--
CREATE TABLE `assinatura` (
`id` int(11) NOT NULL,
`id_assinante` int(11) NOT NULL,
`id_pacote` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `categorias`
--
CREATE TABLE `categorias` (
`id` int(11) NOT NULL,
`nome` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `categorias`
--
INSERT INTO `categorias` (`id`, `nome`) VALUES
(1, 'Nerd'),
(2, 'Alimentação'),
(3, 'Bebidas'),
(4, 'Livros');
-- --------------------------------------------------------
--
-- Estrutura da tabela `cidade`
--
CREATE TABLE `cidade` (
`id` int(11) NOT NULL,
`nome` varchar(100) NOT NULL,
`estado` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `cliente`
--
CREATE TABLE `cliente` (
`id` int(11) NOT NULL,
`nomeFantasia` varchar(255) NOT NULL,
`cnpj` varchar(14) NOT NULL,
`razaoSocial` varchar(255) NOT NULL,
`categoria` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `cliente`
--
INSERT INTO `cliente` (`id`, `nomeFantasia`, `cnpj`, `razaoSocial`, `categoria`) VALUES
(0, 'Clube de Assinatura de Testes', '50391122000124', 'Testes Marco LTDA', 1);
-- --------------------------------------------------------
--
-- Estrutura da tabela `clubes`
--
CREATE TABLE `clubes` (
`id` int(11) NOT NULL,
`nome` varchar(255) NOT NULL,
`razaoSocial` varchar(255) NOT NULL,
`cnpj` varchar(14) NOT NULL,
`cep` varchar(8) NOT NULL,
`rua` varchar(255) NOT NULL,
`numero` varchar(10) NOT NULL,
`complemento` varchar(50) DEFAULT NULL,
`bairro` varchar(60) NOT NULL,
`cidade` int(11) NOT NULL,
`uf` int(11) NOT NULL,
`telefone` varchar(11) NOT NULL,
`celular` varchar(11) NOT NULL,
`email` varchar(255) NOT NULL,
`senha` varchar(255) NOT NULL,
`categoria` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `clubes`
--
INSERT INTO `clubes` (`id`, `nome`, `razaoSocial`, `cnpj`, `cep`, `rua`, `numero`, `complemento`, `bairro`, `cidade`, `uf`, `telefone`, `celular`, `email`, `senha`, `categoria`) VALUES
(1, 'Clube de Testes', 'Clube de Testes Comércio Online', '72332796000190', '17052330', 'Rua Fortunato Resta', '640', '', 'Vila Giunta', 0, 0, '1432430816', '14981047450', 'marco_oliveira94@live.com', 'd90c7638025bb8e4d6dbda0c7051d9e7', 1);
-- --------------------------------------------------------
--
-- Estrutura da tabela `estados`
--
CREATE TABLE `estados` (
`id` int(11) NOT NULL,
`nome` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `pacotes`
--
CREATE TABLE `pacotes` (
`id` int(11) NOT NULL,
`idClube` int(11) NOT NULL,
`nome` varchar(255) NOT NULL,
`categoria` int(11) NOT NULL,
`valor` decimal(5,2) NOT NULL,
`imagem` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Extraindo dados da tabela `pacotes`
--
INSERT INTO `pacotes` (`id`, `idClube`, `nome`, `categoria`, `valor`, `imagem`) VALUES
(0, 1, 'Thor Ragnarok', 1, '89.99', 'clubeNerdTeste.jpg');
-- --------------------------------------------------------
--
-- Estrutura da tabela `periodicidade`
--
CREATE TABLE `periodicidade` (
`id` int(11) NOT NULL,
`data_inicio` date NOT NULL,
`data_fim` date NOT NULL,
`id_pacote` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Estrutura da tabela `vendas`
--
CREATE TABLE `vendas` (
`id` int(11) NOT NULL,
`valor_total` decimal(8,2) NOT NULL,
`id_cliente` int(11) NOT NULL,
`id_assinante` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `assinantes`
--
ALTER TABLE `assinantes`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `cpf` (`cpf`),
ADD UNIQUE KEY `rg` (`rg`),
ADD UNIQUE KEY `email` (`email`);
--
-- Indexes for table `assinatura`
--
ALTER TABLE `assinatura`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `categorias`
--
ALTER TABLE `categorias`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `cidade`
--
ALTER TABLE `cidade`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `cliente`
--
ALTER TABLE `cliente`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `clubes`
--
ALTER TABLE `clubes`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `cnpj` (`cnpj`),
ADD UNIQUE KEY `email` (`email`);
--
-- Indexes for table `estados`
--
ALTER TABLE `estados`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `pacotes`
--
ALTER TABLE `pacotes`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `periodicidade`
--
ALTER TABLE `periodicidade`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `vendas`
--
ALTER TABLE `vendas`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `assinantes`
--
ALTER TABLE `assinantes`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `categorias`
--
ALTER TABLE `categorias`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `clubes`
--
ALTER TABLE `clubes`
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 */;
|
DROP TABLE ISSUE_REPLY;
CREATE TABLE ISSUE_REPLY(ISSUE_NUM NUMBER REFERENCES PRJ_ISSUE(ISSUE_NUM) ON DELETE CASCADE,
USER_NICKNAME VARCHAR2(100),
REPLY_CONTENT VARCHAR2(4000),
REPLY_DATE_CREATE DATE);
SELECT * FROM ISSUE_REPLY;
SELECT * FROM ISSUE_REPLY WHERE ISSUE_NUM = 43;
192.168.10.139 |
(select name, customers_number
from lawyers
order by customers_number desc
limit 1)
union all
(select name, customers_number
from lawyers
order by customers_number asc
limit 1)
union all
(select 'Average', cast(avg(customers_number) as int)
from lawyers) |
CREATE PROC usp_DepositMoney (@AccountId INT, @moneyAmount MONEY)
AS
BEGIN
BEGIN TRANSACTION
UPDATE Accounts
SET Balance += @moneyAmount
WHERE Id = @AccountId
IF (@@ROWCOUNT <> 1)
BEGIN
ROLLBACK
RETURN
END
COMMIT
END
--EXEC dbo.usp_DepositMoney 1, 1000
--EXEC dbo.usp_DepositMoney 1, -1000 |
SELECT * FROM WEBHOOKS
WHERE DELETE_FLAG = 0
ORDER BY INSERT_DATETIME %s;
|
CREATE TABLE member (
mb_no int(11) NOT NULL AUTO_INCREMENT,
mb_id varchar(20) NOT NULL DEFAULT '',
mb_password varchar(255) NOT NULL DEFAULT '',
mb_name varchar(255) NOT NULL DEFAULT '',
mb_birth datetime NOT NULL DEFAULT '2000-01-01',
mb_email varchar(255) NOT NULL DEFAULT '',
mb_gender varchar(255) NOT NULL DEFAULT '',
mb_ip varchar(255) NOT NULL DEFAULT '',
mb_datetime datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
mb_modify_datetime datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
PRIMARY KEY (mb_no),
UNIQUE KEY mb_id (mb_id),
KEY mb_datetime (mb_datetime)
);
CREATE TABLE younivmember(
mb_no int(11) NOT NULL AUTO_INCREMENT,
mb_id varchar(50) NOT NULL DEFAULT '',
mb_password varchar(20) NOT NULL DEFAULT '',
mb_name varchar(20) NOT NULL DEFAULT '',
PRIMARY KEY (mb_no),
UNIQUE KEY mb_no (mb_no),
KEY mb_id (mb_id)
);
alter table creator add crt_subsc int(11) null after crt_link;
CREATE TABLE memo(
me_id int(11) not null AUTO_INCREMENT,
me_recv_mb_id varchar(20) NOT NULL DEFAULT '',
me_send_mb_id varchar(20) NOT NULL DEFAULT '',
me_send_datetime datetime not NULL DEFAULT '1000-01-01 00:00:00',
me_read_datetime datetime not NULL DEFAULT '1000-01-01 00:00:00',
me_memo text NOT NULL,
primary key(me_id),
key me_recv_mb_id(me_recv_mb_id)
);
CREATE TABLE recruit(
rc_no int(11) NOT NULL AUTO_INCREMENT,
rc_title varchar(30) NOT NULL DEFAULT '',
rc_group varchar(20) NOT NULL DEFAULT '',
rc_form varchar(20) NOT NULL DEFAULT '',
rc_career varchar(30) NOT NULL DEFAULT '',
rc_deadline datetime NOT NULL DEFAULT '2000-01-01',
rc_text text NULL,
rc_directory varchar(255) NULL,
rc_imagename varchar(255) NULL,
PRIMARY KEY (rc_no),
UNIQUE KEY rc_no (rc_no),
KEY rc_title (rc_title)
);
CREATE TABLE creator(
crt_no int(11) NOT NULL AUTO_INCREMENT,
crt_name varchar(70) NOT NULL DEFAULT '',
crt_intro text null,
crt_area varchar(50) NOT NULL DEFAULT '',
crt_link varchar(150) NOT NULL DEFAULT '',
crt_num int NULL,
crt_directory varchar(255) NULL,
crt_imagename varchar(255) NULL,
PRIMARY KEY (crt_no),
UNIQUE KEY crt_no (crt_no),
KEY crt_name (crt_name)
);
|
execute create_user('bailey.aa.fsa','L','Leo', 1000164052 ,'SDPA');
execute create_user('bailey.aa.fsa','L','Leo', 1000162156,'SDPA');
execute create_user('bailey.aa.fsa','L','Leo', 1000163403 ,'SDPA');
EXECUTE create_user('bailey.aa.fsa','L','Leo', 1000054727 ,'SDPA');
EXECUTE create_user('bailey.aa.fsa','L','leo', 1000054872 ,'SDPA');
execute create_user('bailey.aa.fsa','L','Leo', 1000055988 ,'SDPA'); |
rem
rem $Header: dropcat6.sql,v 1.1 1992/09/29 15:46:40 RLIM Stab $
rem
Rem Copyright (c) 1992 by Oracle Corporation
Rem NAME
Rem dropcat6.sql
Rem FUNCTION
Rem Drop version 6 dictionary objects owned by SYS
Rem NOTES
Rem This script should be run while logged-in as SYS on a version 6
Rem database. It drops all version 6 dictionary objects.
Rem If a user is about to perform a full database export of a
Rem version 6 database that will be imported into a version 7
Rem database, he should first run this script to prevent the export
Rem and later import of the old dictionary objects.
Rem
Rem MODIFIED
Rem rlim 09/29/92 - Creation
Rem
set echo on
drop public synonym dual;
drop public synonym ACCESSIBLE_TABLES;
drop public synonym ACCESSIBLE_COLUMNS;
drop public synonym CONSTRAINT_DEFS;
drop public synonym CONSTRAINT_COLUMNS;
drop public synonym USER_CROSS_REFS;
drop public synonym USER_TAB_GRANTS;
drop public synonym USER_TAB_GRANTS_MADE;
drop public synonym ALL_TAB_GRANTS_MADE;
drop public synonym USER_TAB_GRANTS_RECD;
drop public synonym ALL_TAB_GRANTS_RECD;
drop public synonym USER_COL_GRANTS;
drop public synonym ALL_TAB_GRANTS;
drop public synonym ALL_COL_GRANTS;
drop public synonym USER_COL_GRANTS_MADE;
drop public synonym ALL_COL_GRANTS_MADE;
drop public synonym USER_COL_GRANTS_RECD;
drop public synonym ALL_COL_GRANTS_RECD;
drop public synonym USER_AUDIT_CONNECT;
drop public synonym DBA_AUDIT_CONNECT;
drop public synonym USER_AUDIT_RESOURCE;
drop public synonym DBA_AUDIT_RESOURCE;
drop public synonym DBA_AUDIT_DBA;
drop public synonym USER_TAB_AUDIT_OPTS;
drop table dual;
drop view ACCESSIBLE_TABLES;
drop view CONSTRAINT_DEFS;
drop view CONSTRAINT_COLUMNS;
drop view USER_CROSS_REFS;
drop view DBA_CROSS_REFS;
drop view USER_TAB_GRANTS;
drop view DBA_TAB_GRANTS;
drop view USER_TAB_GRANTS_MADE;
drop view ALL_TAB_GRANTS_MADE;
drop view USER_TAB_GRANTS_RECD;
drop view ALL_TAB_GRANTS_RECD;
drop view USER_COL_GRANTS;
drop view DBA_COL_GRANTS;
drop view USER_COL_GRANTS_MADE;
drop view ALL_COL_GRANTS_MADE;
drop view USER_COL_GRANTS_RECD;
drop view ALL_COL_GRANTS_RECD;
drop view USER_AUDIT_CONNECT;
drop view USER_AUDIT_RESOURCE;
drop view DBA_AUDIT_DBA;
drop view USER_TAB_AUDIT_OPTS;
drop view DBA_TAB_AUDIT_OPTS;
set echo off;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.