[SQL]SQLÐÔÄܵ÷ÓÅ
³õ¼¶Æª —— ¼òµ¥²éѯÓï¾äµÄµ÷ÓÅ ÀîÃ÷»Û , Èí¼þ¹¤³Ìʦ, IBM
ÀîÃ÷»Û£¬ÔÚ IBM ÖйúÈí¼þ¿ª·¢ÖÐÐÄ Data Studio ÍŶӹ¤×÷´ÓÊ InfoSphere Warehouse Administration Console µÄ¹¦ÄܲâÊÔ¹¤×÷¡£ÔøÔÚ developerWorks ·¢±í¡¶½« DB2 DWE 9.1.X ǨÒƵ½ DB2 Warehouse 9.5¡·¡¢¡¶InfoSphere Warehouse SQL ²Ö´¢ÃüÁîÐнӿڡ·¡¢¡¶Linux ÏÂÀûÓà squid ·´Ïò´úÀíÌá¸ßÍøÕ¾ÐÔÄÜ¡·ÒÔ¼°¡¶InfoSphere Warehouse Administration Console µÄ¶Ô±È½éÉÜ¡·µÈÎÄÕ¡£
¼ò½é£º ¾³£Ìýµ½ÓÐ×öÓ¦ÓõÄÅóÓѱ§Ô¹Êý¾Ý¿âµÄÐÔÄÜÎÊÌ⣬±ÈÈç·Ç³£µÍµÄ²¢·¢£¬ÁîÈ˱ÀÀ£µÄÏìӦʱ¼ä£¬³¤Ê±¼äµÄËøµÈ´ý£¬ËøÉý¼¶,ÉõÖÁÊÇËÀËø£¬µÈµÈ¡£±¾ÎÄÕë¶ÔÓ¦Óÿª·¢ÈËÔ±¾³£½Ó´¥µÄ SQL Êéд²¿·Ö½øÐÐÓÅ»¯£¬ÒÔÆÚÍûÄܶÔÊý¾Ý¿â¿ª·¢ÈËÔ±ÓÐËù°ïÖú¡£
¾³£Ìýµ½ÓÐ×öÓ¦ÓõÄÅóÓѱ§Ô¹Êý¾Ý¿âµÄÐÔÄÜÎÊÌ⣬±ÈÈç·Ç³£µÍµÄ²¢·¢£¬ÁîÈ˱ÀÀ£µÄÏìӦʱ¼ä£¬³¤Ê±¼äµÄËøµÈ´ý£¬ËøÉý¼¶ , ÉõÖÁÊÇËÀËø£¬µÈµÈ¡£ÔÚ½â¾öÕâЩÎÊÌâµÄ¹ý³ÌÖУ¬DBA ¾³£·¢ÏÖÓ¦Óÿª·¢ÈËÔ±¶ÔÊý¾Ý¿âµÄ“ÎóÓÔ¡£°üÀ¨ , ·µ»Ø¹ý¶à²»±ØÒªµÄÊý¾Ý , ²»±ØÒªºÍ²»Êʵ±¼ÓËø£¬¶Ô¸ôÀ뼶±ðµÄÎóÓúͶԴ洢¹ý³ÌµÄÎóÓõȵȡ£µ«ÊÇ£¬Ãæ¶ÔºÆÈçÑ̺£µÄÊý¾Ý¿â֪ʶ , ÒªÇóÍêÈ«ÕÆÎÕ , ¶ÔÓ¦Óÿª·¢ÈËÔ±À´ËµÒ²È·Êµ¿ÝÔï¼èÉî . Òò´Ë£¬±ÊÕßÌرðÌáÁ¶¶ÔÓ¦Óÿª·¢ÈËÔ±ÓаïÖúµÄ SQL Êéд²¿·Ö£¬ÒÔÆÚÍûÄܶÔÊý¾Ý¿â¿ª·¢ÈËÔ±ÓÐËù°ïÖú¡£
“¸ù¾ÝÎÒÃǵľÑ飨ÓɺܶàÒµ½çר¼ÒÖ¤Ã÷£©£¬ÔÚ SQL Server ÉÏÈ¡µÃµÄÐÔÄÜÌá¸ßÓÐ 80% À´×Ô¶Ô SQL ±àÂëµÄ¸Ä½ø£¬¶ø²»ÊÇÀ´×ÔÓÚ¶ÔÓÚÅäÖûòϵͳÐÔÄܵĵ÷Õû¡£”
—¿ÎÄ ¿ËÀ³¶÷µÈ£¬Transact-SQL Programming ×÷Õß
“¾Ñé±íÃ÷ 80%-90% µÄÐÔÄܵ÷ÓÅÊÇÔÚÓ¦Óü¶×öµÄ£¬¶ø²»ÊÇÔÚÊý¾Ý¿â¼¶”
—ÍÐÂí˹ °×ÌØ£¬Expert One on One: Oracle ×÷Õß
±¾ÎĽ«Ö÷ÒªÌÖÂÛ»ùÓÚÓï·¨µÄÓÅ»¯ÒÔ¼°¼ò¼òµ¥µÄ²éѯÌõ¼þ¡£»ùÓÚÓï·¨µÄÓÅ»¯Ö¸µÄÊÇΪ²»¿¼ÂÇÈκεķÇÓï·¨ÒòËØ£¨ÀýÈ磬Ë÷Òý£¬±í´óСºÍ´æ´¢µÈ£©£¬½ö¿¼ÂÇÔÚ SQL Óï¾äÖжÔÓÚ´ÊÓïµÄÑ¡ÔñÒÔ¼°ÊéдµÄ˳Ðò¡£
Ò»°ã¹æÔò
ÕâÒ»²¿·Ö£¬½«¿´Ò»ÏÂһЩÔÚÊéд¼òµ¥²éѯÓïʱÐèҪעÒâµÄͨÓõĹæÔò¡£
¸ù¾ÝȨֵÀ´ÓÅ»¯²éѯÌõ¼þ
×îºÃµÄ²éѯÓï¾äÊǽ«¼òµ¥µÄ±È½Ï²Ù×÷×÷ÓÃÓÚ×îÉÙµÄÐÐÉÏ¡£ÒÔÏÂÁ½ÕÅ±í£¬±í 1 ºÍ±í 2 ÒÔÓɺõ½²îµÄ˳ÐòÁгöÁ˵äÐͲéѯÌõ¼þ²Ù×÷·û²¢¸³ÓëȨֵ¡£
±í 1. ²éѯÌõ¼þÖвÙ×÷·ûµÄÈ
Ïà¹ØÎĵµ£º
DELETE from SCOTT.EMP;
DROP from SCOTT.EMP;
TRUNCATE from EMP;
Ïàͬµã
truncateºÍ²»´øwhere×Ó¾äµÄdelete, ÒÔ¼°drop¶¼»áɾ³ý±íÄÚµÄÊý¾Ý
²»Í¬µã:
1. truncateºÍ deleteֻɾ³ýÊý¾Ý²»É¾³ý±íµÄ½á¹¹(¶¨Òå)
dropÓï¾ä½«É¾³ý±íµÄ½á¹¹±»ÒÀÀµµÄÔ¼Êø(constrain),´¥·¢Æ÷(trigge ......
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö× ......
²éѯÓÅ»¯µÄÄ¿µÄÊÇÌá¸ßÊý¾Ý¼ìË÷Ëٶȣ¬Ìá¸ßÊý¾Ý¼ìË÷Òâζ׿õÉÙ´ÅÅÌ
IO
¶ÁÈ¡»òÕßÂß¼ÄÚ´æ¶ÁÈ¡´ÎÊý£¬ÕâÐèÒª´ÓÁ½¸ö·½ÃæÈëÊÖ£ºÊý¾ÝÒª¾¡¿ÉÄܵĻº´æµ½ÄÚ´æ¡¢¾¡¿ÉÄܵÄʹÓÃË÷Òý¡£ÄÚ´æµÄÎÊÌâ¿ÉÒԲμû
:
http://msdn.microsoft.com/zh-cn/library/ms188284.aspx
£¬±¾ÎÄÖ÷ÒªÊÇÌåÏÖÈçºÎʹÓÃË÷ÒýÀ´Ìá¸ßËٶȡ£¾ßÌå·½·¨£º
1) ......
SELECT
(case when a.colorder=1 then d.name
--+'('+cast(h.value as nvarchar)+')'
else '' end)±íÃû,
a.colorder ×Ö¶ÎÐòºÅ,
a.name ×Ö¶ÎÃû,
isnull(g.[value],'') AS ×Ö¶Î˵Ã÷,
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '¡Ì'else '' end) ±êʶ,
(case whe ......
Çé¿ö£ºÎÒÒÔÇ°°²×°¹ýSQL Server 2000£¬Å¶£¬»¹ÓÐSQL Server 2005¡¢MySQLÄØ£¬ºóÀ´ÏµÍ³ÖØ×°ÁË£¬²»¹ýÕâЩӦÓóÌÐò¶¼ÔÚEÅÌÀ²»ÔÚϵͳÅÌÀ¾ÍÔÚ°²×°µÄʱºò³öÏÖÈçÏÂÈý¸ö´íÎó£¬ÔÚ´ËÖð¸ö½â¾ö˵Ã÷ÈçÏ£º
ÎÊÌâÒ»£º
±¨´íÐÅÏ¢£ºÒÔÇ°µÄij¸ö³ÌÐò°²×°ÒÑÔÚ°²×°¼ÆËã»úÉÏ´´½¨¹ÒÆðµÄÎļþ²Ù×÷¡£ÔËÐа²×°³ÌÐò֮ǰ±ØÐëÖØÐÂÆô¶¯¼ÆËã»ú¡£
½â¾ö·½ ......