<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Foxwx微信公众号管理软件---同心软件</title><link>http://www.foxwx.cn/</link><description>-以高级编程语言进行微信公众号管理，我们一直在努力!</description><generator>RainbowSoft Studio Z-Blog 2.2 Prism Build 140101</generator><language>zh-CN</language><pubDate>Sun, 23 Apr 2023 10:58:29 +0800</pubDate><item><title>微信小程序开发截图</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/68.html</link><pubDate>Sat, 15 Feb 2020 17:33:46 +0800</pubDate><guid>http://www.foxwx.cn/post/68.html</guid><description><![CDATA[<p>微信小程序开发截图</p><p><img src="http://www.foxwx.cn/zb_users/upload/2020/2/2020021563393441.png" title="小程序之工单提交演示截图.png" alt="小程序之工单提交演示截图.png" width="650" height="420"/></p><p><img src="http://www.foxwx.cn/zb_users/upload/2020/2/2020021563418537.png" title="QQ截图20200215170008.png" alt="QQ截图20200215170008.png" width="650" height="420"/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/68.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=68</wfw:commentRss></item><item><title>FOXWX客户端微信扫码登录演示</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/67.html</link><pubDate>Fri, 07 Feb 2020 09:06:06 +0800</pubDate><guid>http://www.foxwx.cn/post/67.html</guid><description><![CDATA[<p>
    FOXWX客户端微信扫码登录演示&nbsp; &nbsp;GIF有点大22M打开肯定慢要等等
</p>
<p>
    &nbsp; &nbsp;<img src="http://www.foxwx.cn/mp3/aaaa.gif" width="234" height="480" title="1" border="1" hspace="1" vspace="1"/>
