ÀûÓÃSQLÓï¾ä½«Êý¾Ýµ¼³öInsertÓï¾ä
ÓÐʱºò£¬ÔÚ¹¤×÷ÖлáÓöµ½½«Ò»¸öÊý¾Ý¿âÖбíµÄÊý¾Ýµ¼µ½ÁíÒ»¸öÊý¾Ý¿âµÄ±íÖУ¬µ«Êǹ¤¾ßÓÖûÓÐÌṩÕâÑùµÄ¹¦ÄÜ
ÏÂÃæÄÜͨ¹ýSQLÓï¾äÉú³ÉInsertÓï¾ä£¬ÔÙ²åÈëµ½ÁíÒ»¸öÊý¾Ý¿âÖС£
MSSQL:
SELECT 'INSERT INTO StatInfo(UserName,CardId,Address,WageCount,Pension)'+
' VALUES('''+a.UserName+''','''+a.CardId+''','''+a.Address+''','+cast(b.WageCount as VARCHAR)+','+cast(b.Pension as VARCHAR)+');' from EmployeeInfo as a,EmployeeWage as b where a.CardId = b.CardId
ORACLE:
SELECT 'INSERT INTO StatInfo(UserName,CardId,Address,WageCount,Pension)'+
' VALUES('''||a.UserName||''','''||a.CardId||''','''||a.Address||''','||cast(b.WageCount as VARCHAR)||','||cast(b.Pension as VARCHAR)||');' from EmployeeInfo as a,EmployeeWage as b where a.CardId = b.CardId
MSSQLºÍORACLE²»Í¬µÄµØ·½ÊÇ£ºMSSQLÓÓ+”Á¬½Ó£¬¶øORACLEÓÓ||”Á¬½Ó¡£
ͨ¹ýÒÔÉÏSQLÓï¾ä£¬¾Í¿ÉÒԵõ½ÏÂÃæÊý¾Ý£º
INSERT INTO StatInfo(UserName,CardId,Address,WageCount,Pension) VALUES('ÕÅÈý','430821197411159000','»ªÇ¿±±Â·108ºÅ',5000,89);
INSERT INTO StatInfo(UserName,CardId,Address,WageCount,Pension) VALUES('ÀîËÄ','430821198112012145','»ªÇ¿±±Â·108ºÅ',6400,125);
ÔÚÐèÒªµ¼ÈëµÄÊý¾Ý¿âÖÐÖ´ÐÐÒÔÉÏInsertÓï¾ä¾Í¿ÉÒÔ½«Êý¾Ý²åÈë±íÖС£
Ïà¹ØÎĵµ£º
ÏÖÔÚ·¢ÏÖSQLÓï¾äȷʵÊÇÌ«Ç¿´óÁË£¬ÒÔºóÓöµ½ÎÊÌâÒª¾¡Á¿ÏȺúÃ˼¿¼Ï£¬²»Òª°´ÕÕ×µÄ·½·¨À´×ö£¡
1.´ÓtblFaultDetailTemp±íÖУ¬ÕÒµ½ID=14µÄÏ²¢½«ËùÁгöµÄËĸö×ֶεÄÖµ¿½±´µ½tblFaultDetail±íÖÐ
Insert into tblFaultDetail(Code,FileType,FaultCode,FaultRect) select Code,FileType,FaultCode,FaultRect from tblF ......
²Ù×÷·ûÓÅ»¯
IN ²Ù×÷·û
ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ׶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£
µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊDZȽϵ͵ģ¬´ÓORACLEÖ´ÐеIJ½ÖèÀ´·ÖÎöÓÃINµÄSQLÓë²»ÓÃINµÄSQLÓÐÒÔÏÂÇø±ð£º
ORACLEÊÔͼ½«Æäת»»³É¶à¸ö±íµÄÁ¬½Ó£¬Èç¹ûת»»²»³É¹¦ÔòÏÈÖ´ÐÐINÀïÃæµÄ×Ó²éѯ£¬ÔÙ²éѯÍâ²ãµÄ±í¼Ç¼£¬Èç¹ûת»»³ ......
¹ØÓÚSQL×¢Èë(SQL Injection)µÄ·½·¨Æäʵ¶¼ºÜÆÕ±éºÍʹÓ㬹éÄÉÆðÀ´Ò²ºÜ·½±ã¡£Ò»°ã“ºÚ¿Í”ʹÓõÄÊÇÏֳɵŤ¾ßÈç“WEBÅÔ×¢¡¢°¢DÍøÂ繤¾ß°ü¡¢½ÌÖ÷XXX”µÈÕâЩ¶¼ÊǼ¯³ÉÁË
һЩ³£ÓõÄsql×¢ÈëÓï¾ä¡£ÏÂÃæÎÒ½«½éÉÜÈçºÎʹÓÃÊÖ¹¤×¢ÈëMYSQL,MSSQLÊý¾Ý¿â.
Ò»°ã©¶´²ú ......
---------Êýѧº¯Êý
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.È¡Õû£¨½ØÈ¡£©
S:select cast(-1.002 as int) v ......