·ÀÖ¹SQL×¢Èë
ÔÎĵØÖ·:http://hi.baidu.com/%BC%D9%BA%EC%D2%B6%CE%E8%CE%F7%B7%E7/blog/item/81f35da209e287abcbefd005.html
1. ʲôÊÇSQL×¢Èë
ËùνSQL×¢È룬¾ÍÊÇͨ¹ý°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÝ½»»òÊäÈëÓòÃû»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬×îÖÕ´ïµ½ÆÛÆ·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁͨ¹ýµÝ½»²ÎÊý¹¹ÔìÇÉÃîµÄSQLÓï¾ä£¬´Ó¶ø³É¹¦»ñÈ¡ÏëÒªµÄÊý¾Ý¡£
2. SQL×¢ÈëµÄÖÖÀà
´Ó¾ßÌå¶øÑÔ£¬SQL×¢Èë¿É·ÖΪÎå´óÀ࣬·Ö±ðÊÇ£ºÊý×ÖÐÍ×¢Èë¡¢×Ö·ûÐÍ×¢Èë¡¢ËÑË÷ÐÍ×¢È루like£©¡¢inÐ͵Ä×¢Èë¡¢¾äÓïÁ¬½ÓÐÍ×¢Èë¡£´ÓÓ¦ÓÃÀ´Ëµ£¬ÒªÌرð×¢ÒâIP¡¢ËÑË÷¡¢ÅúÁ¿É¾³ý¡¢´ÓÊý¾Ý¿âתµ½Êý¾Ý¿âµÈµØ·½µÄSQL×¢Èë¡£
3. ÈçºÎ·ÀÖ¹SQL×¢Èë
3.1 SQL×¢Èë²úÉúµÄÔÒò
¿´ÏÂÃæ¼ì²éµÇ½µÄSQLÓï¾ä£º
SQL´úÂë
SqlCommand cmd = new SqlCommand("SELECT * from PE_USERS WHERE UserName = '"
+ UserName + "' AND UserPassword = '" + PassWord + "'", conn);
ÓÉÓÚûÓжÔUserNameºÍPassWord½øÐÐÈκÎÑéÖ¤£¬Èç¹ûUserName=” admin’ OR 1=1--“
ËùÖ´ÐеÄSQLÓï¾ä¾Í³ÉÁË£º
SQL´úÂë
SELECT * from PE_USERS WHERE UserName=’admin’ OR 1=1—‘ AND UserPassword=’’
Õâ¾ÍÔì³ÉÁËSQL×¢È룬Ìõ¼þÓÀԶΪÕ棬Ҳ¾Í²»ÓÃÃÜÂëÒ²Äܵǽ³É¹¦¡£
3.2Ö÷Òª·ÀÓù·½Ê½
·ÀÓùÊÖ¶ÎÒ»:²ÎÊý»¯²éѯ
±£»¤¼¶±ð£º¡ï¡ï¡ï¡ï¡ï
ÃèÊö:
ʹÓòÎÊý»¯²éѯµÄºÃ´¦£º¿ÉÒÔ·ÀÖ¹sql×¢Èëʽ¹¥»÷£¬Ìá¸ß³ÌÐòÖ´ÐÐЧÂÊ¡£
ÀýÈç:
SQL´úÂë
const string strSql = "SELECT * from [PE_Users] WHERE UserName = @UserName";
Parameters parms = new Parameters("@UserName", DbType.String, userName);
ÖÐÓÐÒ»¸ö²ÎÊý@UserName, ʹÓÃPrarmeter¶ÔÏó£¬Í¨¹ýËü°Ñ²ÎÊýÌí¼Óµ½Command¶ÔÏóÉÏ£¬
ÕâÑù¾Í»ñµÃ²ÎÊý»¯²éѯ¡£
14
14 °²È«¿ª·¢ÊÖ²á
ÈçÉÏÊöÓï¾ä,ADO.NET »áÏòSQL Server ·¢ËÍÏÂÃæµÄSQLÓï¾ä:
SQL´úÂë
Exec sp_executesql N ‘select * from [pe_users] where username=@username ‘,N
‘@username nvarchar(20) ‘,@username=N ‘name’
SQL Server °Ñ@username Ìæ»»³É×Ö·û´®”name”,È»ºóÔÙÖ´Ðвéѯ.
¼ÙÉèÓÐÏÂÃæµÄÊäÈë:
SQL´úÂë
‘ union select @@version,null,null—
Éú³ÉµÄSQLÓï¾äÈçÏÂËùʾ:
SQL´úÂë
Exec sp_executesql N ‘select * from [pe_users] where username=@username &
Ïà¹ØÎĵµ£º
ÃæÏò OLTP Ó¦ÓóÌÐòµÄÖØÒª SQL Server 2005 ÐÔÄÜÎÊÌâ
OLTP ¹¤×÷¸ººÉµÄÌØÕ÷ÊÇ´æÔÚ´óÁ¿ÏàËƵÄСÐÍÊÂÎñ¡£
ÔÚ¼ì²éÊý¾Ý¿âÉè¼Æ¡¢×ÊÔ´ÀûÓúÍϵͳÐÔÄܵÄÖØÒªÐÔʱ£¬ÇëÎñ±ØÀμÇÕâЩÌØÕ÷¡£ÏÂÃæ¼òÊöÃæÏò OLTP
Ó¦ÓóÌÐòµÄÖØÒªÐÔÄÜÆ¿¾±»òȱÏÝ¡£
Êý¾Ý
¿âÉè¼ÆÎÊÌâ
³£Óòéѯ´æÔÚ¹ý¶àµÄ±íÁª½Ó¡£ÔÚ OLTP Ó¦ÓóÌÐòÖйý¶àʹÓÃÁª½Ó½«µ¼ ......
PL/SQL DEVELOPER »ù±¾Ó÷¨Ïê½â(½¨Òéд¹ýµÚÒ»¸ö´æ´¢¹ý³ÌºóµÄ³õÊֱضÁ)
ÓùýoracleµÄ¶¼±§Ô¹£¬ÎªÁËÎȶ¨ ËüÌṩµÄͼÐλ¯²Ù×÷ ËÙ¶ÈÂýµÄÈÃÈËÉËÐÄѽ£¬p4+128MµÄ»úÆ÷Ö»ÒªÆô¶¯Ò»¸ö
oracle·þÎñ¾Í¹»ÈÃÈËÉËÐĵģ¬ÔÙÔÚdba studioÀïÃæ²Ù×÷ÕæÄÜÈÃÈË¿Þ¡£
pl/sql developerÕýÊǽâ¾öÕâ¸öÎÊÌâµ ......
ORACLE SQLÐÔÄÜÓÅ»¯ÏµÁÐ
1. ·ÃÎÊTableµÄ·½Ê½
ORACLE ²ÉÓÃÁ½ÖÖ·ÃÎʱíÖмǼµÄ·½Ê½:
a. È«±íɨÃè
È«±íɨÃè¾ÍÊÇ˳ÐòµØ·ÃÎʱíÖÐÿÌõ¼Ç¼. ORACLE²ÉÓÃÒ»´Î¶ÁÈë¶à¸öÊý¾Ý¿é(database block)µÄ·½Ê½ÓÅ»¯È«±íɨÃè.
b. ͨ¹ýROWID·ÃÎʱí
Äã¿ÉÒÔ²ÉÓûùÓÚROWIDµÄ·ÃÎÊ·½Ê½Çé¿ö,Ìá¸ß·ÃÎʱíµÄЧÂÊ, , ROWID°üº¬Á˱íÖмǼµ ......