Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL ÖÐ where 1=1 ºÍ 1=0µÄ ×÷ÓÃ

where 1=1ÓÐʲôÓã¿ÔÚSQLÓïÑÔÖУ¬Ð´Õâôһ¾ä»°¾Í¸úûдһÑù¡£
select * from table1 where 1=1Óëselect * from table1ÍêȫûÓÐÇø±ð£¬ÉõÖÁ»¹ÓÐÆäËûÐí¶àд·¨£¬1<>2£¬'a'='a','a'<>'b'£¬ÆäÄ¿µÄ¾ÍÖ»ÓÐÒ»¸ö£¬whereµÄÌõ¼þΪÓÀÕ棬µÃµ½µÄ½á¹û¾ÍÊÇδ¼ÓÔ¼ÊøÌõ¼þµÄ¡£
ÔÚSQL×¢Èëʱ»áÓõ½Õâ¸ö£¬ÀýÈçselect * from table1 where name='lala'¸øÇ¿ÐмÓÉÏselect * from table1 where name='lala' or 1=1Õâ¾ÍÓÖ±ä³ÉÁËÎÞÔ¼ÊøµÄ²éѯÁË¡£
×î½ü·¢ÏÖµÄÃîÓÃÔÚÓÚ£¬ÔÚ²»¶¨ÊýÁ¿²éѯÌõ¼þÇé¿öÏ£¬1=1¿ÉÒԺܷ½±ãµÄ¹æ·¶Óï¾ä¡£ÀýÈçÒ»¸ö²éѯ¿ÉÄÜÓÐname,age,height,weightÔ¼Êø£¬Ò²¿ÉÄÜûÓУ¬ÄǸÃÈçºÎ´¦ÀíÄØ£¿
String sql=select * from table1 where 1=1
ΪʲôҪд¶àÓàµÄ1=1£¿ÂíÉϾÍÖªµÀÁË¡£
if(!name.equals("")){
sql=sql+"name='"+name+"'";
}
if(!age.equals("")){
sql=sql+"age'"+age+"'";
}
if(!height.equals("")){
sql=sql+"height='"+height+"'";
}
if(!weight.equals("")){
sql=sql+"weight='"+weight+"'";
}
Èç¹û²»Ð´1=1ÄØ£¬ÄÇôÔÚÿһ¸ö²»Îª¿ÕµÄ²éѯÌõ¼þÃæÇ°£¬¶¼±ØÐëÅжÏÓÐûÓÐwhere×־䣬·ñÔòÒªÔÚµÚÒ»¸ö³öÏֵĵط½¼Ówhere
ÓÐÒ»´ÎÔÚÂÛ̳Àï¿´µ½£º"SELECT * from strName WHERE 1 = 0";
²»Àí½âΪʲôÓÐ1=0£¿
¸ÃselectÓï¾äÖ÷ÒªÓÃÓÚ¶ÁÈ¡±íµÄ½á¹¹¶ø²»¿¼ÂDZíÖеÄÊý¾Ý£¬ÕâÑù½ÚÊ¡ÁËÄڴ棬ÒòΪ¿ÉÒÔ²»Óñ£´æ½á¹û¼¯¡£
ÁíÍ⣬Õâ¸öÓÃÔÚʲôµØ·½ÄØ£¿Ö÷ÒªÓÃÓÚ´´½¨Ò»¸öÐÂ±í£¬¶øбíµÄ½á¹¹Óë²éѯµÄ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ¡£ÈçÏÂSQLÓï¾ä£º
create table newtable as select * from oldtable where 1=0;


Ïà¹ØÎĵµ£º

Sql serverÖÐʱ¼äº¯ÊýÓ÷¨Ïê½â

SQLÖеÄʱ¼äº¯Êý·Ç³£ÓÐÓã¬ÌرðÊÇÔÚÎÒÃǽøÐгõʼ¸³Öµ¡¢¸´ÔÓ²éѯµÄʱºò£¬¾ÍÏÔµÃÌر𷽱㡣
1¡¢»ñµÃϵͳµ±Ç°Ê±¼ä
select getdate() 
2¡¢DateName ( datepart , date )·µ»Ø±íʾָ¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®¡£
--½ñÌìÊÇ2009-2-24--ÐÇÆÚ¶þ
SELECT DATENAME(year, getdate()) AS 'Year&nbs ......

