- 浏览: 1365975 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (897)
- spring4 (14)
- hibernate3 (26)
- spring2 (35)
- struts2 (55)
- struts1 (15)
- 设计模式 (15)
- java (172)
- mybatis3 (11)
- sql (17)
- mysql (13)
- jbpm (10)
- J2EE (45)
- tools (29)
- js (83)
- 数据结构 (13)
- Html (26)
- web (22)
- flex (33)
- Oracle (57)
- linux (49)
- 算法 (6)
- 其它 (12)
- easyui (1)
- bootstrap (13)
- xml (2)
- tomcat (1)
- redis (10)
- activemq (2)
- webservice (11)
- maven (2)
- springboot (1)
- ubuntu (1)
- python (14)
- rocketmq (1)
- springcloud (11)
- opencv (10)
最新评论
-
mike_eclipse:
Hashtable是线程不安全的吗?好像是线程安全的吧?
多线程之集合类 -
July01:
推荐用StratoIO打印控件,浏览器和系统的兼容性都很好,而 ...
lodop打印控件 -
xingcxb:
经过测试,假的,依旧会出现中文乱码!!!!store方法里面采 ...
java 读写Properties文件,不会出现中文乱码 -
tiger20111989:
...
Spring注解方式管理事务 -
zw7534313:
...
js 文字上下滚动 无间断循环显示
mysql 中sql优化:
show procedure procedure_name;
show procedure status like 'procedure_name'; //显示所有存储过程
1.用自连接而不是用子查询 自联接通常作为外部语名用来替代从相同表中检索数据时使用的子查询语名。虽然最终的结果是相同的,但有时候处理联结比处理子查询快得多。应该试一下两种方法,以确定哪一种的性能更好。
select c.* ,o.order_num,o.order_date from customers as c,orders as o,orderitems as oi and oi.order_num=o.order_num and prod_id='FB';
每一个内部联结都是自然联结。
2.分组 select *,count(*) from T_Category group by Pid 会报错?
只能是这样的:select Pid, count(*) from T_Category group by Pid
使用带聚集函数的联结 (如下图)
select customers.cust_name,
customers.cust_id,
count(orders.order_num) as num_ord
from customers inner join orders on
customers.cust_id=orders.cust_id group by customers.cust_id;
3.mysql 分页: select * from T_Category limit 20,30
20表示第20行开始,查询结果为30行
SELECT @@IDENTITY
create procedure testproc(
out plow decimal(8,2) ,
out phigh decimal(8,2),
out pavg decimal(8,2))
begin
select min(prod_price) into plow from products;
select max(prod_price) into phigh from products;
select avg(prod_price) into pavg from products;
end //
delimiter ;
in onumber int,
in taxable boolean,
out ototal decimal(8,2))
comment 'Obtain order total,optionally adding tax'
begin
declare total decimal(8,2);
declare taxrate int default 6; //在mysql存储过程中定义变量
select sum(item_price*quantity) from orderitems where
order_id=onumber into total;
select total+(total/100*taxrate) into total;
end if;
select total into ototal; //给变量赋值
end //
begin
declare done boolean default 0;
declare o int;
declare mycusor cursor for
select quantity from orderitems;
declare continue handler for sqlstate '02000' set done=1; //当没有数据时,sqlstate=02000
open mycusor;
repeat
fetch mycusor into o;
select o;
until done end repeat; //done=1结束循环
close mycusor;
end //
begin
declare done boolean default 0;
declare o int;
declare t decimal(8,2);
declare mycursor cursor for
select ord_id from orders;
declare continue handler for sqlstate '02000' set done=1;
create table if not exists temp(order_id int,total decimal(8,2)); //创建 一个表
open mycursor;
repeat
fetch mycursor into o;
call ordertotal(o,1,t);
insert into temp(order_id,total) values(o,t);
until done end repeat;
close mycursor;
end //
发表评论
-
sybase 常用函数
2012-03-05 21:27 3001a.substring b.LEN 查找:串内搜索 ch ... -
db2 select中使用case替代行转列操作 .
2011-08-25 11:04 1680在DB2中进行行转列比较麻烦,这里我在select里用cas ... -
db2
2011-07-20 15:43 12671.建序列 CREATE SEQUENCE & ... -
jdbc 批量添加 batch
2010-11-26 20:34 2400/* *应用在需要一次插入多行,表示两个对象的关联 */ ... -
解决MySQL里的ERROR 1366 Incorrect string value
2010-09-09 09:00 39711.这个就是编码的问题,可能在装MySql 的时候选择的是默认 ... -
sqlserver 类型
2010-04-16 13:53 1107数据类型 类型 描 ... -
动态sql 实现
2010-04-16 11:07 1043介绍一种动态装载配置的做法。对于那种很多的查询条件的情况下尤其 ... -
sql统计查询
2010-01-06 10:13 941物品编号 批次 数量 100 1 10 100 2 20 ... -
交叉表 sql
2009-10-13 14:04 11971.静态交叉表(mysql) SELECT ... -
jdbc sql
2009-09-18 11:43 12081.java.sql.SQLException: Result ... -
日期 database
2009-09-18 10:14 10721.access 数据库: (1)可以在日期/时间 ... -
access
2009-08-13 15:20 12871.分页: SELECT ... -
access
2009-07-16 08:26 1663下载:http://www.downxia.com/downi ... -
p6spy
2009-07-10 15:50 1516下载www.pyspy.com中p6spy-install.z ... -
jpa
2009-07-08 13:01 3444http://doc.javanb.com/spring-fr ... -
连接池
2009-06-25 17:03 1539java.lang.NoClassDefFoundError: ...
相关推荐
SQL优化是数据库管理中的关键环节,它涉及到提升查询性能、减少资源消耗以及改善系统整体效率。SQL优化软件和工具能够帮助数据库管理员(DBA)和开发人员找出性能瓶颈,优化查询逻辑,从而提高数据库系统的响应速度...
在“基于案例学习SQL优化”的课程中,我们主要探讨如何提升数据库性能,特别是针对SQL查询的优化技巧。DBA(数据库管理员)作为关键角色,需要掌握这些技能来确保系统的高效运行。以下是根据课程标题和描述提炼出的...
- **全书总结**:本书不仅是一本关于SQL优化的技术书籍,更是引导读者进入SQL优化世界的指南。通过丰富的案例、实战经验和深入的技术探讨,帮助读者建立起从宏观到微观的优化思路,并最终达到“爽”的境界。 - **...
第2章 风驰电掣——有效缩短SQL优化过程 24 2.1 SQL调优时间都去哪儿了 25 2.1.1 不善于批处理频频忙交互 25 2.1.2 无法抓住主要矛盾瞎折腾 25 2.1.3 未能明确需求目标白费劲 26 2.1.4 没有分析操作难度乱调优...
### MySQL数据库SQL优化 #### 一、SQL优化 在MySQL数据库管理中,SQL查询的性能直接影响到系统的响应时间和资源消耗。通过合理的SQL优化,可以显著提高数据处理速度,降低服务器负载,提升用户体验。 ##### 1.1 ...