</p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/67.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=67</wfw:commentRss></item><item><title>easyui 人员管理 界面</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/66.html</link><pubDate>Thu, 12 Dec 2019 14:57:28 +0800</pubDate><guid>http://www.foxwx.cn/post/66.html</guid><description><![CDATA[<p>EASYUI&nbsp;表格增改删&nbsp;&nbsp;查找&nbsp;&nbsp;筛选&nbsp;套打&nbsp;字段验证&nbsp;。 登录 等全部演示</p><p>后台使用FOXWX微信公众号管理软件的组件库</p><p>即纯VFP后台。。或使用SQL 后台</p><p>使用HTML + AJAX +FOXWX</p><p>模板与后台分离</p><p>高速高效</p><p><img src="http://www.foxwx.cn/zb_users/upload/2019/12/2019121254251929.gif" title="easyui增改删套打筛选等演示.gif"/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/66.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=66</wfw:commentRss></item><item><title>运行库VFP9R及VFP9RCHS改名</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/65.html</link><pubDate>Thu, 18 Jul 2019 11:07:17 +0800</pubDate><guid>http://www.foxwx.cn/post/65.html</guid><description><![CDATA[<p>*!* 将运行库VFP9R及VFP9RCHS改名:</p><p><br/></p><p>*!* 假如:</p><p>*!* VFP9R.DLL &nbsp; &nbsp;=&amp;gt; &nbsp; &nbsp;AAAAA.DLL</p><p>*!* VFP9RCHS.DLL =&amp;gt; BBBBBCHS.DLL</p><p>*!* 1:打开VFP9RCHS.DLL,将里面的VFP9R%s改成BBBBB%s；将VFP9RCHS.DLL改名为BBBBBCHS.DLL；</p><p>*!* 2:打开VFP9R.DLL,将里面的VFP9R.DLL改成AAAAA.DLL；将VFP9R.DLL改名为AAAAA.DLL；</p><p>*!* 3.打开该exe程序,将里面的VFP9R.DLL改成AAAAA.DLL</p><p>*!* 4.开启修改后的EXE运行,完!</p><p><br/></p><p>*!* 最好不要变动字符长度,如果改变了字符的长度,请相应处理修改后的文件</p><p>*!* 把CHS也改掉的话,需要将VFP9R.DLL中的VFP9R%s和VFP9R???同时替换</p><p>*!* 同样的可以应对VFP9T.DLL</p><p><br/></p><p>*!* 同样的方法可以修改掉里面的错误信息.如:</p><p>*!* ---------------------------</p><p>*!* Microsoft Visual FoxPro</p><p>*!* ---------------------------</p><p>*!* Visual FoxPro cannot start. Could not load resources.</p><p>*!* ---------------------------</p><p>*!* 确定 &nbsp;&nbsp;</p><p>*!* ---------------------------</p><p><br/></p><p>SET DEFAULT TO JUSTPATH(SYS(16,0))</p><p>SET SAFETY OFF&nbsp;</p><p>SET NOTIFY OFF&nbsp;</p><p><br/></p><p>CLEAR&nbsp;</p><p><br/></p><p>*!* PRG目录下请存放EXE文件/VFP9R.DLl/VP9RCHS.DLL</p><p><br/></p><p>IF !DIRECTORY([BIN])</p><p>&nbsp;MD BIN</p><p>ENDIF&nbsp;</p><p>lcFile = [x5Kit.EXE]</p><p><br/></p><p>****************************************</p><p>*!* EXE:&nbsp;</p><p>IF FILE()</p><p>COPY FILE (lcFile) TO ([BIN\] + lcFile)</p><p>DispelFile([BIN\] + lcFile)</p><p><br/></p><p>*!* VFP9R.DLL</p><p>IF FILE([VFP9R.DLL])</p><p>&nbsp;COPY FILE ([VFP9R.DLL]) TO ([BIN\Iamx5.DLL])</p><p>&nbsp;DispelFile([BIN\Iamx5.DLL],.T.)&nbsp;</p><p>ENDIF&nbsp;</p><p><br/></p><p>*!* VFP9RCHS.DLL</p><p>IF FILE([VFP9RCHS.DLL])</p><p>&nbsp;COPY FILE ([VFP9RCHS.DLL]) TO ([BIN\Iamx5Lib.DLL])</p><p>&nbsp;DispelFile([BIN\Iamx5Lib.DLL],.T.)</p><p>ENDIF&nbsp;</p><p><br/></p><p>? [Done~~~~]</p><p><br/></p><p>*!* COPY FILE (lcSaveName) TO ([\\192.168.0.109\hare$\Test] + lcSaveName)</p><p><br/></p><p><br/></p><p>****************************************</p><p>FUNCTION DispelFile</p><p>&nbsp;LPARAMETERS lcFile,llEraseMS</p><p>&nbsp;*!* VFP9R</p><p>&nbsp;lcStr &nbsp; &nbsp;= Chr0string([VFP9R]) &amp;&amp; Get 2</p><p>&nbsp;lcNewStr = Chr0string([Iamx5])</p><p>&nbsp;UpdateFile(lcFile,lcStr,lcNewStr)</p><p>&nbsp;lcStr &nbsp; &nbsp;= [VFP9R] &amp;&amp; Get 2</p><p>&nbsp;lcNewStr = [Iamx5]</p><p>&nbsp;UpdateFile(lcFile,lcStr,lcNewStr)</p><p>&nbsp;IF llEraseMS = .T.</p><p>&nbsp; *!* MicroSoft</p><p>&nbsp; lcStr &nbsp; &nbsp;= Chr0string([MicroSoft]) &amp;&amp; Get 2</p><p>&nbsp; lcNewStr = Chr0string([Iamx5Soft])</p><p>&nbsp; UpdateFile(lcFile,lcStr,lcNewStr)</p><p>&nbsp; lcStr &nbsp; &nbsp;= [MicroSoft] &amp;&amp; Get 2</p><p>&nbsp; lcNewStr = [Iamx5Soft]</p><p>&nbsp; UpdateFile(lcFile,lcStr,lcNewStr)</p><p>&nbsp;ENDIF&nbsp;</p><p>&nbsp;*!* Visual FoxPro</p><p>&nbsp;lcStr &nbsp; &nbsp;= Chr0string([Visual FOXPRO]) &amp;&amp; 6 Times</p><p>&nbsp;lcNewStr = Chr0string([Dispel x5Libs],LEN(lcStr))</p><p>&nbsp;UpdateFile(lcFile,lcStr,lcNewStr)</p><p>&nbsp;lcStr &nbsp; &nbsp;= [Visual FOXPRO] &amp;&amp; Get 6</p><p>&nbsp;lcNewStr = [Dispel x5Libs]</p><p>&nbsp;UpdateFile(lcFile,lcStr,lcNewStr)</p><p>&nbsp;*!* FoxPro</p><p>&nbsp;lcStr &nbsp; &nbsp;= Chr0string([FOXPRO]) &amp;&amp; 6 Times</p><p>&nbsp;lcNewStr = Chr0string([x5Libs],LEN(lcStr))</p><p>&nbsp;UpdateFile(lcFile,lcStr,lcNewStr)</p><p>&nbsp;lcStr &nbsp; &nbsp;= [FOXPRO] &amp;&amp; Get 6</p><p>&nbsp;lcNewStr = [x5Libs]</p><p>&nbsp;UpdateFile(lcFile,lcStr,lcNewStr)</p><p>ENDFUNC&nbsp;</p><p><br/></p><p>****************************************</p><p>FUNCTION UpdateFile</p><p>&nbsp;LPARAMETERS lcFile,lcStr,lcNewStr</p><p>&nbsp;? [Searched &nbsp; : ] + lcFile</p><p>&nbsp;lnHandle = FOPEN(lcFile,2)</p><p>&nbsp;IF lnHandle &amp;lt; 0</p><p>&nbsp; ? [Open Error]</p><p>&nbsp; RETURN&nbsp;</p><p>&nbsp;ENDIF&nbsp;</p><p>&nbsp;ON ERROR FCLOSE(lnHandle)</p><p>&nbsp;lnSeekSize = LEN(lcStr)</p><p>&nbsp;SET COMPATIBLE ON&nbsp;</p><p>&nbsp;lnFileSize = FSIZE(lcFile)</p><p>&nbsp;FOR i=1 TO lnFileSize</p><p>&nbsp; FSEEK(lnHandle,i,0)</p><p>&nbsp; lcGets = FREAD(lnHandle,lnSeekSize)</p><p>&nbsp; IF UPPER(LEFT(lcGets,lnSeekSize)) == UPPER(lcStr)</p><p>&nbsp; &nbsp;? [ ] + TRANSFORM(i,[@0]) + [: ]</p><p>&nbsp; &nbsp;FSeek(lnHandle,-lnSeekSize,1)</p><p>&nbsp; &nbsp;?? IIF(FWRITE(lnHandle,lcNewStr)&amp;gt;0,[Success],[Failure])</p><p>&nbsp; &nbsp;FFLUSH(lnHandle,.T.)</p><p>&nbsp; ENDIF&nbsp;</p><p>&nbsp;ENDFOR&nbsp;</p><p>&nbsp;?[------------------]</p><p>&nbsp;?</p><p>&nbsp;FCLOSE(lnHandle)</p><p>ENDFUNC&nbsp;</p><p><br/></p><p>****************************************</p><p>FUNCTION Chr0string</p><p>&nbsp;LPARAMETERS lcString,lnReturnLen</p><p>&nbsp;IF VARTYPE(lnReturnLen) # [N]</p><p>&nbsp; lnReturnLen = 0</p><p>&nbsp;ENDIF&nbsp;</p><p>&nbsp;LOCAL lcNewString ,lnlen,i</p><p>&nbsp;lnLen = LEN(lcString)</p><p>&nbsp;lcNewString = []</p><p>&nbsp;FOR i = 1 TO lnLen</p><p>&nbsp; lcNewString = lcNewString + SUBSTR(lcString,i,1) + CHR(0)</p><p>&nbsp;ENDFOR&nbsp;</p><p>&nbsp;IF lnReturnLen &amp;gt; 0</p><p>&nbsp; lcNewString = PADR(lcNewString,lnReturnLen,CHR(0))</p><p>&nbsp;ENDIF&nbsp;</p><p>&nbsp;RETURN lcNewString</p><p>ENDFUNC&nbsp;</p><p><br/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/65.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=65</wfw:commentRss></item><item><title>SendMessage 参数</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/64.html</link><pubDate>Thu, 18 Jul 2019 11:06:29 +0800</pubDate><guid>http://www.foxwx.cn/post/64.html</guid><description><![CDATA[<p>Windows是一个消息驱动式系 统，SendMessage是应用程序和应用程序之间进行消息传递的主要手段之一，这里我搜集整理了SendMessage函数的详细参数介绍，以备自用。</p><p>VFP声明:</p><p>DECLARE INTEGER SendMessage IN user32;</p><p>&nbsp; &nbsp; INTEGER hWnd,;</p><p>&nbsp; &nbsp; INTEGER wMsg,;</p><p>&nbsp; &nbsp; INTEGER wParam,;</p><p>&nbsp; &nbsp; INTEGER lParam</p><p>参数1：hWnd-窗口句柄。窗口可以是任何类型的屏幕对象。</p><p>参数2：wMsg-用于区别其他消息的常量值.</p><p>参数3：wParam-通常是一个与消息有关的常量值，也可能是窗口或控件的句柄.</p><p>参数4: lParam-通常是一个指向内存中数据的指针。</p><p><br/></p><p>wMsg参数常量值：#DeFine WM_CREATE 0x01 &nbsp;创建一个窗口#DeFine WM_DESTROY 0x02当一个窗口被破坏时发送#DeFine WM_MOVE 0x03移动一个窗口#DeFine WM_SIZE 0x05改变一个窗口的大小#DeFine WM_ACTIVATE 0x06一个窗口被激活或失去激活状态#DeFine WM_SETFOCUS 0x07一个窗口获得焦点#DeFine WM_KILLFOCUS 0x08一个窗口失去焦点#DeFine WM_ENABLE 0x0A一个窗口改变成Enable状态#DeFine WM_SETREDRAW 0x0B设置窗口是否能重画#DeFine WM_SETTEXT 0x0C应用程序发送此消息来设置一个窗口的文本#DeFine WM_GETTEXT 0x0D应用程序发送此消息来复制对应窗口的文本到缓冲区#DeFine WM_GETTEXTLENGTH 0x0E得到与一个窗口有关的文本的长度（不包含空字符）#DeFine WM_PAINT 0x0F要求一个窗口重画自己#DeFine WM_CLOSE 0x10当一个窗口或应用程序要关闭时发送一个信号#DeFine WM_QUERYENDSESSION 0x11当用户选择结束对话框或程序自己调用ExitWindows函数#DeFine WM_QUIT 0x12用来结束程序运行#DeFine WM_QUERYOPEN 0x13当用户窗口恢复以前的大小位置时，把此消息发送给某个图标#DeFine WM_ERASEBKGND 0x14当窗口背景必须被擦除时（例在窗口改变大小时）#DeFine WM_SYSCOLORCHANGE 0x15当系统颜色改变时，发送此消息给所有顶级窗口#DeFine WM_ENDSESSION 0x16当系统进程发出WM_QUERYENDSESSION消息后，此消息发送给应用程序，通知它对话是否结束#DeFine WM_SHOWWINDOW 0x18当隐藏或显示窗口是发送此消息给这个窗口#DeFine WM_ACTIVATEAPP 0x1C发此消息给应用程序哪个窗口是激活的，哪个是非激活的#DeFine WM_FONTCHANGE 0x1D当系统的字体资源库变化时发送此消息给所有顶级窗口#DeFine WM_TIMECHANGE 0x1E当系统的时间变化时发送此消息给所有顶级窗口#DeFine WM_CANCELMODE 0x1F发送此消息来取消某种正在进行的摸态（操作）#DeFine WM_SETCURSOR 0x20如果鼠标引起光标在某个窗口中移动且鼠标输入没有被捕获时，就发消息给某个窗口#DeFine WM_MOUSEACTIVATE 0x21当光标在某个非激活的窗口中而用户正按着鼠标的某个键发送此消息给当前窗口#DeFine WM_CHILDACTIVATE 0x22发送此消息给MDI子窗口当用户点击此窗口的标题栏，或当窗口被激活，移动，改变大小#DeFine WM_QUEUESYNC 0x23此消息由基于计算机的训练程序发送，通过WH_JOURNALPALYBACK的hook程序分离出用户输入消息#DeFine WM_GETMINMAXINFO 0x24此消息发送给窗口当它将要改变大小或位置#DeFine WM_PAINTICON 0x26发送给最小化窗口当它图标将要被重画#DeFine WM_ICONERASEBKGND 0x27此消息发送给某个最小化窗口，仅当它在画图标前它的背景必须被重画#DeFine WM_NEXTDLGCTL 0x28发送此消息给一个对话框程序去更改焦点位置#DeFine WM_SPOOLERSTATUS 0x2A每当打印管理列队增加或减少一条作业时发出此消息 #DeFine WM_DRAWITEM 0x2B当button，combobox，listbox，menu的可视外观改变时发送#DeFine WM_MEASUREITEM 0x2C当button, combo box, list box, list view control, or menu item 被创建时#DeFine WM_VKEYTOITEM 0x2E此消息有一个LBS_WANTKEYBOARDINPUT风格的发出给它的所有者来响应WM_KEYDOWN消息 #DeFine WM_CHARTOITEM 0x2F此消息由一个LBS_WANTKEYBOARDINPUT风格的列表框发送给他的所有者来响应WM_CHAR消息 #DeFine WM_SETFONT 0x30当绘制文本时程序发送此消息得到控件要用的颜色#DeFine WM_GETFONT 0x31应用程序发送此消息得到当前控件绘制文本的字体#DeFine WM_SETHOTKEY 0x32应用程序发送此消息让一个窗口与一个热键相关连 #DeFine WM_GETHOTKEY 0x33应用程序发送此消息来判断热键与某个窗口是否有关联#DeFine WM_QUERYDRAGICON 0x37此消息发送给最小化窗口，当此窗口将要被拖放而它的类中没有定义图标，应用程序能返回一个图标或光标的句柄，当用户拖放图标时系统显示这个图标或光标#DeFine WM_COMPAREITEM 0x39发送此消息来判定combobox或listbox新增加的项的相对位置#DeFine WM_COMPACTING 0x41显示内存已经很少了#DeFine WM_WINDOWPOSCHANGING 0x46发送此消息给那个窗口的大小和位置将要被改变时，来调用setwindowpos函数或其它窗口管理函数#DeFine WM_WINDOWPOSCHANGED 0x47发送此消息给那个窗口的大小和位置已经被改变时，来调用setwindowpos函数或其它窗口管理函数#DeFine WM_POWER 0x48当系统将要进入暂停状态时发送此消息#DeFine WM_COPYDATA 0x4A当一个应用程序传递数据给另一个应用程序时发送此消息#DeFine WM_CANCELJOURNA 0x4B当某个用户取消程序日志激活状态，提交此消息给程序#DeFine WM_NOTIFY 0x4E当某个控件的某个事件已经发生或这个控件需要得到一些信息时，发送此消息给它的父窗口 #DeFine WM_INPUTLANGCHANGEREQUEST 0x50当用户选择某种输入语言，或输入语言的热键改变#DeFine WM_INPUTLANGCHANGE 0x51当平台现场已经被改变后发送此消息给受影响的最顶级窗口#DeFine WM_TCARD 0x52当程序已经初始化windows帮助例程时发送此消息给应用程序#DeFine WM_HELP 0x53此消息显示用户按下了F1，如果某个菜单是激活的，就发送此消息个此窗口关联的菜单，否则就发送给有焦点的窗口，如果当前都没有焦点，就把此消息发送给当前激活的窗口#DeFine WM_USERCHANGED 0x54当用户已经登入或退出后发送此消息给所有的窗口，当用户登入或退出时系统更新用户的具体设置信息，在用户更新设置时系统马上发送此消息#DeFine WM_NOTIFYFORMAT 0x55公用控件，自定义控件和他们的父窗口通过此消息来判断控件是使用ANSI还是UNICODE结构#DeFine WM_CONTEXTMENU ??当用户某个窗口中点击了一下右键就发送此消息给这个窗口#DeFine WM_STYLECHANGING 0x7C当调用SETWINDOWLONG函数将要改变一个或多个 窗口的风格时发送此消息给那个窗口#DeFine WM_STYLECHANGED 0x7D当调用SETWINDOWLONG函数一个或多个 窗口的风格后发送此消息给那个窗口#DeFine WM_DISPLAYCHANGE 0x7E当显示器的分辨率改变后发送此消息给所有的窗口#DeFine WM_GETICON 0x7F此消息发送给某个窗口来返回与某个窗口有关连的大图标或小图标的句柄#DeFine WM_SETICON 0x80程序发送此消息让一个新的大图标或小图标与某个窗口关联#DeFine WM_NCCREATE 0x81当某个窗口第一次被创建时，此消息在WM_CREATE消息发送前发送#DeFine WM_NCDESTROY 0x82此消息通知某个窗口，非客户区正在销毁 #DeFine WM_NCCALCSIZE 0x83当某个窗口的客户区域必须被核算时发送此消息#DeFine WM_NCHITTEST 0x84移动鼠标，按住或释放鼠标时发生#DeFine WM_NCPAINT 0x85程序发送此消息给某个窗口当它（窗口）的框架必须被绘制时#DeFine WM_NCACTIVATE 0x86此消息发送给某个窗口仅当它的非客户区需要被改变来显示是激活还是非激活状态#DeFine WM_GETDLGCODE 0x87发送此消息给某个与对话框程序关联的控件，widdows控制方位键和TAB键使输入进入此控件通过应#DeFine WM_NCMOUSEMOVE 0xA0当光标在一个窗口的非客户区内移动时发送此消息给这个窗口 非客户区为：窗体的标题栏及窗 的边框体#DeFine WM_NCLBUTTONDOWN 0xA1当光标在一个窗口的非客户区同时按下鼠标左键时提交此消息#DeFine WM_NCLBUTTONUP 0xA2当用户释放鼠标左键同时光标某个窗口在非客户区十发送此消息 #DeFine WM_NCLBUTTONDBLCLK 0xA3当用户双击鼠标左键同时光标某个窗口在非客户区十发送此消息#DeFine WM_NCRBUTTONDOWN 0xA4当用户按下鼠标右键同时光标又在窗口的非客户区时发送此消息#DeFine WM_NCRBUTTONUP 0xA5当用户释放鼠标右键同时光标又在窗口的非客户区时发送此消息#DeFine WM_NCRBUTTONDBLCLK 0xA6当用户双击鼠标右键同时光标某个窗口在非客户区十发送此消息#DeFine WM_NCMBUTTONDOWN 0xA7当用户按下鼠标中键同时光标又在窗口的非客户区时发送此消息#DeFine WM_NCMBUTTONUP 0xA8当用户释放鼠标中键同时光标又在窗口的非客户区时发送此消息#DeFine WM_NCMBUTTONDBLCLK 0xA9当用户双击鼠标中键同时光标又在窗口的非客户区时发送此消息</p><p>#DeFine WM_KEYFIRST 0x100WM_KEYDOWN 按下一个键#DeFine WM_KEYUP 0x101释放一个键#DeFine WM_CHAR 0x102按下某键，并已发出WM_KEYDOWN， WM_KEYUP消息#DeFine WM_DEADCHAR 0x103当用translatemessage函数翻译WM_KEYUP消息时发送此消息给拥有焦点的窗口#DeFine WM_SYSKEYDOWN 0x104当用户按住ALT键同时按下其它键时提交此消息给拥有焦点的窗口 #DeFine WM_SYSKEYUP 0x105当用户释放一个键同时ALT 键还按着时提交此消息给拥有焦点的窗口#DeFine WM_SYSCHAR 0x106当WM_SYSKEYDOWN消息被TRANSLATEMESSAGE函数翻译后提交此消息给拥有焦点的窗口#DeFine WM_SYSDEADCHAR 0x107当WM_SYSKEYDOWN消息被TRANSLATEMESSAGE函数翻译后发送此消息给拥有焦点的窗口#DeFine WM_INITDIALOG 0x110在一个对话框程序被显示前发送此消息给它，通常用此消息初始化控件和执行其它任务#DeFine WM_COMMAND 0x111当用户选择一条菜单命令项或当某个控件发送一条消息给它的父窗口，一个快捷键被翻译 #DeFine WM_SYSCOMMAND 0x112当用户选择窗口菜单的一条命令或当用户选择最大化或最小化时那个窗口会收到此消息#DeFine WM_TIMER 0x113 发生了定时器事件#DeFine WM_HSCROLL 0x114 当一个窗口标准水平滚动条产生一个滚动事件时发送此消息给那个窗口，也发送给拥有它的控件#DeFine WM_VSCROLL 0x115 当一个窗口标准垂直滚动条产生一个滚动事件时发送此消息给那个窗口也，发送给拥有它的控件 #DeFine WM_INITMENU 0x116当一个菜单将要被激活时发送此消息，它发生在用户菜单条中的某项或按下某个菜单键，它允许程序在显示前更改菜单#DeFine WM_INITMENUPOPUP 0x117当一个下拉菜单或子菜单将要被激活时发送此消息，它允许程序在它显示前更改菜单，而不要改变全部 #DeFine WM_MENUSELECT 0x11F当用户选择一条菜单项时发送此消息给菜单的所有者（一般是窗口）#DeFine WM_MENUCHAR 0x120当菜单已被激活用户按下了某个键（不同于加速键），发送此消息给菜单的所有者 #DeFine WM_ENTERIDLE 0x121当一个模态对话框或菜单进入空载状态时发送此消息给它的所有者，一个模态对话框或菜单进入空载状态就是在处理完一条或几条先前的消息后没有消息它的列队中等待#DeFine WM_CTLCOLORMSGBOX 0x132在windows绘制消息框前发送此消息给消息框的所有者窗口，通过响应这条消息，所有者窗口可以通过使用给定的相关显示设备的句柄来设置消息框的文本和背景颜色#DeFine WM_CTLCOLOREDIT 0x133当一个编辑型控件将要被绘制时发送此消息给它的父窗口 通过响应这条消息，所有者窗口可以通过使用给定的相关显示设备的句柄来设置编辑框的文本和背景颜色#DeFine WM_CTLCOLORLISTBOX 0x134当一个列表框控件将要被绘制前发送此消息给它的父窗口 通过响应这条消息，所有者窗口可以通过使用给定的相关显示设备的句柄来设置列表框的文本和背景颜色 #DeFine WM_CTLCOLORBTN 0x135当一个按钮控件将要被绘制时发送此消息给它的父窗口 通过响应这条消息，所有者窗口可以通过使用给定的相关显示设备的句柄来设置按纽的文本和背景颜色#DeFine WM_CTLCOLORDLG 0x136当一个对话框控件将要被绘制前发送此消息给它的父窗口 通过响应这条消息，所有者窗口可以通过使用给定的相关显示设备的句柄来设置对话框的文本背景颜色#DeFine WM_CTLCOLORSCROLLBAR 0x137当一个滚动条控件将要被绘制时发送此消息给它的父窗口 通过响应这条消息，所有者窗口可以通过使用给定的相关显示设备的句柄来设置滚动条的背景颜色#DeFine WM_CTLCOLORSTATIC 0x138当一个静态控件将要被绘制时发送此消息给它的父窗口 通过响应这条消息，所有者窗口可以 通过使用给定的相关显示设备的句柄来设置静态控件的文本和背景颜色#DeFine WM_MOUSEFIRST 0x200移动鼠标时发生#DeFine WM_MOUSEMOVE 0x200移动鼠标时发生，同WM_MOUSEFIRST#DeFine WM_LBUTTONDOWN 0x201按下鼠标左键#DeFine WM_LBUTTONUP 0x202释放鼠标左键#DeFine WM_LBUTTONDBLCLK 0x203双击鼠标左键#DeFine WM_RBUTTONDOWN 0x204按下鼠标右键#DeFine WM_RBUTTONUP 0x205释放鼠标右键#DeFine WM_RBUTTONDBLCLK 0x206双击鼠标右键#DeFine WM_MBUTTONDOWN 0x207按下鼠标中键 #DeFine WM_MBUTTONUP 0x208释放鼠标中键#DeFine WM_MBUTTONDBLCLK 0x209双击鼠标中键#DeFine WM_MOUSEWHEEL 0x20A当鼠标轮子转动时发送此消息个当前有焦点的控件</p><p><br/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/64.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=64</wfw:commentRss></item><item><title>使用GDI对图片文件进行缩放</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/63.html</link><pubDate>Thu, 18 Jul 2019 11:04:54 +0800</pubDate><guid>http://www.foxwx.cn/post/63.html</guid><description><![CDATA[<p>FUNCTION resizeimage(pSourceFileNAme as String,pNewFileNAme as String,nHeight as long)</p><p><br/></p><p>*******************************************</p><p>算法制作:行者孙(QQ:310727570)</p><p>*******************************************</p><p>VFP应用程式算法群:12787940</p><p>*******************************************</p><p>****pSourceFileNAme 原始图片文件名</p><p>****pNewFileNAme &nbsp; &nbsp; &nbsp;缩略图片文件名</p><p>****nHeight &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 缩略图片高度（缩略图的宽度是根据原始图片比例来计算的）</p><p><br/></p><p>DECLARE INTEGER GdiplusStartup IN gdiplus;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER @token, STRING @INPUT, INTEGER OUTPUT</p><p>DECLARE INTEGER GdipGetImageHeight IN gdiplus;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER &nbsp; img,;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER @ imgheight</p><p>DECLARE INTEGER GdipGetImageWidth IN gdiplus;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER &nbsp; img,INTEGER @ imgwidth</p><p>DECLARE INTEGER GdipLoadImageFromFile IN gdiplus.DLL ;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; STRING wFilename, INTEGER @nImage</p><p>DECLARE INTEGER GdipDrawImageRect IN gdiplus.DLL ;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER nGraphics, INTEGER nImage, SINGLE,SINGLE,SINGLE,SINGLE</p><p>DECLARE INTEGER GdipCreateBitmapFromScan0 IN gdiplus.DLL ;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER nWidth, INTEGER nHeight, INTEGER nStride,;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER nPixelFormat,STRING @ cScan0, INTEGER @ nImage</p><p>DECLARE INTEGER GdipGetImageGraphicsContext IN gdiplus.DLL ;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER nImage, INTEGER @ nGraphics</p><p>DECLARE INTEGER CLSIDFromString IN ole32 STRING lpsz, STRING @pclsid</p><p>DECLARE INTEGER GdipSaveImageToFile IN gdiplus.DLL ;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; INTEGER nImage, STRING wFilename, STRING qEncoder, INTEGER nEncoderParamsPtr</p><p>DECLARE INTEGER GdiplusShutdown IN gdiplus INTEGER token</p><p>#DEFINE &nbsp; GDIPLUS_PIXELFORMAT_32bppARGB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0026200A</p><p>STORE 0 TO hToken,nImage,nGraphics,nBitmap,nWidth,uWidth,uHeight</p><p>cInput = PADR(CHR(1), 16, CHR(0))</p><p>GdiplusStartup(@hToken, @cInput, 0)</p><p>GdipLoadImageFromFile(STRCONV(pSourceFileNAme+CHR(0),5),@nImage)</p><p>GdipGetImageHeight(nImage,@uHeight)</p><p>GdipGetImageWidth(nImage,@uWidth)</p><p>nWidth=uWidth*(nHeight/uHeight)&amp;&amp;同比变比</p><p>GdipCreateBitmapFromScan0(nWidth,nHeight,0,GDIPLUS_PIXELFORMAT_32bppARGB, 0, @nBitmap)</p><p>GdipGetImageGraphicsContext (nBitmap, @nGraphics)</p><p>GdipDrawImageRect(nGraphics,nImage,0,0,nWidth, nHeight)</p><p>lcEncoder = REPLICATE(CHR(0),16)</p><p>CLSIDFromString(STRCONV(&quot;{557CF401-1A04-11D3-9A73-0000F81EF32E}&quot;+CHR(0),5),@lcEncoder)</p><p>GdipSaveImageToFile (nBitmap, STRCONV(pNewFileNAme,5)+CHR(0),lcEncoder,0)</p><p>GdiplusShutdown(hToken)</p><p>ENDFUNC</p><p><br/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/63.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=63</wfw:commentRss></item><item><title>进制转换</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/62.html</link><pubDate>Thu, 18 Jul 2019 11:03:45 +0800</pubDate><guid>http://www.foxwx.cn/post/62.html</guid><description><![CDATA[<p>? A2B (19820627,16)</p><p><br/></p><p>*!* 2010.08.27 By HARE≌XuWu</p><p>FUNCTION A2B</p><p>&nbsp;LPARAMETERS lnValue, lnType</p><p>&nbsp;lcResult = []</p><p>&nbsp;</p><p>&nbsp;DO WHILE lnValue # 0</p><p>&nbsp; lnTem = MOD(lnValue,lnType)</p><p>&nbsp; lnTem = lnTem + ASC([0]) + IIF(lnTem &amp;gt;= 10,7,0)</p><p><br/></p><p>&nbsp; lcResult = CHR(lnTem) + lcResult</p><p>&nbsp;&nbsp;</p><p>&nbsp; lnValue = INT(lnValue/lnType)</p><p>&nbsp;ENDDO&nbsp;</p><p>&nbsp;</p><p>&nbsp;RETURN lcResult&nbsp;</p><p>ENDFUNC&nbsp;</p><p><br/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/62.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=62</wfw:commentRss></item><item><title>中国大陆18位身份证号码校验函数</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/61.html</link><pubDate>Thu, 18 Jul 2019 11:02:55 +0800</pubDate><guid>http://www.foxwx.cn/post/61.html</guid><description><![CDATA[<p>** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **</p><p>* 程序：中国大陆18位身份证号码校验函数</p><p>* 作者：宋祎礽</p><p>* 公司：SYRSOFT(R) 上海 中国</p><p>* 版权所有(C)宋祎礽 保留所有权利</p><p>** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **</p><p>* 语法：IdVerify(cExpression [,nModel])</p><p>* 参数：</p><p>* cExpression</p><p>* 指定要校验的18位身份证号。若cExpression参数缺省或为空字符串</p><p>* 或为非18位身份证号，则返回逻辑.F.值。</p><p>* nModel</p><p>* 指定返回值类型。若nModel参数缺省或为0，则返回值为逻辑型，表</p><p>* 示校验码是否正确；1 则返回值为字符型，表示正确的校验码。</p><p>* 返回值类型：逻辑型、字符型</p><p>** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **</p><p><br/></p><p>FUNCTION IdVerify</p><p>&nbsp;PARAMETERS cIdNumber,nModel</p><p><br/></p><p>&nbsp;LOCAL lcCorrect,cVerify,nSummary,i</p><p>&nbsp;LOCAL ARRAY aPosition(17)</p><p><br/></p><p>&nbsp;lcCorrect=.F.</p><p><br/></p><p>&nbsp;IF TYPE(&#39;cIdNumber&#39;)#&#39;C&#39; &amp;&amp;若证件号参数类型不符</p><p>&nbsp; RETURN lcCorrect</p><p>&nbsp;ELSE</p><p>&nbsp; IF LEN(cIdNumber)#18 &amp;&amp;若非18位身份证号</p><p>&nbsp; &nbsp;RETURN lcCorrect</p><p>&nbsp; ENDIF</p><p>&nbsp;ENDIF</p><p><br/></p><p>&nbsp;IF TYPE(&#39;nModel&#39;)#&#39;N&#39; &amp;&amp;检查并纠正模式参数</p><p>&nbsp; nModel=0</p><p>&nbsp;ELSE</p><p>&nbsp; IF BETWEEN(nModel,0,1)=.F.</p><p>&nbsp; &nbsp;nModel=0</p><p>&nbsp; ENDIF</p><p>&nbsp;ENDIF</p><p><br/></p><p>&nbsp;*定义加权因子数组*</p><p>&nbsp;aPosition(1)=7</p><p>&nbsp;aPosition(2)=9</p><p>&nbsp;aPosition(3)=10</p><p>&nbsp;aPosition(4)=5</p><p>&nbsp;aPosition(5)=8</p><p>&nbsp;aPosition(6)=4</p><p>&nbsp;aPosition(7)=2</p><p>&nbsp;aPosition(8)=1</p><p>&nbsp;aPosition(9)=6</p><p>&nbsp;aPosition(10)=3</p><p>&nbsp;aPosition(11)=7</p><p>&nbsp;aPosition(12)=9</p><p>&nbsp;aPosition(13)=10</p><p>&nbsp;aPosition(14)=5</p><p>&nbsp;aPosition(15)=8</p><p>&nbsp;aPosition(16)=4</p><p>&nbsp;aPosition(17)=2</p><p><br/></p><p>&nbsp;cVerify=&#39;10X98765432&#39; &amp;&amp;定义对应校验码变量</p><p><br/></p><p>&nbsp;nSummary=0</p><p>&nbsp;FOR i=1 TO 17</p><p>&nbsp; nSummary=nSummary+VAL(SUBSTR(cIdNumber,i,1))*aPosition(i)</p><p>&nbsp;ENDFOR</p><p><br/></p><p>&nbsp;DO CASE</p><p>&nbsp; CASE nModel=0 &amp;&amp;验证校验码模式</p><p>&nbsp; &nbsp;IF UPPER(RIGHT(cIdNumber,1))=SUBSTR(cVerify,MOD(nSummary,11)+1,1)</p><p>&nbsp; &nbsp; lcCorrect=.T.</p><p>&nbsp; &nbsp;ELSE</p><p>&nbsp; &nbsp; lcCorrect=.F.</p><p>&nbsp; &nbsp;ENDIF</p><p><br/></p><p>&nbsp; CASE nModel=1 &amp;&amp;请求校验码模式</p><p>&nbsp; &nbsp;lcCorrect=SUBSTR(cVerify,MOD(nSummary,11)+1,1)</p><p>&nbsp;ENDCASE</p><p><br/></p><p>&nbsp;RETURN lcCorrect</p><p>ENDFUNC</p><p><br/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/61.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=61</wfw:commentRss></item><item><title>删除报表打印机信息</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/60.html</link><pubDate>Thu, 18 Jul 2019 10:57:52 +0800</pubDate><guid>http://www.foxwx.cn/post/60.html</guid><description><![CDATA[<p>cRptFile = [AAA.FRX]</p><p><br/></p><p>USE (cRptFile)</p><p>LOCATE</p><p>REPLACE Expr WITH &quot;&quot;, Tag WITH &quot;&quot;, Tag2 WITH &quot;&quot;</p><p>*!* Above line releases and following inserted</p><p>*!* to preserve the Report ORIENTATION</p><p>REPLACE Expr WITH ;</p><p>&nbsp;MLINE(Expr,ATLINE(&quot;ORIENTATION&quot;,Expr)), ;</p><p>&nbsp;Tag WITH &quot;&quot;, Tag2 WITH &quot;&quot;</p><p>USE</p><p><br/></p><p>*!* 以下代码处理VFP中打开的所有项目中的FRX文件</p><p><br/></p><p>PROCEDURE setfrx</p><p><br/></p><p>LOCAL cRptFile, i, p</p><p><br/></p><p>FOR p = 1 TO application.Projects.Count</p><p>&nbsp; &nbsp;FOR i = &nbsp;1 TO application.Projects(p).Files.Count</p><p>&nbsp; &nbsp; &nbsp; cRptFile = application.Projects(p).Files(i).NAME&nbsp;</p><p>&nbsp; &nbsp; &nbsp; IF UPPER(JUSTEXT(cRptFile)) = &quot;FRX&quot;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WAIT WINDOW cRptFile &amp;&amp; add NOWAIT if desired</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;USE (cRptFile)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LOCATE</p><p>** &nbsp; &nbsp; &nbsp; REPLACE Expr WITH &quot;&quot;, Tag WITH &quot;&quot;, Tag2 WITH &quot;&quot;</p><p>** &nbsp; &nbsp; &nbsp; Above line releases and following inserted</p><p>** &nbsp; &nbsp; &nbsp; to preserve the Report ORIENTATION</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;REPLACE Expr WITH ;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MLINE(Expr,ATLINE(&quot;ORIENTATION&quot;,Expr)), ;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tag WITH &quot;&quot;, Tag2 WITH &quot;&quot;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;USE</p><p>&nbsp; &nbsp; &nbsp; ENDIF</p><p>&nbsp; &nbsp;ENDFOR</p><p>ENDFOR</p><p>RETURN</p><p><br/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/60.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=60</wfw:commentRss></item><item><title>SQL语句优化</title><author>atong2001@163.com (admin)</author><link>http://www.foxwx.cn/post/59.html</link><pubDate>Wed, 31 Oct 2018 12:41:06 +0800</pubDate><guid>http://www.foxwx.cn/post/59.html</guid><description><![CDATA[<p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">1.对查询进行优化，应尽量避免全表扫描，首先应考虑在 where 及 order by 涉及的列上建立索引。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">2.应尽量避免在 where 子句中使用!=或&lt;&gt;操作符，否则将引擎放弃使用索引而进行全表扫描。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">3.应尽量避免在 where 子句中对字段进行 null 值判断，否则将导致引擎放弃使用索引而进行全表扫描，如：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num is null</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">可以在num上设置默认值0，确保表中num列没有null值，然后这样查询：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num=0</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">4.应尽量避免在 where 子句中使用 or 来连接条件，否则将导致引擎放弃使用索引而进行全表扫描，如：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num=10 or num=20</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">可以这样查询：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num=10</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">union all</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num=20</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">5.下面的查询也将导致全表扫描：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where name like &#39;%abc%&#39;</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">若要提高效率，可以考虑全文检索。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">6.in 和 not in 也要慎用，否则会导致全表扫描，如：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num in(1,2,3)</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">对于连续的数值，能用 between 就不要用 in 了：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num between 1 and 3</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">7.如果在 where 子句中使用参数，也会导致全表扫描。因为SQL只有在运行时才会解析局部变量，但优化程序不能将访问计划的选择推迟到运行时；它必须在编译时进行选择。然而，如果在编译时建立访问计划，变量的值还是未知的，因而无法作为索引选择的输入项。如下面语句将进行全表扫描：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num=@num</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">可以改为强制查询使用索引：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t with(index(索引名)) where num=@num</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">8.应尽量避免在 where 子句中对字段进行表达式操作，这将导致引擎放弃使用索引而进行全表扫描。如：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num/2=100</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">应改为:</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where num=100*2</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">9.应尽量避免在where子句中对字段进行函数操作，这将导致引擎放弃使用索引而进行全表扫描。如：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where substring(name,1,3)=&#39;abc&#39;--name以abc开头的id</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where datediff(day,createdate,&#39;2005-11-30&#39;)=0--&#39;2005-11-30&#39;生成的id</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">应改为:</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where name like &#39;abc%&#39;</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select id from t where createdate&gt;=&#39;2005-11-30&#39; and createdate&lt;&#39;2005-12-1&#39;</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">10.不要在 where 子句中的“=”左边进行函数、算术运算或其他表达式运算，否则系统将可能无法正确使用索引。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">11.在使用索引字段作为条件时，如果该索引是复合索引，那么必须使用到该索引中的第一个字段作为条件时才能保证系统使用该索引，否则该索引将不会被使用，并且应尽可能的让字段顺序与索引顺序相一致。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">12.不要写一些没有意义的查询，如需要生成一个空表结构：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select col1,col2 into #t from t where 1=0</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">这类代码不会返回任何结果集，但是会消耗系统资源的，应改成这样：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">create table #t(...)</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">13.很多时候用 exists 代替 in 是一个好的选择：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select num from a where num in(select num from b)</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">用下面的语句替换：</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">select num from a where exists(select 1 from b where num=a.num)</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">14.并不是所有索引对查询都有效，SQL是根据表中数据来进行查询优化的，当索引列有大量数据重复时，SQL查询可能不会去利用索引，如一表中有字段sex，male、female几乎各一半，那么即使在sex上建了索引也对查询效率起不了作用。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">15.索引并不是越多越好，索引固然可以提高相应的 select 的效率，但同时也降低了 insert 及 update 的效率，因为 insert 或 update 时有可能会重建索引，所以怎样建索引需要慎重考虑，视具体情况而定。一个表的索引数最好不要超过6个，若太多则应考虑一些不常使用到的列上建的索引是否有必要。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">16.应尽可能的避免更新 clustered 索引数据列，因为 clustered 索引数据列的顺序就是表记录的物理存储顺序，一旦该列值改变将导致整个表记录的顺序的调整，会耗费相当大的资源。若应用系统需要频繁更新 clustered 索引数据列，那么需要考虑是否应将该索引建为 clustered 索引。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">17.尽量使用数字型字段，若只含数值信息的字段尽量不要设计为字符型，这会降低查询和连接的性能，并会增加存储开销。这是因为引擎在处理查询和连接时会逐个比较字符串中每一个字符，而对于数字型而言只需要比较一次就够了。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">18.尽可能的使用 varchar/nvarchar 代替 char/nchar ，因为首先变长字段存储空间小，可以节省存储空间，其次对于查询来说，在一个相对较小的字段内搜索效率显然要高些。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">19.任何地方都不要使用 select * from t ，用具体的字段列表代替“*”，不要返回用不到的任何字段。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">20.尽量使用表变量来代替临时表。如果表变量包含大量数据，请注意索引非常有限（只有主键索引）。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">21.避免频繁创建和删除临时表，以减少系统表资源的消耗。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">22.临时表并不是不可使用，适当地使用它们可以使某些例程更有效，例如，当需要重复引用大型表或常用表中的某个数据集时。但是，对于一次性事件，最好使用导出表。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">23.在新建临时表时，如果一次性插入数据量很大，那么可以使用 select into 代替 create table，避免造成大量 log ，以提高速度；如果数据量不大，为了缓和系统表的资源，应先create table，然后insert。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">24.如果使用到了临时表，在存储过程的最后务必将所有的临时表显式删除，先 truncate table ，然后 drop table ，这样可以避免系统表的较长时间锁定。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">25.尽量避免使用游标，因为游标的效率较差，如果游标操作的数据超过1万行，那么就应该考虑改写。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">26.使用基于游标的方法或临时表方法之前，应先寻找基于集的解决方案来解决问题，基于集的方法通常更有效。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">27.与临时表一样，游标并不是不可使用。对小型数据集使用 FAST_FORWARD 游标通常要优于其他逐行处理方法，尤其是在必须引用几个表才能获得所需的数据时。在结果集中包括“合计”的例程通常要比使用游标执行的速度快。如果开发时间允许，基于游标的方法和基于集的方法都可以尝试一下，看哪一种方法的效果更好。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">28.在所有的存储过程和触发器的开始处设置 SET NOCOUNT ON ，在结束时设置 SET NOCOUNT OFF 。无需在执行存储过程和触发器的每个语句后向客户端发送 DONE_IN_PROC 消息。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">29.尽量避免向客户端返回大数据量，若数据量过大，应该考虑相应需求是否合理。</p><p style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; margin-top: 16px; margin-bottom: 16px; padding: 0px; color: rgb(34, 34, 34); font-family: &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; line-height: 28px; white-space: normal; widows: 1; background-color: rgb(255, 255, 255);">30.尽量避免大事务操作，提高系统并发能力。</p><p><br/></p>]]></description><category>程序开发</category><comments>http://www.foxwx.cn/post/59.html#comment</comments><wfw:commentRss>http://www.foxwx.cn/feed.asp?cmt=59</wfw:commentRss></item></channel></rss>
