- 博客(156)
- 收藏
- 关注
原创 oracle 11g for Linux(Red Hat 4.8.5-11) 部署手记
查看系统版本信息[root@db_slave ~]# uname -aLinux db_slave 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux[root@db_slave ~]# lsb_release -abash: lsb_release: comm
2017-08-24 22:04:34
1909
原创 Mysql主从同步报错问题解决 Slave_IO_Running NO
--slave 报错信息show slave statusError:Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has pur
2017-08-24 11:11:18
994
原创 mysql主从同步出错troubleShooting一例,原因及常见解决方法
问题解决DEMO整体思路:分析同步异常信息,按部就班解决问题,若修复三个问题之后还有问题且数据量不太大考虑重建同步。show slave statusError:Worker 4 failed executing transaction '' at master log mysql-bin.000012, end_log_pos 60158; Error 'Can't DROP 'linenum
2017-08-23 18:03:55
789
原创 Mysql5.7.16 主从并行复制设置及troubleShooting
-----------------------------------------主从复制1、配置并行复制###检查基本参数设置grep 'log-bin' my.cnfgrep 'server-id' my.cnfgrep 'innodb_flush_log_at_trx_commit' my.cnfgrep 'sync_binlog' my.cnf###my.cnf增加并行复制线程信
2017-08-23 17:48:57
341
原创 Ubuntu 16.04 LTS X64 Install MySQL Community Server 5.7.19
Ubuntu 16.04 LTS X64 Install MySQL Community Server 5.7.19###版本确认# lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 16.04 LTSRelease: 16.04Codename: xe
2017-08-23 17:39:41
610
原创 Mysql 主从复制心跳(heartbeat)解析
心跳(heartbeat)含义:在master没有写binlog时发出heartbeat,以便slave知道master是否正常。取值范围:单位秒,0 到 4294967秒。精确度可以达到毫秒,最小的非0值是0.001秒。发出条件:master在主机binlog日志文件在设定的间隔时间内没有收到新的事件时发出。参数查看:--salve envselect heartbeat from m
2017-08-23 16:59:46
1909
原创 过滤条件顺序导致不一致问题
背景:派生表中的条件已经过滤掉非法的数据,但是最终查询的时候还是出现报错的问题。 原因:sqlserver在决定生产最终的执行计划的时候会在不改变最终查询结果的前提下会做条件的合并(派生表中的条件和最外层条件处于相同优先级),然后按照cost最优的原则选择条件的执行顺序。 if(object_id('testa','U') is not null) drop table testa;
2017-08-07 17:36:49
397
原创 output Demo
--output Demo--Basic dataif(object_id('dbo.prd','U') is not null) drop table dbo.prd;CREATE TABLE dbo.prd(id bigint not null identity(1,1) constraint pk_prd primary key,code varchar(20) not null,p
2017-08-07 17:21:18
527
原创 【Sqlserver】复杂去重需求实现DEMO
use tempdbGOif(object_id('asktom','U') is not null) drop table asktom;create table asktom(id bigint not null identity(1,1) constraint pk_asktom primary key,pid varchar(10) not null,is_childp bit n
2017-08-03 20:58:53
340
原创 【SqlServer】Cross Apply的另一个妙用和for xml查询字段赋别名问题的解决
--创建测试表create table ta (id int ,val varchar(10));create table tb (id int ,val varchar(10));insert into ta values(1,'A'),(2,'B');insert into tb values(1,'AA'),(2,'BB'),(1,'AC'),(2,'BC');--有一个字符串拼接需求,
2017-08-03 14:54:43
527
原创 【Sqlserver】基于备份和日志备份的还原测试
--------------------step1. create database & table USE master;-- Drop databaseIF DB_ID('TestBakDB') IS NOT NULL DROP DATABASE TestBakDB;-- If database could not be created due to open connections, ab
2017-08-03 14:30:58
436
原创 【Sqlserver】基于备份和差异备份的还原测试
--------------------step1. create database & table USE master;-- Drop databaseIF DB_ID('TestBakDB') IS NOT NULL DROP DATABASE TestBakDB;-- If database could not be created due to open connections, ab
2017-08-03 14:30:00
363
原创 【MYSQL】Mysql长时间SQL优化一例(force index)
SELECT SUBSTR(eff_time,1,10),ns_name,COUNT(*) FROM HEHEDA WHERE isActive = 1 AND stype <> 'report' AND usefull = 1 AND eff_time > '2014-01-01' AND itype =1 AND ns_name IN ('凤凰网', '新浪财经', '和讯网', '金融界'
2017-07-10 20:07:09
396
原创 【数据库需求】生成指定区域内所有扩展数据
-------需求:生成指定区域内所有扩展数据--(id,id2,create_number<=num,num) DEMO:(1,1,3)->(1,1,1,3),(1,1,2,3)(1,1,3,3)if(object_id('tempdb..#a','U') is not null) drop table #a;create table #a(pk_id int not null iden
2017-07-10 19:58:26
260
原创 sp_OACreate和SQL Server中执行正则表达式
前面数据库迁移有遇到sp_OACreate的相关报错,当时修改数据库选项并赋权解决了该问题,但具体是哪边使用了sp_OACreate导致的并没有深究,今天专门研究了一下。--报错EXEC sp_OACreate;SQL Server 阻止了对组件“Ole Automation Procedures”的 过程“sys.sp_OACreate”的访问,因为此组件已作为此服务器安全配置的一部分而被关
2017-07-10 16:25:09
737
原创 【in - exists-join(distinct)】SQL调优改写一例
相关数据已经脱敏处理原SQLMERGE INTO IntoTable t USING ( SELECT x.PID, b.SEC_ID, b.T_SYB, b.E_CD, x.END_DATE, x.xh 区间级别, isnull(x.hj, 0) 区间人数 FROM
2017-07-10 11:13:34
328
原创 【SQL SERVER】删除过期的SQL Server备份文件
近期遇到定时任务中清理数据库过期文件失效的问题,总结了下删除过期数据库备份文件的相关方法,总结如下:1.BAT脚本法脚本DEMO(删除两天前的数据): FORFILES /P “E:\Backup” /M *.bak /C “cmd /C del /Q @path” /d -2 说明: FORFILES /P “文件路径” /M 文件名(通配符) /C “cmd /C del /Q @pat
2017-07-03 14:32:12
1119
原创 update demo
-- update demo--BASIC DATAuse tempdb;GOif(object_id('torder','U') is not null) drop table torder;create table torder(id bigint not null identity(1,1) constraint PK_TORDER primary key,onumb varcha
2017-06-06 17:11:20
362
原创 Delete DEMO
-- delete DEMOuse tempdb;GOif (object_id('tuser','U') is not null) drop table tuser;create table tuser(id int not null identity(1,1) constraint PK_TUSER primary key ,uid int not null constraint TU
2017-06-06 17:10:00
312
原创 插入数据简单测试
--Create tableif(object_id('testa','U') is not null) drop table testa;create table testa (id int not null identity(1,1) primary key,val varchar(200) not null constraint testa$BPK_AK_Key unique non
2017-06-06 17:08:34
303
原创 Merge into test
--merge into test/*使用Merge关键字的好处:简洁有效,性能更强Note:在SQL Server 2008之前没有Merge*/create table testsou( --源测试表id int,name varchar(10),des varchar(50))create table testtag( --目标表id int,name varchar(1
2017-06-06 16:37:40
432
原创 select into VS insert select VS bulk insert 效率测试
--select into VS insert select VS bulk insert 效率测试--数据库恢复模式:简单--Basic tableuse tempdb;GOif(object_id('dbo.orders','U') is not NULL) drop table dbo.orders;GOcreate table dbo.orders(orderid int no
2017-05-16 20:17:51
942
原创 identity 完全测试
--identity--include: seed(initial value),step(increment value)--usage:surrogate key(代理键,业务无关,系统生成)--basic tableif(object_id('dbo.t1','U') is not null) drop table t1;GOcreate table dbo.t1(id int n
2017-05-16 17:21:30
908
原创 Insert Data Demo--插入数据的四种方式及测试
--Insert Data Demo--basic tableuse tempdb;GOif(object_id('dbo.orders','U') is not NULL) drop table dbo.orders;GOcreate table dbo.orders(orderid int not null /*identity(1,1)*/ constraint PK_orders
2017-05-16 17:07:46
1786
原创 Mysql text MEDIUMTEXT 在5.5和5.7中的差异及扩容测试
# text LENGTH#TINYTEXT: 256 bytes#TEXT: 65,535 bytes => ~64kb#MEDIUMTEXT: 16,777,215 bytes => ~16MB#LONGTEXT: 4,294,967,295 bytes => ~4GBselect version();# 5.7.17create table testTB (id int not nu
2017-05-10 11:23:45
1025
原创 Mysql [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause
select version();# 5.7.17常规查询报错: [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column Trouble shooting过程(注意mysql5.7配置文件的路径):root@TESTDB:~# cd /ro
2017-05-10 10:25:51
861
原创 透视,逆透视,分组集 pivoting ,unpivoting ,grouping set
--透视,逆透视,分组集 pivoting ,unpivoting ,grouping set---------------基本数据use tempdbgoif(object_id('dbo.asktom') is not null ) drop table asktom;create table asktom(id int not null identity(1,1),adate dat
2017-05-09 20:46:28
403
原创 CentOS如何删除旧的内核(kernel)
(1)查看已经安装的内核命令:rpm -q kernel 显示结果: kernel-2.6.32-279.14.1.el6.i686 kernel-2.6.32-279.el6.x86_64 kernel-2.6.32-358.6.1.el6.x86_64(2)删除旧的内核方法一:安装yum-utls: yum install -y yum-utils 设置你想要保留多少旧的内核,比
2017-05-09 10:48:28
1180
原创 ubuntu crontab 不执行问题排查
定时任务脚本: 02 10 * * * nohup sh /opt/DBback/Backed/backup.sh > /opt/DBback/backup.log 2>&1 &1.脚本单独执行nohup sh /opt/DBback/Backed/backup.sh > /opt/DBback/backup.log 2>&1 & 正常,没有报错。2.开启日志,查看报错rontab记录日志
2017-05-09 10:45:26
611
原创 【Sqlserver】堵塞问题解决思路
背景: App userA:主要负责数据入库(线程较少) ; userB:负责数据查询和校验(线程较多,多为个人连接数据库查询)。 userA和userB之间经常会存在锁导致堵塞,从公司层面看,userA的是主体核心业务,userB是从业务。最好的改进方式是全任务的计划执行,在App改进之前,先用如下定时任务临时缓解问题。 - 操作:kill user=userB,而且堵塞
2017-05-05 20:13:22
573
原创 【Mysql】【子查询-left join改写】前端SQL调优
相关数据已经脱敏处理-- 原SQLSELECT * FROM (SELECT a.*, (SELECT sum(CASE WHEN (b.confidence < c.THRESHOLD * d.THRESHOLD AND b.KEY_N
2017-05-05 20:01:56
446
原创 sqlserver UNION-OR 改写一例
------原SQL info:select name=name,xtype=0,rowcnt=-1 from sysobjects with (nolock) where status>=0 and objectproperty(id,'ISUSERTABLE')=1unionselect name,1,-1 from sysobjects with (nolock) where statu
2017-05-05 11:28:50
647
原创 tempdb test
临时表主要用来干什么的用户对象(user_object_reserved_page_count) 由用户显式创建。包括: 用户定义的表和索引系统表和索引全局临时表和索引局部临时表和索引table 变量表值函数中返回的表内部对象(internal_object_reserved_page_count) 由 SQL Server 数据库引擎创建,用于处理 SQL Server 语句。
2017-04-28 18:30:34
333
原创 集合运算
--集合运算(结果不一定是集合<可能存在重复行>,可能是多集)--基础数据if(object_id('dbo.testa','U') is not null) drop table testa;GOcreate table testa (id int not null,tname varchar(50) NULL);if(object_id('dbo.testb','U') is not
2017-04-28 18:07:15
461
原创 子查询列名中的替换错误
create table #T (id int);create table #B (id int,iid int);insert into #T values(1),(2),(3);insert into #B values(1,4),(2,5),(4,6);select * from #T where id in (select id from #B);/*12*/alter tabl
2017-04-24 19:09:31
315
原创 CROSS APPLY--windows function 改写
--客户最新的三个订单(1:N关系)select * from sales.orders where custid =85 order by orderdate desc;--select * from Sales.Customers where custid=85;--CROSS ALPPLYSELECT C.custid, d.* FROM Sales.Customers AS C
2017-04-24 19:08:04
251
原创 truncate 和 delete对自增ID的影响
if(object_id('dbo.testa') is not null) drop table testa;gocreate table testa(id bigint not null primary key identity(1,1) ,tname nvarchar(max) );--3 Timesinsert into testa(tname) values(N'ddcawsdqw
2017-04-20 20:06:25
1337
原创 索引视图测试
--索引视图/*原理:对视图创建唯一聚集索引后,结果集将存储在数据库中,就像带有聚集索引的表一样。适用范围:(1)大量行进行复杂处理(如聚合大量数据或联接许多行)的视图。(2)在查询中频繁地引用这类视图。不适用情景:(1)具有大量写操作的 OLTP 系统。(2)具有大量更新的数据库(维护索引视图的成本可能高于维护表索引的成本)。(3)数据频繁变化(维护索引视图数据的成本可能超过使用索引
2017-04-20 20:05:08
353
原创 inline table-valued function DEMO
--------------inline table-valued function DEMOIF OBJECT_ID('dbo.fn_usacus') is not null drop function dbo.fn_usacus;gocreate function dbo.fn_usacus(@i varchar(20) ) returns tableasreturnSELECT
2017-04-20 20:03:54
333
原创 VIEW DEMO
--------------VIEW DEMO-------BASICIF OBJECT_ID('dbo.vw_usacus') is not null drop view dbo.vw_usacus;gocreate view dbo.vw_usacus as SELECT custid id, companyname nameFROM InsideTSQL.Sales.Custo
2017-04-20 20:02:29
377
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人