¾«ÃîSqlÓï¾ä
1£® ÅжÏa±íÖÐÓжøb±íÖÐûÓеļǼ
select a.* from tbl1 a
left join tbl2 b
on a.key = b.key
where b.key is null
ËäȻʹÓÃinÒ²¿ÉÒÔʵÏÖ£¬µ«ÊÇÕâÖÖ·½·¨µÄЧÂʸü¸ßһЩ
2£® н¨Ò»¸öÓëij¸ö±íÏàͬ½á¹¹µÄ±í
select * into b
from a where 1<>1
3£®betweenµÄÓ÷¨,betweenÏÞÖÆ²éѯÊý¾Ý·¶Î§Ê±°üÀ¨Á˱߽çÖµ,not between²»°üÀ¨
select * from table1 where time between time1 and time2
select a,b,c, from table1 where a not between ÊýÖµ1 and ÊýÖµ2
4. ˵Ã÷£º°üÀ¨ËùÓÐÔÚ TableA Öе«²»ÔÚ TableBºÍTableC ÖеÄÐв¢Ïû³ýËùÓÐÖØ¸´ÐжøÅÉÉú³öÒ»¸ö½á¹û±í
(select a from tableA ) except (select a from tableB) except (select a from tableC)
5. ³õʼ»¯±í£¬¿ÉÒÔ½«×ÔÔö³¤±íµÄ×ÖÔö³¤×Ö¶ÎÖÃΪ1
TRUNCATE TABLE table1
6£®¶àÓïÑÔÉèÖÃÊý¾Ý¿â»òÕß±í»òÕßorder byµÄÅÅÐò¹æÔò
--ÐÞ¸ÄÓû§Êý¾Ý¿âµÄÅÅÐò¹æÔò
ater database dbname collate SQL_Latin1_General_CP1_CI_AS
--ÐÞ¸Ä×ֶεÄÅÅÐò¹æÔò
alter table a alter column c2 varchar(50) collate SQL_Latin1_General_CP1_CI_AS
--°´ÐÕÊϱʻÅÅÐò
select * from ±íÃû order by ÁÐÃû Collate Chinese_PRC_Stroke_ci_as
--°´Æ´ÒôÊ××ÖĸÅÅÐò
select * from ±íÃû order by ÁÐÃû Collate Chinese_PRC_CS_AS_KS_WS
7£®ÁгöËùÓеÄÓû§Êý¾Ý±í£º
SELECT TOP 100 PERCENT o.name AS ±íÃû
from dbo.syscolumns c INNER JOIN
dbo.sysobjects o ON o.id = c.id AND objectproperty(o.id, N'IsUserTable') = 1 AND
o.name <> 'dtproperties' LEFT OUTER JOIN
dbo.sysproperties m ON m.id = o.id AND m.smallid = c.colorder
WHERE (c.colid = 1)
ORDER BY o.name, c.colid
8£®ÁгöËùÓеÄÓû§Êý¾Ý±í¼°Æä×Ö¶ÎÐÅÏ¢£º
SELECT TOP 100 PERCENT c.colid AS ÐòºÅ, o.name AS ±íÃû, c.name AS ÁÐÃû,
t.name AS ÀàÐÍ, c.length AS ³¤¶È, c.isnullable AS ÔÊÐí¿Õ,
CAST(m.[value] AS Varchar(100)) AS ˵Ã÷
from dbo.syscolumns c INNER JOIN
dbo.sysobjects o ON o.id = c.id A
Ïà¹ØÎĵµ£º
Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚ³ÌÐòÔ±µÄˮƽ¼°¾ÑéÒ²²Î²î²»Æë£¬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´úÂ룬¸ù¾Ý³ÌÐò·µ»ØµÄ½á¹û£¬»ñµÃijЩËûÏëµÃÖªµÄÊý¾Ý£¬Õâ¾ÍÊÇËùνµÄSQL Inj ......
Îå¡¢ÉÏ´«ASPľÂí
ËùνASPľÂí£¬¾ÍÊÇÒ»¶ÎÓÐÌØÊ⹦ÄܵÄASP´úÂ룬²¢·ÅÈëWEBÐéÄâĿ¼µÄScriptsÏ£¬Ô¶³Ì¿Í»§Í¨¹ýIE¾Í¿ÉÖ´ÐÐËü£¬½ø¶øµÃµ½ÏµÍ³µÄUSERȨÏÞ£¬ÊµÏÖ¶ÔϵͳµÄ³õ²½¿ØÖÆ¡£ÉÏ´«ASPľÂíÒ»°ãÓÐÁ½ÖֱȽÏÓÐЧµÄ·½·¨£º
1¡¢ÀûÓÃWEBµÄÔ¶³Ì¹ÜÀí¹¦ÄÜ
  ......
SQL> var v_str varchar2(100);
SQL> exec :v_str:=',id1,id11,id101,';
PL/SQL procedure successfully completed.
SQL> select :v_str a,replace(:v_str,',','') b
2 ,substr(:v_str,instr(:v_str,',',1,rownum)+1,
3 instr(:v_str,',',1,rownum+1)-ins ......
ͨ³££¬ÄãÐèÒª»ñµÃµ±Ç°ÈÕÆÚºÍ¼ÆËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬ÄãµÄ³ÌÐò¿ÉÄÜÐèÒªÅжÏÒ»¸öÔµĵÚÒ»Ìì»òÕß×îºóÒ»Ìì¡£ÄãÃǴ󲿷ÖÈË´ó¸Å¶¼ÖªµÀÔõÑù°ÑÈÕÆÚ½øÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»ºó½ö½öÓ÷ָî³öÀ´µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ¼¸¸öº¯ÊýÖмÆËã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡ÔÚÕâÆªÎÄÕÂÀÎÒ½«¸æËßÄãÈçºÎʹÓÃDATEADDºÍDATEDIFFº¯ÊýÀ´¼ÆËã³öÔÚÄãµÄ³ÌÐòÖ ......
ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQL,ÒÔÏÂΪ±ÊÕßѧϰ¡¢ÕªÂ¼¡¢²¢»ã×ܲ¿·Ö×ÊÁÏÓë´ó¼Ò·ÖÏí£¡
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLE µÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom× ......