创建Mysql 序列
摘要:create table sequence( name varchar(50) not null primary key, current_value BIGINT not null DEFAULT 0, increment int not null DEFAULT 1, max_value BIGINT, -- 最大值 initial_value BIGIN...
阅读全文
posted @
2016-01-13 11:27
思静
阅读(2699)
推荐(0) 编辑
备份BinLog并压缩 全备份
摘要:Rem Backup Mysql Binlog
Rem Backup Yesterday and RAR
Rem Backup every day 00:01 begin backup yesterday and now binlog @set curPath=%~dp0
@set SourcePath="\\110\ProgramData\MySQL\MySQL_Server_5.6\d...
阅读全文
posted @
2014-08-22 10:07
思静
阅读(964)
推荐(0) 编辑
Mysql 冷备份批处理
摘要:@Rem Generate today date@echo wscript.echo dateadd("d",0,date)>GetOldDate.vbs@for /f %%a in ('cscript /nologo GetOldDate.vbs') do @set OldDate=%%a@Rem echo %OldDate%@del GetOldDate.vbs@rem Replace/to-@set Current_Date=%OldDate:/=-%@Rem Generate 7 days ago@echo wscript.echo datea
阅读全文
posted @
2014-02-25 15:37
思静
阅读(926)
推荐(0) 编辑
关于四字节字符入库时错误的解决方案(Incorrect string value: '\xF0\x9F\x99\x8F' for column 'Reply_Content' at row 1)
摘要:1. 将表字段字符集设置成utf8mb4 2. 执行插入前执行:SET NAMES utf8mb4; 如: SET NAMES utf8mb4; INSERT test(Content) VALUES('~'); PHP例子: $paramValues=array('Content'=>'~'); $dbCommand->query('SET NAMES utf8...
阅读全文
posted @
2014-01-17 15:47
思静
阅读(17830)
推荐(1) 编辑
Mysql 中 like 查询存在反斜杠的解决办法
摘要:如 要查询 %\ABC\% 应该这样写, 写成四个反斜杠 like ‘%\\\\ABC\\\\%’
阅读全文
posted @
2013-10-10 16:33
思静
阅读(1089)
推荐(0) 编辑
ODBC连接MySQL出现"E_FAIL"错误
摘要:ODBC不能处理这种格式的数据:0000-00-00,将其更新为正常的时间即可解决
阅读全文
posted @
2013-10-09 16:43
思静
阅读(321)
推荐(0) 编辑
Mysql 创建联合索引注意事项
摘要:当一个表有多条索引可走时, Mysql 根据查询语句的成本来选择走哪条索引, 联合索引的话, 它往往计算的是第一个字段(最左边那个), 这样往往会走错索引. 如: 索引Index_1(Create_Time, Category_ID), Index_2(Category_ID) 如果每天的数据都特别多, 而且有很多category, 但具体每个category的记录不会...
阅读全文
posted @
2013-07-12 14:27
思静
阅读(16261)
推荐(0) 编辑
MySQL 取分类后的前n条
摘要:select *from (SELECT @num:=0,@AAA:= 0) temp join( select @num := if(@AAA = AAA, @num + 1, 1) as row_number, @AAA := AAA as Dummy, mt.* from table1 mt where Created_Time BETWEEN DATE_SU...
阅读全文
posted @
2013-03-12 17:06
思静
阅读(620)
推荐(0) 编辑
短信猫 Mysql ODBC问题
摘要:用了某公司的短信猫, 测试连不上MySQL数据库, 一直以为是MySQL ODBC的问题. 后来发现, 是某个表表名太长所致.
阅读全文
posted @
2013-01-25 18:20
思静
阅读(242)
推荐(0) 编辑
Fixed Event Scheduler No data - zero rows fetched, selected, or processed
摘要:在windows系统日志里出现Mysql调度错误日志: Fixed Event Scheduler No data - zero rows fetched, selected, or processed 网上找资料说在end loop后增加一行 SELECT ID INTO @Connid FROM information_schema.PROCESSLIST LIMIT 1; 即可 但试了还...
阅读全文
posted @
2013-01-21 17:41
思静
阅读(1692)
推荐(0) 编辑
本月,下一月, 上一月 的 1号, 最后一号
摘要:-- 上个月1号select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(day from now())-1 day),interval 1 month)-- 上个月最后一天select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval ext...
阅读全文
posted @
2013-01-17 11:16
思静
阅读(220)
推荐(0) 编辑
存储过程中的 prepare
摘要:set @ins := concat('replace into ',@tbl,'_archive select * from ',@tbl,' where ',@col,' < ',@plw);prepare instmnt from @ins;execute instmnt;
阅读全文
posted @
2013-01-16 10:14
思静
阅读(771)
推荐(0) 编辑
MySQL周分区 生成周分区辅助存储过程
摘要:按周分区的建表语句如下: CREATE TABLE `article` ( `Article_ID` int(11) NOT NULL AUTO_INCREMENT, ... ... `Extracted_Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, KEY `PRIMARYKeyID` (`Ar...
阅读全文
posted @
2013-01-10 15:30
思静
阅读(1974)
推荐(0) 编辑
Mysql 查看进程SQL
摘要:SELECT * FROM information_schema.PROCESSLISTWHERE info IS NOT NULLORDER BY TIME desc,state,INFO;SELECT CONCAT('kill ',id,';') AS KillSQL FROM information_schema.PROCESSLIST WHERE info LIKE '%from /...
阅读全文
posted @
2012-12-13 14:33
思静
阅读(2432)
推荐(0) 编辑
Mysql 设置变量的几种方式
摘要:1. SET @Template_Title_L=(SELECT Title FROM AA WHERE ID=1); 2. DECLARE Article_Title_L VARCHAR(1000); DECLARE Article_URL_L VARCHAR(1000); SELECT IFNULL(Article_Title,''),IFNULL(Article_...
阅读全文
posted @
2012-12-13 14:31
思静
阅读(1621)
推荐(0) 编辑
Mysql Alter table 操作
摘要:-- 增加字段alter table users add `AA` decimal(1,0) DEFAULT '0' COMMENT 'AAA' AFTER BB;-- 修改字段alter table users change old_column_name new_column_name decimal(1,0) NOT NULL DEFAULT '0';show create table msg_detail;-- 删除字段altertable`users`dropcolumnAA;-- 删除主键Alter TABLE 【表名字】 drop
阅读全文
posted @
2012-12-10 17:06
思静
阅读(489)
推荐(0) 编辑
Mysql 根据URL获取顶级域名
摘要:CREATE DEFINER=`root`@`%` FUNCTION `fn_get_topDomainName_from_url`(`Article_URL_In` varchar(1000)) RETURNS varchar(200) CHARSET utf8BEGIN /*********************************************************** 根据URL获取顶级域名 ************************************************************/ declare domain_name_...
阅读全文
posted @
2012-12-10 12:01
思静
阅读(2920)
推荐(1) 编辑
Truncate有外键约束的表
摘要:SET FOREIGN_KEY_CHECKS=0;TRUNCATE TABLE table_name;SET FOREIGN_KEY_CHECKS=1;
阅读全文
posted @
2012-12-07 10:23
思静
阅读(1932)
推荐(0) 编辑
MySQL Event 不会调度问题
摘要:今天发现客户那边新安装的数据库的MySQL Event 不会自动调度. 试了各种方法:SHOW VARIABLES LIKE 'event_scheduler';赋权限等, 都不行后来发现是最后执行时间(Last_Executed)超过了今天, 原因是刚安装好数据库时系统时间不正确, 早了一天, 后来修改正常了, 导致最后执行时间(Last_Executed)超过了今天
阅读全文
posted @
2012-12-04 18:50
思静
阅读(225)
推荐(0) 编辑
MySQL分区表操作
摘要:-- 查看分区表信息SHOW CREATE TABLE table1;SHOW TABLE STATUS LIKE 'table1';-- 查看各分区信息SELECT TABLE_NAME,PARTITION_NAME,PARTITION_EXPRESSION,PARTITION_DESCRIPTION,TABLE_ROWS,AVG_ROW_LENGTH/1024 as 'AVG_RO...
阅读全文
posted @
2012-11-28 17:52
思静
阅读(618)
推荐(0) 编辑