SQL ²éѯÓÅ»¯ £¨Ò»£©
ʹÓþۼ¯Ë÷ÒýÓÅ»¯SQL²éѯ
Ê×ÏÈÈÃÎÒÃÇ×öÒ»¸ö²âÊÔ£¬ÏÖ´´½¨Ò»¸ö±í Ïò±íÖвåÈë²»µÈÊý¾Ý
--DROP TABLE T_UserInfo--------------------------------------
CREATE
TABLE
T_UserInfo
(
Userid
varchar(20),
UserName varchar(20)
)
--
DECLARE
@I INT
DECLARE
@ENDID INT
SELECT
@I =
1
SELECT
@ENDID = 100
-- ÔÚ´Ë´¦¸ü¸ÄÒª²åÈëµÄÊý¾Ý£¬ÖØвåÈë֮ǰҪɾµôËùÓÐÊý¾Ý
WHILE @I <=@ENDID
BEGIN
INSERT INTO T_UserInfo
SELECT 'ABCDE'+CAST(@I AS VARCHAR(20))+'EF','Fan'+CAST(@I AS VARCHAR(20))
SELECT @I = @I+1
END
--Ïà¹ØSQLÓï¾ä½âÊÍ
-------------------------------------------------------------½¨¾Û¼¯Ë÷Òý
CREATE CLUSTERED INDEX INDEX_Userid ON T_UserInfo (Userid)
--½¨·Ç¾Û¼¯Ë÷Òý
CREATE NONCLUSTERED INDEX INDEX_Userid ON T_UserInfo (Userid)
--ɾ³ýË÷Òý
DROP INDEX T_UserInfo.INDEX_Userid
ÎÒÃÇ´´½¨ ±íT_UserInfo £¬ÏòT_UserInfo Ìí¼Ó100ÌõÊý¾Ý¡£Õâʱ²»´´½¨Ë÷Òý¡£
È»ºóдÁËÒ»Ìõ²éѯÓï¾ä£º
SELECT * from T_UserInfo WHERE USERID='ABCDE6EF' Ñ¡ÖÐÒÔÉÏÓï¾ä£¬
°´Ctrl+L
±íɨÃ裺ɨÃè±íÖеÄÐÐ
Ö´ÐÐ:SET STATISTICS IO ON
´ËʱÔÙÖ´ÐиÃSQL:SELECT * from T_UserInfo WHERE USERID='ABCDE6EF'
Çл»µ½ÏûÏ¢À¸ÏÔʾÈçÏ£º
±í'T_UserInfo'¡£É¨Ãè¼ÆÊý1£¬Âß¼¶Á1 ´Î£¬ÎïÀí¶Á0 ´Î£¬Ô¤¶Á0 ´Î¡£
½âÊÍÏÂÆäÒâ˼£º
ËĸöÖµ·Ö±ðΪ£º
Ö´ÐеÄɨÃè´ÎÊý;
´ÓÊý¾Ý»º´æ¶ÁÈ¡µÄÒ³Êý;
´Ó´ÅÅ̶ÁÈ¡µÄÒ³Êý;
Ϊ½øÐвéѯ¶ø·ÅÈ뻺´æµÄÒ³Êý
ÎÒÃÇÔÚ´´½¨Ò»¸öË÷Òý
Ö´ÐÐCREATE CLUSTERED INDEX INDEX_Userid ON T_UserInfo (Userid)
È»ºóÔÙÖ´ÐÐSELECT * from T_UserInfo WHERE USERID='ABCDE6EF'
Çл»µ½ÏûÏ¢À¸ÈçÏÂÏÔʾ£º
CTRL+ L
±í'T_UserInfo'¡£É¨Ãè¼ÆÊý1£¬Âß¼¶Á2 ´Î£¬ÎïÀí¶Á0 ´Î£¬Ô¤¶Á0 ´Î¡£
´ËʱÂß¼¶ÁÓÉÔÀ´µÄ1±ä³É2£¬ ˵Ã÷ÎÒÃÇÓÖ¼ÓÁËÒ»¸öË÷ÒýÒ³£¬ÏÖÔÚÎÒÃDzéѯʱ£¬Âß¼¶Á¾ÍÊÇÒª¶ÁÁ½Ò³(1Ë÷ÒýÒ³+1Êý¾ÝÒ³)£¬´ËʱµÄЧÂÊ»¹²»Èç²»½¨Ë÷Òý¡£
ÄÇôokay, ÈÃÎÒÃÇ°ÑÊý¾ÝÌî
Ïà¹ØÎĵµ£º
½ñÌìÎÒÃÇ¿ªÊ¼SQL SERVER BIµÄÁíÍâÒ»¸öÖØÒªµÄ²¿·Ö --Reporting Service£¬Ïà¶ÔÓÚIntegration ServiceºÍAnalysis Service£¬Reporing ServiceÔÚ¹úÄÚµÄʹÓÃÕßÓ¦¸Ã¶àºÜ¶à.Ò»·½ÃæÓÉÓÚReporing Service·ÑÓñȽϵͣ¬Ö±½Ó¸½ÊôÔÚSQL SERVERÖУ¬ÁíÍâÒ»·½ÃæÆäʵSSRSÔںܴó³Ì¶ÈÉÏ»¹ÊÇÂú×ãÎÒÃǵı¨±íÐèÇóµÄ¡£ ÔÚSQL Server 2008ÖУ¬ ......
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Ò»)--sum()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(¶þ)--max()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Èý)--row_number() /rank()/dense_rank()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(ËÄ)--lag()/lead()
ʵ¼ÊÓ¦ÓÃÖÐÎÒÃÇ¿ÉÒÔͨ¹ýsum()ͳ¼Æ³ö×éÖеÄ×ܼƻòÕßÊÇÀÛ¼ÓÖµ£¬¾ßÌåʾÀýÈçÏ£º
......
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Ò»)--sum()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(¶þ)--max()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(Èý)--row_number() /rank()/dense_rank()
[Oracle]¸ßЧµÄSQLÓï¾äÖ®·ÖÎöº¯Êý(ËÄ)--lag()/lead()
ÓÐʱºò±¨±íÉÏÃæÐèÒªÏÔʾ¸Ã±Ê²Ù×÷µÄÉÏÒ»²½Öè»òÕßÏÂÒ»²½ÖèµÄÏêϸÐÅÏ¢£¬Õâ¸öʱºò¿ ......
±¾ÏµÁÐÎÄÕµ¼º½
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Ò»)--αÁÐROWNUMʹÓü¼ÇÉ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(¶þ)--±êÁ¿×Ó²éѯ
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Èý)--PackageµÄÓŵã
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(ËÄ)--ÅúÁ¿´¦Àí
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Îå)--µ÷Óô洢¹ý³Ì·µ»Ø½á¹û¼¯
[Oracle]¸ßЧµÄPL/SQL³ÌÐòÉè¼Æ(Áù)- ......