SQL总结之对比和备份
-----用户解锁
select * from wfuser for update
-----------------
-----修改金额
select * from bp_account where acntidx = 'YC0003' for update
select * from bp_account_balance where acntidx = 'YC0003' for update
---==========================================================================================
-------------------零售扣款 A和B比对
select t2.contract_no,t2.pay_amt,t2.pay_name,t2.rec_account_no,t2.pay_acc from
(select a.contract_no,a.pay_amt,a.pay_name,a.rec_account_no,a.pay_acc from bi_retail_dd a where a.create_time > date '2017-01-05'
minus
select b.contract_no,b.pay_amt,b.pay_name,b.rec_account_no,b.pay_acc from bi_retail_dd@DBLINK b
where b.create_time > date '2017-01-03' and b.create_time < date '2017-01-04') t2;
-------------------零售扣款 B和A比对
select t2.contract_no,t2.pay_amt,t2.pay_name,t2.rec_account_no,t2.pay_acc from
(select a.contract_no,a.pay_amt,a.pay_name,a.rec_account_no,a.pay_acc from bi_retail_dd@DBLINK a
where a.create_time > date '2017-01-03'and a.create_time < date '2017-01-04'
minus
select b.contract_no,b.pay_amt,b.pay_name,b.rec_account_no,b.pay_acc from bi_retail_dd b
where b.create_time > date '2017-01-04' ) t2;
---------------------
select * from bi_retail_dd where contract_no = 'PA20150500006' and create_time > date '2017-01-04';
select * from bi_retail_dd@DBLINK where contract_no = 'PA20150500006' and create_time > date '2017-01-03' and create_time < date '2017-01-04';
----------------------按照时间查询C和D的全部数据-----
select * from bi_retail_dd@DBLINK where create_time > date '2017-01-03' and create_time < date '2017-01-04' order by tid desc;
select * from bi_retail_dd where create_time > date '2017-01-05' order by tid desc;
----------------------------------------------------------------------------------------------------------------------------------------------------
----------------------零售放款 D和C比对
select t2.contract_no,t2.pay_account_no,t2.rec_dept_name,t2.pay_amt,t2.rec_dept_acc from
(select a.contract_no,a.pay_account_no,a.rec_dept_name,a.pay_amt,a.rec_dept_acc from bi_retail_dc a where a.create_time > date '2017-01-04'
minus
select b.contract_no,b.pay_account_no,b.rec_dept_name,b.pay_amt,b.rec_dept_acc from bi_retail_dc@DBLINK b where b.create_time > date '2017-01-03' and b.create_time < date '2017-01-04') t2;
----------------------零售放款 E和F比对
select t2.contract_no,t2.pay_account_no,t2.rec_dept_name,t2.pay_amt,t2.rec_dept_acc from
(select b.contract_no,b.pay_account_no,b.rec_dept_name,b.pay_amt,b.rec_dept_acc from bi_retail_dc@DBLINK b where b.create_time > date '2017-01-03' and b.create_time < date '2017-01-04'
minus
select a.contract_no,a.pay_account_no,a.rec_dept_name,a.pay_amt,a.rec_dept_acc from bi_retail_dc a where a.create_time > date '2017-01-05')t2;
----------------------备份表后再修改
create table bi_retail_dd20170105 as
select * from bi_retail_dd;
update bi_retail_dc set state=2,FEEDBACK_RESULT=0 where create_time > date '2017-01-05' and create_time < date '2017-01-06'
--------------------
----------------------零售扣款需要改--------
select * from bp_batchsuborder where actdate=date'2017-1-5'
update bp_batchsuborder a set a.suborderstate=2 where actdate=date'2017-1-3'
-----------------------银行指令表
select * from bp_order where actdate=date'2017-1-5'
update bp_order set orderstate=2,transstate=1 where actdate=date'2017-1-4'
SELECT rowid, t.* from lc_acc_account t WHERE cust_code ='001' AND account_type ='1'
select * from cntbusssheet
select count(*) from bi_retail_dd a where a.feedback_result=1
--查询多维码不同
select t2.cust_id from
(select distinct (cust_id) from cntvoucher where vchdate = date '2017-1-3'
minus
select mcno from AMCODE where mgno = '10') t2;
--多维码凭证表
select * from cntvoucher where vchdate=date'2017-1-3' and vchmemo='收取月供'
--单据表
select * from cntbusssheet where actdate=date'2017-1-3'
-------------------------------------------------------------------------------
------库存放款数据比对
select t2.contract_no,t2.pay_amt,t2.pay_account_no,t2.rec_dept_acc,t2.vin_no from
(select a.contract_no,a.pay_amt,a.pay_account_no,a.rec_dept_acc,a.vin_no from bi_dc a where a.create_time > date '2017-01-03'
minus
select b.contract_no,b.pay_amt,b.pay_account_no,b.rec_dept_acc,b.vin_no from bi_dc@DBLINK b where b.create_time > date '2017-01-03') t2;
------库存扣款数据比对
select t2.vin_no,t2.pay_amt,t2.rec_account_no,t2.pay_name,t2.pay_acc from
(select a.vin_no,a.pay_amt,a.rec_account_no,a.pay_name,a.pay_acc from bi_dd a where a.create_time > date '2017-01-03'
minus
select b.vin_no,b.pay_amt,b.rec_account_no,b.pay_name,b.pay_acc from bi_dd@DBLINK b where b.create_time > date '2017-01-03') t2;
-----修改的语句
update bi_retail_dd a set a.state=2,a.FEEDBACK_RESULT=1 where
(a.CONTRACT_NO,a.PAY_AMT) not in
(select CONTRACT_NO,PAY_AMT from bi_retail_dddb20170105 b where
b.create_time > date '2017-01-03' and b.create_time < date '2017-01-04' and b.FEEDBACK_RESULT='0' )
and a.update_time>date'2017-1-3'
----------------------------------------------------------------------------------------------
update bi_retail_dd a set a.state=2,a.FEEDBACK_RESULT=0 where (a.CONTRACT_NO,a.PAY_AMT) in
(select CONTRACT_NO,PAY_AMT from bi_retail_dddb20170105 b where
b.create_time > date '2017-01-03' and b.create_time < date '2017-01-04' and b.FEEDBACK_RESULT='0' )
and a.update_time>date'2017-1-3'
------------------------------------------------------------------------------------------------
select * from bi_retail_dd a where
(a.CONTRACT_NO,a.PAY_AMT) in
(select CONTRACT_NO,PAY_AMT from bi_retail_dddb20170105 b where
b.create_time > date '2017-01-03' and b.create_time < date '2017-01-04' and b.FEEDBACK_RESULT='0' )
and a.update_time>date'2017-1-4'
----------------------------------------
--备份一下表数据
create table bi_retail_dddb20170105 as
select * from bi_retail_dd@DBLINK b where b.create_time > date '2017-01-03' and b.create_time < date '2017-01-04' and b.FEEDBACK_RESULT='0';
----------------------------------------
SQL总结之对比和备份的更多相关文章
- SQL Server如何提高数据库备份的速度
对于一个数据库完整备份来说,备份的速度很大程度上取决于下面两个因素:读磁盘数据.日志文件的吞吐量,写磁盘数据文件的吞吐量. 下图是备份过程中磁盘的变化情况: 读吞吐量 读吞吐量的大小取决于磁盘读取数据 ...
- mysql与sql server参照对比学习mysql
mysql与sql server参照对比学习mysql 关键词:mysql语法.mysql基础 转自桦仔系列:http://www.cnblogs.com/lyhabc/p/3691555.html ...
- SQL Server 批量主分区备份(Multiple Jobs)
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 案例分析(Case) 方案一(Solution One) 方案二(Solution Two) ...
- SQL Server 批量主分区备份(One Job)
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 案例分析(Case) 实现代码(SQL Codes) 主分区完整.差异还原(Primary B ...
- 1、SQL Server自动化运维 - 备份(一)业务数据库
为了能够恢复数据,数据库运维基础就是备份,备份自动化也是运维自动化首要进行的. 笔者的备份自动化,通过配置表快速配置为前提,同时记录备份过程,尽可能的减少人工操作.首先将SQL Server备份按用途 ...
- SQL Server数据库定时自动备份
SQL Server 数据库定时自动备份[转] 在SQL Server中出于数据安全的考虑,所以需要定期的备份数据库.而备份数据库一般又是在凌晨时间基本没有数据库操作的时候进行,所以我们不可能要求 ...
- SQL Server 维护计划实现数据库备份(策略实战)
一.背景 之前写过一篇关于备份的文章:SQL Server 维护计划实现数据库备份,上面文章使用完整备份和差异备份基本上能解决数据库备份的问题,但是为了保障数据更加安全,我们需要再次完善我们的备份计划 ...
- SQL Server 维护计划实现数据库备份(Step by Step)(转)
SQL Server 维护计划实现数据库备份(Step by Step) 一.前言 SQL Server 备份和还原全攻略,里面包括了通过SSMS操作还原各种备份文件的图形指导,SQL Server ...
- SQL server 2008数据库的备份与还原、分离(转)
SQL server 2008数据库的备份与还原.分离(转) 一.SQL数据库的备份: 1.依次打开 开始菜单 → 程序 → Microsoft SQL Server 2008 → SQL Ser ...
随机推荐
- Sqoop自定义多字节列分隔符
Sqoop提供的--fields-terminated-by选项可以支持指定自定义的分隔符,但是它只支持单字节的分隔符,对于我们特殊的需求:希望使用双字节的“|!”,默认的是不支持的. Sqoop在进 ...
- Scala中的语言特性是如何实现的(3) -- Trait
我的新博客地址:http://cuipengfei.me/blog/2013/10/13/scala-trait/ 我在Coursera上跟了一门叫做Functional Programming Pr ...
- 控制winform中控件的输入格式
private void txtNum1_KeyPress(object sender, KeyPressEventArgs e) { ') && e.KeyChar != '\r' ...
- 多线程编程中使用pthread_create内存泄露问题
//tls5源代码: #include <stdio.h> #include <unistd.h> #include <string.h> #include &qu ...
- GeoHash核心解析
GeoHash核心解析 引子 机机是个好动又好学的孩子,平日里就喜欢拿着手机地图点点按按来查询一些好玩的东西.某一天机机到北海公园游玩,肚肚饿了,于是乎打开手机地图,搜索北海公园附近的餐馆,并选了其中 ...
- Class org.apache.struts2.json.JSONWriter can not access a member of class oracle.jdbc.driver.Physica
产生这个错误的原因是因为我的oracle数据库中有一个CLOB字段,查询出来的时候要转换为JSON而报错. Class org.apache.struts2.json.JSONWriter can n ...
- Morn简介及使用教程
[Morn UI系列教程]Morn简介及使用教程 网页游戏开发的一大部分工作是在和UI制作上,一个好的工具及框架能使开发事半功倍,Adobe自带flash IDE和Flex各有不足. Morn UI学 ...
- SVN 在 Xcode中的状态说明
最近同事总是问我关于SVN状态的问题,‘C’是什么意思啦?‘A’是什么意思啦?等等一系列问题. 为了方便以后查阅,以及新同事的快速融入,特在此记录一下^_^. 当然了大家也可以google一下,一搜一 ...
- 反向代理(Reverse Proxy)
反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时 ...
- 推荐一个很好用的HTTP操作类
/// <summary> /// 类说明:HttpHelps类,用来实现Http访问,Post或者Get方式的,直接访问,带Cookie的,带证书的等方式,可以设置代理 /// 重要提示 ...