ѧϰoracle sql loader µÄʹÓÃ

Ò»£ºsql loader µÄÌصã
oracle×Ô¼º´øÁ˺ܶàµÄ¹¤¾ß¿ÉÒÔÓÃÀ´½øÐÐÊý¾ÝµÄǨÒÆ¡¢±¸·ÝºÍ»Ö¸´µÈ¹¤×÷¡£µ«ÊÇÿ¸ö¹¤¾ß¶¼ÓÐ×Ô¼ºµÄÌص㡣
 ±ÈÈç˵expºÍimp¿ÉÒÔ¶ÔÊý¾Ý¿âÖеÄÊý¾Ý½øÐе¼³öºÍµ¼³öµÄ¹¤×÷£¬ÊÇÒ»ÖֺܺõÄÊý¾Ý¿â±¸·ÝºÍ»Ö¸´µÄ¹¤¾ß£¬Òò´ËÖ÷ÒªÓÃÔÚÊý¾Ý¿âµÄÈȱ¸·ÝºÍ»Ö¸´·½Ãæ¡£ÓÐ×ÅËٶȿ죬ʹÓüòµ¥£¬¿ì½ÝµÄÓŵ㣻ͬʱҲÓÐһР......

SQL Server ±à³Ì(Ò») ×Ö·û´®´¦Àí

      ×Ö·û´®º¯Êý¶Ô¶þ½øÖÆÊý¾Ý¡¢×Ö·û´®ºÍ±í´ïʽִÐв»Í¬µÄÔËËã¡£´ËÀຯÊý×÷ÓÃÓÚCHAR¡¢VARCHAR¡¢ BINARY¡¢ ºÍVARBINARY Êý¾ÝÀàÐÍÒÔ¼°¿ÉÒÔÒþʽת»»ÎªCHAR »òVARCHARµÄÊý¾ÝÀàÐÍ¡£¿ÉÒÔÔÚSELECT Óï¾äµÄSELECT ºÍWHERE ×Ó¾äÒÔ¼°±í´ïʽÖÐʹÓÃ×Ö·û´®º¯Êý¡£
Ò»¡¢×Ö·ûת»»º¯Êý
1¡¢ASCII()
·µ»Ø×Ö·û±í´ïʽ ......

×ÔÔö×ֶεÄSQLÓï¾ä½â¾ö·½°¸

 create table [±íÃû]
(
[×Ô¶¯±àºÅ×Ö¶Î] int IDENTITY (1,1) PRIMARY KEY ,
[×Ö¶Î1] nVarChar(50) default 'ĬÈÏÖµ' null ,
[×Ö¶Î2] ntext null ,
[×Ö¶Î3] datetime,
[×Ö¶Î4] money null ,
[×Ö¶Î5] int default 0,
[×Ö¶Î6] Decimal (12,4) default 0,
[×Ö¶Î7] image null ,
)
ɾ³ý±í£º
Drop t ......

OracleµÄSQL*PLUSÃüÁîµÄʹÓôóÈ«

 OracleµÄsql*plusÊÇÓëoracle½øÐн»»¥µÄ¿Í»§¶Ë¹¤¾ß¡£ÔÚsql*plusÖУ¬¿ÉÒÔÔËÐÐsql*plusÃüÁîÓësql*plusÓï¾ä¡£
¡¡¡¡
¡¡¡¡ÎÒÃÇͨ³£Ëù˵µÄDML¡¢DDL¡¢DCLÓï¾ä¶¼ÊÇsql*plusÓï¾ä£¬ËüÃÇÖ´ÐÐÍêºó£¬¶¼¿ÉÒÔ±£´æÔÚÒ»¸ö±»³ÆΪsql bufferµÄÄÚ´æÇøÓòÖУ¬²¢ÇÒÖ»Äܱ£´æÒ»Ìõ×î½üÖ´ÐеÄsqlÓï¾ä£¬ÎÒÃÇ¿ÉÒÔ¶Ô±£´æÔÚsql bufferÖеÄsql Óï¾ä½ø ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