首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

修改特别慢,该怎么处理

2012-03-14 
修改特别慢updatesq_trqsetylsql10,nlsql10wherexh1010andrqto_date( 2007-01-01 , yyyy-MM-dd )这条

修改特别慢
update   sq_trq   set   ylsql=10,nlsql=10   where   xh=1010   and   rq=to_date( '2007-01-01 ', 'yyyy-MM-dd ')
这条语句,我在sql*plus里执行特别快,但是在C#程序里执行特别慢.
程序代码如下:
sql= "update   sq_trq   set   ylsql= "+ylsql+ ",nlsql= "+nlsql+ "   where   xh= "+mt0.Rows[0][0]+ "   and   rq=to_date( ' "+rq+ " ', 'yyyy-MM-dd ') ";
cmd=new   OracleCommand(sql,conn);
cmd.ExecuteNonQuery();

为什么?

[解决办法]
建议用绑定变量重写SQL语句
update sq_trq set ylsql=:x1,nlsql=:x2 where xh=:x3 and rq=:x4

[解决办法]
楼上说的对,使用绑定变量,再看看执行计划

update sq_trq set ylsql=:x1,nlsql=:x2 where xh=:x3 and rq=:x4

热点排行