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

SQL ÓÅ»¯¼¼ÇÉ

1 ±ÜÃâÎ޼ƻ®µÄÈ«±íɨÃè
  ÈçÏÂÇé¿ö½øÐÐÈ«±íɨÃ裺
-          ¸Ã±íÎÞË÷Òý
-          ¶Ô·µ»ØµÄÐÐÎÞÈ˺ÍÏÞÖÆÌõ¼þ£¨ÎÞWhere×Ӿ䣩
-          ¶ÔÓÚË÷ÒýÖ÷ÁУ¨Ë÷ÒýµÄµÚÒ»ÁУ©ÎÞÏÞÖÆÌõ¼þ
-          ¶ÔË÷ÒýÖ÷ÁеÄÌõ¼þº¬ÔÚ±í´ïʽÖÐ
-          ¶ÔË÷ÒýÖ÷ÁеÄÏÞÖÆÌõ¼þÊÇis (not) null»ò!=
-          ¶ÔË÷ÒýÖ÷ÁеÄÏÞÖÆÌõ¼þÊÇlike²Ù×÷ÇÒÖµÊÇÒ»¸öbind variable»ò%´òÍ·µÄÖµ
2 ֻʹÓÃÑ¡ÔñÐÔË÷Òý
   Ë÷ÒýµÄÑ¡ÔñÐÔÊÇÖ¸Ë÷ÒýÁÐÖв»Í¬ÖµµÃÊýÄ¿ºÍ±êÖ¾ÖмǼÊýµÄ±È£¬Ñ¡ÔñÐÔ×îºÃµÄÊÇ·Ç¿ÕÁеÄΨһË÷ÒýΪ1.0¡£
¸´ºÏË÷ÒýÖÐÁеĴÎÐòµÄÎÊÌ⣺
  1 ÔÚÏÞ¶¨Ìõ¼þÀï×îƵ·±Ê¹ÓõÄÁÐÓ¦¸ÃÊÇÖ÷ÁÐ
  2 ×î¾ßÓÐÑ¡ÔñÐÔµÄÁУ¨¼´×îÇåÎúµÄÁУ©Ó¦¸ÃÊÇÖ÷ÁÐ
  Èç¹û1ºÍ2 ²»Ò»Ö£¬¿ÉÒÔ¿¼Âǽ¨Á¢¶à¸öË÷Òý¡£
ÔÚ¸´ºÏË÷ÒýºÍ¶à¸öµ¥¸öË÷ÒýÖÐ×÷Ñ¡Ôñ£º
  ¿¼ÂÇÑ¡ÔñÐÔ ¿¼ÂǶÁÈ¡Ë÷ÒýµÄ´ÎÊý  ¿¼ÂÇAND-EQUAL²Ù×÷
3 ¹ÜÀí¶à±íÁ¬½Ó£¨Nested Loops, Merge JoinsºÍHash Joins£©  ÓÅ»¯Áª½Ó²Ù×÷
  Merge JoinsÊǼ¯ºÏ²Ù×÷  Nested LoopsºÍHash JoinsÊǼǼ²Ù×÷·µ»ØµÚÒ»Åú¼Ç¼ѸËÙ
Merge JoinsµÄ²Ù×÷ÊÊÓÃÓÚÅú´¦Àí²Ù×÷£¬¾Þ´ó±í ºÍÔ¶³Ì²éѯ
 1È«±íɨÃè  --¡µ 2ÅÅÐò   --¡µ3±È½ÏºÍºÏ²¢  ÐÔÄÜ¿ªÏúÖ÷ÒªÔÚÇ°Á½²½
  ÊÊÓÃÈ«±íɨÃèµÄÇéÐΣ¬¶¼ÊÊÓÃMerge Joins²Ù×÷£¨±ÈNested LoopsÓÐЧ£©¡£
  ¸ÄÉÆ1µÄЧÂÊ£º ÓÅ»¯I/O£¬ Ìá¸ßʹÓÃORACLE¶à¿é¶ÁµÄÄÜÁ¦£¬ ʹÓò¢ÐвéѯµÄÑ¡Ïî
  ¸ÄÉÆ1µÄЧÂÊ£ºÌá¸ßSort_Area_SizeµÄÖµ£¬ ʹÓÃSort Direct Writes£¬ÎªÁÙʱ¶ÎÌṩרÓñí¿Õ¼ä
4 ¹ÜÀí°üº¬ÊÓͼµÄSQLÓï¾ä
  ÓÅ»¯Æ÷Ö´Ðаüº¬ÊÓͼµÄSQLÓï¾äÓÐÁ½ÖÖ·½·¨£º
