码迷,mamicode.com
首页 >  
搜索关键字:where    ( 20257个结果
SQL Server 海量数据查询代码优化以及建议
1.应尽量避免在  where  子句中对字段进行   null  值判断,否则将导致引擎放弃使用索引而进  行全表扫描,如:     select id from t where num is null     可以在num 上设置默认值0 ,确保表中num 列没有null 值,然后这样查询:     select id from t wh...
分类:数据库   时间:2015-07-20 19:34:15    阅读次数:161
[PL/SQL] 如何规避异常ORA-01403
如果mytable表中不存在ID = 123 的数据,那么SELECT Flag INTO flag FROM mytable WHERE ID = 123 将抛出异常ORA-01403SELECT nvl(max(Flag),'') INTO flag FROM mytable WHERE ID ...
分类:数据库   时间:2015-07-20 18:50:05    阅读次数:192
sql 查询前十条数据
-- oracle sql 查询前十条数据select * from b2c_code where rownum <= '10';-- sql server 查询前十条数据select top 10 * from b2c_code;
分类:数据库   时间:2015-07-20 18:39:53    阅读次数:222
1=1用法和性能
1=1用法和性能导火索:在优化存储过程中发现一些WHERE和JOINON语句带有1=1的条件。为什么要用WHERE1=1为了方便sql条件的拼接:实例:DECLARE@SQL1NVARCHAR(MAX),@SQL2NVARCHAR(MAX),@CLASSIDINT SET@CLASSID=2 SELECT@SQL1=‘SELECT*FROMW_QuestionWHERE1=1‘ IFISNULL(@CLASSID,..
分类:其他好文   时间:2015-07-20 17:00:51    阅读次数:117
LeetCode238:Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements ofnums except nums[i]. Solve it without division and in O(...
分类:其他好文   时间:2015-07-20 16:21:30    阅读次数:102
sql server 死锁情况处理
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='OBJECT'declare @spid.....
分类:数据库   时间:2015-07-20 16:13:13    阅读次数:155
mysql小技巧 用rand()写随机查询
if ($intelligent_count > 1) { //随机抽取推荐菜单 $intelligent = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_intelligent') . " WHERE name=:nam...
分类:数据库   时间:2015-07-20 12:24:49    阅读次数:146
存储过程编译时会卡死
Oracle存储过程编译卡死 解决方法如下: 1:查V$DB_OBJECT_CACHE SELECT * FROM V$DB_OBJECT_CACHE WHERE name='CRM_LASTCHGINFO_DAY' AND LOCKS!='0'; 注意:CRM_LASTCHGINFO_DA...
分类:其他好文   时间:2015-07-20 12:17:05    阅读次数:107
sql两表联合查询
SELECT yt_fault_componentId FROM yt_fault_component a join yt_fault_assembly b on a.yt_fault_assembly=b.yt_fault_assemblyId where a.yt_code='' and...
分类:数据库   时间:2015-07-20 09:16:05    阅读次数:151
转载-mysql查看语句执行效率
Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好的优化语句。Explain语法:explain select … from … [where ...]...
分类:数据库   时间:2015-07-20 09:11:36    阅读次数:123
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!