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

SQL Server²éѯËٶȻºÂý½â¾ö°ì·¨(2)

ÔÚT-sqlµÄд·¨ÉÏÓкܴóµÄ½²¾¿£¬ÏÂÃæÁгö³£¼ûµÄÒªµã£ºÊ×ÏÈ£¬DBMS´¦Àí²éѯ¼Æ»®µÄ¹ý³ÌÊÇÕâÑùµÄ£º
1¡¢²éѯÓï¾äµÄ´Ê·¨¡¢Óï·¨¼ì²é
2¡¢½«Óï¾äÌá½»¸øDBMSµÄ²éѯÓÅ»¯Æ÷
3¡¢ÓÅ»¯Æ÷×ö´úÊýÓÅ»¯ºÍ´æȡ·¾¶µÄÓÅ»¯
4¡¢ÓÉÔ¤±àÒëÄ£¿éÉú³É²éѯ¹æ»®
5¡¢È»ºóÔÚºÏÊʵÄʱ¼äÌá½»¸øϵͳ´¦ÀíÖ´ÐÐ
6¡¢×îºó½«Ö´Ðнá¹û·µ»Ø¸øÓû§¡£
Æä´Î£¬¿´Ò»ÏÂSQL SERVERµÄÊý¾Ý´æ·ÅµÄ½á¹¹£ºÒ»¸öÒ³ÃæµÄ´óСΪ8K(8060)×Ö½Ú£¬8¸öÒ³ÃæΪһ¸öÅÌÇø£¬°´ÕÕBÊ÷´æ·Å¡£
12¡¢CommitºÍrollbackµÄÇø±ðRollback£º»Ø¹öËùÓеÄÊÂÎï¡£Commit£ºÌá½»µ±Ç°µÄÊÂÎûÓбØÒªÔÚ¶¯Ì¬SQLÀïдÊÂÎÈç¹ûҪдÇëдÔÚÍâÃæÈ磺begin tran exec(@s) commit trans»òÕß½«¶¯Ì¬SQLд³Éº¯Êý»òÕß´æ´¢¹ý³Ì¡£
13¡¢ÔÚ²éѯSelectÓï¾äÖÐÓÃWhere×Ö¾äÏÞÖÆ·µ»ØµÄÐÐÊý,±ÜÃâ±íɨÃè,Èç¹û·µ»Ø²»±ØÒªµÄÊý¾Ý£¬ÀË·ÑÁË·þÎñÆ÷µÄI/O×ÊÔ´£¬¼ÓÖØÁËÍøÂçµÄ¸ºµ£½µµÍÐÔÄÜ¡£Èç¹û±íºÜ´ó£¬ÔÚ±íɨÃèµÄÆڼ佫±íËøס£¬½ûÖ¹ÆäËûµÄÁª½Ó·ÃÎʱí,ºó¹ûÑÏÖØ¡£
14¡¢SQLµÄ×¢ÊÍÉêÃ÷¶ÔÖ´ÐÐûÓÐÈκÎÓ°Ïì
15¡¢¾¡¿ÉÄܲ»Ê¹Óùâ±ê£¬ËüÕ¼ÓôóÁ¿µÄ×ÊÔ´¡£Èç¹ûÐèÒªrow-by-rowµØÖ´ÐУ¬¾¡Á¿²ÉÓ÷ǹâ±ê¼¼Êõ£¬È磺ÔÚ¿Í»§¶ËÑ­»·£¬ÓÃÁÙʱ±í£¬Table±äÁ¿£¬ÓÃ×Ó²éѯ£¬ÓÃCaseÓï¾äµÈµÈ¡£
Óαê¿ÉÒÔ°´ÕÕËüËùÖ§³ÖµÄÌáÈ¡Ñ¡Ïî½øÐзÖÀֻࣺ½ø±ØÐë°´ÕÕ´ÓµÚÒ»Ðе½×îºóÒ»ÐеÄ˳ÐòÌáÈ¡ÐС£FETCH NEXTÊÇΨһÔÊÐíµÄÌáÈ¡²Ù×÷£¬Ò²ÊÇĬÈÏ·½Ê½¡£¿É¹ö¶¯ÐÔ¿ÉÒÔÔÚÓαêÖÐÈκεط½Ëæ»úÌáÈ¡ÈÎÒâÐС£ÓαêµÄ¼¼ÊõÔÚSQL2000ϱäµÃ¹¦ÄܺÜÇ¿´ó£¬ËûµÄÄ¿µÄÊÇÖ§³ÖÑ­»·¡£
ÓÐËĸö²¢·¢Ñ¡Ïî READ_ONLY£º²»ÔÊÐíͨ¹ýÓα궨λ¸üÐÂ(Update)£¬ÇÒÔÚ×é³É½á¹û¼¯µÄÐÐÖÐûÓÐËø¡£
OPTIMISTIC WITH valueS£ºÀÖ¹Û²¢·¢¿ØÖÆÊÇÊÂÎñ¿ØÖÆÀíÂÛµÄÒ»¸ö±ê×¼²¿·Ö¡£ÀÖ¹Û²¢·¢¿ØÖÆÓÃÓÚÕâÑùµÄÇéÐΣ¬¼´ÔÚ´ò¿ªÓα꼰¸üÐÂÐеļä¸ôÖУ¬Ö»ÓкÜСµÄ»ú»áÈõڶþ¸öÓû§¸üÐÂijһÐС£µ±Ä³¸öÓαêÒÔ´ËÑ¡Ïî´ò¿ªÊ±£¬Ã»ÓÐËø¿ØÖÆÆäÖеÄÐУ¬Õ⽫ÓÐÖúÓÚ×î´ó»¯Æä´¦ÀíÄÜÁ¦¡£Èç¹ûÓû§ÊÔͼÐÞ¸ÄijһÐУ¬Ôò´ËÐеĵ±Ç°Öµ»áÓë×îºóÒ»´ÎÌáÈ¡´ËÐÐʱ»ñÈ¡µÄÖµ½øÐбȽϡ£Èç¹ûÈκÎÖµ·¢Éú¸Ä±ä£¬Ôò·þÎñÆ÷¾Í»áÖªµÀÆäËûÈËÒѸüÐÂÁË´ËÐУ¬²¢»á·µ»ØÒ»¸ö´íÎó¡£Èç¹ûÖµÊÇÒ»ÑùµÄ£¬·þÎñÆ÷¾ÍÖ´ÐÐÐ޸ġ£
Ñ¡ÔñÕâ¸ö²¢·¢Ñ¡ÏîOPTIMISTIC WITH ROW VERSIONING:´ËÀÖ¹Û²¢·¢¿ØÖÆÑ¡Ïî»ùÓÚÐа汾¿ØÖÆ¡£Ê¹ÓÃÐа汾¿ØÖÆ£¬ÆäÖеıí±ØÐë¾ßÓÐijÖÖ°æ±¾±êʶ·û£¬·þÎñÆ÷¿ÉÓÃËüÀ´È·¶¨¸ÃÐÐÔÚ¶ÁÈëÓαêºóÊÇ·ñÓÐËù¸ü¸Ä¡£ÔÚSQL ServerÖУ¬Õâ¸öÐÔÄÜÓÉtimestampÊý¾ÝÀàÐÍÌṩ£¬ËüÊÇÒ»¸ö¶þ½øÖÆÊý×Ö£¬±íʾÊý¾Ý¿âÖиü¸ÄµÄÏà¶Ô˳Ðò¡£
ÿ¸öÊ