-          ÏÈÖ´ÐÐÊÓͼ£¬Íê³ÉÈ«²¿µÄ½á¹û¼¯£¬È»ºóÓÃÆäÓàµÄ²éѯÌõ¼þ×÷¹ýÂËÆ÷Ö´Ðвéѯ
-          ½«ÊÓͼÎı¾¼¯³Éµ½²éѯÀïÈ¥
º¬ÓÐgroup by×Ó¾äµÄÊÓͼ²»Äܱ»¼¯³Éµ½Ò»¸ö´óµÄ²éѯÖÐÈ¥¡£
ÔÚÊÓͼÖÐʹÓÃunion£¬²»×èÖ¹ÊÓͼµÄSQL¼¯³Éµ½²éѯµÄÓï·¨ÖÐÈ¥¡£
5 ÓÅ»¯×Ó²éѯ
6 ʹÓø´ºÏKeys/S


Ïà¹ØÎĵµ£º

Sql Server 2005 ÖеÄͬÒå´ÊÓ븴ÖÆ

ÔÚ2005ÖÐÓÐͬÒå´ÊÓ븴ÖƵĸÅÄî
ͬÒå´ÊµÄÖ÷Òª×÷ÓÃÊÇ£º
        Ò»£ºË޶̶ÔÏóµÄÃû³Æ£¬¼õÉÙ¹¤×÷ÈËÔ±ÊéдµÄʱ¼ä£¬Ìá¸ßЧÂÊ¡£ÎÒÃÇÖªµÀ·ÃÎÊÊý¾Ý¿âÒ»¸ö¶ÔÏóµÄͨ³£×îÈ«µÄ¶ÔÏóÃû³ÆÊÇ£º·þÎñÆ÷Ãû³Æ¡£Êý¾Ý¿âÃû³Æ¡£¼Ü¹¹Ãû³Æ¡£¶ÔÏóÃû³Æ
        ¶þ£ºÍ¬²½Êý¾Ý¡£ ......

½â¾öSQL ServerÀïsp_helptextÊä³ö¸ñʽ´íÐÐÎÊÌâ

use Master 
go 
if object_id('SP_SQL') is not null 
  drop proc SP_SQL 
go 
create proc [dbo].[SP_SQL](@ObjectName sysname) 
as 
set nocount on ; 
declare @Print varchar(max) 
if exists(select 1 from syscomments  where ID=objec ......

³£ÓÃSQLÓï¾ä¼¯ºÏ

1¡¢ËµÃ÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb) (Access¿ÉÓÃ)
·¨Ò»£ºselect * into b from a where 1 <>1
·¨¶þ£ºselect top 0 * into b from a
2¡¢ËµÃ÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb) (Access¿ÉÓÃ)
insert into b(a, b, c) select d,e,f from b;
3¡¢ËµÃ÷£º¿çÊý¾Ý¿âÖ®¼ä±íµÄ¿½±´(¾ßÌåÊý¾ÝʹÓà ......

sql isnullº¯ÊýµÄʹÓÃ


sql isnullº¯ÊýµÄʹÓÃ
ISNULL
ʹÓÃÖ¸¶¨µÄÌæ»»ÖµÌæ»» NULL¡£
Óï·¨
ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_value
ÔÚ check_expression Ϊ NULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ±ØÐëÓë chec ......

oracle sqlÓï¾äÓÅ»¯»ù´¡

¾¡Á¿ÉÙÓÃIN²Ù×÷·û£¬»ù±¾ÉÏËùÓеÄIN²Ù×÷·û¶¼¿ÉÒÔÓÃEXISTS´úÌæ¡£
²»ÓÃNOT IN²Ù×÷·û£¬¿ÉÒÔÓÃNOT EXISTS»òÕßÍâÁ¬½Ó+Ìæ´ú¡£
OracleÔÚÖ´ÐÐIN×Ó²éѯʱ£¬Ê×ÏÈÖ´ÐÐ×Ó²éѯ£¬½«²éѯ½á¹û·ÅÈëÁÙʱ±íÔÙÖ´ÐÐÖ÷²éѯ¡£¶øEXISTÔòÊÇÊ×Ïȼì²éÖ÷²éѯ£¬È»ºóÔËÐÐ×Ó²éѯֱµ½ÕÒµ½µÚÒ»¸öÆ¥ÅäÏî¡£NOT EXISTS±ÈNOT INЧÂÊÉԸߡ£µ«¾ßÌåÔÚÑ¡ÔñIN»òEXIST² ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