--SQL查询每个表的字段数量select b.[name], count(*) As AllCount,ISNULL(ISNULL(sum(case when isnullable=0 then 1 end),null),null) as NotNullCountfrom syscolumns aINNER JOIN( select [id], [name] from [sysobjects] where [type] = 'u' ) AS b ON a.id = b.[id] GROUP b…
奇怪的慢sql 我们先来看2条sql 第一条: select * from acct_trans_log WHERE acct_id = 1000000000009000757 order by create_time desc limit 0,10 第二条: select * from acct_trans_log WHERE acct_id = 1000000000009003061 order by create_time desc limit 0,10 表的索引及数据总…
--例如: id NAME VALUE 1 a pp 2 a pp 3 b iii 4 b pp 5 b pp 6 c pp 7 c pp 8 c iii --id是主键 --要求得到这样的结果 id NAME VALUE 1 a pp 3 b iii 4 b pp 6 c pp 8 c iii --方法1 DELETE YourTable WHERE [id] NOT IN (SELECT MAX([id]) FROM YourTable GROUP BY (NAME + VALUE)) --…
oracle认为 null 最大. 升序排列,默认情况下,null值排后面. 降序排序,默认情况下,null值排前面. 有几种办法改变这种情况: (1)用 nvl 函数或decode 函数 将null转换为一特定值 (2)用case语法将null转换为一特定值(oracle9i以后版本支持.和sqlserver类似): 1.当值为某个值的时候,指定排序的时候的位置 select * from ( select 1 t from dual union all select 2 t fro…