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
如果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
-- 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用法和性能导火索:在优化存储过程中发现一些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
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
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
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
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
Explain命令在解决数据库性能上是第一推荐使用命令,大部分的性能问题可以通过此命令来简单的解决,Explain可以用来查看SQL 语句的执行效 果,可以帮助选择更好的索引和优化查询语句,写出更好的优化语句。Explain语法:explain select … from … [where ...]...
分类:
数据库 时间:
2015-07-20 09:11:36
阅读次数:
123