
数据库
绝尘的绝
作品才是你的名片
展开
-
MySQL删除外键列
今天遇到一个要删除外键列的问题,我发现:show create table userfans;| userfans | CREATE TABLE `userfans` ( `id` int(11) NOT NULL AUTO_INCREMENT, `status` int(11) DEFAULT NULL, `update_time` datetime DEFAULT N...2011-09-16 09:38:54 · 415 阅读 · 0 评论 -
Oracle guide_Spring2.5_CN_reference_pdf
http://www.oracle.com/pls/db112/homepage原创 2011-11-28 15:49:14 · 98 阅读 · 0 评论 -
索引--mysql 数据库Load data大量数据时性能因素之一
发现load data infile 插入数据时越来越慢,后来发现是因为创建表时有创建索引的动作。把索引创建删除掉之后,导入很迅速,导入后再创建索引,效率果有提高。...2012-09-12 17:40:27 · 674 阅读 · 1 评论 -
UNION 和 UNION ALL的区别,一个例子就看明白
【UNION ALL】select a,b,sum(sm) AS s1, SUM(qm) AS s2 from ( select 'a' AS a, 'b' AS b, 2 AS sm, 200 AS qm UNION ALL select 'a' AS a, 'b' AS b, 2 AS sm, 200 AS qm)rgroup by a,b ab4400【...原创 2015-04-09 15:47:29 · 2589 阅读 · 0 评论 -
mysql char varchar
摘自:http://dev.mysql.com/doc/refman/5.6/en/char.htmlIn contrast to CHAR, VARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in ...原创 2015-08-28 20:38:17 · 122 阅读 · 0 评论 -
mysql使用规范
<1>.索引1.单表索引不超过5个;2.单个索引不超过5列;3.innodb主键推荐自增列; 主键不改被修改; 字符串不应该做主键; 若不指定主键,innodb会使用唯一且非空值索引代替;4.若是复合索引,区分度大的前置;5.核心sql优先考虑索引;6.区分度的的字段前置;7.避免冗余或重复索引:合理创建联合索引: index(a,b,c...原创 2015-10-19 21:11:38 · 104 阅读 · 0 评论 -
mysql查询上月天数/当月第一天/上月第一天
select (DATEDIFF(DATE_ADD(curdate(), INTERVAL - DAY(curdate())+ 1 DAY), date_add(curdate()- DAY(curdate())+ 1, INTERVAL -1 MONTH))) 上月总天数 , DATE_ADD(curdate(),interval -day(curdate())+1 day) 当月...2016-09-17 17:38:38 · 1860 阅读 · 0 评论 -
mysql上月最后一天,当月最后一天
select last_day(DATE_SUB(now(),INTERVAL 1 MONTH)) #上月最后一天日期 %Y-%m-%dselect last_day(curdate()) #当月最后一天日期 %Y-%m-%d2016-09-26 15:58:20 · 1648 阅读 · 0 评论 -
null列的值不参与比较
假如数据库有表emp:empno name age001 lucy 22002 lily null003 lilei null004 lucy null005 pear null006 pear null 当执行sql:SEL...2016-10-26 17:23:04 · 461 阅读 · 0 评论 -
mysql优化之2--索引优化
1. 创建联合索引时,要注意,离散度大的列前置。可以通过select count(distinct(A)),count(distinct(B)) from tb; 看哪个列离散度大。 2. 索引列检查工具-检查mysql索引中重复或冗余的索引列 pt-duplicate-key-checker: 可以检测出数据库中的冗余索引列,并给出删除建议;执行:退...原创 2017-03-09 22:45:56 · 142 阅读 · 0 评论