实践出真知之Oracle篇

it2024-08-13  38

存储过程跑批小循环(可根据自己的情况适度修改)

DECLARE O_RET_VAL NUMBER; START_DAYS VARCHAR2(8); END_DAYS VARCHAR2(8); BEGIN START_DAYS := '20200101'; --重跑开始日期 日期不固定可根据自己需要的日期进行修改 END_DAYS := '20200430'; --重跑结束日期 WHILE START_DAYS <= END_DAYS LOOP ---------------------------------------------贷款 SP_CIF_INF_PS_ACCT_LOAN(START_DAYS, START_DAYS, O_RET_VAL); --存储过程名称可根据自己的实际存储过程进行修改 SP_CIF_INF_CO_ACCT_LOAN(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_PS_ACCT_LOAN(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_PS_ACCT_LOAN_HIS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_CO_ACCT_LOAN(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_CO_ACCT_LOAN_HIS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_INF_PS_CONT(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_INF_CO_CONT(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_PS_CONT(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_PS_CONT_HIS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_CO_CONT(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_CO_CONT_HIS(START_DAYS, START_DAYS, O_RET_VAL); -----------------------------------------------存款 SP_CIF_DAT_PS_ACCT_DEPS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_PS_ACCT_DEPS_HIS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_CO_ACCT_DEPS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_DAT_CO_ACCT_DEPS_HIS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_INF_PS_ACCT_DEPS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_INF_CO_ACCT_DEPS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_OP_AS_AR_SA_DEPS(START_DAYS, START_DAYS, O_RET_VAL); SP_CIF_OP_AS_AR_CO_DEPS(START_DAYS, START_DAYS, O_RET_VAL); --如果有多个存储过程,按顺序下去执行 START_DAYS := TO_CHAR((TO_DATE(START_DAYS, 'yyyymmdd') + 1), 'yyyymmdd'); END LOOP; END;

imp命令

imp user/pwd(用户名/密码) @网络服务器 file=\ \ \文件名.dmp full=y(#导入全部) ignore=y(重新创建数据库的所有对象,不会因为对象已存在而造成输入操作错误)

锁表,杀进程

--1、查看锁 SELECT S.SID, S.SERIAL#, V.*, AO.* FROM V$LOCKED_OBJECT V, ALL_OBJECTS AO, V$SESSION S WHERE V.OBJECT_ID = AO.OBJECT_ID AND S.SID = V.SESSION_ID; --2、解锁 ALTER SYSTEM KILL SESSION 'sid,serial#'; --3、解不了锁执行 SELECT P.SPID, S.OSUSER, S.PROGRAM FROM V$SESSION S, V$PROCESS P WHERE S.PADDR = P.ADDR AND S.SID = 129; --4、然后在linux执行 KILL - 9 SPID

判断两个表数据是否相同(dblink)篇 用来对照两个库相同表之间的数据

select * fromSELECT * FROM sys_employee@dblink224 WHERE sum_org_no='149002' AND emp_no NOT IN (SELECT emp_no FROM sys_employee WHERE sum_org_no='149002');

运用dblink来进行跨表插入

insert into A_CBS_DPSFMACDC SELECT * FROM A_CBS_DPSFMACDC@DBLINK21;

Linux命令文件导入篇

sqlldr userid=pfm/pfm@172.21.11.177:1521/pfmdb SKIP=0 log=/home/oracle/TaskSch/log/20200924/A_ODS_BE_CST_A.log bad=/home/oracle/TaskSch/bad/20200924/A_ODS_BE_CST_A.bad direct=true control=/home/oracle/TaskSch/ctl/20200924/ODS_BE_CST_W_INCR.ctl
最新回复(0)