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

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

¾¡Á¿ÉÙÓÃIN²Ù×÷·û£¬»ù±¾ÉÏËùÓеÄIN²Ù×÷·û¶¼¿ÉÒÔÓÃEXISTS´úÌæ¡£
²»ÓÃNOT IN²Ù×÷·û£¬¿ÉÒÔÓÃNOT EXISTS»òÕßÍâÁ¬½Ó+Ìæ´ú¡£
OracleÔÚÖ´ÐÐIN×Ó²éѯʱ£¬Ê×ÏÈÖ´ÐÐ×Ó²éѯ£¬½«²éѯ½á¹û·ÅÈëÁÙʱ±íÔÙÖ´ÐÐÖ÷²éѯ¡£¶øEXISTÔòÊÇÊ×Ïȼì²éÖ÷²éѯ£¬È»ºóÔËÐÐ×Ó²éѯֱµ½ÕÒµ½µÚÒ»¸öÆ¥ÅäÏî¡£NOT EXISTS±ÈNOT INЧÂÊÉԸߡ£µ«¾ßÌåÔÚÑ¡ÔñIN»òEXIST²Ù×÷ʱ£¬Òª¸ù¾ÝÖ÷×Ó±íÊý¾ÝÁ¿´óСÀ´¾ßÌ忼ÂÇ¡£
²»ÓÓ<>”»òÕß“!=”²Ù×÷·û¡£¶Ô²»µÈÓÚ²Ù×÷·ûµÄ´¦Àí»áÔì³ÉÈ«±íɨÃ裬¿ÉÒÔÓÓ<” or
“>”´úÌæ¡£
Where×Ó¾äÖгöÏÖIS NULL»òÕßIS NOT NULLʱ£¬Oracle»áֹͣʹÓÃË÷Òý¶øÖ´ÐÐÈ«±íɨ
Ãè¡£¿ÉÒÔ¿¼ÂÇÔÚÉè¼Æ±íʱ£¬¶ÔË÷ÒýÁÐÉèÖÃΪNOT NULL¡£ÕâÑù¾Í¿ÉÒÔÓÃÆäËû²Ù×÷À´È¡´úÅжÏNULLµÄ²Ù×÷¡£
µ±Í¨Åä·û“%”»òÕß“_”×÷Ϊ²éѯ×Ö·û´®µÄµÚÒ»¸ö×Ö·ûʱ£¬Ë÷Òý²»»á±»Ê¹Óá£
¶ÔÓÚÓÐÁ¬½ÓµÄÁГ||”£¬×îºóÒ»¸öÁ¬½ÓÁÐË÷Òý»áÎÞЧ¡£¾¡Á¿±ÜÃâÁ¬½Ó£¬¿ÉÒÔ·Ö¿ªÁ¬½Ó»ò
ÕßʹÓò»×÷ÓÃÔÚÁÐÉϵĺ¯ÊýÌæ´ú¡£
Èç¹ûË÷Òý²»ÊÇ»ùÓÚº¯ÊýµÄ£¬ÄÇôµ±ÔÚWhere×Ó¾äÖжÔË÷ÒýÁÐʹÓú¯Êýʱ£¬Ë÷Òý²»ÔÙÆð×÷

