- 1、本文档共14页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
触发器及建表sl语句
下面是机构管理部分数据库的建立
create table users
(
username varchar(8) primary key,
passwd varchar(15) not null,
permit integer not null,
org varchar(30) not null
);
create table county
(
county_name varchar(10) primary key,
init char(2)
);
create table hospital
(
code char(4) primary key,
hos_name varchar(20) not NULL,
county varchar(10) not null,
foreign key(county) references county(county_name)
);
create table community
(
code char(4) primary key,
hos_name varchar(20) not NULL,
county varchar(10) not null,
foreign key(county) references county(county_name)
);
下面是机构管理的触发器和数据初始化
社区信息表community触发器所完成的功能:
插入功能:当向community输入一个新用户的时候会在users表默认生成两个账户,账户名为两位的区县代号+四位的社区代号+00(或者02),相应的账号密码为账号+888,,权限分别为33和65
更新功能:不能更新该社区所在的区县号,其它参数可以改变。修改社区相关信息时会改变users表下的相应账户信息,按照默认的情况同时更新信息上报员和账户管理员的用户名和密码
删除功能:如果删除社区,会同时在users表中删除该社区所拥有的信息上抱员和账户管理员的账户和密码
create or replace trigger community_trigger after insert or update or delete
on community for each row
begin if inserting then
Insert into users(username,passwd,permit,org) values((select DISTINCT init from county where county_name=:NEW.county) || :NEW.code ||00 ,(select DISTINCT init from county where county_name=:NEW.county) || :NEW.code || 00 || 888 , 33 , :NEW.hos_name);
Insert into users(username,passwd,permit,org) values((select DISTINCT init from county where county_name=:NEW.county)||:NEW.code||02,(select DISTINCT init from county where county_name=:NEW.county) || :NEW.code || 02 || 888 ,65, :NEW.hos_name);
elsif updating then
Update users set
username=(select DISTINCT init from county where county_name=:NEW.county) || :NEW.code || 00,
passwd=(select DISTINCT init from county where county_name=:NEW.county) || :NEW.code || 00 || 888,
org=:NEW.hos_name
Where username=(select DISTINCT init from county where county_name=:OLD.county)||:OLD.code||00;
Update users set
username=(select DISTINCT init from county where county_name=:NEW.county) || :NEW.code || 02
您可能关注的文档
- 西湖职业高级中领导一行来我校参观指导.docx
- 西软酒店收单一化软件使用说明书.doc
- 西石高速举办消应急演练活动.docx
- 要做重视细节的心人.doc
- 见证取证监理细正文.doc
- 视易点歌系统加方法.doc
- 视觉新脉动—215陈列道具流行趋势预测.docx
- 视频分析软件平介绍.doc
- 视频公开课引入校课堂教学的策略研究.doc
- 视频监控项目需分析书.doc
- 大学生职业规划大赛《新闻学专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《应用统计学专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《音乐学专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《中医学专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《信息管理与信息系统专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《汽车服务工程专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《水产养殖学专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《市场营销专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《音乐表演专业》生涯发展展示PPT.pptx
- 大学生职业规划大赛《音乐学专业》生涯发展展示PPT.pptx
文档评论(0)