SQL WHEREµÄÓ÷¨
ÎÒÃDz¢²»Ò»¶¨Ã¿Ò»´Î¶¼Òª½«±í¸ñÄÚµÄ×ÊÁ϶¼Íêȫץ³ö¡£ÔÚÐí¶àʱºò£¬ÎÒÃÇ»áÐèҪѡÔñÐÔµØ×¥×ÊÁÏ¡£¾ÍÎÒÃǵÄÀý×ÓÀ´Ëµ£¬ÎÒÃÇ¿ÉÄÜֻҪץ³öÓªÒµ¶î³¬¹ý $1,000 µÄ×ÊÁÏ¡£Òª×öµ½ÕâÒ»µã£¬ÎÒÃǾÍÐèÒªÓõ½ WHERE Õâ¸öÖ¸Áî¡£Õâ¸öÖ¸ÁîµÄÓï·¨ÈçÏ£º
SELECT "À¸Î»Ãû"
from "±í¸ñÃû"
WHERE "Ìõ¼þ"
ÈôÎÒÃÇÒªÓÉÒÔϵıí¸ñ×¥³öÓªÒµ¶î³¬¹ý $1,000 µÄ×ÊÁÏ£¬
Store_Information
store_name
Sales
Date
Los Angeles
$1500
Jan-05-1999
San Diego
$250
Jan-07-1999
Los Angeles
$300
Jan-08-1999
Boston
$700
Jan-08-1999
±í¸ñ
ÎÒÃǾʹòÈ룬
SELECT store_name
from Store_Information
WHERE Sales > 1000
½á¹û:
store_name
Los Angeles
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
ÔÚJAVAÖеÄSQL Óï¾äµÄ±àд·½Ã棬ûÓÐʹÓÃORACLE °ó¶¨±äÁ¿£¬ºÜ´ó³Ì¶ÈÉϽµµÍÁËÊý¾Ý¿âµÄÐÔÄÜ£¬±íÏÖÔÚÁ½¸ö·½Ã棺
1¡¢SQLÓï¾äÓ²·ÖÎö(Hard Parse)Ì«¶à£¬ÑÏÖØÏûºÄCPU×ÊÔ´£¬ÑÓ³¤ÁËSQLÓï¾ä×ܵÄÖ´ÐÐʱ¼ä
SQLÓï¾äµÄÖ´Ðйý³Ì·Ö¼¸¸ö²½Ö裺Óï·¨¼ì²é¡¢·ÖÎö¡¢Ö´ÐС¢·µ»Ø½á¹û¡£ÆäÖзÖÎöÓÖ·ÖΪӲ·ÖÎö(Hard Parse)ºÍÈí·ÖÎö(Soft Pars ......
ʹÓÃË÷Òý¿É¿ìËÙ·ÃÎÊÊý¾Ý¿â±íÖеÄÌض¨ÐÅÏ¢¡£Ë÷ÒýÊǶÔÊý¾Ý¿â±íÖÐÒ»Áлò¶àÁеÄÖµ½øÐÐÅÅÐòµÄÒ»Öֽṹ£¬ÀýÈç employee ±íµÄÐÕ£¨lname£©ÁС£Èç¹ûÒª°´ÐÕ²éÕÒÌض¨Ö°Ô±£¬Óë±ØÐëËÑË÷±íÖеÄËùÓÐÐÐÏà±È£¬Ë÷Òý»á°ïÖúÄú¸ü¿ìµØ»ñµÃ¸ÃÐÅÏ¢¡£
¡¡¡¡Ë÷ÒýÊÇÒ»¸öµ¥¶ÀµÄ¡¢ÎïÀíµÄÊý¾Ý¿â½á¹¹£¬ËüÊÇij¸ö±íÖÐÒ»ÁлòÈô¸ÉÁÐÖµµÄ¼¯ºÏºÍÏàÓ¦µÄÖ¸Ïò±íÖÐÎïÀ ......
execute immediate Óï·¨
ºóÃæ¸úÉÏsqlÓï¾ä¿ÉÒÔ¶¯Ì¬Ö´ÐÐsqlÓï¾ä.
ʹÓó¡¾°:
(1)¼ÓÈ붯̬±í.±ÈÈçÄãÓÐÒ»ÕűíµÄÃû×Ö²»Ã÷È·,ÊÇÐèÒªÅжϵõ½µÄ,Ôò¿ÉÒÔʹÓøÃÓï·¨À´Éú³ÉsqlÓï¾ä.
(2)¼ÓÈ붯̬×Ö¶Î.Äã¸ù¾ÝÅжÏ,×îÖÕ»á¼ÓÈëͬһÕűí,µ«ÊÇÕâÕűí¸ù¾Ý²»Í¬µÄÅжÏ×ֶλáÓÐËù²»Í¬,´ËʱÈç¹ûÖ±½ÓдsqlÊǼӲ»½øÈ¥µÄ,±ØÐëʹÓö¯Ì¬sqlÓï¾ä,ÈÃo ......
ÒÔÏÂÊǾ²âÑéÄÜÕýÈ·ÔËÐеÄ:
create table t_emp_log212
(
who varchar2(10) not null,
action varchar2(10) not null,
actime date
);
create or replace trigger tri_emp_insert
before insert
on t_emp
begin
insert into t_emp_log(who,action,actime)values(user,'insert',sysdate);
end ......