Where×Ó¾äÖбÜÃâÔÚË÷ÒýÁÐÉÏʹÓüÆË㣬·ñÔò½«µ¼ÖÂË÷ÒýʧЧ¶ø½øÐÐÈ«±íɨÃè¡£
¶ÔÊý¾ÝÀàÐͲ»Í¬µÄÁнøÐбȽÏʱ£¬»áʹË÷ÒýʧЧ¡£
ÓÓ>=”Ìæ´ú“>”¡£
UNION²Ù×÷·û»á¶Ô½á¹û½øÐÐɸѡ£¬Ïû³ýÖظ´£¬Êý¾ÝÁ¿´óµÄÇé¿öÏ¿ÉÄÜ»áÒýÆð´ÅÅÌÅÅÐò¡£
Èç¹û²»ÐèҪɾ³ýÖظ´¼Ç¼£¬Ó¦¸ÃʹÓÃUNION ALL¡£
Oracle´Óϵ½ÉÏ´¦ÀíWhere×Ó¾äÖжà¸ö²éѯÌõ¼þ£¬ËùÒÔ±íÁ¬½ÓÓï¾äӦдÔÚÆäËûWhere
Ìõ¼þÇ°£¬¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐëдÔÚWhere×Ó¾äµÄĩβ¡£
Oracle´ÓÓÒµ½×ó´¦Àífrom×Ó¾äÖеıíÃû£¬ËùÒÔÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬½«
¼Ç¼×îÉٵıí·ÅÔÚ×îºó¡££¨Ö»ÔÚ²ÉÓÃRBOÓÅ»¯Ê±ÓÐЧ£¬ÏÂÎÄÏêÊö£©
Order ByÓï¾äÖеķÇË÷ÒýÁлήµÍÐÔÄÜ£¬¿ÉÒÔͨ¹ýÌí¼ÓË÷ÒýµÄ·½Ê½´¦Àí¡£Ñϸñ¿ØÖÆÔÚ
Order ByÓï¾äÖÐʹÓñí´ïʽ¡£
²»Í¬ÇøÓò³öÏÖµÄÏàͬµÄSqlÓï¾ä£¬Òª±£Ö¤²éѯ×Ö·ûÍêÈ«Ïàͬ£¬ÒÔÀûÓÃSGA¹²Ïí³Ø£¬·ÀÖ¹
ÏàͬµÄSqlÓï¾ä±»¶à´Î·ÖÎö¡£
¶àÀûÓÃÄÚ²¿º¯ÊýÌá¸ßSqlЧÂÊ¡£
µ±ÔÚSqlÓï¾äÖÐÁ¬½Ó¶à¸ö±íʱ£¬Ê¹ÓñíµÄ±ðÃû£¬²¢½«Ö®×÷ΪÿÁеÄǰ׺¡£ÕâÑù¿ÉÒÔ¼õÉÙ
½âÎöʱ¼ä¡£
ÐèҪעÒâµÄÊÇ£¬Ëæ×ÅOracleµÄÉý¼¶£¬²éѯÓÅ»¯Æ÷»á×Ô¶¯¶ÔSqlÓï¾ä½øÐÐÓÅ»¯£¬Ä³Ð©ÏÞÖÆ¿ÉÄÜÔÚа汾µÄOracleϲ»ÔÙÊÇÎÊÌâ¡£ÓÈÆäÊDzÉÓÃCBO£¨Cost-Based Optimization£¬»ùÓÚ´ú¼ÛµÄÓÅ»¯·½Ê½£©


Ïà¹ØÎĵµ£º

SQLǶÌ××Ó²éѯ


      ʹÓÃ×Ó²éѯµÄÔ­Ôò
      1.Ò»¸ö×Ó²éѯ±ØÐë·ÅÔÚÔ²À¨ºÅÖС£
      2.½«×Ó²éѯ·ÅÔڱȽÏÌõ¼þµÄÓÒ±ßÒÔÔö¼Ó¿É¶ÁÐÔ¡£
      ×Ó²éѯ²»°üº¬ ORDER BY ×Ӿ䡣¶ÔÒ»¸ö SELECT Óï¾äÖ»ÄÜÓÃÒ»¸ö ORDER BY ×Ó¾ä,
&nb ......

Éú³É±íÖÐÊý¾ÝµÄsqlÓï·¨µÄ´æ´¢¹ý³Ì

      Ò»°ãÓÃBCPÔÚ´¦ÀíÕâ¸öÊÂÇ飬µ«ÓÐʱҲÐèҪһЩÌØÊâµÄ´¦Àí£¬ÒÔÏÂÊÇÉú³É±íÖеÄһЩÊý¾Ý£¬´øÓÐwhereÌõ¼þµÄÑ¡ÔñÉú³ÉÊý¾Ý£¬ÊÇÎÒÒ»¸öͬÊÂÐ޸ĵģ¬Ö±½ÓÄùýÀ´ÓÃÁË£º
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
Create Proc proc_insert_where (@tablename varchar(256),@where varchar(256 ......

½â¾ö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 Server±í·ÖÇø²Ù×÷Ïê½â

ÄãÊÇ·ñÔÚǧ·½°Ù¼ÆÓÅ»¯SQL Server Êý¾Ý¿âµÄÐÔÄÜ?Èç¹ûÄãµÄÊý¾Ý¿âÖк¬ÓдóÁ¿µÄ±í¸ñ£¬°ÑÕâЩ±í¸ñ·ÖÇø·ÅÈë¶ÀÁ¢µÄÎļþ×é¿ÉÄÜ»áÈÃÄãÊÜÒæ·Ëdz¡£SQL Server 2005ÒýÈëµÄ±í·ÖÇø¼¼Êõ£¬ÈÃÓû§Äܹ»°ÑÊý¾Ý·ÖÉ¢´æ·Åµ½²»Í¬µÄÎïÀí´ÅÅÌÖУ¬Ìá¸ßÕâЩ´ÅÅ̵IJ¢Ðд¦ÀíÐÔÄÜÒÔÓÅ»¯²éѯÐÔÄÜ¡£
¡¡¡¡SQL ServerÊý¾Ý¿â±í·ÖÇø²Ù×÷¹ý³ÌÓÉÈý¸ö²½Öè×é³É£º
¡ ......

³£ÓÃ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¡¢ËµÃ÷£º¿çÊý¾Ý¿âÖ®¼ä±íµÄ¿½±´(¾ßÌåÊý¾ÝʹÓà ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