测试

来源:互联网 发布:软件应用的英文 编辑:程序博客网 时间:2024/06/05 18:38








select * from  scc




select * from dba_constraints where constraint_name like '%病案主页%'
 and constraint_type = 'R';


select * from  病案主页


SELECT *
FROM user_con_columns
WHERE table_name = 'scc';


--查询一个列是哪些表的外键
--


--查询所在表
select * from dba_constraints where constraint_name like '%病案主页%'
-- 
select * from dba_constraints where constraint_name='SYS_C0019149'  
 and constraint_type = 'R';
-- 禁止开启
ALTER TABLE scc
enable  CONSTRAINT SYS_C0019149
ALTER TABLE scc
disable  CONSTRAINT SYS_C0019151
--


-- 开启约束 所有满足  默认
ALTER TABLE scc
ENABLE VALIDATE CONSTRAINT  SYS_C0019149
--


--开启约束 之后的满足
ALTER TABLE scc
ENABLE noVALIDATE CONSTRAINT  SYS_C0019149
--














select a.姓名,a.*  from  病案主页 a where a.病人id = 46247 for update
--1
select * from  病案主页从表  where 病人id = 46247 for update
alter table 病案主页从表 enable noVALIDATE constraint 病案主页从表_FK_主页ID
--2
alter table 病人变动记录 enable noVALIDATE constraint 病人变动记录_FK_主页ID
alter table 病人变动记录 disable constraint 病人变动记录_FK_主页ID
--3
alter table 病人地址信息 disable  constraint 病人地址信息_FK_主页ID
alter table 病人地址信息 enable noVALIDATE constraint 病人地址信息_FK_主页ID
select * from  病人地址信息 where 病人id = 46247 for update
--4
select * from  诊断符合情况 where 病人id = 46247 for update
alter table 诊断符合情况 enable noVALIDATE constraint 诊断符合情况_FK_主页ID
--5
select * from  住院费用记录 where 病人id = 46247 for update
update 住院费用记录 set 主页id = 主页id +1000 where 病人id = 46247 and 主页id = 500
alter table 住院费用记录 enable noVALIDATE constraint 住院费用记录_FK_主页ID
--6
select * from 病人未结费用  where 病人id = 46247 and 主页id = 500 for update
alter table 病人未结费用 enable noVALIDATE constraint 病人未结费用_FK_主页ID
--7
select * from  病人预交记录 where 病人id = 46247  and 主页id = 500 for update
alter table 病人预交记录 enable noVALIDATE constraint 病人预交记录_FK_主页ID
--8
select * from  未发药品记录 where 病人id = 46247 and 主页id = 500 for update
alter table 未发药品记录 enable noVALIDATE constraint 未发药品记录_FK_主页ID
--9
select * from  病人医嘱记录 where 病人id = 46247 and 主页id =500 for update
update 病人医嘱记录 set 主页id = 主页id +1000 where 病人id = 46247 and 主页id = 500
alter table 病人医嘱记录 enable noVALIDATE constraint 病人医嘱记录_FK_主页ID
--10
select * from 病人自动计算  where 病人id = 46247 and 主页id = 500 for update
alter table 病人自动计算 enable noVALIDATE constraint 病人自动计算_FK_主页ID
--11
select * from 在院病人 where 病人id = 46247 and 主页id = 500 for update
alter table 在院病人 enable noVALIDATE constraint 在院病人_FK_病人ID
--12
select * from 病人护理文件 where 病人id = 46247 and 主页id = 500 for update
alter table 病人护理文件 enable noVALIDATE constraint 病人护理文件_FK_主页ID
--


-----------------------
方案 1
流程优化
-- 是否在系统连接数少的时候使用
1 ALTER TABLE scc enable  CONSTRAINT SYS_C0019149
  alter...
   alter...
   
2--update 病案主页   
  
3 ALTER TABLE scc disable  CONSTRAINT SYS_C0019151
   alter...
    alter...


------------------
 方案 2
 可以写一个过程解决  3个参数  病人id old_主页id  new_主页id


-------------------






SELECT  
a.table_name, a.column_name 
FROM  
user_cons_columns a,  
user_constraints b  
WHERE  
a.constraint_name = b.constraint_name
 --AND  b.constraint_type = 'R'
 AND  a.column_name like '%病人ID%'; 

原创粉丝点击