Ïà¹ØÎĵµ£º

SQL·ÖÒ³ ÀûÓÃID´óÓÚ¶àÉÙºÍSELECT TOP·ÖÒ³

Óï¾äÐÎʽ£º¡¡ SELECTTOP10*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOP20id
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fromTestTable
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ORDERBYid)AST))
ORDERBYID
SELECTTOPÒ³´óС*
fromTestTable
WHERE(ID>
¡¡¡¡¡¡¡¡¡¡(SELECTMAX(id)
¡¡¡¡¡¡¡¡from(SELECTTOPÒ³´óС*Ò³Êýid
¡¡¡¡¡ ......

С²¼×÷Æ·£ºOracle 11g SQL»ù´¡ÈëÃÅϵÁÐÅàѵ(È«30½²)

==============================================
 
µÚ01½²: Chapter 00--Oracle 11g SQL Fundamentals Training Introduction
ÔÚÏß¹Û¿´£º http://www.boobooke.com/v/bbk2003
ÊÓƵÏÂÔØ£º http://www.boobooke.com/v/bbk2003.zip
 
µÚ02½²: Chapter 00--Oracle 11g SQL Fundamentals Training Introduction ......

SQL Server 2008ÖеÄ9ÖÖÊý¾ÝÍÚ¾òËã·¨


ÕªÒª£ºSQL Server 2008ÖÐÌṩÁË9ÖÖ³£ÓõÄÊý¾ÝÍÚ¾òËã·¨£¬ÕâЩËã·¨ÓÃÔÚ²»Í¬Êý¾ÝÍÚ¾òµÄÓ¦Óó¡¾°Ï£¬±¾Îľ͸÷¸öËã·¨Öð¸ö·ÖÎöÌÖÂÛ¡£
±êÇ©£ºÊý¾ÝÍÚ¾òËã·¨  SQL Server 2008
1.¾ö²ßÊ÷Ëã·¨
¾ö²ßÊ÷£¬ÓÖ³ÆÅж¨Ê÷£¬ÊÇÒ»ÖÖÀàËƶþ²æÊ÷»ò¶à²æÊ÷µÄÊ÷½á¹¹¡£¾ö²ßÊ÷ÊÇÓÃÑù±¾µÄÊôÐÔ×÷Ϊ½áµã£¬ÓÃÊôÐÔµÄÈ¡Öµ×÷Ϊ·ÖÖ§£¬Ò²¾ÍÊÇÀàËÆÁ ......

¸ü¶à¼òµ¥¶øʵÓÃµÄ DB2 SQL Óï¾ä


----start
ÎÊÌ⣺²é¿´DB2 °æ±¾---SELECT * from SYSIBM.SYSVERSIONS
ÎÊÌ⣺²é¿´ÏµÍ³ÖÐÓÐÄÄЩ±íÒÔ¼°ÕâЩ±íµÄ¸ÅÒªÐÅÏ¢£ºSELECT * from SYSCAT.TABLES
ÎÊÌ⣺²é¿´Ä³¸ö±íÓÐÄÄЩÁÐÒÔ¼°ÕâЩÁеĸÅÒªÐÅÏ¢£ºSELECT * from SYSCAT.COLUMNS WHERE  TABNAME=<YOUR_TABLE_NAME>
---´ýÐøδÍê
---¸ü¶à²Î¼û£ºDB2 SQL ¾«Ò ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