--创建.删除临时表 --第一种方式 create table #tmp(name varchar(255),id int) --第二种方式 select count(id) as storyNum , sum(convert(numeric(10,2),case when isnumeric(code)=1 then code else 0 end)) as codeNum, sum((case when isnumeric(realcode)=1 then convert(numeric(1…
浅谈MySQL中优化sql语句查询常用的30种方法 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描. 3.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如: select id from t where num is null 可以在num上设置默认值0,确保表中num列没有nul…
1.权限问题 alter routine 编辑或删除存储过程 create routine 建立存储过程 execute 创建存储过程 2.存储过程相关的一些命令 show procedure status\G 查看数据库中有哪些存储过程 show procedure status where db = 'db_name'\G 查看指定数据库(db_name)中有哪些存储过程 select name from mysql.proc where db = 'db_name'; 查看指定数据库(…