易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 :

pl/sql 语句的几点优化

1.
     SQL> desc gjh_a05 ;
Name  Type          Nullable Default Comments
----- ------------- -------- ------- --------
A0500 VARCHAR2(2)   Y                        
A0501 VARCHAR2(6)                            
A0502 VARCHAR2(10)  Y                        
A0503 VARCHAR2(10)  Y                        
A0504 VARCHAR2(20)  Y          &nb ......

获取SQL Server所有数据库名,表名,字段名


/*
 * Source URL: http://jonsion.javaeye.com/blog/511584
 */
1. 获取所有数据库名
1> SELECT name from master..sysdatabases;
2> go
2. 获取所有表名
1> USE master
2> go
1> SELECT name from sysobjects WHERE type='U';
2> go
3. 获取所有字段名
1> SELECT name from syscolumns WHERE id=object_id('table_name');
......

对pl/sql 语句的优化(上集)

对这个进行优化
select n5001 门店,n5002 部门,n5004 小分类,n5019 商品编码,c01d21 商品名称,
nvl(xse,0)-nvl(dzxs,0) 销售,
mle 毛利,
nvl(xl,0)-nvl(dzsl,0) 销量
 from
(select n5001,n5002,n5004,n5019,sum(n5011) xse,sum(n5016) mle,sum(n5023) xl
from n50
where to_char(n5010,'yyyymmdd')>='20100401'
and to_char(n5010,'yyyymmdd')<='20100431'
group by n5001,n5002,n5004,n5019),
(select g08,g09,g02,sum(g03*g07) dzxs,sum(G03) dzsl from batchgoods
where to_char(g04,'yyyymmdd')>='20100401'
and to_char(g04,'yyyymmdd')<='20100431'
group by g08,g09,g02),c01d
where n5001=g08(+)
and n5019=g02(+)
and n5001=c01d00(+)
and n5019=c01d01(+)
执行计划
SELECT STATEMENT, GOAL = CHOOSE            Cost=10060    Cardinality=3931    Bytes=475651
 MERGE JOIN OUTER            Cost=10060    Cardinality=3931    Bytes=475651
  SO ......

基于SQL的分页

select top PageSize * from 表
where 条件 and id not in
(select top PageSize*(CurrentPageIndex-1)  id from 表 where 条件 order by 排序条件)
order by 排序条件
《PageSize 是GridView中每页显示的信息条数,PageSize*(CurrentPageIndex-1) 在SQL中不识别,需定义变量来替换》 ......

对pl/sql 语句的优化(下集)

上集中
//////////////////////////////////////////////////
select n5001 门店,n5002 部门,n5004 小分类,n5019 商品编码,c01d21 商品名称,
nvl(xse,0)-nvl(dzxs,0) 销售,
mle 毛利,
nvl(xl,0)-nvl(dzsl,0) 销量
 from
(select n5001,n5002,n5004,n5019,sum(n5011) xse,sum(n5016) mle,sum(n5023) xl
from n50
where n5010 between to_date('20100401','yyyymmdd') and to_date('20100430','yyyymmdd')
group by n5001,n5002,n5004,n5019),
(select g08,g09,g02,sum(g03*g07) dzxs,sum(G03) dzsl from batchgoods
where g04 between to_date('20100401','yyyymmdd') and to_date('20100430','yyyymmdd')
group by g08,g09,g02),c01d
where n5001=g08(+)
and n5019=g02(+)
and n5001=c01d00(+)
and n5019=c01d01(+)
SELECT STATEMENT, GOAL = CHOOSE            Cost=10163    Cardinality=30832    Bytes=3730672
 MERGE JOIN OUTER            Cost=10163    Cardinality=30832    ......

SQL分割逗号的函数和用法

      在程序中我们可能经常会遇到这种情况,比如要取一个listbox里面的选择项,得到的结果可能是string ID="id1,id2,id3,id4",然后我们要把这些ID插入到数据库中,同时每个id对应的是要插入一条记录。实现的方法有很多,但是如果我们通过下面这个函数(RecurrentSplit)就能简单的达到上述效果。RecurrentSplit的使用也非常简单。
例如:
select row_number()over(order by indexno desc) as seq ,* from recurrentsplit('1,2,3,4,5,',',',0,0)
这样我们就会分成5条记录,因为我的要求是一个listbox中item[i]其中最小的说明他的排序在最前头,同时排序是但SEQ的降序排列。所以在这个查询中我用row_number()over(order by indexno desc) as seq得出了他的顺序号
如下
seq indexno   SplitName
1        4          5
2        3          4
3        2          3
4  ......
总记录数:40319; 总页数:6720; 每页6 条; 首页 上一页 [1629] [1630] [1631] [1632] 1633 [1634] [1635] [1636] [1637] [1638]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号